diff options
Diffstat (limited to 'src/test')
15 files changed, 42 insertions, 66 deletions
diff --git a/src/test/java/org/onap/aai/validation/TestApplication.java b/src/test/java/org/onap/aai/validation/TestApplication.java index 9f66df9..13dc999 100644 --- a/src/test/java/org/onap/aai/validation/TestApplication.java +++ b/src/test/java/org/onap/aai/validation/TestApplication.java @@ -27,17 +27,20 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * Invoke the Spring Boot Application (primarily for code coverage). * */ -@SpringBootTest(classes = ValidationServiceApplication.class) -@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties", "classpath:test-application.properties"}) -@ContextConfiguration(locations = {"classpath:validation-service-beans.xml"}) +@SpringBootTest +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = {"classpath:data-dictionary/test-data-dictionary-beans.xml"}) +@TestPropertySource(locations = {"classpath:schema-ingest.properties", "classpath:test-application.properties"}) public class TestApplication { @Rule diff --git a/src/test/java/org/onap/aai/validation/controller/TestValidationController.java b/src/test/java/org/onap/aai/validation/controller/TestValidationController.java index b35ed17..cab1cbb 100644 --- a/src/test/java/org/onap/aai/validation/controller/TestValidationController.java +++ b/src/test/java/org/onap/aai/validation/controller/TestValidationController.java @@ -17,26 +17,17 @@ */ package org.onap.aai.validation.controller; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.stubbing.OngoingStubbing; import org.onap.aai.validation.Validator; import org.onap.aai.validation.config.ValidationControllerConfig; import org.onap.aai.validation.exception.ValidationServiceError; @@ -49,7 +40,11 @@ import org.onap.aai.validation.result.ValidationResult; import org.onap.aai.validation.result.ValidationResultBuilder; import org.onap.aai.validation.result.Violation; -@RunWith(MockitoJUnitRunner.class) +import java.util.*; + +import static org.mockito.Mockito.*; + +@RunWith(MockitoJUnitRunner.Silent.class) public class TestValidationController { private static final String AAI_EVENT = "AAI-EVENT"; @@ -105,7 +100,6 @@ public class TestValidationController { @Before public void setupMocks() throws ValidationServiceException { - Map<String, List<ValidationResult>> validationResultsMap = setupTestData(); when(ruleDrivenValidator.validate(TESTDATA_EVENTTYPE_AAI)) @@ -263,16 +257,19 @@ public class TestValidationController { @Test public void testExecuteForNullDomain() throws Exception { - doVerifyMockInteractionsTest(TESTDATA_DOMAIN_NULL, TEST); + doVerifyMockInteractionsTest(TESTDATA_DOMAIN_NULL, TEST, 2); } - private void doVerifyMockInteractionsTest(String event, String eventSource) throws Exception { + private void doVerifyMockInteractionsTest(String event, String eventSource, int eventReaderCallsCount) throws Exception { validationController.execute(event, eventSource); - verify(eventReader, times(1)).getEventType(Mockito.anyString()); + verify(eventReader, times(eventReaderCallsCount)).getEventType(Mockito.anyString()); verify(ruleDrivenValidator, times(0)).validate(Mockito.anyString()); verify(modelDrivenValidator, times(0)).validate(Mockito.anyString()); verify(messagePublisher, times(0)).publishMessage(Mockito.anyString()); + } + private void doVerifyMockInteractionsTest(String event, String eventSource) throws Exception { + doVerifyMockInteractionsTest(event, eventSource, 1); } @Test @@ -318,7 +315,7 @@ public class TestValidationController { @Test public void testExecuteForEndEventType() throws Exception { - doVerifyMockInteractionsTest(TESTDATA_EVENTTYPE_END_EVENT, TEST); + doVerifyMockInteractionsTest(TESTDATA_EVENTTYPE_END_EVENT, TEST, 2); } @Test @@ -391,4 +388,5 @@ public class TestValidationController { when(entity.getEntityLink()).thenReturn(ENTITY_LINK); when(entity.getResourceVersion()).thenReturn(Optional.of(resourceVersion)); } + } diff --git a/src/test/java/org/onap/aai/validation/modeldriven/validator/TestInstanceReader.java b/src/test/java/org/onap/aai/validation/modeldriven/validator/TestInstanceReader.java index 4d076da..772ccd6 100644 --- a/src/test/java/org/onap/aai/validation/modeldriven/validator/TestInstanceReader.java +++ b/src/test/java/org/onap/aai/validation/modeldriven/validator/TestInstanceReader.java @@ -45,7 +45,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties"}) +@TestPropertySource(locations = {"classpath:schema-ingest.properties"}) @ContextConfiguration(locations = {"classpath:model-validation/instance-reader/test-validation-service-beans.xml"}) public class TestInstanceReader { diff --git a/src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelDrivenValidator.java b/src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelDrivenValidator.java index 5a58f41..ea98a02 100644 --- a/src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelDrivenValidator.java +++ b/src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelDrivenValidator.java @@ -55,7 +55,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @SpringBootTest @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties"}) +@TestPropertySource(locations = {"classpath:schema-ingest.properties"}) @ContextConfiguration(locations = {"classpath:model-validation/instance-validator/test-validation-service-beans.xml"}) public class TestModelDrivenValidator { diff --git a/src/test/java/org/onap/aai/validation/reader/TestEventReader.java b/src/test/java/org/onap/aai/validation/reader/TestEventReader.java index 844c010..1625cd2 100644 --- a/src/test/java/org/onap/aai/validation/reader/TestEventReader.java +++ b/src/test/java/org/onap/aai/validation/reader/TestEventReader.java @@ -45,7 +45,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties"}) +@TestPropertySource(locations = {"classpath:schema-ingest.properties"}) @ContextConfiguration(locations = {"classpath:event-reader/test-validation-service-beans.xml"}) public class TestEventReader { diff --git a/src/test/java/org/onap/aai/validation/reader/TestOxmReader.java b/src/test/java/org/onap/aai/validation/reader/TestOxmReader.java index bbceae5..4432dfa 100644 --- a/src/test/java/org/onap/aai/validation/reader/TestOxmReader.java +++ b/src/test/java/org/onap/aai/validation/reader/TestOxmReader.java @@ -31,7 +31,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties"}) +@TestPropertySource(locations = {"classpath:schema-ingest.properties"}) @ContextConfiguration(locations = {"classpath:oxm-reader/oxm-reader-beans.xml"}) public class TestOxmReader { diff --git a/src/test/java/org/onap/aai/validation/result/TestValidationResult.java b/src/test/java/org/onap/aai/validation/result/TestValidationResult.java index 7ce0b34..d1833f0 100644 --- a/src/test/java/org/onap/aai/validation/result/TestValidationResult.java +++ b/src/test/java/org/onap/aai/validation/result/TestValidationResult.java @@ -54,7 +54,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties"}) +@TestPropertySource(locations = {"classpath:schema-ingest.properties"}) @ContextConfiguration(locations = {"classpath:validation-result/test-validation-service-beans.xml"}) public class TestValidationResult { diff --git a/src/test/java/org/onap/aai/validation/ruledriven/mock/TestDefaultRules.java b/src/test/java/org/onap/aai/validation/ruledriven/mock/TestDefaultRules.java index b87e4af..3695fca 100644 --- a/src/test/java/org/onap/aai/validation/ruledriven/mock/TestDefaultRules.java +++ b/src/test/java/org/onap/aai/validation/ruledriven/mock/TestDefaultRules.java @@ -24,8 +24,9 @@ package org.onap.aai.validation.ruledriven.mock; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.anyListOf; -import static org.mockito.Matchers.anyString; +import static org.mockito.ArgumentMatchers.anyListOf; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.when; import com.google.gson.JsonObject; @@ -41,7 +42,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.mockito.stubbing.Answer; import org.onap.aai.validation.Validator; import org.onap.aai.validation.exception.ValidationServiceException; @@ -58,7 +59,7 @@ import org.onap.aai.validation.ruledriven.RuleDrivenValidator; * for both a supported and an unsupported entity type. * */ -@RunWith(MockitoJUnitRunner.class) +@RunWith(MockitoJUnitRunner.Silent.class) public class TestDefaultRules { static { diff --git a/src/test/java/org/onap/aai/validation/ruledriven/validator/TestDataDictionary.java b/src/test/java/org/onap/aai/validation/ruledriven/validator/TestDataDictionary.java index 7292dec..108ee30 100644 --- a/src/test/java/org/onap/aai/validation/ruledriven/validator/TestDataDictionary.java +++ b/src/test/java/org/onap/aai/validation/ruledriven/validator/TestDataDictionary.java @@ -46,7 +46,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; * */ @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties"}) +@TestPropertySource(locations = {"classpath:schema-ingest.properties"}) @ContextConfiguration(locations = {"classpath:data-dictionary/test-data-dictionary-beans.xml"}) public class TestDataDictionary { diff --git a/src/test/java/org/onap/aai/validation/ruledriven/validator/TestRuleDrivenValidator.java b/src/test/java/org/onap/aai/validation/ruledriven/validator/TestRuleDrivenValidator.java index 27039a0..f33e9e9 100644 --- a/src/test/java/org/onap/aai/validation/ruledriven/validator/TestRuleDrivenValidator.java +++ b/src/test/java/org/onap/aai/validation/ruledriven/validator/TestRuleDrivenValidator.java @@ -53,7 +53,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties"}) +@TestPropertySource(locations = {"classpath:schema-ingest.properties"}) @ContextConfiguration( locations = {"classpath:" + TestRuleDrivenValidator.UNIT_TEST_FOLDER + "/test-rule-driven-validator-beans.xml"}) public class TestRuleDrivenValidator { diff --git a/src/test/java/org/onap/aai/validation/services/TestInfoService.java b/src/test/java/org/onap/aai/validation/services/TestInfoService.java index c975d16..6090576 100644 --- a/src/test/java/org/onap/aai/validation/services/TestInfoService.java +++ b/src/test/java/org/onap/aai/validation/services/TestInfoService.java @@ -47,7 +47,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @SpringBootTest @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties", "classpath:application.properties"}) +@TestPropertySource(locations = {"classpath:schema-ingest.properties", "classpath:application.properties"}) @ContextConfiguration(locations = {"classpath:/info-service/test-validation-service-beans.xml"}) public class TestInfoService { diff --git a/src/test/resources/data-dictionary/test-data-dictionary-beans.xml b/src/test/resources/data-dictionary/test-data-dictionary-beans.xml index 78a92f1..4bbb1af 100644 --- a/src/test/resources/data-dictionary/test-data-dictionary-beans.xml +++ b/src/test/resources/data-dictionary/test-data-dictionary-beans.xml @@ -18,7 +18,7 @@ classpath:aai-environment.properties, classpath:data-dictionary/validation-service.properties, classpath:data-dictionary/validation-service-auth.properties, - classpath:data-dictionary/schemaIngest.properties, + classpath:schema-ingest.properties, classpath:data-dictionary/rule-indexing.properties" ignore-unresolvable="true" /> diff --git a/src/test/resources/oxm-reader/oxm-reader-beans.xml b/src/test/resources/oxm-reader/oxm-reader-beans.xml index 93a2ff7..a85c081 100644 --- a/src/test/resources/oxm-reader/oxm-reader-beans.xml +++ b/src/test/resources/oxm-reader/oxm-reader-beans.xml @@ -7,7 +7,7 @@ <bean id="schemaLocationsBean" class="org.onap.aai.setup.SchemaLocationsBean" /> - <bean id="schemaVersionsBean" class="org.onap.aai.setup.SchemaVersions" /> + <bean id="schemaConfigVersionsBean" class="org.onap.aai.setup.SchemaConfigVersions" /> <bean id="configTranslator" class="org.onap.aai.setup.AAIConfigTranslator" /> diff --git a/src/test/resources/oxm-reader/schemaIngest.properties b/src/test/resources/oxm-reader/schemaIngest.properties deleted file mode 100644 index 34c8796..0000000 --- a/src/test/resources/oxm-reader/schemaIngest.properties +++ /dev/null @@ -1,32 +0,0 @@ -# Properties for the org.onap.aai.setup.SchemaLocationsBean -# Schema related attributes for the oxm and edges -# Any additional schema related attributes should start with prefix schema -schema.configuration.location=N/A -schema.nodes.location=src/test/resources/oxm-reader/single/oxm -schema.edges.location=src/test/resources/oxm-reader/single/dbedgerules - -# Schema Version Related Attributes - -# Lists all of the versions in the schema -schema.version.list=v8,v9,v10 -# Specifies from which version should the depth parameter to default to zero -schema.version.depth.start=v9 -# 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=v10 -# Specifies from which version should the namespace be changed -schema.version.namespace.change.start=v10 -# Specifies from which version should the client start seeing the edge label in payload -schema.version.edge.label.start=v10 -# Specifies the version that the application should default to -schema.version.api.default=v9 - -schema.service.base.url=https://localhost:8452/aai/schema-service/v1/ -schema.service.nodes.endpoint=nodes?version= -schema.service.edges.endpoint=edgerules?version= -schema.service.versions.endpoint=versions - -schema.service.ssl.key-store= -schema.service.ssl.trust-store=
\ No newline at end of file diff --git a/src/test/resources/data-dictionary/schemaIngest.properties b/src/test/resources/schema-ingest.properties index 317f478..bdde478 100644 --- a/src/test/resources/data-dictionary/schemaIngest.properties +++ b/src/test/resources/schema-ingest.properties @@ -39,4 +39,10 @@ schema.version.edge.label.start=v10 # Specifies the version that the application should default to schema.version.api.default=v9 +schema.service.base.url=https://localhost:8452/aai/schema-service/v1/ +schema.service.nodes.endpoint=nodes?version= +schema.service.edges.endpoint=edgerules?version= +schema.service.versions.endpoint=versions +schema.service.ssl.key-store= +schema.service.ssl.trust-store=
\ No newline at end of file |