diff options
Diffstat (limited to 'adapters/mso-adapters-rest-interface/src/test/java/org')
18 files changed, 434 insertions, 444 deletions
diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/BeansTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/BeansTest.java index e3474009c9..3ef91d3dbe 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/BeansTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/BeansTest.java @@ -21,7 +21,6 @@ package org.onap.so.adapters; import org.junit.Test; - import com.openpojo.reflection.PojoClass; import com.openpojo.reflection.PojoClassFilter; import com.openpojo.reflection.filters.FilterNonConcrete; @@ -35,31 +34,27 @@ import com.openpojo.validation.test.impl.SetterTester; public class BeansTest { - private PojoClassFilter filterTestClasses = new FilterTestClasses(); + private PojoClassFilter filterTestClasses = new FilterTestClasses(); + + @Test + public void pojoStructure() { + test("org.onap.so.adapters.nwrest"); + test("org.onap.so.adapters.sdncrest"); + test("org.onap.so.adapters.tenantrest"); + test("org.onap.so.adapters.vnfrest"); + test("org.onap.so.adapters.network.beans"); + test("org.onap.so.openstack.beans"); + } + + private void test(String pojoPackage) { + Validator validator = ValidatorBuilder.create().with(new GetterMustExistRule()).with(new SetterMustExistRule()) + .with(new SetterTester()).with(new GetterTester()).build(); + validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses, new FilterNonConcrete()); + } - @Test - public void pojoStructure() { - test("org.onap.so.adapters.nwrest"); - test("org.onap.so.adapters.sdncrest"); - test("org.onap.so.adapters.tenantrest"); - test("org.onap.so.adapters.vnfrest"); - test("org.onap.so.adapters.network.beans"); - test("org.onap.so.openstack.beans"); - } - - private void test(String pojoPackage) { - Validator validator = ValidatorBuilder.create() - .with(new GetterMustExistRule()) - .with(new SetterMustExistRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .build(); - validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses, new FilterNonConcrete()); - } - - private static class FilterTestClasses implements PojoClassFilter { - public boolean include(PojoClass pojoClass) { - return !pojoClass.getSourcePath().contains("/test-classes/"); - } - } -}
\ No newline at end of file + private static class FilterTestClasses implements PojoClassFilter { + public boolean include(PojoClass pojoClass) { + return !pojoClass.getSourcePath().contains("/test-classes/"); + } + } +} diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/network/mappers/ContrailSubnetMappersTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/network/mappers/ContrailSubnetMappersTest.java index 240074bca7..61beceb922 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/network/mappers/ContrailSubnetMappersTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/network/mappers/ContrailSubnetMappersTest.java @@ -21,11 +21,9 @@ package org.onap.so.adapters.network.mappers; import static org.junit.Assert.assertEquals; - import java.util.ArrayList; import java.util.List; import java.util.Optional; - import org.junit.Test; import org.onap.so.adapters.network.beans.ContrailSubnet; import org.onap.so.adapters.network.beans.ContrailSubnetHostRoute; @@ -38,199 +36,200 @@ import org.onap.so.openstack.beans.Subnet; public class ContrailSubnetMappersTest { - - - @Test - public void contrailSubnetHostRouteMapperTest() { - HostRoute hostRoute = new HostRoute(); - hostRoute.setNextHop("hop"); - hostRoute.setPrefix("prefix"); - ContrailSubnetHostRouteMapper mapper = new ContrailSubnetHostRouteMapper(hostRoute); - ContrailSubnetHostRoute cshr = mapper.map(); - assertEquals("hop", cshr.getNextHop()); - assertEquals("prefix", cshr.getPrefix()); - } - - @Test - public void contrailSubnetPoolMapperTest() { - Pool pool = new Pool(); - pool.setStart("start"); - pool.setEnd("end"); - ContrailSubnetPoolMapper mapper = new ContrailSubnetPoolMapper(pool); - ContrailSubnetPool csPool = mapper.map(); - assertEquals("start", csPool.getStart()); - assertEquals("end", csPool.getEnd()); - } - - @Test - public void checkIsNullOrEmpty() { - ContrailSubnetMapper mapper = new ContrailSubnetMapper(null); - assertEquals(true, mapper.isNullOrEmpty("")); - assertEquals(true, mapper.isNullOrEmpty(null)); - assertEquals(false, mapper.isNullOrEmpty("hello")); - } - - @Test - public void createSubnetTestValidCidr() { - Subnet subnet = new Subnet(); - subnet.setCidr("test/value"); - ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); - ContrailSubnet result = mapper.map(); - - assertEquals("test",result.getSubnet().getIpPrefix()); - assertEquals("value", result.getSubnet().getIpPrefixLen()); - } - - @Test - public void createSubnetTestInvalidCidr() { - Subnet subnet = new Subnet(); - subnet.setCidr("test"); - ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); - ContrailSubnet result = mapper.map(); - assertEquals(null, result.getSubnet().getIpPrefix()); - assertEquals(null, result.getSubnet().getIpPrefixLen()); - - } - - @Test - public void createSubnetTestNullCidr() { - Subnet subnet = new Subnet(); - ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); - ContrailSubnet result = mapper.map(); - assertEquals(null, result.getSubnet().getIpPrefix()); - assertEquals(null, result.getSubnet().getIpPrefixLen()); - } - - @Test - public void createContrailSubnetPoolTest() { - List<Pool> pools = new ArrayList<>(); - Pool pool1 = new Pool(); - pool1.setStart("start1"); - pool1.setEnd("end1"); - Pool pool2 = new Pool(); - pool2.setStart("start2"); - pool2.setEnd("end2"); - pools.add(pool1); - pools.add(pool2); - - Subnet subnet = new Subnet(); - subnet.setAllocationPools(pools); - ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); - ContrailSubnet result = mapper.map(); - List<ContrailSubnetPool> cspools = result.getAllocationPools(); - assertEquals(2, cspools.size()); - assertEquals("start2", cspools.get(1).getStart()); - assertEquals("end2", cspools.get(1).getEnd()); - } - - @Test - public void createContrailSubnetPoolInvalidTest() { - List<Pool> pools = new ArrayList<>(); - Pool pool1 = new Pool(); - pool1.setStart("start1"); - pool1.setEnd("end1"); - Pool pool2 = new Pool(); - pool2.setStart("start2"); - pools.add(pool1); - pools.add(pool2); - - Subnet subnet = new Subnet(); - subnet.setAllocationPools(pools); - ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); - ContrailSubnet result = mapper.map(); - List<ContrailSubnetPool> cspools = result.getAllocationPools(); - assertEquals(1, cspools.size()); - assertEquals("start1", cspools.get(0).getStart()); - assertEquals("end1", cspools.get(0).getEnd()); - } - - @Test - public void createContrailSubnetPoolEmptyTest() { - - Subnet subnet = new Subnet(); - ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); - ContrailSubnet result = mapper.map(); - List<ContrailSubnetPool> cspools = result.getAllocationPools(); - assertEquals(true, cspools.isEmpty()); - - } - - @Test - public void createContrailSubnetHostRoutesTest() { - List<HostRoute> hostRoutes = new ArrayList<>(); - HostRoute hostRoute1 = new HostRoute(); - hostRoute1.setNextHop("next-hop1"); - hostRoute1.setPrefix("prefix1"); - HostRoute hostRoute2 = new HostRoute(); - hostRoute2.setNextHop("next-hop2"); - hostRoute2.setPrefix("prefix2"); - hostRoutes.add(hostRoute1); - hostRoutes.add(hostRoute2); - - Subnet subnet = new Subnet(); - subnet.setHostRoutes(hostRoutes); - ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); - ContrailSubnet result = mapper.map(); - ContrailSubnetHostRoutes routes = result.getHostRoutes(); - assertEquals(2, routes.getHostRoutes().size()); - assertEquals("next-hop2", routes.getHostRoutes().get(1).getNextHop()); - assertEquals("prefix2", routes.getHostRoutes().get(1).getPrefix()); - } - - @Test - public void createContrailSubnetHostRoutesMissingFieldTest() { - List<HostRoute> hostRoutes = new ArrayList<>(); - HostRoute hostRoute1 = new HostRoute(); - hostRoute1.setNextHop("next-hop1"); - HostRoute hostRoute2 = new HostRoute(); - hostRoute2.setNextHop("next-hop2"); - hostRoute2.setPrefix("prefix2"); - hostRoutes.add(hostRoute1); - hostRoutes.add(hostRoute2); - - Subnet subnet = new Subnet(); - subnet.setHostRoutes(hostRoutes); - ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); - ContrailSubnet result = mapper.map(); - ContrailSubnetHostRoutes routes = result.getHostRoutes(); - assertEquals(2, routes.getHostRoutes().size()); - assertEquals("next-hop1", routes.getHostRoutes().get(0).getNextHop()); - assertEquals("prefix2", routes.getHostRoutes().get(1).getPrefix()); - } - - @Test - public void createContrailSubnetHostRoutesEmptyTest() { - List<HostRoute> hostRoutes = new ArrayList<>(); - Subnet subnet = new Subnet(); - subnet.setHostRoutes(hostRoutes); - ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); - ContrailSubnet result = mapper.map(); - ContrailSubnetHostRoutes routes = result.getHostRoutes(); - assertEquals(true, routes.getHostRoutes().isEmpty()); - } - - @Test - public void getSubnetNameTest() { - Subnet subnet = new Subnet(); - subnet.setSubnetName("name"); - ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); - assertEquals("if subnetName is populated map", "name", mapper.getSubnetName(subnet)); - subnet = new Subnet(); - subnet.setSubnetId("id"); - mapper = new ContrailSubnetMapper(subnet); - assertEquals("choose id when name is null", "id", mapper.getSubnetName(subnet)); - subnet = new Subnet(); - mapper = new ContrailSubnetMapper(subnet); - assertEquals("expect null", null, mapper.getSubnetName(subnet)); - } - @Test - public void mapRemainingFields() { - Subnet subnet = new Subnet(); - subnet.setEnableDHCP(true); - subnet.setGatewayIp("gateway-ip"); - ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); - ContrailSubnet result = mapper.map(); - assertEquals(true, result.isEnableDhcp()); - assertEquals("gateway-ip", result.getDefaultGateway()); - } + + + @Test + public void contrailSubnetHostRouteMapperTest() { + HostRoute hostRoute = new HostRoute(); + hostRoute.setNextHop("hop"); + hostRoute.setPrefix("prefix"); + ContrailSubnetHostRouteMapper mapper = new ContrailSubnetHostRouteMapper(hostRoute); + ContrailSubnetHostRoute cshr = mapper.map(); + assertEquals("hop", cshr.getNextHop()); + assertEquals("prefix", cshr.getPrefix()); + } + + @Test + public void contrailSubnetPoolMapperTest() { + Pool pool = new Pool(); + pool.setStart("start"); + pool.setEnd("end"); + ContrailSubnetPoolMapper mapper = new ContrailSubnetPoolMapper(pool); + ContrailSubnetPool csPool = mapper.map(); + assertEquals("start", csPool.getStart()); + assertEquals("end", csPool.getEnd()); + } + + @Test + public void checkIsNullOrEmpty() { + ContrailSubnetMapper mapper = new ContrailSubnetMapper(null); + assertEquals(true, mapper.isNullOrEmpty("")); + assertEquals(true, mapper.isNullOrEmpty(null)); + assertEquals(false, mapper.isNullOrEmpty("hello")); + } + + @Test + public void createSubnetTestValidCidr() { + Subnet subnet = new Subnet(); + subnet.setCidr("test/value"); + ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); + ContrailSubnet result = mapper.map(); + + assertEquals("test", result.getSubnet().getIpPrefix()); + assertEquals("value", result.getSubnet().getIpPrefixLen()); + } + + @Test + public void createSubnetTestInvalidCidr() { + Subnet subnet = new Subnet(); + subnet.setCidr("test"); + ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); + ContrailSubnet result = mapper.map(); + assertEquals(null, result.getSubnet().getIpPrefix()); + assertEquals(null, result.getSubnet().getIpPrefixLen()); + + } + + @Test + public void createSubnetTestNullCidr() { + Subnet subnet = new Subnet(); + ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); + ContrailSubnet result = mapper.map(); + assertEquals(null, result.getSubnet().getIpPrefix()); + assertEquals(null, result.getSubnet().getIpPrefixLen()); + } + + @Test + public void createContrailSubnetPoolTest() { + List<Pool> pools = new ArrayList<>(); + Pool pool1 = new Pool(); + pool1.setStart("start1"); + pool1.setEnd("end1"); + Pool pool2 = new Pool(); + pool2.setStart("start2"); + pool2.setEnd("end2"); + pools.add(pool1); + pools.add(pool2); + + Subnet subnet = new Subnet(); + subnet.setAllocationPools(pools); + ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); + ContrailSubnet result = mapper.map(); + List<ContrailSubnetPool> cspools = result.getAllocationPools(); + assertEquals(2, cspools.size()); + assertEquals("start2", cspools.get(1).getStart()); + assertEquals("end2", cspools.get(1).getEnd()); + } + + @Test + public void createContrailSubnetPoolInvalidTest() { + List<Pool> pools = new ArrayList<>(); + Pool pool1 = new Pool(); + pool1.setStart("start1"); + pool1.setEnd("end1"); + Pool pool2 = new Pool(); + pool2.setStart("start2"); + pools.add(pool1); + pools.add(pool2); + + Subnet subnet = new Subnet(); + subnet.setAllocationPools(pools); + ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); + ContrailSubnet result = mapper.map(); + List<ContrailSubnetPool> cspools = result.getAllocationPools(); + assertEquals(1, cspools.size()); + assertEquals("start1", cspools.get(0).getStart()); + assertEquals("end1", cspools.get(0).getEnd()); + } + + @Test + public void createContrailSubnetPoolEmptyTest() { + + Subnet subnet = new Subnet(); + ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); + ContrailSubnet result = mapper.map(); + List<ContrailSubnetPool> cspools = result.getAllocationPools(); + assertEquals(true, cspools.isEmpty()); + + } + + @Test + public void createContrailSubnetHostRoutesTest() { + List<HostRoute> hostRoutes = new ArrayList<>(); + HostRoute hostRoute1 = new HostRoute(); + hostRoute1.setNextHop("next-hop1"); + hostRoute1.setPrefix("prefix1"); + HostRoute hostRoute2 = new HostRoute(); + hostRoute2.setNextHop("next-hop2"); + hostRoute2.setPrefix("prefix2"); + hostRoutes.add(hostRoute1); + hostRoutes.add(hostRoute2); + + Subnet subnet = new Subnet(); + subnet.setHostRoutes(hostRoutes); + ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); + ContrailSubnet result = mapper.map(); + ContrailSubnetHostRoutes routes = result.getHostRoutes(); + assertEquals(2, routes.getHostRoutes().size()); + assertEquals("next-hop2", routes.getHostRoutes().get(1).getNextHop()); + assertEquals("prefix2", routes.getHostRoutes().get(1).getPrefix()); + } + + @Test + public void createContrailSubnetHostRoutesMissingFieldTest() { + List<HostRoute> hostRoutes = new ArrayList<>(); + HostRoute hostRoute1 = new HostRoute(); + hostRoute1.setNextHop("next-hop1"); + HostRoute hostRoute2 = new HostRoute(); + hostRoute2.setNextHop("next-hop2"); + hostRoute2.setPrefix("prefix2"); + hostRoutes.add(hostRoute1); + hostRoutes.add(hostRoute2); + + Subnet subnet = new Subnet(); + subnet.setHostRoutes(hostRoutes); + ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); + ContrailSubnet result = mapper.map(); + ContrailSubnetHostRoutes routes = result.getHostRoutes(); + assertEquals(2, routes.getHostRoutes().size()); + assertEquals("next-hop1", routes.getHostRoutes().get(0).getNextHop()); + assertEquals("prefix2", routes.getHostRoutes().get(1).getPrefix()); + } + + @Test + public void createContrailSubnetHostRoutesEmptyTest() { + List<HostRoute> hostRoutes = new ArrayList<>(); + Subnet subnet = new Subnet(); + subnet.setHostRoutes(hostRoutes); + ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); + ContrailSubnet result = mapper.map(); + ContrailSubnetHostRoutes routes = result.getHostRoutes(); + assertEquals(true, routes.getHostRoutes().isEmpty()); + } + + @Test + public void getSubnetNameTest() { + Subnet subnet = new Subnet(); + subnet.setSubnetName("name"); + ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); + assertEquals("if subnetName is populated map", "name", mapper.getSubnetName(subnet)); + subnet = new Subnet(); + subnet.setSubnetId("id"); + mapper = new ContrailSubnetMapper(subnet); + assertEquals("choose id when name is null", "id", mapper.getSubnetName(subnet)); + subnet = new Subnet(); + mapper = new ContrailSubnetMapper(subnet); + assertEquals("expect null", null, mapper.getSubnetName(subnet)); + } + + @Test + public void mapRemainingFields() { + Subnet subnet = new Subnet(); + subnet.setEnableDHCP(true); + subnet.setGatewayIp("gateway-ip"); + ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet); + ContrailSubnet result = mapper.map(); + assertEquals(true, result.isEnableDhcp()); + assertEquals("gateway-ip", result.getDefaultGateway()); + } } diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/nwrest/NetworkRequestTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/nwrest/NetworkRequestTest.java index 5e04fc49ee..f0f1565cf3 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/nwrest/NetworkRequestTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/nwrest/NetworkRequestTest.java @@ -21,21 +21,20 @@ package org.onap.so.adapters.nwrest; import static org.junit.Assert.assertEquals; - import org.junit.Test; public class NetworkRequestTest { - - @Test - public void isSynchronousTrue() { - CreateNetworkRequest networkResponse = new CreateNetworkRequest(); - assertEquals(true, networkResponse.isSynchronous()); - //flip synchronous to false in the background - networkResponse.setNotificationUrl("testtest"); - assertEquals(false, networkResponse.isSynchronous()); - networkResponse.setNotificationUrl(""); - assertEquals(true, networkResponse.isSynchronous()); - } - + + @Test + public void isSynchronousTrue() { + CreateNetworkRequest networkResponse = new CreateNetworkRequest(); + assertEquals(true, networkResponse.isSynchronous()); + // flip synchronous to false in the background + networkResponse.setNotificationUrl("testtest"); + assertEquals(false, networkResponse.isSynchronous()); + networkResponse.setNotificationUrl(""); + assertEquals(true, networkResponse.isSynchronous()); + } + } diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/vdu/BeansTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/vdu/BeansTest.java index e681d43256..d7704a46d6 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/vdu/BeansTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/vdu/BeansTest.java @@ -21,7 +21,6 @@ package org.onap.so.adapters.vdu; import org.junit.Test; - import com.openpojo.reflection.PojoClass; import com.openpojo.reflection.PojoClassFilter; import com.openpojo.reflection.filters.FilterPackageInfo; @@ -33,24 +32,22 @@ import com.openpojo.validation.test.impl.SetterTester; public class BeansTest { - private PojoClassFilter filterTestClasses = new FilterTestClasses(); + private PojoClassFilter filterTestClasses = new FilterTestClasses(); + + @Test + public void pojoStructure() { + test("org.onap.so.adapters.vdu"); + } - @Test - public void pojoStructure() { - test("org.onap.so.adapters.vdu"); - } + private void test(String pojoPackage) { + Validator validator = ValidatorBuilder.create().with(new GetterMustExistRule()).with(new SetterTester()) + .with(new GetterTester()).build(); + validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses); + } - private void test(String pojoPackage) { - Validator validator = ValidatorBuilder.create() - .with(new GetterMustExistRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .build(); - validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses); - } - 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/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoAdapterExceptionTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoAdapterExceptionTest.java index 28a4a8302f..4c864a72b7 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoAdapterExceptionTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoAdapterExceptionTest.java @@ -28,14 +28,14 @@ public class MsoAdapterExceptionTest { @Test public void testConstructor() { MsoAdapterException msoAdapterException = new MsoAdapterException("test"); - Assert.assertEquals("test",msoAdapterException.getMessage()); + Assert.assertEquals("test", msoAdapterException.getMessage()); Assert.assertEquals(MsoExceptionCategory.INTERNAL, msoAdapterException.category); } @Test public void testOverloadedConstructor() { - MsoAdapterException msoAdapterException = new MsoAdapterException("test" , new Throwable()); - Assert.assertEquals("test",msoAdapterException.getMessage()); + MsoAdapterException msoAdapterException = new MsoAdapterException("test", new Throwable()); + Assert.assertEquals("test", msoAdapterException.getMessage()); Assert.assertEquals(MsoExceptionCategory.INTERNAL, msoAdapterException.category); Assert.assertNotNull(msoAdapterException.getCause()); } diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoCloudIdentityNotFoundTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoCloudIdentityNotFoundTest.java index e7befed71a..050c784c51 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoCloudIdentityNotFoundTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoCloudIdentityNotFoundTest.java @@ -27,16 +27,16 @@ public class MsoCloudIdentityNotFoundTest { @Test public void testConstructor() { MsoCloudIdentityNotFound msoCloudIdentityNotFound = new MsoCloudIdentityNotFound(); - Assert.assertEquals("Cloud Identity not found",msoCloudIdentityNotFound.getMessage()); - Assert.assertEquals("Cloud Identity not found",msoCloudIdentityNotFound.toString()); + Assert.assertEquals("Cloud Identity not found", msoCloudIdentityNotFound.getMessage()); + Assert.assertEquals("Cloud Identity not found", msoCloudIdentityNotFound.toString()); Assert.assertEquals(MsoExceptionCategory.USERDATA, msoCloudIdentityNotFound.category); } @Test public void testOverloadedConstructor() { MsoCloudIdentityNotFound msoCloudIdentityNotFound = new MsoCloudIdentityNotFound("test"); - Assert.assertEquals("Cloud Identity [test] not found",msoCloudIdentityNotFound.getMessage()); - Assert.assertEquals("Cloud Identity [test] not found",msoCloudIdentityNotFound.toString()); + Assert.assertEquals("Cloud Identity [test] not found", msoCloudIdentityNotFound.getMessage()); + Assert.assertEquals("Cloud Identity [test] not found", msoCloudIdentityNotFound.toString()); Assert.assertEquals(MsoExceptionCategory.USERDATA, msoCloudIdentityNotFound.category); } diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoCloudSiteNotFoundTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoCloudSiteNotFoundTest.java index c75a66e100..d6c57bb267 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoCloudSiteNotFoundTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoCloudSiteNotFoundTest.java @@ -27,16 +27,16 @@ public class MsoCloudSiteNotFoundTest { @Test public void testConstructor() { MsoCloudSiteNotFound msoCloudSiteNotFound = new MsoCloudSiteNotFound(); - Assert.assertEquals("Cloud site not found",msoCloudSiteNotFound.getMessage()); - Assert.assertEquals("Cloud site not found",msoCloudSiteNotFound.toString()); + Assert.assertEquals("Cloud site not found", msoCloudSiteNotFound.getMessage()); + Assert.assertEquals("Cloud site not found", msoCloudSiteNotFound.toString()); Assert.assertEquals(MsoExceptionCategory.USERDATA, msoCloudSiteNotFound.category); } @Test public void testOverloadedConstructor() { MsoCloudSiteNotFound msoCloudSiteNotFound = new MsoCloudSiteNotFound("test"); - Assert.assertEquals("Cloud Site [test] not found",msoCloudSiteNotFound.getMessage()); - Assert.assertEquals("Cloud Site [test] not found",msoCloudSiteNotFound.toString()); + Assert.assertEquals("Cloud Site [test] not found", msoCloudSiteNotFound.getMessage()); + Assert.assertEquals("Cloud Site [test] not found", msoCloudSiteNotFound.toString()); Assert.assertEquals(MsoExceptionCategory.USERDATA, msoCloudSiteNotFound.category); } diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoIOExceptionTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoIOExceptionTest.java index e257e52cd4..58425ed7d1 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoIOExceptionTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoIOExceptionTest.java @@ -27,14 +27,14 @@ public class MsoIOExceptionTest { @Test public void testConstructor() { MsoIOException msoIOException = new MsoIOException("test"); - Assert.assertEquals("test",msoIOException.getMessage()); + Assert.assertEquals("test", msoIOException.getMessage()); Assert.assertEquals(MsoExceptionCategory.IO, msoIOException.category); } @Test public void testOverloadedConstructor() { MsoIOException msoIOException = new MsoIOException("test", new Throwable()); - Assert.assertEquals("test",msoIOException.getMessage()); + Assert.assertEquals("test", msoIOException.getMessage()); Assert.assertEquals(MsoExceptionCategory.IO, msoIOException.category); Assert.assertNotNull(msoIOException.getCause()); } diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoNetworkAlreadyExistsTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoNetworkAlreadyExistsTest.java index 96ff89c094..f19fd57947 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoNetworkAlreadyExistsTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoNetworkAlreadyExistsTest.java @@ -27,9 +27,11 @@ public class MsoNetworkAlreadyExistsTest { @Test public void testConstructor() { - MsoNetworkAlreadyExists msoNetworkAlreadyExists = new MsoNetworkAlreadyExists("test","test","test"); - Assert.assertEquals("Stack test already exists in Tenant test in Cloud test",msoNetworkAlreadyExists.getMessage()); - Assert.assertEquals("409 Conflict: Stack test already exists in Tenant test in Cloud test",msoNetworkAlreadyExists.toString()); + MsoNetworkAlreadyExists msoNetworkAlreadyExists = new MsoNetworkAlreadyExists("test", "test", "test"); + Assert.assertEquals("Stack test already exists in Tenant test in Cloud test", + msoNetworkAlreadyExists.getMessage()); + Assert.assertEquals("409 Conflict: Stack test already exists in Tenant test in Cloud test", + msoNetworkAlreadyExists.toString()); } } diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoNetworkNotFoundTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoNetworkNotFoundTest.java index 5991e55915..e35214f191 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoNetworkNotFoundTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoNetworkNotFoundTest.java @@ -27,9 +27,10 @@ public class MsoNetworkNotFoundTest { @Test public void testConstructor() { - MsoNetworkNotFound msoNetworkNotFound =new MsoNetworkNotFound("test","test","test"); - Assert.assertEquals("Network test does not exist in Cloud/Tenant test/test",msoNetworkNotFound.getMessage()); - Assert.assertEquals("404 Not Found: Network test does not exist in Cloud/Tenant test/test",msoNetworkNotFound.toString()); + MsoNetworkNotFound msoNetworkNotFound = new MsoNetworkNotFound("test", "test", "test"); + Assert.assertEquals("Network test does not exist in Cloud/Tenant test/test", msoNetworkNotFound.getMessage()); + Assert.assertEquals("404 Not Found: Network test does not exist in Cloud/Tenant test/test", + msoNetworkNotFound.toString()); } } diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoOpenstackExceptionTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoOpenstackExceptionTest.java index 7bdb2283e8..f9022c3f57 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoOpenstackExceptionTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoOpenstackExceptionTest.java @@ -27,17 +27,17 @@ public class MsoOpenstackExceptionTest { @Test public void testConstructor() { - MsoOpenstackException msoOpenstackException= new MsoOpenstackException(404,"test","test"); - Assert.assertEquals("test",msoOpenstackException.getMessage()); - Assert.assertEquals("404 test: test",msoOpenstackException.toString()); + MsoOpenstackException msoOpenstackException = new MsoOpenstackException(404, "test", "test"); + Assert.assertEquals("test", msoOpenstackException.getMessage()); + Assert.assertEquals("404 test: test", msoOpenstackException.toString()); Assert.assertEquals(MsoExceptionCategory.OPENSTACK, msoOpenstackException.category); } @Test public void testOverloadedConstructor() { - MsoOpenstackException msoOpenstackExceptionEx= new MsoOpenstackException(404,"test","test",new Exception()); - Assert.assertEquals("test",msoOpenstackExceptionEx.getMessage()); - Assert.assertEquals("404 test: test",msoOpenstackExceptionEx.toString()); + MsoOpenstackException msoOpenstackExceptionEx = new MsoOpenstackException(404, "test", "test", new Exception()); + Assert.assertEquals("test", msoOpenstackExceptionEx.getMessage()); + Assert.assertEquals("404 test: test", msoOpenstackExceptionEx.toString()); Assert.assertEquals(MsoExceptionCategory.OPENSTACK, msoOpenstackExceptionEx.category); Assert.assertNotNull(msoOpenstackExceptionEx.getCause()); diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoStackAlreadyExistsTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoStackAlreadyExistsTest.java index 4b44f0db93..6a9f05d853 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoStackAlreadyExistsTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoStackAlreadyExistsTest.java @@ -28,7 +28,9 @@ public class MsoStackAlreadyExistsTest { @Test public void testConstructor() { MsoStackAlreadyExists msoStackAlreadyExists = new MsoStackAlreadyExists("test", "test", "test"); - Assert.assertEquals("Stack test already exists in Tenant test in Cloud test",msoStackAlreadyExists.getMessage()); - Assert.assertEquals("409 Conflict: Stack test already exists in Tenant test in Cloud test",msoStackAlreadyExists.toString()); + Assert.assertEquals("Stack test already exists in Tenant test in Cloud test", + msoStackAlreadyExists.getMessage()); + Assert.assertEquals("409 Conflict: Stack test already exists in Tenant test in Cloud test", + msoStackAlreadyExists.toString()); } } diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoStackNotFoundTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoStackNotFoundTest.java index 8ce5a33cc4..1dd07b72e5 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoStackNotFoundTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoStackNotFoundTest.java @@ -28,7 +28,8 @@ public class MsoStackNotFoundTest { @Test public void testConstructor() { MsoStackNotFound msoStackNotFound = new MsoStackNotFound("test", "test", "test"); - Assert.assertEquals("Stack test does not exist in Cloud/Tenant test/test",msoStackNotFound.getMessage()); - Assert.assertEquals("404 Not Found: Stack test does not exist in Cloud/Tenant test/test",msoStackNotFound.toString()); + Assert.assertEquals("Stack test does not exist in Cloud/Tenant test/test", msoStackNotFound.getMessage()); + Assert.assertEquals("404 Not Found: Stack test does not exist in Cloud/Tenant test/test", + msoStackNotFound.toString()); } } diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoTenantAlreadyExistsTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoTenantAlreadyExistsTest.java index 5999a587a5..5bfdbd38e4 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoTenantAlreadyExistsTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoTenantAlreadyExistsTest.java @@ -27,8 +27,9 @@ public class MsoTenantAlreadyExistsTest { @Test public void testConstructor() { - MsoTenantAlreadyExists msoTenantAlreadyExists = new MsoTenantAlreadyExists("test","test"); - Assert.assertEquals("Tenant test already exists in Cloud test",msoTenantAlreadyExists.getMessage()); - Assert.assertEquals("409 Conflict: Tenant test already exists in Cloud test",msoTenantAlreadyExists.toString()); + MsoTenantAlreadyExists msoTenantAlreadyExists = new MsoTenantAlreadyExists("test", "test"); + Assert.assertEquals("Tenant test already exists in Cloud test", msoTenantAlreadyExists.getMessage()); + Assert.assertEquals("409 Conflict: Tenant test already exists in Cloud test", + msoTenantAlreadyExists.toString()); } } diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoTenantNotFoundTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoTenantNotFoundTest.java index 23df616573..f45cddc676 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoTenantNotFoundTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/exceptions/MsoTenantNotFoundTest.java @@ -27,9 +27,9 @@ public class MsoTenantNotFoundTest { @Test public void testConstructor() { - MsoTenantNotFound msoTenantNotFound = new MsoTenantNotFound("test","test"); - Assert.assertEquals("Tenant test does not exist in Cloud test",msoTenantNotFound.getMessage()); - Assert.assertEquals("404 Not Found: Tenant test does not exist in Cloud test",msoTenantNotFound.toString()); + MsoTenantNotFound msoTenantNotFound = new MsoTenantNotFound("test", "test"); + Assert.assertEquals("Tenant test does not exist in Cloud test", msoTenantNotFound.getMessage()); + Assert.assertEquals("404 Not Found: Tenant test does not exist in Cloud test", msoTenantNotFound.toString()); } } diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java index 038e88317d..8d27e54892 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/JAXBMarshallingTest.java @@ -21,14 +21,11 @@ package org.onap.so.openstack.mappers; import static org.junit.Assert.assertEquals; - import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; - import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; - import org.junit.Test; import org.onap.so.adapters.vnfrest.CreateVfModuleRequest; @@ -36,16 +33,17 @@ import org.onap.so.adapters.vnfrest.CreateVfModuleRequest; public class JAXBMarshallingTest { - @Test - public void xmlMarshalTest() throws IOException, JAXBException { - JAXBContext context = JAXBContext.newInstance(CreateVfModuleRequest.class); + @Test + public void xmlMarshalTest() throws IOException, JAXBException { + JAXBContext context = JAXBContext.newInstance(CreateVfModuleRequest.class); - CreateVfModuleRequest request = (CreateVfModuleRequest) context.createUnmarshaller().unmarshal(Files.newBufferedReader(Paths.get("src/test/resources/createVfModuleRequest-with-params.xml"))); + CreateVfModuleRequest request = (CreateVfModuleRequest) context.createUnmarshaller().unmarshal( + Files.newBufferedReader(Paths.get("src/test/resources/createVfModuleRequest-with-params.xml"))); - assertEquals("ubuntu-16-04-cloud-amd64", request.getVfModuleParams().get("vcpe_image_name")); - assertEquals("10.2.0.0/24", request.getVfModuleParams().get("cpe_public_net_cidr")); - assertEquals("", request.getVfModuleParams().get("workload_context")); + assertEquals("ubuntu-16-04-cloud-amd64", request.getVfModuleParams().get("vcpe_image_name")); + assertEquals("10.2.0.0/24", request.getVfModuleParams().get("cpe_public_net_cidr")); + assertEquals("", request.getVfModuleParams().get("workload_context")); - } + } } diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/NetworkInfoMapperTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/NetworkInfoMapperTest.java index 90e15f8ba5..0af0efccd2 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/NetworkInfoMapperTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/NetworkInfoMapperTest.java @@ -21,104 +21,101 @@ package org.onap.so.openstack.mappers; import static org.junit.Assert.assertEquals; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Optional; - import org.javatuples.Pair; import org.junit.Test; import org.onap.so.openstack.beans.NetworkInfo; import org.onap.so.openstack.beans.NetworkStatus; - import com.woorea.openstack.quantum.model.Network; import com.woorea.openstack.quantum.model.Segment; public class NetworkInfoMapperTest { - @Test - public void checkNetworkStatusMap() { - NetworkInfoMapper mapper = new NetworkInfoMapper(new Network()); - assertEquals(NetworkStatus.ACTIVE, mapper.mapStatus("ACTIVE")); - assertEquals(NetworkStatus.BUILD, mapper.mapStatus("BUILD")); - assertEquals(NetworkStatus.ERROR, mapper.mapStatus("ERROR")); - assertEquals(NetworkStatus.DOWN, mapper.mapStatus("DOWN")); - assertEquals(NetworkStatus.UNKNOWN, mapper.mapStatus("NOT IN MAP")); - assertEquals(NetworkStatus.UNKNOWN, mapper.mapStatus(null)); - } - - @Test - public void checkLocateVlanInformationNoSegments() { - Network network = new Network(); - network.setProviderPhysicalNetwork("test-physical-network"); - network.setProviderNetworkType("vlan"); - network.setProviderSegmentationId(2); - NetworkInfoMapper mapper = new NetworkInfoMapper(network); - NetworkInfo result = mapper.map(); - assertEquals("test-physical-network", result.getProvider()); - assertEquals(1, result.getVlans().size()); - assertEquals(2, result.getVlans().get(0).intValue()); - } - - @Test - public void checkLocateVlanInformationSegments() { - Network network = new Network(); - addSegments(network); + @Test + public void checkNetworkStatusMap() { + NetworkInfoMapper mapper = new NetworkInfoMapper(new Network()); + assertEquals(NetworkStatus.ACTIVE, mapper.mapStatus("ACTIVE")); + assertEquals(NetworkStatus.BUILD, mapper.mapStatus("BUILD")); + assertEquals(NetworkStatus.ERROR, mapper.mapStatus("ERROR")); + assertEquals(NetworkStatus.DOWN, mapper.mapStatus("DOWN")); + assertEquals(NetworkStatus.UNKNOWN, mapper.mapStatus("NOT IN MAP")); + assertEquals(NetworkStatus.UNKNOWN, mapper.mapStatus(null)); + } + + @Test + public void checkLocateVlanInformationNoSegments() { + Network network = new Network(); + network.setProviderPhysicalNetwork("test-physical-network"); + network.setProviderNetworkType("vlan"); + network.setProviderSegmentationId(2); + NetworkInfoMapper mapper = new NetworkInfoMapper(network); + NetworkInfo result = mapper.map(); + assertEquals("test-physical-network", result.getProvider()); + assertEquals(1, result.getVlans().size()); + assertEquals(2, result.getVlans().get(0).intValue()); + } + + @Test + public void checkLocateVlanInformationSegments() { + Network network = new Network(); + addSegments(network); + + NetworkInfoMapper mapper = new NetworkInfoMapper(network); + NetworkInfo result = mapper.map(); + assertEquals("type1", result.getProvider()); + assertEquals(2, result.getVlans().size()); + assertEquals(Arrays.asList(1, 2).toString(), result.getVlans().toString()); + } + + @Test + public void checkLocateVlanInformationSegmentsAndPhysical() { + Network network = new Network(); + addSegments(network); + network.setProviderPhysicalNetwork("test-physical-network"); + network.setProviderNetworkType("vlan"); + network.setProviderSegmentationId(2); + NetworkInfoMapper mapper = new NetworkInfoMapper(network); + NetworkInfo result = mapper.map(); + assertEquals("test-physical-network", result.getProvider()); + assertEquals(1, result.getVlans().size()); + assertEquals(2, result.getVlans().get(0).intValue()); + } + + @Test + public void nullNetwork() { + NetworkInfoMapper mapper = new NetworkInfoMapper(null); + assertEquals(NetworkStatus.NOTFOUND, mapper.map().getStatus()); + } + + @Test + public void mapFields() { + Network network = new Network(); + network.setId("id"); + network.setName("name"); + network.setSubnets(Arrays.asList("string1", "string2")); + NetworkInfoMapper mapper = new NetworkInfoMapper(network); + NetworkInfo mapped = mapper.map(); + assertEquals("name", mapped.getName()); + assertEquals("id", mapped.getId()); + assertEquals(network.getSubnets(), mapped.getSubnets()); + } - NetworkInfoMapper mapper = new NetworkInfoMapper(network); - NetworkInfo result = mapper.map(); - assertEquals("type1", result.getProvider()); - assertEquals(2, result.getVlans().size()); - assertEquals(Arrays.asList(1, 2).toString(), result.getVlans().toString()); - } - - @Test - public void checkLocateVlanInformationSegmentsAndPhysical() { - Network network = new Network(); - addSegments(network); - network.setProviderPhysicalNetwork("test-physical-network"); - network.setProviderNetworkType("vlan"); - network.setProviderSegmentationId(2); - NetworkInfoMapper mapper = new NetworkInfoMapper(network); - NetworkInfo result = mapper.map(); - assertEquals("test-physical-network", result.getProvider()); - assertEquals(1, result.getVlans().size()); - assertEquals(2, result.getVlans().get(0).intValue()); - } - - @Test - public void nullNetwork() { - NetworkInfoMapper mapper = new NetworkInfoMapper(null); - assertEquals(NetworkStatus.NOTFOUND, mapper.map().getStatus()); - } - - @Test - public void mapFields() { - Network network = new Network(); - network.setId("id"); - network.setName("name"); - network.setSubnets(Arrays.asList("string1", "string2")); - NetworkInfoMapper mapper = new NetworkInfoMapper(network); - NetworkInfo mapped = mapper.map(); - assertEquals("name", mapped.getName()); - assertEquals("id", mapped.getId()); - assertEquals(network.getSubnets(), mapped.getSubnets()); - } - - private Network addSegments(Network network) { - List<Segment> segments = new ArrayList<>(); - Segment segment1 = new Segment(); - segment1.setProviderPhysicalNetwork("type1"); - segment1.setProviderNetworkType("vlan"); - segment1.setProviderSegmentationId(1); - segments.add(segment1); - Segment segment2 = new Segment(); - segment2.setProviderPhysicalNetwork("type2"); - segment2.setProviderNetworkType("vlan"); - segment2.setProviderSegmentationId(2); - segments.add(segment2); - network.setSegments(segments); - return network; - } + private Network addSegments(Network network) { + List<Segment> segments = new ArrayList<>(); + Segment segment1 = new Segment(); + segment1.setProviderPhysicalNetwork("type1"); + segment1.setProviderNetworkType("vlan"); + segment1.setProviderSegmentationId(1); + segments.add(segment1); + Segment segment2 = new Segment(); + segment2.setProviderPhysicalNetwork("type2"); + segment2.setProviderNetworkType("vlan"); + segment2.setProviderSegmentationId(2); + segments.add(segment2); + network.setSegments(segments); + return network; + } } diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/StackInfoMapperTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/StackInfoMapperTest.java index f01745f8c1..4ca0186a82 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/StackInfoMapperTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/openstack/mappers/StackInfoMapperTest.java @@ -21,17 +21,14 @@ package org.onap.so.openstack.mappers; import static org.junit.Assert.assertEquals; - import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; - import org.junit.Test; import org.onap.so.openstack.beans.HeatStatus; import org.onap.so.openstack.beans.StackInfo; - import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -39,56 +36,57 @@ import com.woorea.openstack.heat.model.Stack; public class StackInfoMapperTest { - private static final String PATH = "src/test/resources/"; - @Test - public void nullStack() { - StackInfoMapper mapper = new StackInfoMapper(null); - assertEquals(HeatStatus.NOTFOUND, mapper.map().getStatus()); - } - - @Test - public void checkHeatStatusMap() { - StackInfoMapper mapper = new StackInfoMapper(null); - assertEquals(HeatStatus.BUILDING, mapper.mapStatus("CREATE_IN_PROGRESS")); - assertEquals(HeatStatus.CREATED, mapper.mapStatus("CREATE_COMPLETE")); - assertEquals(HeatStatus.FAILED, mapper.mapStatus("CREATE_FAILED")); - assertEquals(HeatStatus.DELETING, mapper.mapStatus("DELETE_IN_PROGRESS")); - assertEquals(HeatStatus.NOTFOUND, mapper.mapStatus("DELETE_COMPLETE")); - assertEquals(HeatStatus.FAILED, mapper.mapStatus("DELETE_FAILED")); - assertEquals(HeatStatus.UPDATING, mapper.mapStatus("UPDATE_IN_PROGRESS")); - assertEquals(HeatStatus.FAILED, mapper.mapStatus("UPDATE_FAILED")); - assertEquals(HeatStatus.UPDATED, mapper.mapStatus("UPDATE_COMPLETE")); - assertEquals(HeatStatus.INIT, mapper.mapStatus(null)); - assertEquals(HeatStatus.UNKNOWN, mapper.mapStatus("status-not-there")); - } - - @Test - public void checkOutputToMap() throws JsonParseException, JsonMappingException, IOException { - ObjectMapper jacksonMapper = new ObjectMapper(); - Stack sample = jacksonMapper.readValue(this.getJson("stack-example.json"), Stack.class); - StackInfoMapper mapper = new StackInfoMapper(sample); - StackInfo result = mapper.map(); - Map<String, Object> map = result.getOutputs(); - assertEquals(true, map.containsKey("key2")); - assertEquals("value1", map.get("key1")); - } - - @Test - public void mapRemainingFields() { - Stack stack = new Stack(); - stack.setStackName("name"); - stack.setId("id"); - stack.setStackStatusReason("message"); - stack.setParameters(new HashMap<String, Object>()); - StackInfoMapper mapper = new StackInfoMapper(stack); - StackInfo info = mapper.map(); - assertEquals("name", info.getName()); - assertEquals("name/id", info.getCanonicalName()); - assertEquals("message", info.getStatusMessage()); - assertEquals(stack.getParameters(), info.getParameters()); - } - - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get(PATH + filename))); - } + private static final String PATH = "src/test/resources/"; + + @Test + public void nullStack() { + StackInfoMapper mapper = new StackInfoMapper(null); + assertEquals(HeatStatus.NOTFOUND, mapper.map().getStatus()); + } + + @Test + public void checkHeatStatusMap() { + StackInfoMapper mapper = new StackInfoMapper(null); + assertEquals(HeatStatus.BUILDING, mapper.mapStatus("CREATE_IN_PROGRESS")); + assertEquals(HeatStatus.CREATED, mapper.mapStatus("CREATE_COMPLETE")); + assertEquals(HeatStatus.FAILED, mapper.mapStatus("CREATE_FAILED")); + assertEquals(HeatStatus.DELETING, mapper.mapStatus("DELETE_IN_PROGRESS")); + assertEquals(HeatStatus.NOTFOUND, mapper.mapStatus("DELETE_COMPLETE")); + assertEquals(HeatStatus.FAILED, mapper.mapStatus("DELETE_FAILED")); + assertEquals(HeatStatus.UPDATING, mapper.mapStatus("UPDATE_IN_PROGRESS")); + assertEquals(HeatStatus.FAILED, mapper.mapStatus("UPDATE_FAILED")); + assertEquals(HeatStatus.UPDATED, mapper.mapStatus("UPDATE_COMPLETE")); + assertEquals(HeatStatus.INIT, mapper.mapStatus(null)); + assertEquals(HeatStatus.UNKNOWN, mapper.mapStatus("status-not-there")); + } + + @Test + public void checkOutputToMap() throws JsonParseException, JsonMappingException, IOException { + ObjectMapper jacksonMapper = new ObjectMapper(); + Stack sample = jacksonMapper.readValue(this.getJson("stack-example.json"), Stack.class); + StackInfoMapper mapper = new StackInfoMapper(sample); + StackInfo result = mapper.map(); + Map<String, Object> map = result.getOutputs(); + assertEquals(true, map.containsKey("key2")); + assertEquals("value1", map.get("key1")); + } + + @Test + public void mapRemainingFields() { + Stack stack = new Stack(); + stack.setStackName("name"); + stack.setId("id"); + stack.setStackStatusReason("message"); + stack.setParameters(new HashMap<String, Object>()); + StackInfoMapper mapper = new StackInfoMapper(stack); + StackInfo info = mapper.map(); + assertEquals("name", info.getName()); + assertEquals("name/id", info.getCanonicalName()); + assertEquals("message", info.getStatusMessage()); + assertEquals(stack.getParameters(), info.getParameters()); + } + + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get(PATH + filename))); + } } |