diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-07-30 15:56:09 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-07-31 11:09:25 -0400 |
commit | 5a6a6de6f1a26a1897e4917a0df613e25a24eb70 (patch) | |
tree | 59a968f27b4b603aacc9d5e7b51fb598aeec5321 /bpmn/so-bpmn-infrastructure-common/src/test/java | |
parent | b6dc38501f3b746426b42d9de4cc883d894149e8 (diff) |
Containerization feature of SO
Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18
Issue-ID: SO-670
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/test/java')
16 files changed, 2124 insertions, 0 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 new file mode 100644 index 0000000000..0f77e41120 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllBPMNTestSuites.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn; +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 +} 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 new file mode 100644 index 0000000000..57d842f8b5 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllTasksTestsTestSuite.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn; +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"}) +public class AllTasksTestsTestSuite { + // 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 new file mode 100644 index 0000000000..0c0f38c0f9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/AllTestsTestSuite.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.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", + "!**/scripts/*Test.class", "**/*Test.class"}) +public class AllTestsTestSuite { + // 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 new file mode 100644 index 0000000000..f69521fd76 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/BeansTest.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure; + +import org.junit.Test; + +import com.openpojo.validation.Validator; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.GetterTester; +import com.openpojo.validation.test.impl.SetterTester; +import com.openpojo.reflection.PojoClass; +import com.openpojo.reflection.PojoClassFilter; +import com.openpojo.reflection.filters.FilterEnum; +import com.openpojo.reflection.filters.FilterNonConcrete; +import com.openpojo.reflection.filters.FilterPackageInfo; + + +public class BeansTest { + + + 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()) + + .build(); + + + 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/"); + } + } +} 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 new file mode 100644 index 0000000000..ad9e210452 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/WebSecurityConfigImpl.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure; + +import org.onap.so.security.MSOSpringFirewall; +import org.onap.so.security.WebSecurityConfig; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.builders.WebSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.web.firewall.StrictHttpFirewall; +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); + } + +} 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 new file mode 100644 index 0000000000..7d3d298c68 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAICreateResourcesTest.java @@ -0,0 +1,197 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.aai; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.isA; +import static org.mockito.Mockito.doNothing; +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; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.mockito.Spy; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIResourcesClient; +import org.onap.so.client.aai.entities.AAIResultWrapper; +import org.onap.so.client.aai.entities.uri.AAIResourceUri; +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)); + 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(Exception.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 new file mode 100644 index 0000000000..5808a330a3 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIDeleteServiceInstanceTest.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.aai; + +import static org.mockito.Matchers.isA; +import static org.mockito.Mockito.doNothing; +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; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mock; +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(Exception.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 new file mode 100644 index 0000000000..e17d3f8fb5 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/aai/AAIServiceInstanceTest.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + +package org.onap.so.bpmn.infrastructure.aai; + +import org.junit.Test; + + +public class AAIServiceInstanceTest { + + AAIServiceInstance test = new AAIServiceInstance("serviceInstanceName","serviceType","serviceRole","orchestrationStatus","modelInvariantUuid","modelVersionId","environmentContext","workloadContext"); + + @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 new file mode 100644 index 0000000000..ebcce191e9 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/common/name/generation/AAIObjectInstanceNameGeneratorTest.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.common.name.generation; + + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.MockitoAnnotations; +import org.onap.so.bpmn.infrastructure.common.name.generation.AAIObjectInstanceNameGenerator; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; +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)); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationIdTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationIdTest.java new file mode 100644 index 0000000000..24d1810ac6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationIdTest.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.pnf.dmaap; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; +import org.junit.Test; +import org.onap.so.bpmn.infrastructure.pnf.dmaap.JsonUtilForCorrelationId; + +public class JsonUtilForCorrelationIdTest { + + private static final String JSON_EXAMPLE_WITH_CORRELATION_ID = "[\n" + + " {\n" + + " \"pnfRegistrationFields\" : {\n" + + " \"correlationId\" : \"corrTest1\",\n" + + " \"value\" : \"value1\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"pnfRegistrationFields\" : {\n" + + " \"correlationId\" : \"corrTest2\",\n" + + " \"value\" : \"value2\"\n" + + " }\n" + + " }\n" + + "]"; + + private static final String JSON_EXAMPLE_WITH_CORRELATION_ID2 = "{\"pnfRegistrationFields\":{\"correlationId\":\"corrTest3\"}}"; + private static final String JSON_EXAMPLE_WITH_CORRELATION_ID3 = "[\"{\\\"pnfRegistrationFields\\\":" + + "{\\\"correlationId\\\":\\\"corrTest4\\\"}}\", \"{\\\"pnfRegistrationFields\\\":" + + "{\\\"correlationId\\\":\\\"corrTest5\\\"}}\"]"; + private static final String JSON_EXAMPLE_WITH_CORRELATION_ID4 = "{\"header\":{\"key\":\"value\"}}"; + + @Test + public void parseJsonSuccessful() { + List<String> expectedResult = JsonUtilForCorrelationId + .parseJsonToGelAllCorrelationId(JSON_EXAMPLE_WITH_CORRELATION_ID); + assertThat(expectedResult).containsExactly("corrTest1", "corrTest2"); + + List<String> expectedResult2 = JsonUtilForCorrelationId + .parseJsonToGelAllCorrelationId(JSON_EXAMPLE_WITH_CORRELATION_ID2); + assertThat(expectedResult2).containsExactly("corrTest3"); + } + + @Test + public void parseJsonWithEscapeCharacters_Successful() { + List<String> expectedResult = JsonUtilForCorrelationId + .parseJsonToGelAllCorrelationId(JSON_EXAMPLE_WITH_CORRELATION_ID3); + assertThat(expectedResult).containsExactly("corrTest4", "corrTest5"); + } + + @Test + public void parseJson_emptyListReturnedWhenNothingFound() { + List<String> expectedResult = JsonUtilForCorrelationId + .parseJsonToGelAllCorrelationId(JSON_EXAMPLE_WITH_CORRELATION_ID4); + assertThat(expectedResult).isEmpty(); + } + +} 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 new file mode 100644 index 0000000000..239361d306 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/vfcmodel/VfcModelPojoTest.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.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; +import com.openpojo.validation.rule.impl.NoPublicFieldsRule; +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"; + + @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/serviceTask/client/HeaderUtilTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/HeaderUtilTest.java new file mode 100644 index 0000000000..ca8ec22088 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/HeaderUtilTest.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.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); + } + +}
\ 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 new file mode 100644 index 0000000000..828e3fca47 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/AbstractBuilderTest.java @@ -0,0 +1,570 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.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.ProcessEngineServices; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.runtime.Incident; +import org.camunda.bpm.engine.variable.VariableMap; +import org.camunda.bpm.engine.variable.value.TypedValue; +import org.camunda.bpm.model.bpmn.BpmnModelInstance; +import org.camunda.bpm.model.bpmn.instance.FlowElement; +import org.junit.Test; +import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder.RequestAction; +import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder.SvcAction; +import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.entity.ParamEntity; +import org.onap.so.requestsdb.RequestsDbConstant; + +public class AbstractBuilderTest { + + AbstractBuilder<?, ?> abstractBuilder = new AbstractBuilder<Object, Object>() { + @Override + Object build(DelegateExecution execution, Object input) throws Exception { + return null; + } + }; + + DelegateExecution delegateExecution = new DelegateExecution() { + private String operType; + private String resourceType; + private String requestId; + + @Override + public String getProcessInstanceId() { + return null; + } + + @Override + public String getProcessBusinessKey() { + return null; + } + + @Override + public String getProcessDefinitionId() { + return null; + } + + @Override + public String getParentId() { + return null; + } + + @Override + public String getCurrentActivityId() { + return null; + } + + @Override + public String getCurrentActivityName() { + return null; + } + + @Override + public String getActivityInstanceId() { + return null; + } + + @Override + public String getParentActivityInstanceId() { + return null; + } + + @Override + public String getCurrentTransitionId() { + return null; + } + + @Override + public DelegateExecution getProcessInstance() { + return null; + } + + @Override + public DelegateExecution getSuperExecution() { + return null; + } + + @Override + public boolean isCanceled() { + return false; + } + + @Override + public String getTenantId() { + return null; + } + + @Override + public void setVariable(String s, Object o, String s1) { + + } + + @Override + public Incident createIncident(String s, String s1) { + return null; + } + + @Override + public Incident createIncident(String s, String s1, String s2) { + return null; + } + + @Override + public void resolveIncident(String s) { + + } + + @Override + public String getId() { + return null; + } + + @Override + public String getEventName() { + return null; + } + + @Override + public String getBusinessKey() { + return null; + } + + @Override + public BpmnModelInstance getBpmnModelInstance() { + return null; + } + + @Override + public FlowElement getBpmnModelElementInstance() { + return null; + } + + @Override + public ProcessEngineServices getProcessEngineServices() { + return null; + } + + @Override + public String getVariableScopeKey() { + return null; + } + + @Override + public Map<String, Object> getVariables() { + return null; + } + + @Override + public VariableMap getVariablesTyped() { + return null; + } + + @Override + public VariableMap getVariablesTyped(boolean b) { + return null; + } + + @Override + public Map<String, Object> getVariablesLocal() { + return null; + } + + @Override + public VariableMap getVariablesLocalTyped() { + return null; + } + + @Override + public VariableMap getVariablesLocalTyped(boolean b) { + return null; + } + + @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; + } + + @Override + public Object getVariableLocal(String s) { + return null; + } + + @Override + public <T extends TypedValue> T getVariableTyped(String s) { + return null; + } + + @Override + public <T extends TypedValue> T getVariableTyped(String s, boolean b) { + return null; + } + + @Override + public <T extends TypedValue> T getVariableLocalTyped(String s) { + return null; + } + + @Override + public <T extends TypedValue> T getVariableLocalTyped(String s, boolean b) { + return null; + } + + @Override + public Set<String> getVariableNames() { + return null; + } + + @Override + public Set<String> getVariableNamesLocal() { + return null; + } + + @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; + } + } + + @Override + public void setVariableLocal(String s, Object o) { + + } + + @Override + public void setVariables(Map<String, ?> map) { + + } + + @Override + public void setVariablesLocal(Map<String, ?> map) { + + } + + @Override + public boolean hasVariables() { + return false; + } + + @Override + public boolean hasVariablesLocal() { + return false; + } + + @Override + public boolean hasVariable(String s) { + return false; + } + + @Override + public boolean hasVariableLocal(String s) { + return false; + } + + @Override + public void removeVariable(String s) { + + } + + @Override + public void removeVariableLocal(String s) { + + } + + @Override + public void removeVariables(Collection<String> collection) { + + } + + @Override + public void removeVariablesLocal(Collection<String> collection) { + + } + + @Override + public void removeVariables() { + + } + + @Override + public void removeVariablesLocal() { + + } + }; + + @Test + public void requestActionGetIntValueTest() { + assertEquals(0, RequestAction.CREATE_NETWORK_INSTANCE.getIntValue()); + } + + @Test + public void svcActionGetIntValueTest() { + assertEquals(0, SvcAction.RESERVE.getIntValue()); + } + + @Test + public void buildTest() throws Exception { + abstractBuilder.build(null, null); + } + + @Test + public void getRequestActionBlankOperationTypeTest() throws Exception { + 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)); + } + + @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)); + } + + @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)); + } + + @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)); + } + + @Test + public void getRequestActionDeleteOperationTypeTest() throws Exception { + 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)); + } + + @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)); + } + + @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)); + } + + @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)); + } + + @Test + public void getRequestActionCreateOperationTypeTest() throws Exception { + 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)); + } + + @Test + public void getSvcActionBlankOperationTypeTest() throws Exception { + assertEquals(AbstractBuilder.SvcAction.CREATE.getName(), abstractBuilder.getSvcAction(delegateExecution)); + } + + @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)); + } + + @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)); + } + + @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)); + } + + @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)); + } + + @Test + public void getSvcActionDeleteOperationTypeTest() throws Exception { + 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)); + } + + @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)); + } + + @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)); + } + + @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)); + } + + @Test + public void getSvcActionCreateOperationTypeTest() throws Exception { + 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)); + } + + @Test + public void getRequestIdBlankNotOnExecutionTest() { + abstractBuilder.getRequestId(delegateExecution); + } + + @Test + public void getRequestIdBlankOnExecutionTest() { + 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)); + } + + @Test + public void getOnapServiceModelInformationEntityTest() throws Exception { + abstractBuilder.getOnapServiceModelInformationEntity(delegateExecution); + } + + @Test + public void getOnapNetworkModelInformationEntityTest() throws Exception { + abstractBuilder.getOnapNetworkModelInformationEntity(delegateExecution); + } + + @Test + public void getParamEntitiesTest() throws Exception { + 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()); + assertEquals("bar", list.get(0).getValue()); + } + + @Test + public void getParamEntitiesNullInputsTest() { + 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()); + } + + @Test + public void getRequestInformationEntityTest() throws Exception { + abstractBuilder.getRequestInformationEntity(delegateExecution); + } + + @Test + public void getServiceInformationEntityTest() throws Exception { + abstractBuilder.getServiceInformationEntity(delegateExecution); + } + + @Test + public void getServiceInstanceNameTest() throws Exception { + 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 new file mode 100644 index 0000000000..f7d73a33e1 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkRpcInputEntityBuilderTest.java @@ -0,0 +1,323 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder; + +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +import org.camunda.bpm.engine.ProcessEngineServices; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.runtime.Incident; +import org.camunda.bpm.engine.variable.VariableMap; +import org.camunda.bpm.engine.variable.value.TypedValue; +import org.camunda.bpm.model.bpmn.BpmnModelInstance; +import org.camunda.bpm.model.bpmn.instance.FlowElement; +import org.junit.Test; + +public class NetworkRpcInputEntityBuilderTest { + NetworkRpcInputEntityBuilder networRpcInputEntityBuilder = new NetworkRpcInputEntityBuilder(); + + DelegateExecution delegateExecution = new DelegateExecution() { + private String operType; + private String resourceType; + private String requestId; + + @Override + public String getProcessInstanceId() { + return null; + } + + @Override + public String getProcessBusinessKey() { + return null; + } + + @Override + public String getProcessDefinitionId() { + return null; + } + + @Override + public String getParentId() { + return null; + } + + @Override + public String getCurrentActivityId() { + return null; + } + + @Override + public String getCurrentActivityName() { + return null; + } + + @Override + public String getActivityInstanceId() { + return null; + } + + @Override + public String getParentActivityInstanceId() { + return null; + } + + @Override + public String getCurrentTransitionId() { + return null; + } + + @Override + public DelegateExecution getProcessInstance() { + return null; + } + + @Override + public DelegateExecution getSuperExecution() { + return null; + } + + @Override + public boolean isCanceled() { + return false; + } + + @Override + public String getTenantId() { + return null; + } + + @Override + public void setVariable(String s, Object o, String s1) { + + } + + @Override + public Incident createIncident(String s, String s1) { + return null; + } + + @Override + public Incident createIncident(String s, String s1, String s2) { + return null; + } + + @Override + public void resolveIncident(String s) { + + } + + @Override + public String getId() { + return null; + } + + @Override + public String getEventName() { + return null; + } + + @Override + public String getBusinessKey() { + return null; + } + + @Override + public BpmnModelInstance getBpmnModelInstance() { + return null; + } + + @Override + public FlowElement getBpmnModelElementInstance() { + return null; + } + + @Override + public ProcessEngineServices getProcessEngineServices() { + return null; + } + + @Override + public String getVariableScopeKey() { + return null; + } + + @Override + public Map<String, Object> getVariables() { + return null; + } + + @Override + public VariableMap getVariablesTyped() { + return null; + } + + @Override + public VariableMap getVariablesTyped(boolean b) { + return null; + } + + @Override + public Map<String, Object> getVariablesLocal() { + return null; + } + + @Override + public VariableMap getVariablesLocalTyped() { + return null; + } + + @Override + public VariableMap getVariablesLocalTyped(boolean b) { + return null; + } + + @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; + } + + @Override + public Object getVariableLocal(String s) { + return null; + } + + @Override + public <T extends TypedValue> T getVariableTyped(String s) { + return null; + } + + @Override + public <T extends TypedValue> T getVariableTyped(String s, boolean b) { + return null; + } + + @Override + public <T extends TypedValue> T getVariableLocalTyped(String s) { + return null; + } + + @Override + public <T extends TypedValue> T getVariableLocalTyped(String s, boolean b) { + return null; + } + + @Override + public Set<String> getVariableNames() { + return null; + } + + @Override + public Set<String> getVariableNamesLocal() { + return null; + } + + @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; + } + } + + @Override + public void setVariableLocal(String s, Object o) { + + } + + @Override + public void setVariables(Map<String, ?> map) { + + } + + @Override + public void setVariablesLocal(Map<String, ?> map) { + + } + + @Override + public boolean hasVariables() { + return false; + } + + @Override + public boolean hasVariablesLocal() { + return false; + } + + @Override + public boolean hasVariable(String s) { + return false; + } + + @Override + public boolean hasVariableLocal(String s) { + return false; + } + + @Override + public void removeVariable(String s) { + + } + + @Override + public void removeVariableLocal(String s) { + + } + + @Override + public void removeVariables(Collection<String> collection) { + + } + + @Override + public void removeVariablesLocal(Collection<String> collection) { + + } + + @Override + public void removeVariables() { + + } + + @Override + public void removeVariablesLocal() { + + } + }; + + @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 new file mode 100644 index 0000000000..4db0421936 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/builder/ServiceRpcInputEntityBuilderTest.java @@ -0,0 +1,323 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder; + +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +import org.camunda.bpm.engine.ProcessEngineServices; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.runtime.Incident; +import org.camunda.bpm.engine.variable.VariableMap; +import org.camunda.bpm.engine.variable.value.TypedValue; +import org.camunda.bpm.model.bpmn.BpmnModelInstance; +import org.camunda.bpm.model.bpmn.instance.FlowElement; +import org.junit.Test; + +public class ServiceRpcInputEntityBuilderTest { + ServiceRpcInputEntityBuilder serviceRpcInputEntityBuilder = new ServiceRpcInputEntityBuilder(); + + DelegateExecution delegateExecution = new DelegateExecution() { + private String operType; + private String resourceType; + private String requestId; + + @Override + public String getProcessInstanceId() { + return null; + } + + @Override + public String getProcessBusinessKey() { + return null; + } + + @Override + public String getProcessDefinitionId() { + return null; + } + + @Override + public String getParentId() { + return null; + } + + @Override + public String getCurrentActivityId() { + return null; + } + + @Override + public String getCurrentActivityName() { + return null; + } + + @Override + public String getActivityInstanceId() { + return null; + } + + @Override + public String getParentActivityInstanceId() { + return null; + } + + @Override + public String getCurrentTransitionId() { + return null; + } + + @Override + public DelegateExecution getProcessInstance() { + return null; + } + + @Override + public DelegateExecution getSuperExecution() { + return null; + } + + @Override + public boolean isCanceled() { + return false; + } + + @Override + public String getTenantId() { + return null; + } + + @Override + public void setVariable(String s, Object o, String s1) { + + } + + @Override + public Incident createIncident(String s, String s1) { + return null; + } + + @Override + public Incident createIncident(String s, String s1, String s2) { + return null; + } + + @Override + public void resolveIncident(String s) { + + } + + @Override + public String getId() { + return null; + } + + @Override + public String getEventName() { + return null; + } + + @Override + public String getBusinessKey() { + return null; + } + + @Override + public BpmnModelInstance getBpmnModelInstance() { + return null; + } + + @Override + public FlowElement getBpmnModelElementInstance() { + return null; + } + + @Override + public ProcessEngineServices getProcessEngineServices() { + return null; + } + + @Override + public String getVariableScopeKey() { + return null; + } + + @Override + public Map<String, Object> getVariables() { + return null; + } + + @Override + public VariableMap getVariablesTyped() { + return null; + } + + @Override + public VariableMap getVariablesTyped(boolean b) { + return null; + } + + @Override + public Map<String, Object> getVariablesLocal() { + return null; + } + + @Override + public VariableMap getVariablesLocalTyped() { + return null; + } + + @Override + public VariableMap getVariablesLocalTyped(boolean b) { + return null; + } + + @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; + } + + @Override + public Object getVariableLocal(String s) { + return null; + } + + @Override + public <T extends TypedValue> T getVariableTyped(String s) { + return null; + } + + @Override + public <T extends TypedValue> T getVariableTyped(String s, boolean b) { + return null; + } + + @Override + public <T extends TypedValue> T getVariableLocalTyped(String s) { + return null; + } + + @Override + public <T extends TypedValue> T getVariableLocalTyped(String s, boolean b) { + return null; + } + + @Override + public Set<String> getVariableNames() { + return null; + } + + @Override + public Set<String> getVariableNamesLocal() { + return null; + } + + @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; + } + } + + @Override + public void setVariableLocal(String s, Object o) { + + } + + @Override + public void setVariables(Map<String, ?> map) { + + } + + @Override + public void setVariablesLocal(Map<String, ?> map) { + + } + + @Override + public boolean hasVariables() { + return false; + } + + @Override + public boolean hasVariablesLocal() { + return false; + } + + @Override + public boolean hasVariable(String s) { + return false; + } + + @Override + public boolean hasVariableLocal(String s) { + return false; + } + + @Override + public void removeVariable(String s) { + + } + + @Override + public void removeVariableLocal(String s) { + + } + + @Override + public void removeVariables(Collection<String> collection) { + + } + + @Override + public void removeVariablesLocal(Collection<String> collection) { + + } + + @Override + public void removeVariables() { + + } + + @Override + public void removeVariablesLocal() { + + } + }; + + @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 new file mode 100644 index 0000000000..c8949cee0f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/workflow/serviceTask/client/entity/ClientEntityPojoTest.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.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; +import com.openpojo.validation.ValidatorBuilder; +import com.openpojo.validation.rule.impl.GetterMustExistRule; +import com.openpojo.validation.rule.impl.NoNestedClassRule; +import com.openpojo.validation.rule.impl.NoPrimitivesRule; +import com.openpojo.validation.rule.impl.NoPublicFieldsRule; +import com.openpojo.validation.rule.impl.SetterMustExistRule; +import com.openpojo.validation.test.impl.DefaultValuesNullTester; +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); + } +} |