summaryrefslogtreecommitdiffstats
path: root/sparkybe-onap-application/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'sparkybe-onap-application/src/test')
-rw-r--r--sparkybe-onap-application/src/test/java/org/onap/aai/sparky/aggregatevnf/AggregateSummaryProcessorTest.java95
-rw-r--r--sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/Aggregation.java30
-rw-r--r--sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/AggregationFilter.java28
-rw-r--r--sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/AggregationResult.java29
-rw-r--r--sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/AggregationsResponse.java31
-rw-r--r--sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/Bucket.java28
-rw-r--r--sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/BucketResponse.java28
-rw-r--r--sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/FilterAggregationRequest.java29
-rw-r--r--sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/SearchResult.java27
-rw-r--r--sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/SearchServiceAggregationsResponse.java29
10 files changed, 354 insertions, 0 deletions
diff --git a/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/aggregatevnf/AggregateSummaryProcessorTest.java b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/aggregatevnf/AggregateSummaryProcessorTest.java
new file mode 100644
index 0000000..f6a88aa
--- /dev/null
+++ b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/aggregatevnf/AggregateSummaryProcessorTest.java
@@ -0,0 +1,95 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.sparky.aggregatevnf;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.aai.restclient.client.OperationResult;
+import org.onap.aai.sparky.entities.Aggregation;
+import org.onap.aai.sparky.entities.AggregationFilter;
+import org.onap.aai.sparky.entities.AggregationResult;
+import org.onap.aai.sparky.entities.AggregationsResponse;
+import org.onap.aai.sparky.entities.SearchServiceAggregationsResponse;
+import org.onap.aai.sparky.entities.Bucket;
+import org.onap.aai.sparky.entities.BucketResponse;
+import org.onap.aai.sparky.entities.FilterAggregationRequest;
+import org.onap.aai.sparky.entities.SearchResult;
+import org.onap.aai.sparky.search.SearchServiceAdapter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.web.client.RestClientException;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@ActiveProfiles({"oxm-default","oxm-schema-dev", "camel","fe-dev"})
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+public class AggregateSummaryProcessorTest {
+
+ ObjectMapper objectMapper = new ObjectMapper();
+
+ @MockBean SearchServiceAdapter searchServiceAdapter;
+ @Mock OperationResult operationResult;
+
+ @Autowired
+ private TestRestTemplate restTemplate;
+
+ @Value("${schema.ingest.file}") String schemaIngestFileLocation;
+
+ @Test
+ public void someTest() throws RestClientException, JsonProcessingException {
+ when(searchServiceAdapter.doPost(Mockito.any(), Mockito.any())).thenReturn(operationResult);
+ when(operationResult.wasSuccessful()).thenReturn(true);
+
+ List<Aggregation> aggregationList = Arrays.asList(new Aggregation("someAggregation", Arrays.asList(new Bucket(1L,"someKey"))));
+ SearchServiceAggregationsResponse searchServiceAggregationsResponse = new SearchServiceAggregationsResponse(new SearchResult(1L), new AggregationResult(aggregationList), 1L);
+ when(operationResult.getResult()).thenReturn(objectMapper.writeValueAsString(searchServiceAggregationsResponse));
+
+ Map<String,String> params = new HashMap<String,String>();
+ AggregationFilter filter = new AggregationFilter("1","someOrchestrationStatus");
+ FilterAggregationRequest request = new FilterAggregationRequest(Arrays.asList(filter));
+
+ ResponseEntity<AggregationsResponse> response = restTemplate.postForEntity("/rest/search/filterAggregation", objectMapper.writeValueAsString(request), AggregationsResponse.class);
+ AggregationsResponse aggregationsResponse = response.getBody();
+ assertEquals(1L, aggregationsResponse.getTotal());
+ BucketResponse bucket = aggregationsResponse.getAggregations().get("someAggregation").get(0);
+ assertEquals("someKey", bucket.getKey());
+ assertEquals(0, bucket.getDocCount());
+
+ }
+}
diff --git a/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/Aggregation.java b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/Aggregation.java
new file mode 100644
index 0000000..2ad0b44
--- /dev/null
+++ b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/Aggregation.java
@@ -0,0 +1,30 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.sparky.entities;
+
+import java.util.List;
+
+import lombok.Value;
+
+@Value
+public class Aggregation {
+ String name;
+ List<Bucket> buckets;
+}
diff --git a/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/AggregationFilter.java b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/AggregationFilter.java
new file mode 100644
index 0000000..5d4ba6c
--- /dev/null
+++ b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/AggregationFilter.java
@@ -0,0 +1,28 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.sparky.entities;
+
+import lombok.Value;
+
+@Value
+public class AggregationFilter {
+ String filterId;
+ String filterValue;
+}
diff --git a/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/AggregationResult.java b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/AggregationResult.java
new file mode 100644
index 0000000..5f353ad
--- /dev/null
+++ b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/AggregationResult.java
@@ -0,0 +1,29 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.sparky.entities;
+
+import java.util.List;
+
+import lombok.Value;
+
+@Value
+public class AggregationResult {
+ List<Aggregation> aggregations;
+}
diff --git a/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/AggregationsResponse.java b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/AggregationsResponse.java
new file mode 100644
index 0000000..9675fff
--- /dev/null
+++ b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/AggregationsResponse.java
@@ -0,0 +1,31 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.sparky.entities;
+
+import java.util.List;
+import java.util.Map;
+
+import lombok.Data;
+
+@Data
+public class AggregationsResponse {
+ long total;
+ Map<String, List<BucketResponse>> aggregations;
+}
diff --git a/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/Bucket.java b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/Bucket.java
new file mode 100644
index 0000000..8dcf388
--- /dev/null
+++ b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/Bucket.java
@@ -0,0 +1,28 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.sparky.entities;
+
+import lombok.Value;
+
+@Value
+public class Bucket {
+ long count;
+ String key;
+}
diff --git a/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/BucketResponse.java b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/BucketResponse.java
new file mode 100644
index 0000000..ff07df5
--- /dev/null
+++ b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/BucketResponse.java
@@ -0,0 +1,28 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.sparky.entities;
+
+import lombok.Data;
+
+@Data
+public class BucketResponse {
+ long docCount;
+ String key;
+}
diff --git a/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/FilterAggregationRequest.java b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/FilterAggregationRequest.java
new file mode 100644
index 0000000..5733f8d
--- /dev/null
+++ b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/FilterAggregationRequest.java
@@ -0,0 +1,29 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.sparky.entities;
+
+import java.util.List;
+
+import lombok.Value;
+
+@Value
+public class FilterAggregationRequest {
+ List<AggregationFilter> filters;
+}
diff --git a/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/SearchResult.java b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/SearchResult.java
new file mode 100644
index 0000000..0e405b3
--- /dev/null
+++ b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/SearchResult.java
@@ -0,0 +1,27 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.sparky.entities;
+
+import lombok.Value;
+
+@Value
+public class SearchResult {
+ long totalHits;
+}
diff --git a/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/SearchServiceAggregationsResponse.java b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/SearchServiceAggregationsResponse.java
new file mode 100644
index 0000000..a25df4c
--- /dev/null
+++ b/sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/SearchServiceAggregationsResponse.java
@@ -0,0 +1,29 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2024 Deutsche Telekom Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.aai.sparky.entities;
+
+import lombok.Value;
+
+@Value
+public class SearchServiceAggregationsResponse {
+ SearchResult searchResult;
+ AggregationResult aggregationResult;
+ long totalHits;
+}