From 1efee417abaaa07344f4dbb239d2456841faa091 Mon Sep 17 00:00:00 2001 From: Fiete Ostkamp Date: Mon, 10 Jun 2024 10:53:20 +0200 Subject: [PATCH] Add sparky-be integration test - run spring-boot integration test for the AggregateSummaryProcessor in the main sparkybe-onap-application module [1] [1] this is specifically ensuring the proper creation of the beans in the spring context which is done using the spring-beans xml files. In order to replace this outdated approach some time in the future, there have to be integration tests to ensure the proper injection Issue-ID: AAI-3860 Change-Id: Id1488482ba852cce7407aba3e700fba5dd48ae99 Signed-off-by: Fiete Ostkamp --- .gitignore | 3 +- .../config/application.properties | 63 +++++++++- .../config/logging/logback.xml | 4 +- .../config/schemaIngest.properties | 57 --------- .../config/spring-beans/oxm-reader-bean.xml | 62 ++++++++++ .../config/spring-beans/sparky-oxm.xml | 2 +- sparkybe-onap-application/pom.xml | 23 +++- .../AggregateSummaryProcessorTest.java | 95 +++++++++++++++ .../org/onap/aai/sparky/entities/Aggregation.java | 30 +++++ .../aai/sparky/entities/AggregationFilter.java | 28 +++++ .../aai/sparky/entities/AggregationResult.java | 29 +++++ .../aai/sparky/entities/AggregationsResponse.java | 31 +++++ .../java/org/onap/aai/sparky/entities/Bucket.java | 28 +++++ .../onap/aai/sparky/entities/BucketResponse.java | 28 +++++ .../sparky/entities/FilterAggregationRequest.java | 29 +++++ .../org/onap/aai/sparky/entities/SearchResult.java | 27 +++++ .../SearchServiceAggregationsResponse.java | 29 +++++ sparkybe-onap-service/pom.xml | 135 +++------------------ .../aai/sparky/config/SparkyResourceLoader.java | 6 +- .../src/main/resources/application.properties | 1 + .../sync/AutosuggestionSynchronizerTest.java | 3 +- .../BaseVisualizationContextTest.java | 5 +- .../src/test/resources/application.properties | 1 + .../oxm-reader/schema-ingest-single-oxm.properties | 4 +- 24 files changed, 532 insertions(+), 191 deletions(-) create mode 100644 sparkybe-onap-application/config/spring-beans/oxm-reader-bean.xml create mode 100644 sparkybe-onap-application/src/test/java/org/onap/aai/sparky/aggregatevnf/AggregateSummaryProcessorTest.java create mode 100644 sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/Aggregation.java create mode 100644 sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/AggregationFilter.java create mode 100644 sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/AggregationResult.java create mode 100644 sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/AggregationsResponse.java create mode 100644 sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/Bucket.java create mode 100644 sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/BucketResponse.java create mode 100644 sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/FilterAggregationRequest.java create mode 100644 sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/SearchResult.java create mode 100644 sparkybe-onap-application/src/test/java/org/onap/aai/sparky/entities/SearchServiceAggregationsResponse.java create mode 100644 sparkybe-onap-service/src/main/resources/application.properties create mode 100644 sparkybe-onap-service/src/test/resources/application.properties diff --git a/.gitignore b/.gitignore index 3ebf204..63ebe64 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ debug-logs/ */appconfig-local/ /.metadata/ *.iml -.idea \ No newline at end of file +.idea +**/schema/**/*.xml \ No newline at end of file diff --git a/sparkybe-onap-application/config/application.properties b/sparkybe-onap-application/config/application.properties index cdebe11..e96247c 100644 --- a/sparkybe-onap-application/config/application.properties +++ b/sparkybe-onap-application/config/application.properties @@ -1,3 +1,6 @@ +APP_HOME=. +CONFIG_HOME=./config + # # disable the default thyme leaf icon on web-pages # @@ -25,4 +28,62 @@ searchservice.truststore=tomcat_keystore spring.mvc.favicon.enabled=false -schema.ingest.file=${CONFIG_HOME}/schemaIngest.properties \ No newline at end of file +schema.ingest.file=${CONFIG_HOME}/schemaIngest.properties + +# Properties for the SchemaLocationsBean +# Files named aai_oxm_v*.xml are unpacked here: +# Schema Version Related Attributes +schema.uri.base.path=/aai +# Lists all of the versions in the schema +schema.version.list=v9,v10,v11,v12,v13,v14 +# Specifies from which version should the depth parameter to default to zero +schema.version.depth.start=v10 +# Specifies from which version should the related link be displayed in response payload +schema.version.related.link.start=v10 +# Specifies from which version should the client see only the uri excluding host info +# Before this version server base will also be included +schema.version.app.root.start=v11 +# Specifies from which version should the namespace be changed +schema.version.namespace.change.start=v12 +# Specifies from which version should the client start seeing the edge label in payload +schema.version.edge.label.start=v12 +# Specifies the version that the application should default to +schema.version.api.default=v14 + +# Schema Location Related Attributes +schema.configuration.location=NA + +# New propterties required by the aai-common - aai-schema-ingest lib as of 1.3.0 +schema.configuration.location=N/A +schema.nodes.location=${APP_HOME}/onap/oxm +schema.edges.location= + +# Setting this values to ${oxm.apiVersion} only to ensure the value used exists (we don't use this properties in our application) +# schema.version.depth.start=${oxm.apiVersion} +# schema.version.related.link.start=${oxm.apiVersion} +# schema.version.app.root.start=${oxm.apiVersion} +# schema.version.namespace.change.start=${oxm.apiVersion} +# schema.version.edge.label.start=${oxm.apiVersion} + +# Properties required by AAI Schema Service MS +schema.translator.list=config +schema.service.base.url=${oxm.schemaServiceBaseUrl} +schema.service.nodes.endpoint=nodes?version= +schema.service.edges.endpoint=edgerules?version= +schema.service.versions.endpoint=versions +schema.local=true +schema.filename=mockrequests +#Default rest client is the two-way-ssl +#schema.service.client=two-way-ssl +#Replace the below with the A&AI client key store +schema.service.ssl.key-store=${oxm.schemaServiceKeystore} +#Replace the below with the A&AI tomcat trust store +schema.service.ssl.trust-store=${oxm.schemaServiceTruststore} +schema.service.ssl.key-store-password=${oxm.schemaServiceKeystorePassword} +schema.service.ssl.trust-store-password=${oxm.schemaServiceTruststorePassword} + +spring.application.name=sparky + +nodeDir=src/main/resources/schema/onap/oxm/ +edgeDir=src/main/resources/schema/onap/oxm +schemaIngestPropLoc=src/main/resources/schema/onap/oxm \ No newline at end of file diff --git a/sparkybe-onap-application/config/logging/logback.xml b/sparkybe-onap-application/config/logging/logback.xml index 3d132b7..0838bda 100644 --- a/sparkybe-onap-application/config/logging/logback.xml +++ b/sparkybe-onap-application/config/logging/logback.xml @@ -164,8 +164,8 @@ - - + + diff --git a/sparkybe-onap-application/config/schemaIngest.properties b/sparkybe-onap-application/config/schemaIngest.properties index f88a7ef..e69de29 100644 --- a/sparkybe-onap-application/config/schemaIngest.properties +++ b/sparkybe-onap-application/config/schemaIngest.properties @@ -1,57 +0,0 @@ -# Properties for the SchemaLocationsBean -# Files named aai_oxm_v*.xml are unpacked here: -# Schema Version Related Attributes -schema.uri.base.path=/aai -# Lists all of the versions in the schema -schema.version.list=v9,v10,v11,v12,v13,v14 -# Specifies from which version should the depth parameter to default to zero -schema.version.depth.start=v10 -# Specifies from which version should the related link be displayed in response payload -schema.version.related.link.start=v10 -# Specifies from which version should the client see only the uri excluding host info -# Before this version server base will also be included -schema.version.app.root.start=v11 -# Specifies from which version should the namespace be changed -schema.version.namespace.change.start=v12 -# Specifies from which version should the client start seeing the edge label in payload -schema.version.edge.label.start=v12 -# Specifies the version that the application should default to -schema.version.api.default=v14 - -# Schema Location Related Attributes -schema.configuration.location=NA - -# New propterties required by the aai-common - aai-schema-ingest lib as of 1.3.0 -schema.configuration.location=N/A -schema.nodes.location=${oxm.schemaNodeDir} -schema.edges.location= -# These versions need to exist if they are included in the list -schema.version.list=${oxm.apiVersionList} -# Decalares the oxm version to load -schema.version.api.default=${oxm.apiVersion} - -# Setting this values to ${oxm.apiVersion} only to ensure the value used exists (we don't use this properties in our application) -schema.version.depth.start=${oxm.apiVersion} -schema.version.related.link.start=${oxm.apiVersion} -schema.version.app.root.start=${oxm.apiVersion} -schema.version.namespace.change.start=${oxm.apiVersion} -schema.version.edge.label.start=${oxm.apiVersion} - -# Properties required by AAI Schema Service MS -schema.translator.list=config -schema.service.base.url=${oxm.schemaServiceBaseUrl} -schema.service.nodes.endpoint=nodes?version= -schema.service.edges.endpoint=edgerules?version= -schema.service.versions.endpoint=versions -schema.local=true -schema.filename=mockrequests -#Default rest client is the two-way-ssl -#schema.service.client=two-way-ssl -#Replace the below with the A&AI client key store -schema.service.ssl.key-store=${oxm.schemaServiceKeystore} -#Replace the below with the A&AI tomcat trust store -schema.service.ssl.trust-store=${oxm.schemaServiceTruststore} -schema.service.ssl.key-store-password=${oxm.schemaServiceKeystorePassword} -schema.service.ssl.trust-store-password=${oxm.schemaServiceTruststorePassword} - -spring.application.name=sparky \ No newline at end of file diff --git a/sparkybe-onap-application/config/spring-beans/oxm-reader-bean.xml b/sparkybe-onap-application/config/spring-beans/oxm-reader-bean.xml new file mode 100644 index 0000000..74a291c --- /dev/null +++ b/sparkybe-onap-application/config/spring-beans/oxm-reader-bean.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sparkybe-onap-application/config/spring-beans/sparky-oxm.xml b/sparkybe-onap-application/config/spring-beans/sparky-oxm.xml index a210d12..c182c98 100644 --- a/sparkybe-onap-application/config/spring-beans/sparky-oxm.xml +++ b/sparkybe-onap-application/config/spring-beans/sparky-oxm.xml @@ -39,7 +39,7 @@ class="org.onap.aai.sparky.search.registry.SearchProviderRegistry" /> - + diff --git a/sparkybe-onap-application/pom.xml b/sparkybe-onap-application/pom.xml index 3b0301b..1d7d3b0 100644 --- a/sparkybe-onap-application/pom.xml +++ b/sparkybe-onap-application/pom.xml @@ -37,6 +37,7 @@ onap alpine 1.13.2 + 0.10 yyyyMMdd'T'HHmmss'Z' @@ -93,6 +94,11 @@ spring-boot-starter-actuator + + org.springframework.boot + spring-boot-starter-test + + org.apache.camel camel-restlet @@ -287,6 +293,13 @@ + + org.projectlombok + lombok + 1.18.30 + provided + + @@ -534,7 +547,7 @@ unpack - prepare-package + initialize unpack @@ -548,6 +561,14 @@ /${shemaUnpackVersion}/oxm/ ${aai.build.directory} + + org.onap.aai.schema-service + aai-schema + ${version.aai-schema} + jar + ${project.basedir}/src/main/resources/schema/ + **/oxm/**/*.xml + 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 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 params = new HashMap(); + AggregationFilter filter = new AggregationFilter("1","someOrchestrationStatus"); + FilterAggregationRequest request = new FilterAggregationRequest(Arrays.asList(filter)); + + ResponseEntity 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 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 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> 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 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; +} diff --git a/sparkybe-onap-service/pom.xml b/sparkybe-onap-service/pom.xml index 7647010..80b50f9 100644 --- a/sparkybe-onap-service/pom.xml +++ b/sparkybe-onap-service/pom.xml @@ -1,7 +1,7 @@ 4.0.0 - + org.onap.aai sparky-be 2.0.5-SNAPSHOT @@ -62,7 +62,7 @@ some of the depedencies should probably have a scope of provided so they don't a --> - + @@ -351,14 +351,11 @@ some of the depedencies should probably have a scope of provided so they don't a test - - - + + - - org.apache.maven.plugins maven-compiler-plugin @@ -367,40 +364,7 @@ some of the depedencies should probably have a scope of provided so they don't a 11 - - - - @@ -424,84 +388,16 @@ some of the depedencies should probably have a scope of provided so they don't a - - - - - - - - org.apache.maven.plugins - maven-deploy-plugin - 2.8.2 - - + + org.apache.maven.plugins + maven-deploy-plugin + 2.8.2 + + - + ecomp-releases ECOMP Release Repository @@ -516,9 +412,9 @@ some of the depedencies should probably have a scope of provided so they don't a ecomp-site dav:${onap.nexus.url}${sitePath} - + - + central Maven 2 repository 2 @@ -539,8 +435,5 @@ some of the depedencies should probably have a scope of provided so they don't a ECOMP Snapshot Repository ${onap.nexus.url}/content/repositories/snapshots/ - - - - + diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java index 6bb0c45..aec2b3f 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/config/SparkyResourceLoader.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ResourceLoaderAware; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; @@ -34,7 +35,8 @@ public class SparkyResourceLoader implements ResourceLoaderAware { private static final String FILE_URI = "file:"; private ResourceLoader resourceLoader; - private String configHomeEnvVar; + + @Value("${CONFIG_HOME}") private String configHomeEnvVar; // private static Logger LOG = LoggerFactory.getInstance().getLogger(SparkyResourceLoader.class); @@ -44,7 +46,7 @@ public class SparkyResourceLoader implements ResourceLoaderAware { } public String getFullFileUri(String uriFilePath) { - return FILE_URI + System.getProperty(configHomeEnvVar) + uriFilePath; + return FILE_URI + configHomeEnvVar + "/" + uriFilePath; } public String getAbsolutePath(String uriFilePath) { diff --git a/sparkybe-onap-service/src/main/resources/application.properties b/sparkybe-onap-service/src/main/resources/application.properties new file mode 100644 index 0000000..41bb8d8 --- /dev/null +++ b/sparkybe-onap-service/src/main/resources/application.properties @@ -0,0 +1 @@ +CONFIG_HOME=./config \ No newline at end of file diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizerTest.java index d8833e3..269e867 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizerTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizerTest.java @@ -62,7 +62,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; @RunWith(SpringJUnit4ClassRunner.class) @TestPropertySource(properties = { -"schemaIngestPropLoc = src/test/resources/oxm-reader/schema-ingest-single-oxm.properties" }) +"schemaIngestPropLoc = src/test/resources/oxm-reader/schema-ingest-single-oxm.properties", +"CONFIG_HOME = ./config" }) @ContextConfiguration(locations = { "classpath:oxm-reader/oxm-reader-bean.xml" }) diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationContextTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationContextTest.java index 1de7263..9b086c5 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationContextTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationContextTest.java @@ -67,10 +67,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @TestPropertySource(properties = { -"schemaIngestPropLoc = src/test/resources/oxm-reader/schema-ingest-single-oxm.properties" }) +"schemaIngestPropLoc = src/test/resources/oxm-reader/schema-ingest-single-oxm.properties", +"CONFIG_HOME = ./config" }) @ContextConfiguration(locations = { "classpath:oxm-reader/oxm-reader-bean.xml" }) - - public class BaseVisualizationContextTest { private static SecureRandom secureRandom = new SecureRandom(); diff --git a/sparkybe-onap-service/src/test/resources/application.properties b/sparkybe-onap-service/src/test/resources/application.properties new file mode 100644 index 0000000..41bb8d8 --- /dev/null +++ b/sparkybe-onap-service/src/test/resources/application.properties @@ -0,0 +1 @@ +CONFIG_HOME=./config \ No newline at end of file diff --git a/sparkybe-onap-service/src/test/resources/oxm-reader/schema-ingest-single-oxm.properties b/sparkybe-onap-service/src/test/resources/oxm-reader/schema-ingest-single-oxm.properties index 897f7da..d66500a 100644 --- a/sparkybe-onap-service/src/test/resources/oxm-reader/schema-ingest-single-oxm.properties +++ b/sparkybe-onap-service/src/test/resources/oxm-reader/schema-ingest-single-oxm.properties @@ -17,4 +17,6 @@ schema.version.depth.start=v11 schema.version.related.link.start=v11 schema.version.app.root.start=v11 schema.version.namespace.change.start=v11 -schema.version.edge.label.start=v11 \ No newline at end of file +schema.version.edge.label.start=v11 + +CONFIG_HOME=./config \ No newline at end of file -- 2.16.6