diff options
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/test/java/org')
29 files changed, 736 insertions, 806 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllBPMNTestSuites.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllBPMNTestSuites.java index 0f77e41120..03d9b37522 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllBPMNTestSuites.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllBPMNTestSuites.java @@ -19,14 +19,14 @@ */ package org.onap.so.bpmn; -import org.junit.runner.RunWith; +import org.junit.runner.RunWith; import com.googlecode.junittoolbox.SuiteClasses; import com.googlecode.junittoolbox.WildcardPatternSuite; @RunWith(WildcardPatternSuite.class) @SuiteClasses({"**/service/*Test.class", "**/process/*Test.class", "**/subprocess/*Test.class"}) public class AllBPMNTestSuites { - // the class remains empty, - // used only as a holder for the above annotations + // the class remains empty, + // used only as a holder for the above annotations } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllTasksTestsTestSuite.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllTasksTestsTestSuite.java index 57d842f8b5..7f86709432 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllTasksTestsTestSuite.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllTasksTestsTestSuite.java @@ -19,14 +19,14 @@ */ package org.onap.so.bpmn; -import org.junit.runner.RunWith; +import org.junit.runner.RunWith; import com.googlecode.junittoolbox.SuiteClasses; import com.googlecode.junittoolbox.WildcardPatternSuite; @RunWith(WildcardPatternSuite.class) -@SuiteClasses({"**/tasks/*Test.class","**/infrastructure/aai/*Test.class"}) +@SuiteClasses({"**/tasks/*Test.class", "**/infrastructure/aai/*Test.class"}) public class AllTasksTestsTestSuite { - // the class remains empty, - // used only as a holder for the above annotations + // the class remains empty, + // used only as a holder for the above annotations } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllTestsTestSuite.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllTestsTestSuite.java index ddcc6fe875..7123567247 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllTestsTestSuite.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllTestsTestSuite.java @@ -23,19 +23,16 @@ package org.onap.so.bpmn; import org.junit.runner.RunWith; - import com.googlecode.junittoolbox.SuiteClasses; import com.googlecode.junittoolbox.WildcardPatternSuite; @RunWith(WildcardPatternSuite.class) -@SuiteClasses({"!**/service/*Test.class", "!**/subprocess/*Test.class", "!**/process/*Test.class", - "!**/tasks/*Test.class", "!**/infrastructure/aai/*Test.class", - "!**/infrastructure/scripts/*Test.class", - "**/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.class", - "**/infrastructure/scripts/DoUpdateNetworkInstanceTest.class", - "**/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.class", - "**/*Test.class"}) +@SuiteClasses({"!**/service/*Test.class", "!**/subprocess/*Test.class", "!**/process/*Test.class", + "!**/tasks/*Test.class", "!**/infrastructure/aai/*Test.class", "!**/infrastructure/scripts/*Test.class", + "**/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.class", + "**/infrastructure/scripts/DoUpdateNetworkInstanceTest.class", + "**/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.class", "**/*Test.class"}) public class AllTestsTestSuite { - // the class remains empty, - // used only as a holder for the above annotations + // the class remains empty, + // used only as a holder for the above annotations } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/BeansTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/BeansTest.java index f69521fd76..1c4074cae1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/BeansTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/BeansTest.java @@ -21,7 +21,6 @@ package org.onap.so.bpmn.infrastructure; import org.junit.Test; - import com.openpojo.validation.Validator; import com.openpojo.validation.ValidatorBuilder; import com.openpojo.validation.rule.impl.GetterMustExistRule; @@ -38,35 +37,31 @@ import com.openpojo.reflection.filters.FilterPackageInfo; public class BeansTest { - private PojoClassFilter filterTestClasses = new FilterTestClasses(); - - private PojoClassFilter enumFilter = new FilterEnum(); - + private PojoClassFilter filterTestClasses = new FilterTestClasses(); + + private PojoClassFilter enumFilter = new FilterEnum(); + + + @Test + public void pojoStructure() { + test("org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity"); + } + + private void test(String pojoPackage) { + Validator validator = ValidatorBuilder.create().with(new GetterMustExistRule()).with(new SetterMustExistRule()) + + .with(new SetterTester()).with(new GetterTester()).with(new SetterTester()).with(new GetterTester()) - @Test - public void pojoStructure() { - test("org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity"); - } + .build(); - private void test(String pojoPackage) { - Validator validator = ValidatorBuilder.create() - .with(new GetterMustExistRule()) - .with(new SetterMustExistRule()) - - .with(new SetterTester()) - .with(new GetterTester()) - .with(new SetterTester()) - .with(new GetterTester()) - - .build(); + validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses, enumFilter, + new FilterNonConcrete()); + } - validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses,enumFilter,new FilterNonConcrete()); - } - - private static class FilterTestClasses implements PojoClassFilter { - public boolean include(PojoClass pojoClass) { - return !pojoClass.getSourcePath().contains("/test-classes/"); - } - } + private static class FilterTestClasses implements PojoClassFilter { + public boolean include(PojoClass pojoClass) { + return !pojoClass.getSourcePath().contains("/test-classes/"); + } + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java index ad9e210452..c2af155d51 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java @@ -31,22 +31,19 @@ import org.springframework.util.StringUtils; @EnableWebSecurity public class WebSecurityConfigImpl extends WebSecurityConfig { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable() - .authorizeRequests() - .antMatchers("/manage/health","/manage/info").permitAll() - .antMatchers("/async/services/**", "/workflow/services/*", "/SDNCAdapterCallbackService", "/WorkflowMessage", "/vnfAdapterNotify", "/vnfAdapterRestNotify") - .hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(),",").toString()) - .and() - .httpBasic(); - } - - @Override - public void configure(WebSecurity web) throws Exception { - super.configure(web); - StrictHttpFirewall firewall = new MSOSpringFirewall(); - web.httpFirewall(firewall); - } + @Override + protected void configure(HttpSecurity http) throws Exception { + http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() + .antMatchers("/async/services/**", "/workflow/services/*", "/SDNCAdapterCallbackService", + "/WorkflowMessage", "/vnfAdapterNotify", "/vnfAdapterRestNotify") + .hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",").toString()).and().httpBasic(); + } + + @Override + public void configure(WebSecurity web) throws Exception { + super.configure(web); + StrictHttpFirewall firewall = new MSOSpringFirewall(); + web.httpFirewall(firewall); + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java index 2e588b7078..289d97108f 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java @@ -28,10 +28,8 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; - import java.util.HashMap; import java.util.Optional; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -48,150 +46,157 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory; @RunWith(MockitoJUnitRunner.class) public class AAICreateResourcesTest { - - private AAICreateResources aaiCreateResources; - - private String projectName; - private String serviceInstanceId; - private String owningEntityId; - private String owningEntityName; - private String platformName; - private String vnfId; - private String lineOfBusiness; - private String globalCustomerId; - private String serviceType; - - @Spy - private AAIResourcesClient aaiResourcesClient; - - @Before - public void before() { - - - aaiCreateResources = new AAICreateResources(); - aaiCreateResources.setAaiClient(aaiResourcesClient); - - projectName = "projectName"; - serviceInstanceId = "serviceInstanceId"; - owningEntityId = "owningEntityId"; - owningEntityName = "owningEntityName"; - platformName = "platformName"; - vnfId = "vnfId"; - lineOfBusiness = "lineOfBusiness"; - globalCustomerId = "globalCustomerId"; - serviceType = "serviceType"; - } - - @Test - public void createAAIProjectTest() { - doReturn(aaiResourcesClient).when(aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), isA(Optional.class)); - doNothing().when(aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); - - - aaiCreateResources.createAAIProject(projectName, serviceInstanceId); - - AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, projectName); - - verify(aaiResourcesClient, times(1)).createIfNotExists(projectURI, Optional.empty()); - verify(aaiResourcesClient, times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); - } - - @Test - public void createAAIOwningEntityTest() { - doReturn(aaiResourcesClient).when(aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), isA(Optional.class)); - doNothing().when(aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); - - aaiCreateResources.createAAIOwningEntity(owningEntityId, owningEntityName, serviceInstanceId); - - HashMap<String, String> owningEntityMap = new HashMap<>(); - owningEntityMap.put("owning-entity-name", owningEntityName); - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); - - verify(aaiResourcesClient, times(1)).createIfNotExists(owningEntityURI, Optional.of(owningEntityMap)); - verify(aaiResourcesClient, times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); - } - - @Test - public void existsOwningEntityTest() { - doReturn(true).when(aaiResourcesClient).exists(isA(AAIResourceUri.class)); - - boolean expectedBoolean = aaiCreateResources.existsOwningEntity(owningEntityId); - - AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); - - verify(aaiResourcesClient, times(1)).exists(owningEntityURI); - assertTrue(expectedBoolean); - } - - @Test - public void connectOwningEntityandServiceInstanceTest() { - doNothing().when(aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); - - aaiCreateResources.connectOwningEntityandServiceInstance(owningEntityId, serviceInstanceId); - - verify(aaiResourcesClient, times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); - } - - @Test - public void createAAIPlatformTest() { - doReturn(aaiResourcesClient).when(aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), isA(Optional.class)); - doNothing().when(aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); - - aaiCreateResources.createAAIPlatform(platformName, vnfId); - - AAIResourceUri platformURI = AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platformName); - - verify(aaiResourcesClient, times(1)).createIfNotExists(platformURI, Optional.empty()); - verify(aaiResourcesClient, times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); - } - - @Test - public void createAAILineOfBusinessTest() { - doReturn(aaiResourcesClient).when(aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), isA(Optional.class)); - doNothing().when(aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); - - aaiCreateResources.createAAILineOfBusiness(lineOfBusiness, vnfId); - - AAIResourceUri lineOfBusinessURI = AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness); - - verify(aaiResourcesClient, times(1)).createIfNotExists(lineOfBusinessURI, Optional.empty()); - verify(aaiResourcesClient, times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); - } - - @Test - public void createAAIServiceInstanceTest() { - doReturn(aaiResourcesClient).when(aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), isA(Optional.class)); - - aaiCreateResources.createAAIServiceInstance(globalCustomerId, serviceType, serviceInstanceId); - - AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustomerId,serviceType,serviceInstanceId); - - verify(aaiResourcesClient, times(1)).createIfNotExists(serviceInstanceURI, Optional.empty()); - } - - @Test - public void getVnfInstanceTest() { - AAIResultWrapper aaiResultWrapper = new AAIResultWrapper("vnfUriAaiResponse"); - - doReturn(aaiResultWrapper).when(aaiResourcesClient).get(isA(AAIResourceUri.class)); - - Optional<GenericVnf> actualVnf = aaiCreateResources.getVnfInstance(vnfId); - - AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); - - verify(aaiResourcesClient, times(1)).get(vnfURI); - assertEquals(actualVnf, aaiResultWrapper.asBean(GenericVnf.class)); - } - - @Test - public void getVnfInstanceExceptionTest() { - doThrow(RuntimeException.class).when(aaiResourcesClient).get(isA(AAIResourceUri.class)); - - Optional<GenericVnf> actualVnf = aaiCreateResources.getVnfInstance(vnfId); - - AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); - - verify(aaiResourcesClient, times(1)).get(vnfURI); - assertEquals(actualVnf, Optional.empty()); - } + + private AAICreateResources aaiCreateResources; + + private String projectName; + private String serviceInstanceId; + private String owningEntityId; + private String owningEntityName; + private String platformName; + private String vnfId; + private String lineOfBusiness; + private String globalCustomerId; + private String serviceType; + + @Spy + private AAIResourcesClient aaiResourcesClient; + + @Before + public void before() { + + + aaiCreateResources = new AAICreateResources(); + aaiCreateResources.setAaiClient(aaiResourcesClient); + + projectName = "projectName"; + serviceInstanceId = "serviceInstanceId"; + owningEntityId = "owningEntityId"; + owningEntityName = "owningEntityName"; + platformName = "platformName"; + vnfId = "vnfId"; + lineOfBusiness = "lineOfBusiness"; + globalCustomerId = "globalCustomerId"; + serviceType = "serviceType"; + } + + @Test + public void createAAIProjectTest() { + doReturn(aaiResourcesClient).when(aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), + isA(Optional.class)); + doNothing().when(aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); + + + aaiCreateResources.createAAIProject(projectName, serviceInstanceId); + + AAIResourceUri projectURI = AAIUriFactory.createResourceUri(AAIObjectType.PROJECT, projectName); + + verify(aaiResourcesClient, times(1)).createIfNotExists(projectURI, Optional.empty()); + verify(aaiResourcesClient, times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); + } + + @Test + public void createAAIOwningEntityTest() { + doReturn(aaiResourcesClient).when(aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), + isA(Optional.class)); + doNothing().when(aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); + + aaiCreateResources.createAAIOwningEntity(owningEntityId, owningEntityName, serviceInstanceId); + + HashMap<String, String> owningEntityMap = new HashMap<>(); + owningEntityMap.put("owning-entity-name", owningEntityName); + AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + + verify(aaiResourcesClient, times(1)).createIfNotExists(owningEntityURI, Optional.of(owningEntityMap)); + verify(aaiResourcesClient, times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); + } + + @Test + public void existsOwningEntityTest() { + doReturn(true).when(aaiResourcesClient).exists(isA(AAIResourceUri.class)); + + boolean expectedBoolean = aaiCreateResources.existsOwningEntity(owningEntityId); + + AAIResourceUri owningEntityURI = AAIUriFactory.createResourceUri(AAIObjectType.OWNING_ENTITY, owningEntityId); + + verify(aaiResourcesClient, times(1)).exists(owningEntityURI); + assertTrue(expectedBoolean); + } + + @Test + public void connectOwningEntityandServiceInstanceTest() { + doNothing().when(aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); + + aaiCreateResources.connectOwningEntityandServiceInstance(owningEntityId, serviceInstanceId); + + verify(aaiResourcesClient, times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); + } + + @Test + public void createAAIPlatformTest() { + doReturn(aaiResourcesClient).when(aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), + isA(Optional.class)); + doNothing().when(aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); + + aaiCreateResources.createAAIPlatform(platformName, vnfId); + + AAIResourceUri platformURI = AAIUriFactory.createResourceUri(AAIObjectType.PLATFORM, platformName); + + verify(aaiResourcesClient, times(1)).createIfNotExists(platformURI, Optional.empty()); + verify(aaiResourcesClient, times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); + } + + @Test + public void createAAILineOfBusinessTest() { + doReturn(aaiResourcesClient).when(aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), + isA(Optional.class)); + doNothing().when(aaiResourcesClient).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); + + aaiCreateResources.createAAILineOfBusiness(lineOfBusiness, vnfId); + + AAIResourceUri lineOfBusinessURI = + AAIUriFactory.createResourceUri(AAIObjectType.LINE_OF_BUSINESS, lineOfBusiness); + + verify(aaiResourcesClient, times(1)).createIfNotExists(lineOfBusinessURI, Optional.empty()); + verify(aaiResourcesClient, times(1)).connect(isA(AAIResourceUri.class), isA(AAIResourceUri.class)); + } + + @Test + public void createAAIServiceInstanceTest() { + doReturn(aaiResourcesClient).when(aaiResourcesClient).createIfNotExists(isA(AAIResourceUri.class), + isA(Optional.class)); + + aaiCreateResources.createAAIServiceInstance(globalCustomerId, serviceType, serviceInstanceId); + + AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalCustomerId, serviceType, serviceInstanceId); + + verify(aaiResourcesClient, times(1)).createIfNotExists(serviceInstanceURI, Optional.empty()); + } + + @Test + public void getVnfInstanceTest() { + AAIResultWrapper aaiResultWrapper = new AAIResultWrapper("vnfUriAaiResponse"); + + doReturn(aaiResultWrapper).when(aaiResourcesClient).get(isA(AAIResourceUri.class)); + + Optional<GenericVnf> actualVnf = aaiCreateResources.getVnfInstance(vnfId); + + AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + + verify(aaiResourcesClient, times(1)).get(vnfURI); + assertEquals(actualVnf, aaiResultWrapper.asBean(GenericVnf.class)); + } + + @Test + public void getVnfInstanceExceptionTest() { + doThrow(RuntimeException.class).when(aaiResourcesClient).get(isA(AAIResourceUri.class)); + + Optional<GenericVnf> actualVnf = aaiCreateResources.getVnfInstance(vnfId); + + AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId); + + verify(aaiResourcesClient, times(1)).get(vnfURI); + assertEquals(actualVnf, Optional.empty()); + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java index a540a6d2cc..1aca331a17 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java @@ -26,7 +26,6 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; - import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.junit.Before; @@ -38,47 +37,47 @@ import org.mockito.MockitoAnnotations; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.uri.AAIResourceUri; -public class AAIDeleteServiceInstanceTest { - private AAIDeleteServiceInstance aaiDeleteServiceInstance; - @Mock - private DelegateExecution execution; - - @Mock - private AAIResourcesClient aaiResourcesClient; - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - - @Before - public void before() { - MockitoAnnotations.initMocks(this); - - aaiDeleteServiceInstance = new AAIDeleteServiceInstance(); - aaiDeleteServiceInstance.setAaiClient(aaiResourcesClient); - } - - @Test - public void executeTest() throws Exception { - doReturn("serviceInstanceId").when(execution).getVariable("serviceInstanceId"); - doNothing().when(aaiResourcesClient).delete(isA(AAIResourceUri.class)); - doNothing().when(execution).setVariable(isA(String.class), isA(Boolean.class)); - - aaiDeleteServiceInstance.execute(execution); - - verify(execution, times(1)).getVariable("serviceInstanceId"); - verify(aaiResourcesClient, times(1)).delete(isA(AAIResourceUri.class)); - verify(execution, times(1)).setVariable("GENDS_SuccessIndicator", true); - } - - @Test - public void executeExceptionTest() throws Exception { - expectedException.expect(BpmnError.class); - - doReturn("testProcessKey").when(execution).getVariable("testProcessKey"); - doReturn("serviceInstanceId").when(execution).getVariable("serviceInstanceId"); - doThrow(RuntimeException.class).when(aaiResourcesClient).delete(isA(AAIResourceUri.class)); - - aaiDeleteServiceInstance.execute(execution); - } +public class AAIDeleteServiceInstanceTest { + private AAIDeleteServiceInstance aaiDeleteServiceInstance; + @Mock + private DelegateExecution execution; + + @Mock + private AAIResourcesClient aaiResourcesClient; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + + @Before + public void before() { + MockitoAnnotations.initMocks(this); + + aaiDeleteServiceInstance = new AAIDeleteServiceInstance(); + aaiDeleteServiceInstance.setAaiClient(aaiResourcesClient); + } + + @Test + public void executeTest() throws Exception { + doReturn("serviceInstanceId").when(execution).getVariable("serviceInstanceId"); + doNothing().when(aaiResourcesClient).delete(isA(AAIResourceUri.class)); + doNothing().when(execution).setVariable(isA(String.class), isA(Boolean.class)); + + aaiDeleteServiceInstance.execute(execution); + + verify(execution, times(1)).getVariable("serviceInstanceId"); + verify(aaiResourcesClient, times(1)).delete(isA(AAIResourceUri.class)); + verify(execution, times(1)).setVariable("GENDS_SuccessIndicator", true); + } + + @Test + public void executeExceptionTest() throws Exception { + expectedException.expect(BpmnError.class); + + doReturn("testProcessKey").when(execution).getVariable("testProcessKey"); + doReturn("serviceInstanceId").when(execution).getVariable("serviceInstanceId"); + doThrow(RuntimeException.class).when(aaiResourcesClient).delete(isA(AAIResourceUri.class)); + + aaiDeleteServiceInstance.execute(execution); + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstanceTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstanceTest.java index b68b787904..90576c9566 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstanceTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstanceTest.java @@ -26,91 +26,91 @@ import org.junit.Test; public class AAIServiceInstanceTest { - AAIServiceInstance test = new AAIServiceInstance.AAIServiceInstanceBuilder() - .setServiceInstanceName("serviceInstanceName").setServiceType("serviceType").setServiceRole("serviceRole") - .setOrchestrationStatus("orchestrationStatus").setModelInvariantUuid("modelInvariantUuid") - .setModelVersionId("modelVersionId").setEnvironmentContext("environmentContext") - .setWorkloadContext("workloadContext").createAAIServiceInstance(); - - @Test - public void getServiceInstanceNameTest() throws Exception { - test.getServiceInstanceName(); - } - - @Test - public void setServiceInstanceNameTest() throws Exception { - test.setServiceInstanceName("serviceInstanceName"); - } - - @Test - public void getServiceTypeTest() throws Exception { - test.getServiceType(); - } - - @Test - public void setServiceTypeTest() throws Exception { - test.setServiceType("serviceType"); - } - - @Test - public void getServiceRoleTest() throws Exception { - test.getServiceRole(); - } - - @Test - public void setServiceRoleTest() throws Exception { - test.setServiceRole("serviceRole"); - } - - @Test - public void getOrchestrationStatusTest() throws Exception { - test.getOrchestrationStatus(); - } - - @Test - public void setOrchestrationStatusTest() throws Exception { - test.setOrchestrationStatus("status"); - } - - @Test - public void getModelInvariantUuidTest() throws Exception { - test.getModelInvariantUuid(); - } - - @Test - public void setModelInvariantUuidTest() throws Exception { - test.setModelInvariantUuid("uuid"); - } - - @Test - public void getModelVersionIdTest() throws Exception { - test.getModelVersionId(); - } - - @Test - public void setModelVersionIdTest() throws Exception { - test.setModelVersionId("versionId"); - } - - @Test - public void getEnvironmentContextTest() throws Exception { - test.getEnvironmentContext(); - } - - @Test - public void setEnvironmentContextTest() throws Exception { - test.setEnvironmentContext("context"); - } - - @Test - public void getWorkloadContextTest() throws Exception { - test.getWorkloadContext(); - } - - @Test - public void setWorkloadContextTest() throws Exception { - test.setWorkloadContext("context"); - } + AAIServiceInstance test = new AAIServiceInstance.AAIServiceInstanceBuilder() + .setServiceInstanceName("serviceInstanceName").setServiceType("serviceType").setServiceRole("serviceRole") + .setOrchestrationStatus("orchestrationStatus").setModelInvariantUuid("modelInvariantUuid") + .setModelVersionId("modelVersionId").setEnvironmentContext("environmentContext") + .setWorkloadContext("workloadContext").createAAIServiceInstance(); + + @Test + public void getServiceInstanceNameTest() throws Exception { + test.getServiceInstanceName(); + } + + @Test + public void setServiceInstanceNameTest() throws Exception { + test.setServiceInstanceName("serviceInstanceName"); + } + + @Test + public void getServiceTypeTest() throws Exception { + test.getServiceType(); + } + + @Test + public void setServiceTypeTest() throws Exception { + test.setServiceType("serviceType"); + } + + @Test + public void getServiceRoleTest() throws Exception { + test.getServiceRole(); + } + + @Test + public void setServiceRoleTest() throws Exception { + test.setServiceRole("serviceRole"); + } + + @Test + public void getOrchestrationStatusTest() throws Exception { + test.getOrchestrationStatus(); + } + + @Test + public void setOrchestrationStatusTest() throws Exception { + test.setOrchestrationStatus("status"); + } + + @Test + public void getModelInvariantUuidTest() throws Exception { + test.getModelInvariantUuid(); + } + + @Test + public void setModelInvariantUuidTest() throws Exception { + test.setModelInvariantUuid("uuid"); + } + + @Test + public void getModelVersionIdTest() throws Exception { + test.getModelVersionId(); + } + + @Test + public void setModelVersionIdTest() throws Exception { + test.setModelVersionId("versionId"); + } + + @Test + public void getEnvironmentContextTest() throws Exception { + test.getEnvironmentContext(); + } + + @Test + public void setEnvironmentContextTest() throws Exception { + test.setEnvironmentContext("context"); + } + + @Test + public void getWorkloadContextTest() throws Exception { + test.getWorkloadContext(); + } + + @Test + public void setWorkloadContextTest() throws Exception { + test.setWorkloadContext("context"); + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/common/name/generation/AAIObjectInstanceNameGeneratorTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/common/name/generation/AAIObjectInstanceNameGeneratorTest.java index ebcce191e9..9030fa8328 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/common/name/generation/AAIObjectInstanceNameGeneratorTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/common/name/generation/AAIObjectInstanceNameGeneratorTest.java @@ -22,7 +22,6 @@ package org.onap.so.bpmn.infrastructure.common.name.generation; import static org.junit.Assert.assertEquals; - import org.junit.Before; import org.junit.Test; import org.mockito.MockitoAnnotations; @@ -34,25 +33,25 @@ import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; public class AAIObjectInstanceNameGeneratorTest { - @Before - public void before() { - } - - @Test - public void generateInstanceGroupNameTest() throws Exception { - - ModelInfoInstanceGroup modelVnfc = new ModelInfoInstanceGroup(); - modelVnfc.setFunction("vre"); - modelVnfc.setType("VNFC"); - - InstanceGroup instanceGroup = new InstanceGroup(); - instanceGroup.setId("test-001"); - instanceGroup.setModelInfoInstanceGroup(modelVnfc); - GenericVnf vnf = new GenericVnf(); - vnf.setVnfId("vnf-123"); - vnf.setVnfName("test-vnf"); - - assertEquals("test-vnf_vre", new AAIObjectInstanceNameGenerator().generateInstanceGroupName(instanceGroup, vnf)); - } - + @Before + public void before() {} + + @Test + public void generateInstanceGroupNameTest() throws Exception { + + ModelInfoInstanceGroup modelVnfc = new ModelInfoInstanceGroup(); + modelVnfc.setFunction("vre"); + modelVnfc.setType("VNFC"); + + InstanceGroup instanceGroup = new InstanceGroup(); + instanceGroup.setId("test-001"); + instanceGroup.setModelInfoInstanceGroup(modelVnfc); + GenericVnf vnf = new GenericVnf(); + vnf.setVnfId("vnf-123"); + vnf.setVnfName("test-vnf"); + + assertEquals("test-vnf_vre", + new AAIObjectInstanceNameGenerator().generateInstanceGroupName(instanceGroup, vnf)); + } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java index b0ff82e3aa..c67b44e44a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CancelDmaapSubscriptionTest.java @@ -22,7 +22,6 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.junit.Test; - import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; @@ -37,7 +36,8 @@ public class CancelDmaapSubscriptionTest { DmaapClientTestImpl dmaapClientTest = new DmaapClientTestImpl(); delegate.setDmaapClient(dmaapClientTest); DelegateExecution delegateExecution = mock(DelegateExecution.class); - when(delegateExecution.getVariable(eq(ExecutionVariableNames.PNF_CORRELATION_ID))).thenReturn("testPnfCorrelationId"); + when(delegateExecution.getVariable(eq(ExecutionVariableNames.PNF_CORRELATION_ID))) + .thenReturn("testPnfCorrelationId"); when(delegateExecution.getProcessBusinessKey()).thenReturn("testBusinessKey"); dmaapClientTest.registerForUpdate("testPnfCorrelationId", () -> { }); @@ -46,4 +46,4 @@ public class CancelDmaapSubscriptionTest { // then assertThat(dmaapClientTest.haveRegisteredConsumer()).isFalse(); } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForPnfCorrelationIdDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForPnfCorrelationIdDelegateTest.java index 6a0aaf776e..4206d796f6 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForPnfCorrelationIdDelegateTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForPnfCorrelationIdDelegateTest.java @@ -29,7 +29,6 @@ import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl.ID_WITH_ENTRY; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; - import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.junit.Before; @@ -46,9 +45,9 @@ public class CheckAaiForPnfCorrelationIdDelegateTest { public static class ConnectionOkTests { private CheckAaiForPnfCorrelationIdDelegate delegate; - + @Rule - public ExpectedException expectedException = ExpectedException.none(); + public ExpectedException expectedException = ExpectedException.none(); @Before public void setUp() { @@ -94,9 +93,9 @@ public class CheckAaiForPnfCorrelationIdDelegateTest { public static class NoConnectionTests { private CheckAaiForPnfCorrelationIdDelegate delegate; - + @Rule - public ExpectedException expectedException = ExpectedException.none(); + public ExpectedException expectedException = ExpectedException.none(); @Before public void setUp() { @@ -116,4 +115,4 @@ public class CheckAaiForPnfCorrelationIdDelegateTest { verify(execution).setVariable(eq("WorkflowException"), any(WorkflowException.class)); } } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegateTest.java index 571f64335f..5000ca017c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegateTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegateTest.java @@ -1,20 +1,15 @@ /* - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * 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 + * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix + * Foundation. ================================================================================ 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. + * 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. * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= + * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END========================================================= */ package org.onap.so.bpmn.infrastructure.pnf.delegate; @@ -30,7 +25,6 @@ import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableName import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_INSTANCE_NAME; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_MODEL_INFO; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SKIP_POST_INSTANTIATION_CONFIGURATION; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -52,7 +46,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {CatalogDbClient.class, ExceptionBuilder.class, ConfigCheckerDelegate.class, - ProcessEngineConfiguration.class}) + ProcessEngineConfiguration.class}) public class ConfigCheckerDelegateTest { private static String TEST_PROCESS_KEY = "processKey1"; @@ -64,14 +58,11 @@ public class ConfigCheckerDelegateTest { /** * Service model info json. */ - private static String TEST_SERVICE_MODEL_INFO = "{\n" - + " \"modelType\":\"service\",\n" - + " \"modelInvariantUuid\":\"539b7a2f-9524-4dbf-9eee-f2e05521df3f\",\n" - + " \"modelInvariantId\":\"539b7a2f-9524-4dbf-9eee-f2e05521df3f\",\n" - + " \"modelUuid\":\"f2daaac6-5017-4e1e-96c8-6a27dfbe1421\",\n" - + " \"modelName\":\"PNF_demo_resource\",\n" - + " \"modelVersion\":\"1.0\"\n" - + " }"; + private static String TEST_SERVICE_MODEL_INFO = "{\n" + " \"modelType\":\"service\",\n" + + " \"modelInvariantUuid\":\"539b7a2f-9524-4dbf-9eee-f2e05521df3f\",\n" + + " \"modelInvariantId\":\"539b7a2f-9524-4dbf-9eee-f2e05521df3f\",\n" + + " \"modelUuid\":\"f2daaac6-5017-4e1e-96c8-6a27dfbe1421\",\n" + + " \"modelName\":\"PNF_demo_resource\",\n" + " \"modelVersion\":\"1.0\"\n" + " }"; /** * Testing model UUID, should be the same as specified in the TEST_SERVICE_MODEL_INFO. @@ -94,7 +85,7 @@ public class ConfigCheckerDelegateTest { List<PnfResourceCustomization> pnfResourceCustomizations = new ArrayList<>(); pnfResourceCustomizations.add(buildPnfResourceCustomization()); given(catalogDbClient.getPnfResourceCustomizationByModelUuid(TEST_MODEL_UUID)) - .willReturn(pnfResourceCustomizations); + .willReturn(pnfResourceCustomizations); execution.setVariable("testProcessKey", TEST_PROCESS_KEY); execution.setVariable(SERVICE_MODEL_INFO, TEST_SERVICE_MODEL_INFO); } @@ -128,12 +119,12 @@ public class ConfigCheckerDelegateTest { @Test public void testExecution_EmptyPnfResourceCustomization_exceptionThrown() { given(catalogDbClient.getPnfResourceCustomizationByModelUuid("f2daaac6-5017-4e1e-96c8-6a27dfbe1421")) - .willReturn(Collections.EMPTY_LIST); + .willReturn(Collections.EMPTY_LIST); assertThatThrownBy(() -> configCheckerDelegate.execute(execution)).isInstanceOf(BpmnError.class); assertThat(execution.getVariable("WorkflowExceptionErrorMessage")).asString() - .contains("Unable to find the PNF resource customizations of model service UUID") - .contains("f2daaac6-5017-4e1e-96c8-6a27dfbe1421"); + .contains("Unable to find the PNF resource customizations of model service UUID") + .contains("f2daaac6-5017-4e1e-96c8-6a27dfbe1421"); assertThat(execution.getVariable("WorkflowException")).isInstanceOf(WorkflowException.class); } @@ -142,7 +133,7 @@ public class ConfigCheckerDelegateTest { execution.removeVariable("serviceModelInfo"); assertThatThrownBy(() -> configCheckerDelegate.execute(execution)).isInstanceOf(BpmnError.class); assertThat(execution.getVariable("WorkflowExceptionErrorMessage")).asString() - .contains("Unable to find parameter serviceModelInfo"); + .contains("Unable to find parameter serviceModelInfo"); assertThat(execution.getVariable("WorkflowException")).isInstanceOf(WorkflowException.class); } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java index 986edfeecf..c90235b103 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java @@ -27,7 +27,6 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; - import java.util.UUID; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.junit.Test; diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java index c743ee7018..85a9a5c166 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java @@ -23,7 +23,6 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; - import java.io.IOException; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegateTest.java index 8a1cdfa4c0..597d111e2c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegateTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/GeneratePnfUuidDelegateTest.java @@ -22,7 +22,6 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; import static org.assertj.core.api.Assertions.assertThat; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; - import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; import org.junit.Test; diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java index eb9f657d4f..446c73dda1 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/InformDmaapClientTest.java @@ -27,7 +27,6 @@ import org.camunda.bpm.engine.runtime.MessageCorrelationBuilder; import org.junit.Before; import org.junit.Test; import org.mockito.InOrder; - import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; @@ -74,7 +73,8 @@ public class InformDmaapClientTest { private DelegateExecution mockDelegateExecution() { DelegateExecution delegateExecution = mock(DelegateExecution.class); - when(delegateExecution.getVariable(eq(ExecutionVariableNames.PNF_CORRELATION_ID))).thenReturn("testPnfCorrelationId"); + when(delegateExecution.getVariable(eq(ExecutionVariableNames.PNF_CORRELATION_ID))) + .thenReturn("testPnfCorrelationId"); when(delegateExecution.getProcessBusinessKey()).thenReturn("testBusinessKey"); ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class); when(delegateExecution.getProcessEngineServices()).thenReturn(processEngineServices); @@ -85,4 +85,4 @@ public class InformDmaapClientTest { when(messageCorrelationBuilder.processInstanceBusinessKey(any())).thenReturn(messageCorrelationBuilder); return delegateExecution; } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java index 001815b206..6c8716cbd7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java @@ -24,7 +24,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID; - import java.util.UUID; import org.apache.commons.lang3.StringUtils; import org.camunda.bpm.engine.delegate.BpmnError; diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java index 3a9d6d0055..8577d9555b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java @@ -22,7 +22,6 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; import org.onap.aai.domain.yang.Pnf; import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; - import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -51,8 +50,7 @@ public class PnfManagementTestImpl implements PnfManagement { } @Override - public void createRelation(String serviceInstanceId, String pnfName) { - } + public void createRelation(String serviceInstanceId, String pnfName) {} public Map<String, Pnf> getCreated() { return created; diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegateTest.java index 8d817e5bca..110ee2146c 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegateTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigAssignDelegateTest.java @@ -1,20 +1,15 @@ /* - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * 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 + * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix + * Foundation. ================================================================================ 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. + * 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. * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= + * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END========================================================= */ package org.onap.so.bpmn.infrastructure.pnf.delegate; @@ -32,7 +27,6 @@ import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableName import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CUSTOMIZATION_UUID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_INSTANCE_NAME; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID; - import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; @@ -72,7 +66,7 @@ public class PrepareConfigAssignDelegateTest { private DelegateExecution execution = new DelegateExecutionFake(); @Before - public void setUp(){ + public void setUp() { execution.setVariable("testProcessKey", TEST_PROCESS_KEY); execution.setVariable(PNF_CORRELATION_ID, TEST_PNF_CORRELATION_ID); execution.setVariable(MODEL_UUID, TEST_MODEL_UUID); @@ -118,8 +112,8 @@ public class PrepareConfigAssignDelegateTest { try { ObjectMapper mapper = new ObjectMapper(); JsonNode tree = mapper.readTree(requestObject); - ConfigAssignRequestPnf configAssignRequestPnf = mapper - .treeToValue(tree.at("/config-assign-request"), ConfigAssignRequestPnf.class); + ConfigAssignRequestPnf configAssignRequestPnf = + mapper.treeToValue(tree.at("/config-assign-request"), ConfigAssignRequestPnf.class); assertThat(configAssignRequestPnf.getResolutionKey()).matches(TEST_PNF_CORRELATION_ID); ConfigAssignPropertiesForPnf properties = configAssignRequestPnf.getConfigAssignPropertiesForPnf(); @@ -133,4 +127,4 @@ public class PrepareConfigAssignDelegateTest { fail("Check request body is json message" + e.getMessage()); } } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegateTest.java index 0964d2146b..8d19d9e563 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegateTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PrepareConfigDeployDelegateTest.java @@ -1,20 +1,15 @@ /* - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * 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 + * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix + * Foundation. ================================================================================ 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. + * 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. * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= + * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END========================================================= */ package org.onap.so.bpmn.infrastructure.pnf.delegate; @@ -34,7 +29,6 @@ import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableName import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CUSTOMIZATION_UUID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_INSTANCE_NAME; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID; - import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; @@ -119,7 +113,7 @@ public class PrepareConfigDeployDelegateTest { } @Test - public void testExecution_failedAaiConnection_exceptionThrown(){ + public void testExecution_failedAaiConnection_exceptionThrown() { try { /** * Mock the IOException from AAI. @@ -128,13 +122,14 @@ public class PrepareConfigDeployDelegateTest { } catch (IOException e) { e.printStackTrace(); } - assertThatThrownBy(()->prepareConfigDeployDelegate.execute(execution)).isInstanceOf(BpmnError.class); - assertThat(execution.getVariable("WorkflowExceptionErrorMessage")).asString().contains("Unable to fetch from AAI"); + assertThatThrownBy(() -> prepareConfigDeployDelegate.execute(execution)).isInstanceOf(BpmnError.class); + assertThat(execution.getVariable("WorkflowExceptionErrorMessage")).asString() + .contains("Unable to fetch from AAI"); assertThat(execution.getVariable("WorkflowException")).isInstanceOf(WorkflowException.class); } @Test - public void testExecution_aaiEntryNotExist_exceptionThrown(){ + public void testExecution_aaiEntryNotExist_exceptionThrown() { try { /** * Mock the AAI without PNF. @@ -143,8 +138,9 @@ public class PrepareConfigDeployDelegateTest { } catch (IOException e) { e.printStackTrace(); } - assertThatThrownBy(()->prepareConfigDeployDelegate.execute(execution)).isInstanceOf(BpmnError.class); - assertThat(execution.getVariable("WorkflowExceptionErrorMessage")).asString().contains("AAI entry for PNF: " + TEST_PNF_CORRELATION_ID + " does not exist"); + assertThatThrownBy(() -> prepareConfigDeployDelegate.execute(execution)).isInstanceOf(BpmnError.class); + assertThat(execution.getVariable("WorkflowExceptionErrorMessage")).asString() + .contains("AAI entry for PNF: " + TEST_PNF_CORRELATION_ID + " does not exist"); assertThat(execution.getVariable("WorkflowException")).isInstanceOf(WorkflowException.class); } @@ -167,12 +163,11 @@ public class PrepareConfigDeployDelegateTest { try { ObjectMapper mapper = new ObjectMapper(); JsonNode tree = mapper.readTree(requestObject); - ConfigDeployRequestPnf configDeployRequestPnf = mapper - .treeToValue(tree.at("/config-deploy-request"), ConfigDeployRequestPnf.class); + ConfigDeployRequestPnf configDeployRequestPnf = + mapper.treeToValue(tree.at("/config-deploy-request"), ConfigDeployRequestPnf.class); assertThat(configDeployRequestPnf.getResolutionKey()).matches(TEST_PNF_CORRELATION_ID); - ConfigDeployPropertiesForPnf properties = configDeployRequestPnf - .getConfigDeployPropertiesForPnf(); + ConfigDeployPropertiesForPnf properties = configDeployRequestPnf.getConfigDeployPropertiesForPnf(); assertThat(properties.getServiceInstanceId()).matches(TEST_SERVICE_INSTANCE_ID); assertThat(properties.getPnfName()).matches(TEST_PNF_CORRELATION_ID); assertThat(properties.getPnfId()).matches(TEST_PNF_UUID); @@ -185,4 +180,4 @@ public class PrepareConfigDeployDelegateTest { fail("Check request body is json message" + e.getMessage()); } } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java index 17a6ee09d8..8741208d26 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java @@ -23,7 +23,6 @@ package org.onap.so.bpmn.infrastructure.pnf.dmaap; import static org.assertj.core.api.Assertions.assertThat; - import java.util.List; import org.junit.Test; @@ -41,12 +40,12 @@ public class JsonUtilForPnfCorrelationIdTest { @Test public void parseJsonSuccessful() { - List<String> expectedResult = JsonUtilForPnfCorrelationId - .parseJsonToGelAllPnfCorrelationId(JSON_EXAMPLE_WITH_PNF_CORRELATION_ID); + List<String> expectedResult = + JsonUtilForPnfCorrelationId.parseJsonToGelAllPnfCorrelationId(JSON_EXAMPLE_WITH_PNF_CORRELATION_ID); assertThat(expectedResult).containsExactly("corrTest1", "corrTest2"); - List<String> expectedResult2 = JsonUtilForPnfCorrelationId - .parseJsonToGelAllPnfCorrelationId(JSON_WITH_ONE_PNF_CORRELATION_ID); + List<String> expectedResult2 = + JsonUtilForPnfCorrelationId.parseJsonToGelAllPnfCorrelationId(JSON_WITH_ONE_PNF_CORRELATION_ID); assertThat(expectedResult2).containsExactly("corrTest3"); } @@ -59,8 +58,8 @@ public class JsonUtilForPnfCorrelationIdTest { @Test public void parseJson_emptyListReturnedWhenNothingFound() { - List<String> expectedResult = JsonUtilForPnfCorrelationId - .parseJsonToGelAllPnfCorrelationId(JSON_WITH_NO_PNF_CORRELATION_ID); + List<String> expectedResult = + JsonUtilForPnfCorrelationId.parseJsonToGelAllPnfCorrelationId(JSON_WITH_NO_PNF_CORRELATION_ID); assertThat(expectedResult).isEmpty(); } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java index cbfe6c1512..ca3373e8cb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java @@ -30,14 +30,12 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; - import java.io.IOException; import java.io.UnsupportedEncodingException; import java.lang.reflect.Field; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledThreadPoolExecutor; - import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.ProtocolVersion; @@ -53,6 +51,7 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.bpmn.infrastructure.pnf.dmaap.PnfEventReadyDmaapClient.DmaapTopicListenerThread; import org.springframework.core.env.Environment; + @RunWith(MockitoJUnitRunner.class) public class PnfEventReadyDmaapClientTest { @@ -83,8 +82,8 @@ public class PnfEventReadyDmaapClientTest { @Before public void init() throws NoSuchFieldException, IllegalAccessException { - when(env.getProperty(eq("pnf.dmaap.port"), eq(Integer.class))).thenReturn(PORT); - when(env.getProperty(eq("pnf.dmaap.host"))).thenReturn(HOST); + when(env.getProperty(eq("pnf.dmaap.port"), eq(Integer.class))).thenReturn(PORT); + when(env.getProperty(eq("pnf.dmaap.host"))).thenReturn(HOST); when(env.getProperty(eq("pnf.dmaap.protocol"))).thenReturn(PROTOCOL); when(env.getProperty(eq("pnf.dmaap.uriPathPrefix"))).thenReturn(URI_PATH_PREFIX); when(env.getProperty(eq("pnf.dmaap.topicName"))).thenReturn(EVENT_TOPIC_TEST); @@ -102,56 +101,60 @@ public class PnfEventReadyDmaapClientTest { /** * Test run method, where the are following conditions: - * <p> - DmaapThreadListener is running, flag is set to true - * <p> - map is filled with one entry with the key that we get from response - * <p> run method should invoke thread from map to notify camunda process, remove element from the map (map is - * empty) and shutdown the executor because of empty map + * <p> + * - DmaapThreadListener is running, flag is set to true + * <p> + * - map is filled with one entry with the key that we get from response + * <p> + * run method should invoke thread from map to notify camunda process, remove element from the map (map is empty) + * and shutdown the executor because of empty map */ @Test - public void pnfCorrelationIdIsFoundInHttpResponse_notifyAboutPnfReady() - throws IOException { - when(httpClientMock.execute(any(HttpGet.class))). - thenReturn(createResponse(String.format(JSON_EXAMPLE_WITH_PNF_CORRELATION_ID, PNF_CORRELATION_ID))); + public void pnfCorrelationIdIsFoundInHttpResponse_notifyAboutPnfReady() throws IOException { + when(httpClientMock.execute(any(HttpGet.class))) + .thenReturn(createResponse(String.format(JSON_EXAMPLE_WITH_PNF_CORRELATION_ID, PNF_CORRELATION_ID))); testedObjectInnerClassThread.run(); ArgumentCaptor<HttpGet> captor1 = ArgumentCaptor.forClass(HttpGet.class); - verify(httpClientMock).execute(captor1.capture()); - - assertEquals(captor1.getValue().getURI().getHost(),HOST); - assertEquals(captor1.getValue().getURI().getPort(),PORT); - assertEquals(captor1.getValue().getURI().getScheme(),PROTOCOL); - assertEquals(captor1.getValue().getURI().getPath(),"/" + URI_PATH_PREFIX + "/" + EVENT_TOPIC_TEST + "/" + CONSUMER_GROUP + "/" + CONSUMER_ID + ""); - - //verify(threadMockToNotifyCamundaFlow).run(); + verify(httpClientMock).execute(captor1.capture()); + + assertEquals(captor1.getValue().getURI().getHost(), HOST); + assertEquals(captor1.getValue().getURI().getPort(), PORT); + assertEquals(captor1.getValue().getURI().getScheme(), PROTOCOL); + assertEquals(captor1.getValue().getURI().getPath(), + "/" + URI_PATH_PREFIX + "/" + EVENT_TOPIC_TEST + "/" + CONSUMER_GROUP + "/" + CONSUMER_ID + ""); + + // verify(threadMockToNotifyCamundaFlow).run(); verify(executorMock).shutdown(); } /** * Test run method, where the are following conditions: - * <p> - DmaapThreadListener is running, flag is set to true - * <p> - map is filled with one entry with the pnfCorrelationId that does not match to pnfCorrelationId - * taken from http response. run method should not do anything with the map not run any thread to notify camunda - * process + * <p> + * - DmaapThreadListener is running, flag is set to true + * <p> + * - map is filled with one entry with the pnfCorrelationId that does not match to pnfCorrelationId taken from http + * response. run method should not do anything with the map not run any thread to notify camunda process */ @Test - public void pnfCorrelationIdIsFoundInHttpResponse_NotFoundInMap() - throws IOException { - when(httpClientMock.execute(any(HttpGet.class))). - thenReturn(createResponse( - String.format(JSON_EXAMPLE_WITH_PNF_CORRELATION_ID, PNF_CORRELATION_ID_NOT_FOUND_IN_MAP))); + public void pnfCorrelationIdIsFoundInHttpResponse_NotFoundInMap() throws IOException { + when(httpClientMock.execute(any(HttpGet.class))).thenReturn(createResponse( + String.format(JSON_EXAMPLE_WITH_PNF_CORRELATION_ID, PNF_CORRELATION_ID_NOT_FOUND_IN_MAP))); testedObjectInnerClassThread.run(); verifyZeroInteractions(threadMockToNotifyCamundaFlow, executorMock); } /** * Test run method, where the are following conditions: - * <p> - DmaapThreadListener is running, flag is set to true - * <p> - map is filled with one entry with the pnfCorrelationId but no correlation id is taken from HttpResponse - * run method should not do anything with the map and not run any thread to notify camunda process + * <p> + * - DmaapThreadListener is running, flag is set to true + * <p> + * - map is filled with one entry with the pnfCorrelationId but no correlation id is taken from HttpResponse run + * method should not do anything with the map and not run any thread to notify camunda process */ @Test public void pnfCorrelationIdIsNotFoundInHttpResponse() throws IOException { - when(httpClientMock.execute(any(HttpGet.class))). - thenReturn(createResponse(JSON_EXAMPLE_WITH_NO_PNF_CORRELATION_ID)); + when(httpClientMock.execute(any(HttpGet.class))) + .thenReturn(createResponse(JSON_EXAMPLE_WITH_NO_PNF_CORRELATION_ID)); testedObjectInnerClassThread.run(); verifyZeroInteractions(threadMockToNotifyCamundaFlow, executorMock); } @@ -167,8 +170,7 @@ public class PnfEventReadyDmaapClientTest { executorField.set(testedObject, executorMock); executorField.setAccessible(false); - Field pnfCorrelationToThreadMapField = testedObject.getClass() - .getDeclaredField("pnfCorrelationIdToThreadMap"); + Field pnfCorrelationToThreadMapField = testedObject.getClass().getDeclaredField("pnfCorrelationIdToThreadMap"); pnfCorrelationToThreadMapField.setAccessible(true); Map<String, Runnable> pnfCorrelationToThreadMap = new ConcurrentHashMap<>(); pnfCorrelationToThreadMap.put(PNF_CORRELATION_ID, threadMockToNotifyCamundaFlow); diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/vfcmodel/VfcModelPojoTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/vfcmodel/VfcModelPojoTest.java index 239361d306..61a4654668 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/vfcmodel/VfcModelPojoTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/vfcmodel/VfcModelPojoTest.java @@ -21,7 +21,6 @@ package org.onap.so.bpmn.infrastructure.vfcmodel; import org.junit.Test; - import com.openpojo.validation.Validator; import com.openpojo.validation.ValidatorBuilder; import com.openpojo.validation.rule.impl.NoNestedClassRule; @@ -30,16 +29,12 @@ import com.openpojo.validation.test.impl.GetterTester; import com.openpojo.validation.test.impl.SetterTester; public class VfcModelPojoTest { - private String packageName = "org.onap.so.bpmn.infrastructure.vfcmodel"; + private String packageName = "org.onap.so.bpmn.infrastructure.vfcmodel"; - @Test - public void validate() { - Validator validator = ValidatorBuilder.create() - .with(new NoNestedClassRule()) - .with(new NoPublicFieldsRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .build(); - validator.validate(packageName); - } + @Test + public void validate() { + Validator validator = ValidatorBuilder.create().with(new NoNestedClassRule()).with(new NoPublicFieldsRule()) + .with(new SetterTester()).with(new GetterTester()).build(); + validator.validate(packageName); + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactoryTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactoryTest.java index 6e22123996..0b4050beec 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactoryTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactoryTest.java @@ -20,7 +20,6 @@ package org.onap.so.bpmn.infrastructure.workflow.service; import static org.mockito.Mockito.doReturn; - import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -38,80 +37,53 @@ public class ServicePluginFactoryTest { @Spy ServicePluginFactory servicePluginFactory; - String uuiRequest = "{" - + " \"service\":{" - + " \"name\":\"ONAP_223531\"," - + " \"description\":\"ONAP_1546\"," - + " \"serviceInvariantUuid\":\"4a09419a-c9fd-4a53-b1bd-b49603169ca1\"," - + " \"serviceUuid\":\"1bd0eae6-2dcc-4461-9ae6-56d641f369d6\"," - + " \"globalSubscriberId\":\"test_custormer\"," - + " \"serviceType\":\"example-service-type\"," - + " \"parameters\":{" - + " \"locationConstraints\":[" - + " ]," - + " \"resources\":[" - + " {" - + " \"resourceName\":\"vEPC_ONAP01\"," - + " \"resourceInvariantUuid\":\"36ebe421-283a-4ee8-92f1-d09e7c44b911\"," - + " \"resourceUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed111\"," - + " \"resourceCustomizationUuid\":\"47a0e235-b67a-4ea4-a0cf-25761afed231\"," - + " \"parameters\":{" - + " \"locationConstraints\":[" - + " {" - + " \"vnfProfileId\":\"b244d433-8c9c-49ad-9c70-8e34b8dc8328\"," - + " \"locationConstraints\":{" - + " \"vimId\":\"vmware_vio\"" - + " }" - + " }," - + " {" - + " \"vnfProfileId\":\"8a9f7c48-21ce-41b7-95b8-a8ac61ccb1ff\"," - + " \"locationConstraints\":{" - + " \"vimId\":\"core-dc_RegionOne\"" - + " }" - + " }" - + " ]," - + " \"resources\":[" - + " ]," - + " \"requestInputs\":{" - + " \"sdncontroller\":\"\"" - + " }" - + " }" - + " }," - + " {" - + " \"resourceName\":\"VL OVERLAYTUNNEL\"," - + " \"resourceInvariantUuid\":\"184494cf-472f-436f-82e2-d83dddde21cb\"," - + " \"resourceUuid\":\"95bc3e59-c9c5-458f-ad6e-78874ab4b3cc\"," - + " \"resourceCustomizationUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed232\"," - + " \"parameters\":{" - + " \"locationConstraints\":[" - + " ]," - + " \"resources\":[" - + " ]," - + " \"requestInputs\":{" - + " }" - + " }" - + " }" - + " ]," - + " \"requestInputs\":{" - + " \"vlunderlayvpn0_name\":\"l3connect\"," - + " \"vlunderlayvpn0_site1_id\":\"IP-WAN-Controller-1\"," - + " \"vlunderlayvpn0_site2_id\":\"SPTNController\"," - + " \"vlunderlayvpn0_site1_networkName\":\"network1,network2\"," - + " \"vlunderlayvpn0_site2_networkName\":\"network3,network4\"," - + " \"vlunderlayvpn0_site1_routerId\":\"a8098c1a-f86e-11da-bd1a-00112444be1a\"," - + " \"vlunderlayvpn0_site2_routerId\":\"a8098c1a-f86e-11da-bd1a-00112444be1e\"," - + " \"vlunderlayvpn0_site2_importRT1\":\"200:1,200:2\"," - + " \"vlunderlayvpn0_site1_exportRT1\":\"300:1,300:2\"," - + " \"vlunderlayvpn0_site2_exportRT1\":\"400:1,400:2\"," - + " \"vlunderlayvpn0_site1_vni\":\"2000\"," - + " \"vlunderlayvpn0_site2_vni\":\"3000\"," - + " \"vlunderlayvpn0_tunnelType\":\"L3-DCI\"," - + " \"CallSource\":\"NOT-ExternalAPI\"," - + " \"sotnconnectivity\":\"\"" - + " }" - + " }" - + " }" - + "}"; + String uuiRequest = "{" + " \"service\":{" + " \"name\":\"ONAP_223531\"," + + " \"description\":\"ONAP_1546\"," + + " \"serviceInvariantUuid\":\"4a09419a-c9fd-4a53-b1bd-b49603169ca1\"," + + " \"serviceUuid\":\"1bd0eae6-2dcc-4461-9ae6-56d641f369d6\"," + + " \"globalSubscriberId\":\"test_custormer\"," + " \"serviceType\":\"example-service-type\"," + + " \"parameters\":{" + " \"locationConstraints\":[" + " ]," + + " \"resources\":[" + " {" + + " \"resourceName\":\"vEPC_ONAP01\"," + + " \"resourceInvariantUuid\":\"36ebe421-283a-4ee8-92f1-d09e7c44b911\"," + + " \"resourceUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed111\"," + + " \"resourceCustomizationUuid\":\"47a0e235-b67a-4ea4-a0cf-25761afed231\"," + + " \"parameters\":{" + " \"locationConstraints\":[" + + " {" + + " \"vnfProfileId\":\"b244d433-8c9c-49ad-9c70-8e34b8dc8328\"," + + " \"locationConstraints\":{" + + " \"vimId\":\"vmware_vio\"" + " }" + + " }," + " {" + + " \"vnfProfileId\":\"8a9f7c48-21ce-41b7-95b8-a8ac61ccb1ff\"," + + " \"locationConstraints\":{" + + " \"vimId\":\"core-dc_RegionOne\"" + + " }" + " }" + " ]," + + " \"resources\":[" + " ]," + + " \"requestInputs\":{" + " \"sdncontroller\":\"\"" + + " }" + " }" + " }," + " {" + + " \"resourceName\":\"VL OVERLAYTUNNEL\"," + + " \"resourceInvariantUuid\":\"184494cf-472f-436f-82e2-d83dddde21cb\"," + + " \"resourceUuid\":\"95bc3e59-c9c5-458f-ad6e-78874ab4b3cc\"," + + " \"resourceCustomizationUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed232\"," + + " \"parameters\":{" + " \"locationConstraints\":[" + + " ]," + " \"resources\":[" + " ]," + + " \"requestInputs\":{" + " }" + " }" + + " }" + " ]," + " \"requestInputs\":{" + + " \"vlunderlayvpn0_name\":\"l3connect\"," + + " \"vlunderlayvpn0_site1_id\":\"IP-WAN-Controller-1\"," + + " \"vlunderlayvpn0_site2_id\":\"SPTNController\"," + + " \"vlunderlayvpn0_site1_networkName\":\"network1,network2\"," + + " \"vlunderlayvpn0_site2_networkName\":\"network3,network4\"," + + " \"vlunderlayvpn0_site1_routerId\":\"a8098c1a-f86e-11da-bd1a-00112444be1a\"," + + " \"vlunderlayvpn0_site2_routerId\":\"a8098c1a-f86e-11da-bd1a-00112444be1e\"," + + " \"vlunderlayvpn0_site2_importRT1\":\"200:1,200:2\"," + + " \"vlunderlayvpn0_site1_exportRT1\":\"300:1,300:2\"," + + " \"vlunderlayvpn0_site2_exportRT1\":\"400:1,400:2\"," + + " \"vlunderlayvpn0_site1_vni\":\"2000\"," + + " \"vlunderlayvpn0_site2_vni\":\"3000\"," + + " \"vlunderlayvpn0_tunnelType\":\"L3-DCI\"," + + " \"CallSource\":\"NOT-ExternalAPI\"," + " \"sotnconnectivity\":\"\"" + + " }" + " }" + " }" + "}"; @Test @@ -123,16 +95,14 @@ public class ServicePluginFactoryTest { @Test public void doProcessSiteLocation_uuiObjectNull() { String faultyJsonInput = "site_address,sotncondition_clientsignal"; - String result = servicePluginFactory.doProcessSiteLocation( - serviceDecomposition, faultyJsonInput); + String result = servicePluginFactory.doProcessSiteLocation(serviceDecomposition, faultyJsonInput); Assert.assertEquals(result, faultyJsonInput); } @Test public void doProcessSiteLocation_isSiteLocationLocal() { String jsonWithOnlyNeededValues = "{\"site_address\":\"\",\"sotncondition_clientsignal\":\"\"}"; - String result = servicePluginFactory.doProcessSiteLocation( - serviceDecomposition, jsonWithOnlyNeededValues); + String result = servicePluginFactory.doProcessSiteLocation(serviceDecomposition, jsonWithOnlyNeededValues); Assert.assertEquals(result, jsonWithOnlyNeededValues); } @@ -153,7 +123,7 @@ public class ServicePluginFactoryTest { @Test public void doTPResourcesAllocation_isNeedAllocateCrossTPResources() { - //doReturn(null).when(servicePluginFactory).getTPsfromAAI(); + // doReturn(null).when(servicePluginFactory).getTPsfromAAI(); String jsonWithOnlyNeededValues = "{\"site_address\":\"\",\"sotncondition_clientsignal\":\"\"}"; String result = servicePluginFactory.doTPResourcesAllocation(null, jsonWithOnlyNeededValues); Assert.assertEquals(result, jsonWithOnlyNeededValues); diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/HeaderUtilTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/HeaderUtilTest.java index ca8ec22088..f523e7ab1d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/HeaderUtilTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/HeaderUtilTest.java @@ -20,15 +20,14 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask.client; import static org.junit.Assert.assertEquals; - import org.junit.Test; public class HeaderUtilTest { @Test public void getAuthorizationTest() throws Exception { - String authorization = HeaderUtil.getAuthorization(HeaderUtil.USER, HeaderUtil.PASS); - assertEquals("Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==", authorization); + String authorization = HeaderUtil.getAuthorization(HeaderUtil.USER, HeaderUtil.PASS); + assertEquals("Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==", authorization); } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilderTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilderTest.java index 4ac131f873..6f884cb126 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilderTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilderTest.java @@ -20,13 +20,11 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder; import static org.junit.Assert.assertEquals; - import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; - import org.camunda.bpm.engine.ProcessEngine; import org.camunda.bpm.engine.ProcessEngineServices; import org.camunda.bpm.engine.delegate.DelegateExecution; @@ -52,10 +50,10 @@ public class AbstractBuilderTest { DelegateExecution delegateExecution = new DelegateExecution() { private String operType; - private String resourceType; - private String requestId; + private String resourceType; + private String requestId; - @Override + @Override public String getProcessInstanceId() { return null; } @@ -207,14 +205,14 @@ public class AbstractBuilderTest { @Override public Object getVariable(String s) { - if (AbstractBuilder.OPERATION_TYPE.equals(s)) { - return operType; - } else if (AbstractBuilder.RESOURCE_TYPE.equals(s)) { - return resourceType; - } else if ("msoRequestId".equals(s)) { - return requestId; - } - return null; + if (AbstractBuilder.OPERATION_TYPE.equals(s)) { + return operType; + } else if (AbstractBuilder.RESOURCE_TYPE.equals(s)) { + return resourceType; + } else if ("msoRequestId".equals(s)) { + return requestId; + } + return null; } @Override @@ -254,13 +252,13 @@ public class AbstractBuilderTest { @Override public void setVariable(String s, Object o) { - if (AbstractBuilder.OPERATION_TYPE.equals(s)) { - operType = (String) o; - } else if (AbstractBuilder.RESOURCE_TYPE.equals(s)) { - resourceType = (String) o; - } else if ("msoRequestId".equals(s)) { - requestId = (String) o; - } + if (AbstractBuilder.OPERATION_TYPE.equals(s)) { + operType = (String) o; + } else if (AbstractBuilder.RESOURCE_TYPE.equals(s)) { + resourceType = (String) o; + } else if ("msoRequestId".equals(s)) { + requestId = (String) o; + } } @Override @@ -328,27 +326,27 @@ public class AbstractBuilderTest { } - @Override - public ProcessEngine getProcessEngine(){ - // TODO Auto-generated method stub - return null; - } + @Override + public ProcessEngine getProcessEngine() { + // TODO Auto-generated method stub + return null; + } - @Override - public void setProcessBusinessKey(String arg0){ - // TODO Auto-generated method stub + @Override + public void setProcessBusinessKey(String arg0) { + // TODO Auto-generated method stub - } + } }; @Test public void requestActionGetIntValueTest() { - assertEquals(0, RequestAction.CREATE_NETWORK_INSTANCE.getIntValue()); + assertEquals(0, RequestAction.CREATE_NETWORK_INSTANCE.getIntValue()); } @Test public void svcActionGetIntValueTest() { - assertEquals(0, SvcAction.RESERVE.getIntValue()); + assertEquals(0, SvcAction.RESERVE.getIntValue()); } @Test @@ -358,81 +356,93 @@ public class AbstractBuilderTest { @Test public void getRequestActionBlankOperationTypeTest() throws Exception { - assertEquals(AbstractBuilder.RequestAction.CREATE_NETWORK_INSTANCE.getName(), abstractBuilder.getRequestAction(delegateExecution)); + assertEquals(AbstractBuilder.RequestAction.CREATE_NETWORK_INSTANCE.getName(), + abstractBuilder.getRequestAction(delegateExecution)); } @Test public void getRequestActionDeleteOperationTypeBlankResourceTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); - delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, ""); - assertEquals(AbstractBuilder.RequestAction.DELETE_SERVICE_INSTANCE.getName(), abstractBuilder.getRequestAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); + delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, ""); + assertEquals(AbstractBuilder.RequestAction.DELETE_SERVICE_INSTANCE.getName(), + abstractBuilder.getRequestAction(delegateExecution)); } @Test public void getRequestActionDeleteOperationTypeBadResourceTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); - delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "bad"); - assertEquals(AbstractBuilder.RequestAction.DELETE_SERVICE_INSTANCE.getName(), abstractBuilder.getRequestAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); + delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "bad"); + assertEquals(AbstractBuilder.RequestAction.DELETE_SERVICE_INSTANCE.getName(), + abstractBuilder.getRequestAction(delegateExecution)); } @Test public void getRequestActionDeleteOperationTypeOverlayResourceTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); - delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "overlay"); - assertEquals(AbstractBuilder.RequestAction.DEACTIVATE_DCI_NETWORK_INSTANCE.getName(), abstractBuilder.getRequestAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); + delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "overlay"); + assertEquals(AbstractBuilder.RequestAction.DEACTIVATE_DCI_NETWORK_INSTANCE.getName(), + abstractBuilder.getRequestAction(delegateExecution)); } @Test public void getRequestActionDeleteOperationTypeUnderlayResourceTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); - delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "underlay"); - assertEquals(AbstractBuilder.RequestAction.DELETE_NETWORK_INSTANCE.getName(), abstractBuilder.getRequestAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); + delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "underlay"); + assertEquals(AbstractBuilder.RequestAction.DELETE_NETWORK_INSTANCE.getName(), + abstractBuilder.getRequestAction(delegateExecution)); } @Test public void getRequestActionDeleteOperationTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); - assertEquals(AbstractBuilder.RequestAction.DELETE_SERVICE_INSTANCE.getName(), abstractBuilder.getRequestAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); + assertEquals(AbstractBuilder.RequestAction.DELETE_SERVICE_INSTANCE.getName(), + abstractBuilder.getRequestAction(delegateExecution)); } @Test public void getRequestActionCreateOperationTypeBlankResourceTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); - delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, ""); - assertEquals(AbstractBuilder.RequestAction.CREATE_SERVICE_INSTANCE.getName(), abstractBuilder.getRequestAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); + delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, ""); + assertEquals(AbstractBuilder.RequestAction.CREATE_SERVICE_INSTANCE.getName(), + abstractBuilder.getRequestAction(delegateExecution)); } @Test public void getRequestActionCreateOperationTypeBadResourceTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); - delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "bad"); - assertEquals(AbstractBuilder.RequestAction.CREATE_SERVICE_INSTANCE.getName(), abstractBuilder.getRequestAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); + delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "bad"); + assertEquals(AbstractBuilder.RequestAction.CREATE_SERVICE_INSTANCE.getName(), + abstractBuilder.getRequestAction(delegateExecution)); } @Test public void getRequestActionCreateOperationTypeOverlayResourceTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); - delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "overlay"); - assertEquals(AbstractBuilder.RequestAction.ACTIVATE_DCI_NETWORK_INSTANCE.getName(), abstractBuilder.getRequestAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); + delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "overlay"); + assertEquals(AbstractBuilder.RequestAction.ACTIVATE_DCI_NETWORK_INSTANCE.getName(), + abstractBuilder.getRequestAction(delegateExecution)); } @Test public void getRequestActionCreateOperationTypeUnderlayResourceTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); - delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "underlay"); - assertEquals(AbstractBuilder.RequestAction.CREATE_NETWORK_INSTANCE.getName(), abstractBuilder.getRequestAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); + delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "underlay"); + assertEquals(AbstractBuilder.RequestAction.CREATE_NETWORK_INSTANCE.getName(), + abstractBuilder.getRequestAction(delegateExecution)); } @Test public void getRequestActionCreateOperationTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); - assertEquals(AbstractBuilder.RequestAction.CREATE_SERVICE_INSTANCE.getName(), abstractBuilder.getRequestAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); + assertEquals(AbstractBuilder.RequestAction.CREATE_SERVICE_INSTANCE.getName(), + abstractBuilder.getRequestAction(delegateExecution)); } @Test public void getRequestActionBadOperationType() { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, "bad"); - assertEquals(AbstractBuilder.RequestAction.CREATE_NETWORK_INSTANCE.getName(), abstractBuilder.getRequestAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, "bad"); + assertEquals(AbstractBuilder.RequestAction.CREATE_NETWORK_INSTANCE.getName(), + abstractBuilder.getRequestAction(delegateExecution)); } @Test @@ -442,95 +452,95 @@ public class AbstractBuilderTest { @Test public void getSvcActionDeleteOperationTypeBlankResourceTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); - delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, ""); - assertEquals(AbstractBuilder.SvcAction.UNASSIGN.getName(), abstractBuilder.getSvcAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); + delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, ""); + assertEquals(AbstractBuilder.SvcAction.UNASSIGN.getName(), abstractBuilder.getSvcAction(delegateExecution)); } @Test public void getSvcActionDeleteOperationTypeBadResourceTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); - delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "bad"); - assertEquals(AbstractBuilder.SvcAction.UNASSIGN.getName(), abstractBuilder.getSvcAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); + delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "bad"); + assertEquals(AbstractBuilder.SvcAction.UNASSIGN.getName(), abstractBuilder.getSvcAction(delegateExecution)); } @Test public void getSvcActionDeleteOperationTypeOverlayResourceTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); - delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "overlay"); - assertEquals(AbstractBuilder.SvcAction.DEACTIVATE.getName(), abstractBuilder.getSvcAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); + delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "overlay"); + assertEquals(AbstractBuilder.SvcAction.DEACTIVATE.getName(), abstractBuilder.getSvcAction(delegateExecution)); } @Test public void getSvcActionDeleteOperationTypeUnderlayResourceTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); - delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "underlay"); - assertEquals(AbstractBuilder.SvcAction.DELETE.getName(), abstractBuilder.getSvcAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); + delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "underlay"); + assertEquals(AbstractBuilder.SvcAction.DELETE.getName(), abstractBuilder.getSvcAction(delegateExecution)); } @Test public void getSvcActionDeleteOperationTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); - assertEquals(AbstractBuilder.SvcAction.UNASSIGN.getName(), abstractBuilder.getSvcAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.DELETE); + assertEquals(AbstractBuilder.SvcAction.UNASSIGN.getName(), abstractBuilder.getSvcAction(delegateExecution)); } @Test public void getSvcActionCreateOperationTypeBlankResourceTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); - delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, ""); - assertEquals(AbstractBuilder.SvcAction.ASSIGN.getName(), abstractBuilder.getSvcAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); + delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, ""); + assertEquals(AbstractBuilder.SvcAction.ASSIGN.getName(), abstractBuilder.getSvcAction(delegateExecution)); } @Test public void getSvcActionCreateOperationTypeBadResourceTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); - delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "bad"); - assertEquals(AbstractBuilder.SvcAction.ASSIGN.getName(), abstractBuilder.getSvcAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); + delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "bad"); + assertEquals(AbstractBuilder.SvcAction.ASSIGN.getName(), abstractBuilder.getSvcAction(delegateExecution)); } @Test public void getSvcActionCreateOperationTypeOverlayResourceTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); - delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "overlay"); - assertEquals(AbstractBuilder.SvcAction.ACTIVATE.getName(), abstractBuilder.getSvcAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); + delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "overlay"); + assertEquals(AbstractBuilder.SvcAction.ACTIVATE.getName(), abstractBuilder.getSvcAction(delegateExecution)); } @Test public void getSvcActionCreateOperationTypeUnderlayResourceTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); - delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "underlay"); - assertEquals(AbstractBuilder.SvcAction.CREATE.getName(), abstractBuilder.getSvcAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); + delegateExecution.setVariable(AbstractBuilder.RESOURCE_TYPE, "underlay"); + assertEquals(AbstractBuilder.SvcAction.CREATE.getName(), abstractBuilder.getSvcAction(delegateExecution)); } @Test public void getSvcActionCreateOperationTypeTest() throws Exception { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); - assertEquals(AbstractBuilder.SvcAction.ASSIGN.getName(), abstractBuilder.getSvcAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, RequestsDbConstant.OperationType.CREATE); + assertEquals(AbstractBuilder.SvcAction.ASSIGN.getName(), abstractBuilder.getSvcAction(delegateExecution)); } @Test public void getSvcActionBadOperationType() { - delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, "bad"); - assertEquals(AbstractBuilder.SvcAction.CREATE.getName(), abstractBuilder.getSvcAction(delegateExecution)); + delegateExecution.setVariable(AbstractBuilder.OPERATION_TYPE, "bad"); + assertEquals(AbstractBuilder.SvcAction.CREATE.getName(), abstractBuilder.getSvcAction(delegateExecution)); } @Test public void getRequestIdBlankNotOnExecutionTest() { - abstractBuilder.getRequestId(delegateExecution); + abstractBuilder.getRequestId(delegateExecution); } @Test public void getRequestIdBlankOnExecutionTest() { - String expected = "requestId"; - delegateExecution.setVariable("msoRequestId", expected); - assertEquals(expected, abstractBuilder.getRequestId(delegateExecution)); + String expected = "requestId"; + delegateExecution.setVariable("msoRequestId", expected); + assertEquals(expected, abstractBuilder.getRequestId(delegateExecution)); } @Test public void getRequestIdTest() { - String expected = "requestId"; - abstractBuilder.requestId = expected; - assertEquals(expected, abstractBuilder.getRequestId(delegateExecution)); + String expected = "requestId"; + abstractBuilder.requestId = expected; + assertEquals(expected, abstractBuilder.getRequestId(delegateExecution)); } @Test @@ -545,8 +555,8 @@ public class AbstractBuilderTest { @Test public void getParamEntitiesTest() throws Exception { - Map<String, String> inputs = new HashMap<>(); - inputs.put("foo", "bar"); + Map<String, String> inputs = new HashMap<>(); + inputs.put("foo", "bar"); List<ParamEntity> list = abstractBuilder.getParamEntities(inputs); assertEquals(1, list.size()); assertEquals("foo", list.get(0).getName()); @@ -555,14 +565,14 @@ public class AbstractBuilderTest { @Test public void getParamEntitiesNullInputsTest() { - List<ParamEntity> list = abstractBuilder.getParamEntities(null); - assertEquals(0, list.size()); + List<ParamEntity> list = abstractBuilder.getParamEntities(null); + assertEquals(0, list.size()); } @Test public void getParamEntitiesEmptyInputsTest() { - List<ParamEntity> list = abstractBuilder.getParamEntities(new HashMap<>()); - assertEquals(0, list.size()); + List<ParamEntity> list = abstractBuilder.getParamEntities(new HashMap<>()); + assertEquals(0, list.size()); } @Test @@ -580,4 +590,4 @@ public class AbstractBuilderTest { abstractBuilder.getServiceInstanceName(delegateExecution); } -}
\ No newline at end of file +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilderTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilderTest.java index 4e39c7b4e3..ed16f5d197 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilderTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilderTest.java @@ -23,7 +23,6 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder; import java.util.Collection; import java.util.Map; import java.util.Set; - import org.camunda.bpm.engine.ProcessEngine; import org.camunda.bpm.engine.ProcessEngineServices; import org.camunda.bpm.engine.delegate.DelegateExecution; @@ -35,14 +34,14 @@ import org.camunda.bpm.model.bpmn.instance.FlowElement; import org.junit.Test; public class NetworkRpcInputEntityBuilderTest { - NetworkRpcInputEntityBuilder networRpcInputEntityBuilder = new NetworkRpcInputEntityBuilder(); + NetworkRpcInputEntityBuilder networRpcInputEntityBuilder = new NetworkRpcInputEntityBuilder(); - DelegateExecution delegateExecution = new DelegateExecution() { + DelegateExecution delegateExecution = new DelegateExecution() { private String operType; - private String resourceType; - private String requestId; + private String resourceType; + private String requestId; - @Override + @Override public String getProcessInstanceId() { return null; } @@ -194,14 +193,14 @@ public class NetworkRpcInputEntityBuilderTest { @Override public Object getVariable(String s) { - if (AbstractBuilder.OPERATION_TYPE.equals(s)) { - return operType; - } else if (AbstractBuilder.RESOURCE_TYPE.equals(s)) { - return resourceType; - } else if ("msoRequestId".equals(s)) { - return requestId; - } - return null; + if (AbstractBuilder.OPERATION_TYPE.equals(s)) { + return operType; + } else if (AbstractBuilder.RESOURCE_TYPE.equals(s)) { + return resourceType; + } else if ("msoRequestId".equals(s)) { + return requestId; + } + return null; } @Override @@ -241,13 +240,13 @@ public class NetworkRpcInputEntityBuilderTest { @Override public void setVariable(String s, Object o) { - if (AbstractBuilder.OPERATION_TYPE.equals(s)) { - operType = (String) o; - } else if (AbstractBuilder.RESOURCE_TYPE.equals(s)) { - resourceType = (String) o; - } else if ("msoRequestId".equals(s)) { - requestId = (String) o; - } + if (AbstractBuilder.OPERATION_TYPE.equals(s)) { + operType = (String) o; + } else if (AbstractBuilder.RESOURCE_TYPE.equals(s)) { + resourceType = (String) o; + } else if ("msoRequestId".equals(s)) { + requestId = (String) o; + } } @Override @@ -315,22 +314,22 @@ public class NetworkRpcInputEntityBuilderTest { } - @Override - public ProcessEngine getProcessEngine(){ - // TODO Auto-generated method stub - return null; - } + @Override + public ProcessEngine getProcessEngine() { + // TODO Auto-generated method stub + return null; + } - @Override - public void setProcessBusinessKey(String arg0){ - // TODO Auto-generated method stub + @Override + public void setProcessBusinessKey(String arg0) { + // TODO Auto-generated method stub - } + } }; - @Test - public void buildTest() { - networRpcInputEntityBuilder.build(delegateExecution, null); - } + @Test + public void buildTest() { + networRpcInputEntityBuilder.build(delegateExecution, null); + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/ServiceRpcInputEntityBuilderTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/ServiceRpcInputEntityBuilderTest.java index 556ff67fad..3d1b1de8c0 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/ServiceRpcInputEntityBuilderTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/ServiceRpcInputEntityBuilderTest.java @@ -23,7 +23,6 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder; import java.util.Collection; import java.util.Map; import java.util.Set; - import org.camunda.bpm.engine.ProcessEngine; import org.camunda.bpm.engine.ProcessEngineServices; import org.camunda.bpm.engine.delegate.DelegateExecution; @@ -35,14 +34,14 @@ import org.camunda.bpm.model.bpmn.instance.FlowElement; import org.junit.Test; public class ServiceRpcInputEntityBuilderTest { - ServiceRpcInputEntityBuilder serviceRpcInputEntityBuilder = new ServiceRpcInputEntityBuilder(); + ServiceRpcInputEntityBuilder serviceRpcInputEntityBuilder = new ServiceRpcInputEntityBuilder(); - DelegateExecution delegateExecution = new DelegateExecution() { + DelegateExecution delegateExecution = new DelegateExecution() { private String operType; - private String resourceType; - private String requestId; + private String resourceType; + private String requestId; - @Override + @Override public String getProcessInstanceId() { return null; } @@ -194,14 +193,14 @@ public class ServiceRpcInputEntityBuilderTest { @Override public Object getVariable(String s) { - if (AbstractBuilder.OPERATION_TYPE.equals(s)) { - return operType; - } else if (AbstractBuilder.RESOURCE_TYPE.equals(s)) { - return resourceType; - } else if ("msoRequestId".equals(s)) { - return requestId; - } - return null; + if (AbstractBuilder.OPERATION_TYPE.equals(s)) { + return operType; + } else if (AbstractBuilder.RESOURCE_TYPE.equals(s)) { + return resourceType; + } else if ("msoRequestId".equals(s)) { + return requestId; + } + return null; } @Override @@ -241,13 +240,13 @@ public class ServiceRpcInputEntityBuilderTest { @Override public void setVariable(String s, Object o) { - if (AbstractBuilder.OPERATION_TYPE.equals(s)) { - operType = (String) o; - } else if (AbstractBuilder.RESOURCE_TYPE.equals(s)) { - resourceType = (String) o; - } else if ("msoRequestId".equals(s)) { - requestId = (String) o; - } + if (AbstractBuilder.OPERATION_TYPE.equals(s)) { + operType = (String) o; + } else if (AbstractBuilder.RESOURCE_TYPE.equals(s)) { + resourceType = (String) o; + } else if ("msoRequestId".equals(s)) { + requestId = (String) o; + } } @Override @@ -315,22 +314,22 @@ public class ServiceRpcInputEntityBuilderTest { } - @Override - public ProcessEngine getProcessEngine(){ - // TODO Auto-generated method stub - return null; - } + @Override + public ProcessEngine getProcessEngine() { + // TODO Auto-generated method stub + return null; + } - @Override - public void setProcessBusinessKey(String arg0){ - // TODO Auto-generated method stub + @Override + public void setProcessBusinessKey(String arg0) { + // TODO Auto-generated method stub - } + } }; - @Test - public void buildTest() throws Exception { - serviceRpcInputEntityBuilder.build(delegateExecution, null); - } + @Test + public void buildTest() throws Exception { + serviceRpcInputEntityBuilder.build(delegateExecution, null); + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/ClientEntityPojoTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/ClientEntityPojoTest.java index c8949cee0f..70dfd6bd57 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/ClientEntityPojoTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/ClientEntityPojoTest.java @@ -21,7 +21,6 @@ package org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity; import org.junit.Test; - import com.openpojo.reflection.PojoClass; import com.openpojo.reflection.impl.PojoClassFactory; import com.openpojo.validation.Validator; @@ -36,41 +35,34 @@ import com.openpojo.validation.test.impl.GetterTester; import com.openpojo.validation.test.impl.SetterTester; public class ClientEntityPojoTest { - @Test - public void pojoStructure() { - test(PojoClassFactory.getPojoClass(NetworkInformationEntity.class)); - test(PojoClassFactory.getPojoClass(NetworkInputParametersEntity.class)); - test(PojoClassFactory.getPojoClass(NetworkRequestInputEntity.class)); - test(PojoClassFactory.getPojoClass(NetworkResponseInformationEntity.class)); - test(PojoClassFactory.getPojoClass(NetworkTopologyOperationInputEntity.class)); - test(PojoClassFactory.getPojoClass(NetworkTopologyOperationOutputEntity.class)); - test(PojoClassFactory.getPojoClass(OnapModelInformationEntity.class)); - test(PojoClassFactory.getPojoClass(ParamEntity.class)); - test(PojoClassFactory.getPojoClass(RequestInformationEntity.class)); - test(PojoClassFactory.getPojoClass(RpcNetworkTopologyOperationInputEntity.class)); - test(PojoClassFactory.getPojoClass(SdncRequestHeaderEntity.class)); - test(PojoClassFactory.getPojoClass(RpcServiceTopologyOperationInputEntity.class)); - test(PojoClassFactory.getPojoClass(RpcServiceTopologyOperationOutputEntity.class)); - test(PojoClassFactory.getPojoClass(ServiceInformationEntity.class)); - test(PojoClassFactory.getPojoClass(ServiceInputParametersEntity.class)); - test(PojoClassFactory.getPojoClass(ServiceRequestInputEntity.class)); - test(PojoClassFactory.getPojoClass(ServiceResponseInformationEntity.class)); - test(PojoClassFactory.getPojoClass(ServiceTopologyOperationInputEntity.class)); - test(PojoClassFactory.getPojoClass(ServiceTopologyOperationOutputEntity.class)); - test(PojoClassFactory.getPojoClass(RpcNetworkTopologyOperationOutputEntity.class)); - } - - private void test(PojoClass pojoClass) { - Validator validator = ValidatorBuilder.create() - .with(new GetterMustExistRule()) - .with(new SetterMustExistRule()) - .with(new NoNestedClassRule()) - .with(new NoPrimitivesRule()) - .with(new NoPublicFieldsRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .with(new DefaultValuesNullTester()) - .build(); - validator.validate(pojoClass); - } + @Test + public void pojoStructure() { + test(PojoClassFactory.getPojoClass(NetworkInformationEntity.class)); + test(PojoClassFactory.getPojoClass(NetworkInputParametersEntity.class)); + test(PojoClassFactory.getPojoClass(NetworkRequestInputEntity.class)); + test(PojoClassFactory.getPojoClass(NetworkResponseInformationEntity.class)); + test(PojoClassFactory.getPojoClass(NetworkTopologyOperationInputEntity.class)); + test(PojoClassFactory.getPojoClass(NetworkTopologyOperationOutputEntity.class)); + test(PojoClassFactory.getPojoClass(OnapModelInformationEntity.class)); + test(PojoClassFactory.getPojoClass(ParamEntity.class)); + test(PojoClassFactory.getPojoClass(RequestInformationEntity.class)); + test(PojoClassFactory.getPojoClass(RpcNetworkTopologyOperationInputEntity.class)); + test(PojoClassFactory.getPojoClass(SdncRequestHeaderEntity.class)); + test(PojoClassFactory.getPojoClass(RpcServiceTopologyOperationInputEntity.class)); + test(PojoClassFactory.getPojoClass(RpcServiceTopologyOperationOutputEntity.class)); + test(PojoClassFactory.getPojoClass(ServiceInformationEntity.class)); + test(PojoClassFactory.getPojoClass(ServiceInputParametersEntity.class)); + test(PojoClassFactory.getPojoClass(ServiceRequestInputEntity.class)); + test(PojoClassFactory.getPojoClass(ServiceResponseInformationEntity.class)); + test(PojoClassFactory.getPojoClass(ServiceTopologyOperationInputEntity.class)); + test(PojoClassFactory.getPojoClass(ServiceTopologyOperationOutputEntity.class)); + test(PojoClassFactory.getPojoClass(RpcNetworkTopologyOperationOutputEntity.class)); + } + + private void test(PojoClass pojoClass) { + Validator validator = ValidatorBuilder.create().with(new GetterMustExistRule()).with(new SetterMustExistRule()) + .with(new NoNestedClassRule()).with(new NoPrimitivesRule()).with(new NoPublicFieldsRule()) + .with(new SetterTester()).with(new GetterTester()).with(new DefaultValuesNullTester()).build(); + validator.validate(pojoClass); + } } |