diff options
Diffstat (limited to 'mso-catalog-db/src/test')
26 files changed, 772 insertions, 819 deletions
diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BaseTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BaseTest.java index 5bfa300a03..bbd4c99a60 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BaseTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BaseTest.java @@ -34,51 +34,51 @@ import org.springframework.test.context.junit4.SpringRunner; @SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public class BaseTest { - - protected VnfcCustomization setUpVnfcCustomization(){ - VnfcCustomization vnfcCustomization = new VnfcCustomization(); - vnfcCustomization.setModelInstanceName("testVnfcCustomizationModelInstanceName"); - vnfcCustomization.setModelUUID("321228a4-9f15-11e8-98d0-529269fb1459"); - vnfcCustomization.setModelInvariantUUID("c0659136-9f15-11e8-98d0-529269fb1459"); - vnfcCustomization.setModelVersion("testModelVersion"); - vnfcCustomization.setModelName("testModelName"); - vnfcCustomization.setToscaNodeType("testToscaModelType"); - vnfcCustomization.setDescription("testVnfcCustomizationDescription"); - return vnfcCustomization; + + protected VnfcCustomization setUpVnfcCustomization() { + VnfcCustomization vnfcCustomization = new VnfcCustomization(); + vnfcCustomization.setModelInstanceName("testVnfcCustomizationModelInstanceName"); + vnfcCustomization.setModelUUID("321228a4-9f15-11e8-98d0-529269fb1459"); + vnfcCustomization.setModelInvariantUUID("c0659136-9f15-11e8-98d0-529269fb1459"); + vnfcCustomization.setModelVersion("testModelVersion"); + vnfcCustomization.setModelName("testModelName"); + vnfcCustomization.setToscaNodeType("testToscaModelType"); + vnfcCustomization.setDescription("testVnfcCustomizationDescription"); + return vnfcCustomization; } - - protected CvnfcCustomization setUpCvnfcCustomization(){ - CvnfcCustomization cvnfcCustomization = new CvnfcCustomization(); - cvnfcCustomization.setModelInstanceName("cvfncCustomizationTestModelInstanceName"); - cvnfcCustomization.setModelUUID("321228a4-9f15-11e8-98d0-529269fb1459"); - cvnfcCustomization.setModelInvariantUUID("c0659136-9f15-11e8-98d0-529269fb1459"); - cvnfcCustomization.setModelVersion("testModelVersion"); - cvnfcCustomization.setModelName("testModelName"); - cvnfcCustomization.setToscaNodeType("testToscaNodeType"); - cvnfcCustomization.setDescription("description"); - cvnfcCustomization.setNfcFunction("testNfcFunction"); - cvnfcCustomization.setNfcNamingCode("testNfcNamingCode"); - return cvnfcCustomization; + + protected CvnfcCustomization setUpCvnfcCustomization() { + CvnfcCustomization cvnfcCustomization = new CvnfcCustomization(); + cvnfcCustomization.setModelInstanceName("cvfncCustomizationTestModelInstanceName"); + cvnfcCustomization.setModelUUID("321228a4-9f15-11e8-98d0-529269fb1459"); + cvnfcCustomization.setModelInvariantUUID("c0659136-9f15-11e8-98d0-529269fb1459"); + cvnfcCustomization.setModelVersion("testModelVersion"); + cvnfcCustomization.setModelName("testModelName"); + cvnfcCustomization.setToscaNodeType("testToscaNodeType"); + cvnfcCustomization.setDescription("description"); + cvnfcCustomization.setNfcFunction("testNfcFunction"); + cvnfcCustomization.setNfcNamingCode("testNfcNamingCode"); + return cvnfcCustomization; } - - protected VfModule setUpVfModule(){ - VfModule vFModule = new VfModule(); - vFModule.setModelUUID("cb82ffd8-252a-11e7-93ae-92361f002671"); - vFModule.setModelVersion("testModelVersion"); - vFModule.setModelName("testModelName"); - vFModule.setIsBase(false); - return vFModule; + + protected VfModule setUpVfModule() { + VfModule vFModule = new VfModule(); + vFModule.setModelUUID("cb82ffd8-252a-11e7-93ae-92361f002671"); + vFModule.setModelVersion("testModelVersion"); + vFModule.setModelName("testModelName"); + vFModule.setIsBase(false); + return vFModule; } - - protected VnfResource setUpVnfResource(){ - VnfResource vnfResource = new VnfResource(); - vnfResource.setModelUUID("cb82ffd8-252a-11e7-93ae-92361f002671"); - vnfResource.setModelInvariantUUID("az82ffd8-252a-11e7-93ae-92361f002677"); - vnfResource.setModelVersion("testModelVersion"); - vnfResource.setOrchestrationMode("HEAT"); - return vnfResource; + + protected VnfResource setUpVnfResource() { + VnfResource vnfResource = new VnfResource(); + vnfResource.setModelUUID("cb82ffd8-252a-11e7-93ae-92361f002671"); + vnfResource.setModelInvariantUUID("az82ffd8-252a-11e7-93ae-92361f002677"); + vnfResource.setModelVersion("testModelVersion"); + vnfResource.setOrchestrationMode("HEAT"); + return vnfResource; } - + @Test - public void testNothing(){} + public void testNothing() {} } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BuildingBlockDetailTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BuildingBlockDetailTest.java index 73f1ef49fa..6f54288d9a 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BuildingBlockDetailTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BuildingBlockDetailTest.java @@ -21,7 +21,6 @@ package org.onap.so.db.catalog; import static org.junit.Assert.assertEquals; - import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.db.catalog.beans.BuildingBlockDetail; @@ -37,16 +36,17 @@ import org.springframework.test.context.junit4.SpringRunner; @SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public class BuildingBlockDetailTest { - @Autowired - private BuildingBlockDetailRepository buildingBlockDetailRepository; - - @Test - public void BuildingBlockDetailSingleLookupValidationTest() { - String buildingBlockName = "AssignServiceInstanceBB"; - - BuildingBlockDetail buildingBlockDetail = buildingBlockDetailRepository.findOneByBuildingBlockName(buildingBlockName); - assertEquals(buildingBlockName, buildingBlockDetail.getBuildingBlockName()); - assertEquals(ResourceType.SERVICE, buildingBlockDetail.getResourceType()); - assertEquals(OrchestrationAction.ASSIGN, buildingBlockDetail.getTargetAction()); - } + @Autowired + private BuildingBlockDetailRepository buildingBlockDetailRepository; + + @Test + public void BuildingBlockDetailSingleLookupValidationTest() { + String buildingBlockName = "AssignServiceInstanceBB"; + + BuildingBlockDetail buildingBlockDetail = + buildingBlockDetailRepository.findOneByBuildingBlockName(buildingBlockName); + assertEquals(buildingBlockName, buildingBlockDetail.getBuildingBlockName()); + assertEquals(ResourceType.SERVICE, buildingBlockDetail.getResourceType()); + assertEquals(OrchestrationAction.ASSIGN, buildingBlockDetail.getTargetAction()); + } } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ControllerSelectionReferenceTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ControllerSelectionReferenceTest.java index 489f8a0a3d..f3670649ae 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ControllerSelectionReferenceTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ControllerSelectionReferenceTest.java @@ -22,7 +22,6 @@ package org.onap.so.db.catalog; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; - import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.db.catalog.beans.ControllerSelectionReference; @@ -37,32 +36,32 @@ import org.springframework.test.context.junit4.SpringRunner; @ActiveProfiles("test") public class ControllerSelectionReferenceTest { - @Autowired - private ControllerSelectionReferenceRepository controllerSelectionReferenceRepository; - - @Test - public void Find_ControllerNameByVnfTypeAndAction_Test() { - String vnfType = "vLoadBalancerMS/vLoadBalancerMS 0"; - String controllerName = "APPC"; - String actionCategory = "ConfigScaleOut"; - ControllerSelectionReference controller = - controllerSelectionReferenceRepository.findControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, actionCategory); - assertEquals(vnfType, controller.getVnfType()); - assertEquals(controllerName, controller.getControllerName()); - assertEquals(actionCategory, controller.getActionCategory()); - } - - @Test - public final void controllerDataTest() { - ControllerSelectionReference controller = new ControllerSelectionReference(); + @Autowired + private ControllerSelectionReferenceRepository controllerSelectionReferenceRepository; + + @Test + public void Find_ControllerNameByVnfTypeAndAction_Test() { + String vnfType = "vLoadBalancerMS/vLoadBalancerMS 0"; + String controllerName = "APPC"; + String actionCategory = "ConfigScaleOut"; + ControllerSelectionReference controller = controllerSelectionReferenceRepository + .findControllerSelectionReferenceByVnfTypeAndActionCategory(vnfType, actionCategory); + assertEquals(vnfType, controller.getVnfType()); + assertEquals(controllerName, controller.getControllerName()); + assertEquals(actionCategory, controller.getActionCategory()); + } + + @Test + public final void controllerDataTest() { + ControllerSelectionReference controller = new ControllerSelectionReference(); - controller.setVnfType("vnfType"); - assertTrue(controller.getVnfType().equalsIgnoreCase("vnfType")); + controller.setVnfType("vnfType"); + assertTrue(controller.getVnfType().equalsIgnoreCase("vnfType")); - controller.setControllerName("controllerName"); - assertTrue(controller.getControllerName().equalsIgnoreCase("controllerName")); + controller.setControllerName("controllerName"); + assertTrue(controller.getControllerName().equalsIgnoreCase("controllerName")); - controller.setActionCategory("actionCategory"); - assertTrue(controller.getActionCategory().equalsIgnoreCase("actionCategory")); - } + controller.setActionCategory("actionCategory"); + assertTrue(controller.getActionCategory().equalsIgnoreCase("actionCategory")); + } } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/EmbeddedMariaDbConfig.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/EmbeddedMariaDbConfig.java index 06a7b1ed29..314e648d9e 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/EmbeddedMariaDbConfig.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/EmbeddedMariaDbConfig.java @@ -19,6 +19,7 @@ */ package org.onap.so.db.catalog; + import ch.vorburger.exec.ManagedProcessException; import ch.vorburger.mariadb4j.DBConfigurationBuilder; import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; @@ -30,7 +31,7 @@ import org.springframework.context.annotation.Profile; import javax.sql.DataSource; @Configuration -@Profile({"test","local"}) +@Profile({"test", "local"}) public class EmbeddedMariaDbConfig { @Bean @@ -40,21 +41,16 @@ public class EmbeddedMariaDbConfig { @Bean DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService, - @Value("${mariaDB4j.databaseName}") String databaseName, - @Value("${spring.datasource.username}") String datasourceUsername, - @Value("${spring.datasource.password}") String datasourcePassword, - @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { - //Create our database with default root user and no password + @Value("${mariaDB4j.databaseName}") String databaseName, + @Value("${spring.datasource.username}") String datasourceUsername, + @Value("${spring.datasource.password}") String datasourcePassword, + @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { + // Create our database with default root user and no password mariaDB4jSpringService.getDB().createDB(databaseName); DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration(); - return DataSourceBuilder - .create() - .username(datasourceUsername) - .password(datasourcePassword) - .url(config.getURL(databaseName)) - .driverClassName(datasourceDriver) - .build(); + return DataSourceBuilder.create().username(datasourceUsername).password(datasourcePassword) + .url(config.getURL(databaseName)).driverClassName(datasourceDriver).build(); } } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/MavenVersioningTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/MavenVersioningTest.java index b5d6271f7c..63328213c7 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/MavenVersioningTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/MavenVersioningTest.java @@ -22,166 +22,163 @@ package org.onap.so.db.catalog; import static org.junit.Assert.*; - import java.util.Collections; import java.util.LinkedList; import java.util.List; - import org.junit.Test; - import org.onap.so.db.catalog.utils.MavenLikeVersioningComparator; import org.onap.so.db.catalog.utils.MavenLikeVersioning; public class MavenVersioningTest { - @Test - public final void testVersion () { - MavenLikeVersioning mavenVersioning = new MavenLikeVersioning (); - assertFalse(mavenVersioning.isMoreRecentThan("0.0.0")); - assertFalse(mavenVersioning.isMoreRecentThan(null)); - mavenVersioning.setVersion("0.0.1"); - - assertFalse(mavenVersioning.isMoreRecentThan(null)); - assertTrue(mavenVersioning.isMoreRecentThan("0.0.0")); - assertTrue(mavenVersioning.isMoreRecentThan("0.0.0.1")); - - assertFalse(mavenVersioning.isMoreRecentThan("0.0.2")); - assertFalse(mavenVersioning.isMoreRecentThan("0.0.1")); - assertFalse(mavenVersioning.isMoreRecentThan("00.00.01")); - - assertFalse(mavenVersioning.isMoreRecentThan("0.1")); - assertFalse(mavenVersioning.isMoreRecentThan("1")); - assertFalse(mavenVersioning.isMoreRecentThan("0.1.0.2")); - - assertFalse(mavenVersioning.isMoreRecentThan("0.1.1")); - assertFalse(mavenVersioning.isMoreRecentThan("2.1.1")); - - mavenVersioning.setVersion("1.0.1"); - assertTrue(mavenVersioning.isMoreRecentThan("0.0.0")); - assertTrue(mavenVersioning.isMoreRecentThan("0.5.2")); - assertTrue(mavenVersioning.isMoreRecentThan("1.0.0")); - - assertFalse(mavenVersioning.isMoreRecentThan("2.1.1")); - assertFalse(mavenVersioning.isMoreRecentThan("02.001.0001")); - assertFalse(mavenVersioning.isMoreRecentThan("1.0.1")); - assertFalse(mavenVersioning.isMoreRecentThan("1.0.2")); - assertFalse(mavenVersioning.isMoreRecentThan("1.1.1")); - assertFalse(mavenVersioning.isMoreRecentThan("1.0.10")); - - - mavenVersioning.setVersion("100.0.1"); - assertTrue(mavenVersioning.isMoreRecentThan("0.0.0")); - assertTrue(mavenVersioning.isMoreRecentThan("0.5.2")); - assertTrue(mavenVersioning.isMoreRecentThan("1.0.0")); - - assertFalse(mavenVersioning.isMoreRecentThan("101.1.1")); - assertFalse(mavenVersioning.isMoreRecentThan("100.0.1")); - assertFalse(mavenVersioning.isMoreRecentThan("100.0.2")); - assertFalse(mavenVersioning.isMoreRecentThan("100.1.1")); - - assertFalse(mavenVersioning.isMoreRecentThan("100.0.1.4")); - } - - @Test - public final void testOneDigitVersion() { - MavenLikeVersioning oneDigit = new MavenLikeVersioning(); - oneDigit.setVersion("1"); - assertFalse(oneDigit.isMoreRecentThan("2")); - assertFalse(oneDigit.isMoreRecentThan("2.0")); - assertFalse(oneDigit.isMoreRecentThan("1.0")); - - oneDigit.setVersion("1.0"); - assertTrue(oneDigit.isMoreRecentThan("1")); - - oneDigit.setVersion("1"); - assertFalse(oneDigit.isTheSameVersion("1.1")); - assertFalse(oneDigit.isTheSameVersion("1.0")); - assertFalse(oneDigit.isTheSameVersion("1.0.0")); - - oneDigit.setVersion("2"); - assertTrue(oneDigit.isMoreRecentThan("1")); - assertTrue(oneDigit.isMoreRecentThan("1.0")); - assertTrue(oneDigit.isMoreRecentThan("1.1")); - assertTrue(oneDigit.isMoreRecentThan("0.1")); - assertFalse(oneDigit.isMoreRecentThan("2.0")); - - } - - @Test - public final void testVersionEquals () { - - MavenLikeVersioning heatTemplate = new MavenLikeVersioning(); - assertFalse(heatTemplate.isTheSameVersion("100.0")); - assertTrue(heatTemplate.isTheSameVersion(null)); - heatTemplate.setVersion("100.0.1"); - assertFalse(heatTemplate.isTheSameVersion(null)); - assertFalse(heatTemplate.isTheSameVersion("100.0")); - assertFalse(heatTemplate.isTheSameVersion("100")); - assertFalse(heatTemplate.isTheSameVersion("100.0.1.1")); - assertTrue(heatTemplate.isTheSameVersion("100.0.1")); - assertTrue(heatTemplate.isTheSameVersion("00100.000.0001")); - assertFalse(heatTemplate.isTheSameVersion("0.0.1")); - assertTrue(heatTemplate.isTheSameVersion("100.0.01")); - - } - - @Test - public final void testListSort () { - MavenLikeVersioning test1 = new MavenLikeVersioning(); - test1.setVersion("1.1"); - MavenLikeVersioning test2 = new MavenLikeVersioning(); - test2.setVersion("1.10"); - MavenLikeVersioning test3 = new MavenLikeVersioning(); - test3.setVersion("1.2"); - MavenLikeVersioning test4 = new MavenLikeVersioning(); - test4.setVersion("1.20"); - MavenLikeVersioning test5 = new MavenLikeVersioning(); - test5.setVersion("1.02"); - MavenLikeVersioning test6 = new MavenLikeVersioning(); - test6.setVersion("2.02"); - MavenLikeVersioning test7 = new MavenLikeVersioning(); - test7.setVersion("0.02"); - MavenLikeVersioning test8 = new MavenLikeVersioning(); - test8.setVersion("2.02"); - MavenLikeVersioning test9 = new MavenLikeVersioning(); - test9.setVersion("10.2004"); - MavenLikeVersioning test10 = new MavenLikeVersioning(); - test10.setVersion("2"); - MavenLikeVersioning test11 = new MavenLikeVersioning(); - test11.setVersion("12"); - MavenLikeVersioning test12 = new MavenLikeVersioning(); - test12.setVersion("2.0"); - - List<MavenLikeVersioning> list= new LinkedList<MavenLikeVersioning>(); - list.add(test1); - list.add(test2); - list.add(test3); - list.add(test4); - list.add(test5); - list.add(test6); - list.add(test7); - list.add(test8); - list.add(test9); - list.add(test10); - list.add(test11); - list.add(test12); - - Collections.sort(list,new MavenLikeVersioningComparator()); - //Collections.reverse(list); - assertTrue(list.get(0).getVersion().equals("0.02")); - assertTrue(list.get(1).getVersion().equals("1.1")); - assertTrue(list.get(2).getVersion().equals("1.02") || list.get(3).getVersion().equals("1.02")); - assertTrue(list.get(3).getVersion().equals("1.2") || list.get(2).getVersion().equals("1.2")); - assertTrue(list.get(4).getVersion().equals("1.10")); - assertTrue(list.get(5).getVersion().equals("1.20")); - assertTrue(list.get(6).getVersion().equals("2")); - assertTrue(list.get(7).getVersion().equals("2.0")); - assertTrue(list.get(8).getVersion().equals("2.02")); - assertTrue(list.get(9).getVersion().equals("2.02")); - assertTrue(list.get(10).getVersion().equals("10.2004")); - assertTrue(list.get(11).getVersion().equals("12")); - - } + @Test + public final void testVersion() { + MavenLikeVersioning mavenVersioning = new MavenLikeVersioning(); + assertFalse(mavenVersioning.isMoreRecentThan("0.0.0")); + assertFalse(mavenVersioning.isMoreRecentThan(null)); + mavenVersioning.setVersion("0.0.1"); + + assertFalse(mavenVersioning.isMoreRecentThan(null)); + assertTrue(mavenVersioning.isMoreRecentThan("0.0.0")); + assertTrue(mavenVersioning.isMoreRecentThan("0.0.0.1")); + + assertFalse(mavenVersioning.isMoreRecentThan("0.0.2")); + assertFalse(mavenVersioning.isMoreRecentThan("0.0.1")); + assertFalse(mavenVersioning.isMoreRecentThan("00.00.01")); + + assertFalse(mavenVersioning.isMoreRecentThan("0.1")); + assertFalse(mavenVersioning.isMoreRecentThan("1")); + assertFalse(mavenVersioning.isMoreRecentThan("0.1.0.2")); + + assertFalse(mavenVersioning.isMoreRecentThan("0.1.1")); + assertFalse(mavenVersioning.isMoreRecentThan("2.1.1")); + + mavenVersioning.setVersion("1.0.1"); + assertTrue(mavenVersioning.isMoreRecentThan("0.0.0")); + assertTrue(mavenVersioning.isMoreRecentThan("0.5.2")); + assertTrue(mavenVersioning.isMoreRecentThan("1.0.0")); + + assertFalse(mavenVersioning.isMoreRecentThan("2.1.1")); + assertFalse(mavenVersioning.isMoreRecentThan("02.001.0001")); + assertFalse(mavenVersioning.isMoreRecentThan("1.0.1")); + assertFalse(mavenVersioning.isMoreRecentThan("1.0.2")); + assertFalse(mavenVersioning.isMoreRecentThan("1.1.1")); + assertFalse(mavenVersioning.isMoreRecentThan("1.0.10")); + + + mavenVersioning.setVersion("100.0.1"); + assertTrue(mavenVersioning.isMoreRecentThan("0.0.0")); + assertTrue(mavenVersioning.isMoreRecentThan("0.5.2")); + assertTrue(mavenVersioning.isMoreRecentThan("1.0.0")); + + assertFalse(mavenVersioning.isMoreRecentThan("101.1.1")); + assertFalse(mavenVersioning.isMoreRecentThan("100.0.1")); + assertFalse(mavenVersioning.isMoreRecentThan("100.0.2")); + assertFalse(mavenVersioning.isMoreRecentThan("100.1.1")); + + assertFalse(mavenVersioning.isMoreRecentThan("100.0.1.4")); + } + + @Test + public final void testOneDigitVersion() { + MavenLikeVersioning oneDigit = new MavenLikeVersioning(); + oneDigit.setVersion("1"); + assertFalse(oneDigit.isMoreRecentThan("2")); + assertFalse(oneDigit.isMoreRecentThan("2.0")); + assertFalse(oneDigit.isMoreRecentThan("1.0")); + + oneDigit.setVersion("1.0"); + assertTrue(oneDigit.isMoreRecentThan("1")); + + oneDigit.setVersion("1"); + assertFalse(oneDigit.isTheSameVersion("1.1")); + assertFalse(oneDigit.isTheSameVersion("1.0")); + assertFalse(oneDigit.isTheSameVersion("1.0.0")); + + oneDigit.setVersion("2"); + assertTrue(oneDigit.isMoreRecentThan("1")); + assertTrue(oneDigit.isMoreRecentThan("1.0")); + assertTrue(oneDigit.isMoreRecentThan("1.1")); + assertTrue(oneDigit.isMoreRecentThan("0.1")); + assertFalse(oneDigit.isMoreRecentThan("2.0")); + + } + + @Test + public final void testVersionEquals() { + + MavenLikeVersioning heatTemplate = new MavenLikeVersioning(); + assertFalse(heatTemplate.isTheSameVersion("100.0")); + assertTrue(heatTemplate.isTheSameVersion(null)); + heatTemplate.setVersion("100.0.1"); + assertFalse(heatTemplate.isTheSameVersion(null)); + assertFalse(heatTemplate.isTheSameVersion("100.0")); + assertFalse(heatTemplate.isTheSameVersion("100")); + assertFalse(heatTemplate.isTheSameVersion("100.0.1.1")); + assertTrue(heatTemplate.isTheSameVersion("100.0.1")); + assertTrue(heatTemplate.isTheSameVersion("00100.000.0001")); + assertFalse(heatTemplate.isTheSameVersion("0.0.1")); + assertTrue(heatTemplate.isTheSameVersion("100.0.01")); + + } + + @Test + public final void testListSort() { + MavenLikeVersioning test1 = new MavenLikeVersioning(); + test1.setVersion("1.1"); + MavenLikeVersioning test2 = new MavenLikeVersioning(); + test2.setVersion("1.10"); + MavenLikeVersioning test3 = new MavenLikeVersioning(); + test3.setVersion("1.2"); + MavenLikeVersioning test4 = new MavenLikeVersioning(); + test4.setVersion("1.20"); + MavenLikeVersioning test5 = new MavenLikeVersioning(); + test5.setVersion("1.02"); + MavenLikeVersioning test6 = new MavenLikeVersioning(); + test6.setVersion("2.02"); + MavenLikeVersioning test7 = new MavenLikeVersioning(); + test7.setVersion("0.02"); + MavenLikeVersioning test8 = new MavenLikeVersioning(); + test8.setVersion("2.02"); + MavenLikeVersioning test9 = new MavenLikeVersioning(); + test9.setVersion("10.2004"); + MavenLikeVersioning test10 = new MavenLikeVersioning(); + test10.setVersion("2"); + MavenLikeVersioning test11 = new MavenLikeVersioning(); + test11.setVersion("12"); + MavenLikeVersioning test12 = new MavenLikeVersioning(); + test12.setVersion("2.0"); + + List<MavenLikeVersioning> list = new LinkedList<MavenLikeVersioning>(); + list.add(test1); + list.add(test2); + list.add(test3); + list.add(test4); + list.add(test5); + list.add(test6); + list.add(test7); + list.add(test8); + list.add(test9); + list.add(test10); + list.add(test11); + list.add(test12); + + Collections.sort(list, new MavenLikeVersioningComparator()); + // Collections.reverse(list); + assertTrue(list.get(0).getVersion().equals("0.02")); + assertTrue(list.get(1).getVersion().equals("1.1")); + assertTrue(list.get(2).getVersion().equals("1.02") || list.get(3).getVersion().equals("1.02")); + assertTrue(list.get(3).getVersion().equals("1.2") || list.get(2).getVersion().equals("1.2")); + assertTrue(list.get(4).getVersion().equals("1.10")); + assertTrue(list.get(5).getVersion().equals("1.20")); + assertTrue(list.get(6).getVersion().equals("2")); + assertTrue(list.get(7).getVersion().equals("2.0")); + assertTrue(list.get(8).getVersion().equals("2.02")); + assertTrue(list.get(9).getVersion().equals("2.02")); + assertTrue(list.get(10).getVersion().equals("10.2004")); + assertTrue(list.get(11).getVersion().equals("12")); + + } } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/NetworkTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/NetworkTest.java index 456c826d19..7d79a4c464 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/NetworkTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/NetworkTest.java @@ -21,7 +21,6 @@ package org.onap.so.db.catalog; import static org.junit.Assert.assertEquals; - import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.db.catalog.beans.NetworkResource; @@ -35,12 +34,12 @@ import org.springframework.test.context.junit4.SpringRunner; @SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public class NetworkTest { - @Autowired - private NetworkResourceRepository networkRepo; - - @Test - public void BuildingBlockDetailSingleLookupValidationTest() { - NetworkResource latestNetwork = networkRepo.findFirstByModelNameOrderByModelVersionDesc("CONTRAIL30_GNDIRECT"); - assertEquals("10b36f65-f4e6-4be6-ae49-9596dc1c47fz",latestNetwork.getModelUUID()); - } + @Autowired + private NetworkResourceRepository networkRepo; + + @Test + public void BuildingBlockDetailSingleLookupValidationTest() { + NetworkResource latestNetwork = networkRepo.findFirstByModelNameOrderByModelVersionDesc("CONTRAIL30_GNDIRECT"); + assertEquals("10b36f65-f4e6-4be6-ae49-9596dc1c47fz", latestNetwork.getModelUUID()); + } } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/OrchestrationStatusStateTransitionDirectiveTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/OrchestrationStatusStateTransitionDirectiveTest.java index b6aa408185..3d470df593 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/OrchestrationStatusStateTransitionDirectiveTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/OrchestrationStatusStateTransitionDirectiveTest.java @@ -21,7 +21,6 @@ package org.onap.so.db.catalog; import static org.junit.Assert.assertEquals; - import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.db.catalog.beans.OrchestrationAction; @@ -39,15 +38,20 @@ import org.springframework.test.context.junit4.SpringRunner; @SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public class OrchestrationStatusStateTransitionDirectiveTest { - @Autowired - private OrchestrationStatusStateTransitionDirectiveRepository orchestrationStatusStateTransitionDirectiveRepository; + @Autowired + private OrchestrationStatusStateTransitionDirectiveRepository orchestrationStatusStateTransitionDirectiveRepository; - @Test - public void OrchestrationStatusTransitionDBSingleLookupValidationTest() { - OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = orchestrationStatusStateTransitionDirectiveRepository.findOneByResourceTypeAndOrchestrationStatusAndTargetAction(ResourceType.SERVICE, OrchestrationStatus.ASSIGNED, OrchestrationAction.ASSIGN); - assertEquals(ResourceType.SERVICE, orchestrationStatusStateTransitionDirective.getResourceType()); - assertEquals(OrchestrationStatus.ASSIGNED, orchestrationStatusStateTransitionDirective.getOrchestrationStatus()); - assertEquals(OrchestrationAction.ASSIGN, orchestrationStatusStateTransitionDirective.getTargetAction()); - assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, orchestrationStatusStateTransitionDirective.getFlowDirective()); - } + @Test + public void OrchestrationStatusTransitionDBSingleLookupValidationTest() { + OrchestrationStatusStateTransitionDirective orchestrationStatusStateTransitionDirective = + orchestrationStatusStateTransitionDirectiveRepository + .findOneByResourceTypeAndOrchestrationStatusAndTargetAction(ResourceType.SERVICE, + OrchestrationStatus.ASSIGNED, OrchestrationAction.ASSIGN); + assertEquals(ResourceType.SERVICE, orchestrationStatusStateTransitionDirective.getResourceType()); + assertEquals(OrchestrationStatus.ASSIGNED, + orchestrationStatusStateTransitionDirective.getOrchestrationStatus()); + assertEquals(OrchestrationAction.ASSIGN, orchestrationStatusStateTransitionDirective.getTargetAction()); + assertEquals(OrchestrationStatusValidationDirective.SILENT_SUCCESS, + orchestrationStatusStateTransitionDirective.getFlowDirective()); + } } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ServiceTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ServiceTest.java index 7028d9161c..96f7037fc3 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ServiceTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ServiceTest.java @@ -22,9 +22,7 @@ package org.onap.so.db.catalog; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; - import java.util.List; - import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.db.catalog.beans.PnfResource; @@ -46,23 +44,23 @@ public class ServiceTest { @Test public void Find_LatestService_Test() { - Service latestVersionService = serviceRepo - .findFirstByModelNameOrderByModelVersionDesc("MSOTADevInfra_vSAMP10a_Service"); + Service latestVersionService = + serviceRepo.findFirstByModelNameOrderByModelVersionDesc("MSOTADevInfra_vSAMP10a_Service"); assertEquals("5df8b6de-2083-11e7-93ae-92361f002675", latestVersionService.getModelUUID()); } @Test public void Find_LatestService_Test_2() { - Service latestVersionService = serviceRepo - .findByModelNameOrderByModelVersionDesc("MSOTADevInfra_vSAMP10a_Service"); + Service latestVersionService = + serviceRepo.findByModelNameOrderByModelVersionDesc("MSOTADevInfra_vSAMP10a_Service"); assertEquals("5df8b6de-2083-11e7-93ae-92361f002675", latestVersionService.getModelUUID()); } @Test public void Find_LatestService_Test_Invariant_UUID() { - List<Service> latestVersionService = serviceRepo - .findByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671"); + List<Service> latestVersionService = + serviceRepo.findByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671"); assertEquals("5df8b6de-2083-11e7-93ae-92361f002675", latestVersionService.get(0).getModelUUID()); assertEquals("5df8b6de-2083-11e7-93ae-92361f002674", latestVersionService.get(1).getModelUUID()); assertEquals("5df8b6de-2083-11e7-93ae-92361f002673", latestVersionService.get(2).getModelUUID()); @@ -72,15 +70,15 @@ public class ServiceTest { @Test public void Find_LatestService_Test_4() { - Service latestVersionService = serviceRepo - .findOneByModelUUIDOrderByModelVersionDesc("5df8b6de-2083-11e7-93ae-92361f002671"); + Service latestVersionService = + serviceRepo.findOneByModelUUIDOrderByModelVersionDesc("5df8b6de-2083-11e7-93ae-92361f002671"); assertEquals("5df8b6de-2083-11e7-93ae-92361f002671", latestVersionService.getModelUUID()); } @Test public void Find_LatestService_Test_5() { Service latestVersionService = serviceRepo - .findFirstByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671"); + .findFirstByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671"); assertEquals("5df8b6de-2083-11e7-93ae-92361f002675", latestVersionService.getModelUUID()); } @@ -93,8 +91,8 @@ public class ServiceTest { @Test public void findByModelInvariantUUIDOrderByModelVersionDesc_ValidInvariantUuid_ExpectedOutput() { - List<Service> services = serviceRepo - .findByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002676"); + List<Service> services = + serviceRepo.findByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002676"); assertEquals("One PNF service found", 1, services.size()); assertEquals("5df8b6de-2083-11e7-93ae-92361f002676", services.get(0).getModelUUID()); } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/TempNetworkHeatTemplateLookupTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/TempNetworkHeatTemplateLookupTest.java index b09ec7193d..e0de3cf375 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/TempNetworkHeatTemplateLookupTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/TempNetworkHeatTemplateLookupTest.java @@ -21,7 +21,6 @@ package org.onap.so.db.catalog; import static org.junit.Assert.assertTrue; - import org.junit.Test; import org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup; @@ -30,21 +29,21 @@ import org.onap.so.db.catalog.beans.TempNetworkHeatTemplateLookup; public class TempNetworkHeatTemplateLookupTest { - @Test - public final void tempNetworkHeatTemplateLookupDataTest() { - TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup = new TempNetworkHeatTemplateLookup(); - tempNetworkHeatTemplateLookup.setAicVersionMax("aicVersionMax"); - assertTrue(tempNetworkHeatTemplateLookup.getAicVersionMax().equalsIgnoreCase("aicVersionMax")); - tempNetworkHeatTemplateLookup.setAicVersionMin("aicVersionMin"); - assertTrue(tempNetworkHeatTemplateLookup.getAicVersionMin().equalsIgnoreCase("aicVersionMin")); - tempNetworkHeatTemplateLookup.setHeatTemplateArtifactUuid("heatTemplateArtifactUuid"); - assertTrue(tempNetworkHeatTemplateLookup.getHeatTemplateArtifactUuid() - .equalsIgnoreCase("heatTemplateArtifactUuid")); - tempNetworkHeatTemplateLookup.setNetworkResourceModelName("networkResourceModelName"); - assertTrue(tempNetworkHeatTemplateLookup.getNetworkResourceModelName() - .equalsIgnoreCase("networkResourceModelName")); -// assertTrue(tempNetworkHeatTemplateLookup.toString() != null); - - } + @Test + public final void tempNetworkHeatTemplateLookupDataTest() { + TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup = new TempNetworkHeatTemplateLookup(); + tempNetworkHeatTemplateLookup.setAicVersionMax("aicVersionMax"); + assertTrue(tempNetworkHeatTemplateLookup.getAicVersionMax().equalsIgnoreCase("aicVersionMax")); + tempNetworkHeatTemplateLookup.setAicVersionMin("aicVersionMin"); + assertTrue(tempNetworkHeatTemplateLookup.getAicVersionMin().equalsIgnoreCase("aicVersionMin")); + tempNetworkHeatTemplateLookup.setHeatTemplateArtifactUuid("heatTemplateArtifactUuid"); + assertTrue(tempNetworkHeatTemplateLookup.getHeatTemplateArtifactUuid() + .equalsIgnoreCase("heatTemplateArtifactUuid")); + tempNetworkHeatTemplateLookup.setNetworkResourceModelName("networkResourceModelName"); + assertTrue(tempNetworkHeatTemplateLookup.getNetworkResourceModelName() + .equalsIgnoreCase("networkResourceModelName")); + // assertTrue(tempNetworkHeatTemplateLookup.toString() != null); + + } } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/TestApplication.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/TestApplication.java index 64b393628c..2d786fe2a7 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/TestApplication.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/TestApplication.java @@ -26,23 +26,23 @@ import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.context.annotation.Profile; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -@SpringBootApplication(scanBasePackages = { "org.onap.so.db.catalog","org.onap.so.client", "org.onap.so.configuration"}) +@SpringBootApplication(scanBasePackages = {"org.onap.so.db.catalog", "org.onap.so.client", "org.onap.so.configuration"}) @EnableJpaRepositories("org.onap.so.db.catalog.data.repository") @EntityScan("org.onap.so.db.catalog") @Profile("test") public class TestApplication { - private static final String LOGS_DIR = "logs_dir"; - - private static void setLogsDir() { - if (System.getProperty(LOGS_DIR) == null) { - System.getProperties().setProperty(LOGS_DIR, "./logs/catdb/"); - } - } - - public static void main(String... args) { - SpringApplication.run(TestApplication.class, args); - System.getProperties().setProperty("mso.db", "MARIADB"); - System.getProperties().setProperty("server.name", "Springboot"); + private static final String LOGS_DIR = "logs_dir"; + + private static void setLogsDir() { + if (System.getProperty(LOGS_DIR) == null) { + System.getProperties().setProperty(LOGS_DIR, "./logs/catdb/"); + } + } + + public static void main(String... args) { + SpringApplication.run(TestApplication.class, args); + System.getProperties().setProperty("mso.db", "MARIADB"); + System.getProperties().setProperty("server.name", "Springboot"); setLogsDir(); - } + } } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/VFModuleTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/VFModuleTest.java index 1f13bd946a..5887842b74 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/VFModuleTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/VFModuleTest.java @@ -21,9 +21,7 @@ package org.onap.so.db.catalog; import static org.junit.Assert.assertEquals; - import java.util.List; - import org.junit.Test; import org.junit.runner.RunWith; import org.onap.so.db.catalog.beans.VfModule; @@ -37,20 +35,21 @@ import org.springframework.test.context.junit4.SpringRunner; @SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public class VFModuleTest { - @Autowired - private VFModuleRepository vfModuleRepo; - - @Test - public void VFModule_Versioned_LookUp() { - VfModule latestModule = vfModuleRepo.findFirstByModelNameOrderByModelVersionDesc("vSAMP10aDEV::PCM::module-1"); - assertEquals("066de97e-253e-11e7-93ae-92361f002675",latestModule.getModelUUID()); - } - - @Test - public void VFModule_Versioned_LookUp_LIst() { - List<VfModule> moduleList = vfModuleRepo.findByModelInvariantUUIDOrderByModelVersionDesc("64efd51a-2544-11e7-93ae-92361f002671"); - assertEquals("066de97e-253e-11e7-93ae-92361f002675",moduleList.get(0).getModelUUID()); - assertEquals("066de97e-253e-11e7-93ae-92361f002674",moduleList.get(1).getModelUUID()); - assertEquals("066de97e-253e-11e7-93ae-92361f002673",moduleList.get(2).getModelUUID()); - } + @Autowired + private VFModuleRepository vfModuleRepo; + + @Test + public void VFModule_Versioned_LookUp() { + VfModule latestModule = vfModuleRepo.findFirstByModelNameOrderByModelVersionDesc("vSAMP10aDEV::PCM::module-1"); + assertEquals("066de97e-253e-11e7-93ae-92361f002675", latestModule.getModelUUID()); + } + + @Test + public void VFModule_Versioned_LookUp_LIst() { + List<VfModule> moduleList = + vfModuleRepo.findByModelInvariantUUIDOrderByModelVersionDesc("64efd51a-2544-11e7-93ae-92361f002671"); + assertEquals("066de97e-253e-11e7-93ae-92361f002675", moduleList.get(0).getModelUUID()); + assertEquals("066de97e-253e-11e7-93ae-92361f002674", moduleList.get(1).getModelUUID()); + assertEquals("066de97e-253e-11e7-93ae-92361f002673", moduleList.get(2).getModelUUID()); + } } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/BeansTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/BeansTest.java index 2188380bbd..f710890883 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/BeansTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/BeansTest.java @@ -24,11 +24,9 @@ import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.equalTo; import static org.onap.so.openpojo.rules.HasAnnotationMatcher.hasAnnotation; import static org.onap.so.openpojo.rules.HasAnnotationPropertyWithValueMatcher.hasAnnotationPropertyWithValue; - import javax.persistence.Column; import javax.persistence.GeneratedValue; import javax.persistence.Temporal; - import org.junit.Ignore; import org.junit.Test; import org.onap.so.openpojo.rules.CustomSetterMustExistRule; @@ -36,7 +34,6 @@ import org.onap.so.openpojo.rules.EqualsAndHashCodeTester; import org.onap.so.openpojo.rules.HasEqualsAndHashCodeRule; import org.onap.so.openpojo.rules.HasToStringRule; import org.onap.so.openpojo.rules.ToStringTester; - import com.openpojo.reflection.PojoClass; import com.openpojo.reflection.PojoClassFilter; import com.openpojo.reflection.filters.FilterEnum; @@ -57,45 +54,40 @@ import com.openpojo.validation.test.impl.SetterTester; public class BeansTest { - private PojoClassFilter filterTestClasses = new FilterTestClasses(); - - private PojoClassFilter enumFilter = new FilterEnum(); - - + private PojoClassFilter filterTestClasses = new FilterTestClasses(); + + private PojoClassFilter enumFilter = new FilterEnum(); + + + + @Test + public void pojoStructure() { + test("org.onap.so.db.catalog.beans"); + test("org.onap.so.db.catalog.beans.macro"); + } + + private void test(String pojoPackage) { + Validator validator = ValidatorBuilder.create().with(new GetterMustExistRule()).with(new NoPrimitivesRule()) + .with(new NoNestedClassRule()).with(new NoStaticExceptFinalRule()) + .with(new SerializableMustHaveSerialVersionUIDRule()).with(new HasToStringRule()) + .with(new EqualsAndHashCodeTester()).with(new NoPublicFieldsExceptStaticFinalRule()) + .with(new CustomSetterMustExistRule() + .exclude(allOf(hasAnnotationPropertyWithValue(Column.class, "updatable", equalTo(false)), + hasAnnotation(GeneratedValue.class)), hasAnnotation(Temporal.class))) + + .with(new SetterTester()).with(new GetterTester()).with(new ToStringTester()) + .with(new HasEqualsAndHashCodeRule()) + + .build(); + - @Test - public void pojoStructure() { - test("org.onap.so.db.catalog.beans"); - test("org.onap.so.db.catalog.beans.macro"); - } + validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses, enumFilter, + new FilterNonConcrete()); + } - private void test(String pojoPackage) { - Validator validator = ValidatorBuilder.create() - .with(new GetterMustExistRule()) - .with(new NoPrimitivesRule()) - .with(new NoNestedClassRule()) - .with(new NoStaticExceptFinalRule()) - .with(new SerializableMustHaveSerialVersionUIDRule()) - .with(new HasToStringRule()) - .with(new EqualsAndHashCodeTester()) - .with(new NoPublicFieldsExceptStaticFinalRule()) - .with(new CustomSetterMustExistRule().exclude( - allOf(hasAnnotationPropertyWithValue(Column.class, "updatable", equalTo(false)), hasAnnotation(GeneratedValue.class)), - hasAnnotation(Temporal.class))) - - .with(new SetterTester()) - .with(new GetterTester()) - .with(new ToStringTester()) - .with(new HasEqualsAndHashCodeRule()) - - .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/"); - } - } + private static class FilterTestClasses implements PojoClassFilter { + public boolean include(PojoClass pojoClass) { + return !pojoClass.getSourcePath().contains("/test-classes/"); + } + } } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CloudIdentityTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CloudIdentityTest.java index f8f3435fe1..f4e52235d5 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CloudIdentityTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CloudIdentityTest.java @@ -23,9 +23,7 @@ package org.onap.so.db.catalog.beans; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; - import java.security.GeneralSecurityException; - import org.junit.Test; import org.onap.so.db.catalog.beans.AuthenticationType; import org.onap.so.db.catalog.beans.CloudIdentity; @@ -33,71 +31,71 @@ import org.onap.so.db.catalog.beans.ServerType; import org.onap.so.utils.CryptoUtils; public class CloudIdentityTest { - - private CloudIdentity cloudIdentity = new CloudIdentity(); - private static final String ID = "testId"; - private static final String IDENTITY_URL = "testIdentityUrl"; - private static final String MSO_ID = "testMsoId"; - private static final String MSO_PASS = "testMsoPassword"; - private static final String ADMIN_TENANT = "testAdminTenant"; - private static final String MEMBER_ROLE = "testMemberRole"; - private static final Boolean TENANT_METADATA = true; - + + private CloudIdentity cloudIdentity = new CloudIdentity(); + private static final String ID = "testId"; + private static final String IDENTITY_URL = "testIdentityUrl"; + private static final String MSO_ID = "testMsoId"; + private static final String MSO_PASS = "testMsoPassword"; + private static final String ADMIN_TENANT = "testAdminTenant"; + private static final String MEMBER_ROLE = "testMemberRole"; + private static final Boolean TENANT_METADATA = true; + @Test - public final void testCloudIdentity () { - CloudIdentity id = new CloudIdentity (); - id.setAdminTenant ("AdminTenant"); - id.setId ("id"); -// id.setKeystoneUrl ("keystone"); - id.setIdentityUrl ("keystone"); - id.setMemberRole ("member"); - id.setMsoId ("msoId"); - id.setMsoPass (CryptoUtils.encryptCloudConfigPassword("password")); - id.setTenantMetadata (true); + public final void testCloudIdentity() { + CloudIdentity id = new CloudIdentity(); + id.setAdminTenant("AdminTenant"); + id.setId("id"); + // id.setKeystoneUrl ("keystone"); + id.setIdentityUrl("keystone"); + id.setMemberRole("member"); + id.setMsoId("msoId"); + id.setMsoPass(CryptoUtils.encryptCloudConfigPassword("password")); + id.setTenantMetadata(true); id.setIdentityServerType(null); id.setIdentityAuthenticationType(null); - - assertTrue (id.getAdminTenant ().equals ("AdminTenant")); - assertTrue (id.getId ().equals ("id")); -// assertTrue (id.getKeystoneUrl ().equals ("keystone")); - assertTrue (id.getMemberRole ().equals ("member")); - assertTrue (id.getMsoId ().equals ("msoId")); - assertTrue (CryptoUtils.decryptCloudConfigPassword(id.getMsoPass()).equals ("password")); - assertTrue (id.getTenantMetadata ()); -// assertTrue (id.toString ().contains ("keystone")); + + assertTrue(id.getAdminTenant().equals("AdminTenant")); + assertTrue(id.getId().equals("id")); + // assertTrue (id.getKeystoneUrl ().equals ("keystone")); + assertTrue(id.getMemberRole().equals("member")); + assertTrue(id.getMsoId().equals("msoId")); + assertTrue(CryptoUtils.decryptCloudConfigPassword(id.getMsoPass()).equals("password")); + assertTrue(id.getTenantMetadata()); + // assertTrue (id.toString ().contains ("keystone")); assertTrue(id.toString().contains("null")); } @Test - public final void testEncryption () throws GeneralSecurityException { + public final void testEncryption() throws GeneralSecurityException { String encrypted = CryptoUtils.encryptCloudConfigPassword("password"); - assertTrue (encrypted != null); - assertTrue (!encrypted.equals ("password")); + assertTrue(encrypted != null); + assertTrue(!encrypted.equals("password")); } - + @Test public void cloneTest() { - cloudIdentity = setupCloudIdentity(cloudIdentity, ID, IDENTITY_URL, MSO_ID, MSO_PASS, ADMIN_TENANT, - MEMBER_ROLE, TENANT_METADATA, ServerType.ORM, AuthenticationType.USERNAME_PASSWORD); - CloudIdentity cloudIdentity2 = cloudIdentity.clone(); - - assertEquals(cloudIdentity.getClass(), cloudIdentity2.getClass()); + cloudIdentity = setupCloudIdentity(cloudIdentity, ID, IDENTITY_URL, MSO_ID, MSO_PASS, ADMIN_TENANT, MEMBER_ROLE, + TENANT_METADATA, ServerType.ORM, AuthenticationType.USERNAME_PASSWORD); + CloudIdentity cloudIdentity2 = cloudIdentity.clone(); + + assertEquals(cloudIdentity.getClass(), cloudIdentity2.getClass()); + } + + private CloudIdentity setupCloudIdentity(CloudIdentity obj, String id, String identityUrl, String msoId, + String msoPass, String adminTenant, String memberRole, Boolean tenantMetadata, + ServerType identityServerType, AuthenticationType identityAuthenticationType) { + obj.setId(id); + obj.setIdentityUrl(identityUrl); + obj.setMsoId(msoId); + obj.setMsoPass(msoPass); + obj.setAdminTenant(adminTenant); + obj.setMemberRole(memberRole); + obj.setTenantMetadata(tenantMetadata); + obj.setIdentityServerType(identityServerType); + obj.setIdentityAuthenticationType(identityAuthenticationType); + + return obj; } - - private CloudIdentity setupCloudIdentity(CloudIdentity obj, String id, String identityUrl, - String msoId, String msoPass, String adminTenant, String memberRole, Boolean tenantMetadata, - ServerType identityServerType, AuthenticationType identityAuthenticationType) { - obj.setId(id); - obj.setIdentityUrl(identityUrl); - obj.setMsoId(msoId); - obj.setMsoPass(msoPass); - obj.setAdminTenant(adminTenant); - obj.setMemberRole(memberRole); - obj.setTenantMetadata(tenantMetadata); - obj.setIdentityServerType(identityServerType); - obj.setIdentityAuthenticationType(identityAuthenticationType); - - return obj; - } } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CloudifyManagerTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CloudifyManagerTest.java index 2405a413cf..da8abe061b 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CloudifyManagerTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CloudifyManagerTest.java @@ -25,23 +25,23 @@ import org.junit.Test; import org.onap.so.db.catalog.beans.CloudifyManager; public class CloudifyManagerTest { - - private CloudifyManager cloudifyManager = new CloudifyManager(); - private static final String ID = "testId"; - private static final String CLOUDIFY_URL = "testCloudifyUrl"; - private static final String USERNAME = "testUsername"; - private static final String PASSWORD = "testPassword"; - private static final String VERSION = "testVersion"; - - @Test - public void cloneTest() { - cloudifyManager.setId(ID); - cloudifyManager.setCloudifyUrl(CLOUDIFY_URL); - cloudifyManager.setUsername(USERNAME); - cloudifyManager.setPassword(PASSWORD); - cloudifyManager.setVersion(VERSION); - - CloudifyManager clone = cloudifyManager.clone(); - assertEquals(cloudifyManager, clone); - } + + private CloudifyManager cloudifyManager = new CloudifyManager(); + private static final String ID = "testId"; + private static final String CLOUDIFY_URL = "testCloudifyUrl"; + private static final String USERNAME = "testUsername"; + private static final String PASSWORD = "testPassword"; + private static final String VERSION = "testVersion"; + + @Test + public void cloneTest() { + cloudifyManager.setId(ID); + cloudifyManager.setCloudifyUrl(CLOUDIFY_URL); + cloudifyManager.setUsername(USERNAME); + cloudifyManager.setPassword(PASSWORD); + cloudifyManager.setVersion(VERSION); + + CloudifyManager clone = cloudifyManager.clone(); + assertEquals(cloudifyManager, clone); + } } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcConfigurationCustomizationTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcConfigurationCustomizationTest.java index e5a17228b7..8828c8d363 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcConfigurationCustomizationTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcConfigurationCustomizationTest.java @@ -21,49 +21,52 @@ package org.onap.so.db.catalog.beans; import static org.junit.Assert.assertTrue; - import org.junit.Test; public class CvnfcConfigurationCustomizationTest { - - private static final String CONFIGURATION_FUNCTION = "testconfigurationFunction"; - private static final String CONFIGURATION_ROLE = "testconfigurationRole"; - private static final String CONFIGURATION_TYPE = "testconfigurationType"; - private static final Integer ID = new Integer(1); - private static final String MODEL_CUSTOMIZATION_UUID = "testModelCustomizationUUID"; - private static final String MODEL_INSTANCE_NAME = "testModelInstanceName"; - private static final String MODEL_UUID = "testModelUUID"; - private static final String POLICY_NAME = "testPolicyName"; - + + private static final String CONFIGURATION_FUNCTION = "testconfigurationFunction"; + private static final String CONFIGURATION_ROLE = "testconfigurationRole"; + private static final String CONFIGURATION_TYPE = "testconfigurationType"; + private static final Integer ID = new Integer(1); + private static final String MODEL_CUSTOMIZATION_UUID = "testModelCustomizationUUID"; + private static final String MODEL_INSTANCE_NAME = "testModelInstanceName"; + private static final String MODEL_UUID = "testModelUUID"; + private static final String POLICY_NAME = "testPolicyName"; + @Test - public final void testVnfVfmoduleCvnfcConfigurationCustomization () { - CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new CvnfcConfigurationCustomization(); - vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationFunction(CONFIGURATION_FUNCTION); - vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(setupConfigurationResource()); - vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationRole(CONFIGURATION_ROLE); - vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationType(CONFIGURATION_TYPE); - CvnfcCustomization cvnfcCustomization = new CvnfcCustomization(); - cvnfcCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); - vnfVfmoduleCvnfcConfigurationCustomization.setCvnfcCustomization(cvnfcCustomization); - vnfVfmoduleCvnfcConfigurationCustomization.setId(ID); - vnfVfmoduleCvnfcConfigurationCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); - vnfVfmoduleCvnfcConfigurationCustomization.setModelInstanceName(MODEL_INSTANCE_NAME); - vnfVfmoduleCvnfcConfigurationCustomization.setPolicyName(POLICY_NAME); + public final void testVnfVfmoduleCvnfcConfigurationCustomization() { + CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = + new CvnfcConfigurationCustomization(); + vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationFunction(CONFIGURATION_FUNCTION); + vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(setupConfigurationResource()); + vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationRole(CONFIGURATION_ROLE); + vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationType(CONFIGURATION_TYPE); + CvnfcCustomization cvnfcCustomization = new CvnfcCustomization(); + cvnfcCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + vnfVfmoduleCvnfcConfigurationCustomization.setCvnfcCustomization(cvnfcCustomization); + vnfVfmoduleCvnfcConfigurationCustomization.setId(ID); + vnfVfmoduleCvnfcConfigurationCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + vnfVfmoduleCvnfcConfigurationCustomization.setModelInstanceName(MODEL_INSTANCE_NAME); + vnfVfmoduleCvnfcConfigurationCustomization.setPolicyName(POLICY_NAME); - assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getId().equals (new Integer(1))); - assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationFunction().equals (CONFIGURATION_FUNCTION)); - assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationRole().equals (CONFIGURATION_ROLE)); - assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationType().equals (CONFIGURATION_TYPE)); - assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getModelCustomizationUUID().equals (MODEL_CUSTOMIZATION_UUID)); - assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getModelInstanceName().equals (MODEL_INSTANCE_NAME)); - assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getPolicyName().equals (POLICY_NAME)); - assertTrue (vnfVfmoduleCvnfcConfigurationCustomization.getCvnfcCustomization().getModelCustomizationUUID().equals (MODEL_CUSTOMIZATION_UUID)); + assertTrue(vnfVfmoduleCvnfcConfigurationCustomization.getId().equals(new Integer(1))); + assertTrue( + vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationFunction().equals(CONFIGURATION_FUNCTION)); + assertTrue(vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationRole().equals(CONFIGURATION_ROLE)); + assertTrue(vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationType().equals(CONFIGURATION_TYPE)); + assertTrue(vnfVfmoduleCvnfcConfigurationCustomization.getModelCustomizationUUID() + .equals(MODEL_CUSTOMIZATION_UUID)); + assertTrue(vnfVfmoduleCvnfcConfigurationCustomization.getModelInstanceName().equals(MODEL_INSTANCE_NAME)); + assertTrue(vnfVfmoduleCvnfcConfigurationCustomization.getPolicyName().equals(POLICY_NAME)); + assertTrue(vnfVfmoduleCvnfcConfigurationCustomization.getCvnfcCustomization().getModelCustomizationUUID() + .equals(MODEL_CUSTOMIZATION_UUID)); } - - private ConfigurationResource setupConfigurationResource(){ - ConfigurationResource configurationResource = new ConfigurationResource(); - configurationResource.setModelUUID(MODEL_UUID); - return configurationResource; + + private ConfigurationResource setupConfigurationResource() { + ConfigurationResource configurationResource = new ConfigurationResource(); + configurationResource.setModelUUID(MODEL_UUID); + return configurationResource; } -}
\ No newline at end of file +} diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcCustomizationTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcCustomizationTest.java index 4ab05f363a..80e3d53c57 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcCustomizationTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/CvnfcCustomizationTest.java @@ -21,69 +21,68 @@ package org.onap.so.db.catalog.beans; import static org.junit.Assert.assertTrue; - import java.util.HashSet; import java.util.Set; - import org.junit.Test; public class CvnfcCustomizationTest { - - private static final Integer ID = new Integer(1); - private static final String DESCRIPTION = "testDescription"; - private static final String MODEL_CUSTOMIZATION_UUID = "testModelCustomizationUUID"; - private static final String MODEL_INSTANCE_NAME = "testModelInstanceName"; - private static final String MODEL_INVARIANT_UUID = "testModelInvariantUUID"; - private static final String MODEL_NAME = "testModelName"; - private static final String MODEL_UUID = "testModelUUID"; - private static final String MODEL_VERSION = "testModelVersion"; - private static final String TOSCA_NODE_TYPE = "testToscaNodeType"; - private static final String NFC_FUNCTION = "testNfcFunction"; - private static final String NFC_NAMING_CODE = "testNfcNamingCode"; - + + private static final Integer ID = new Integer(1); + private static final String DESCRIPTION = "testDescription"; + private static final String MODEL_CUSTOMIZATION_UUID = "testModelCustomizationUUID"; + private static final String MODEL_INSTANCE_NAME = "testModelInstanceName"; + private static final String MODEL_INVARIANT_UUID = "testModelInvariantUUID"; + private static final String MODEL_NAME = "testModelName"; + private static final String MODEL_UUID = "testModelUUID"; + private static final String MODEL_VERSION = "testModelVersion"; + private static final String TOSCA_NODE_TYPE = "testToscaNodeType"; + private static final String NFC_FUNCTION = "testNfcFunction"; + private static final String NFC_NAMING_CODE = "testNfcNamingCode"; + @Test - public final void testCvnfcCustomization () { - CvnfcCustomization cvnfcCustomization = new CvnfcCustomization(); - cvnfcCustomization.setDescription(DESCRIPTION); - cvnfcCustomization.setId(ID); - cvnfcCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); - cvnfcCustomization.setModelInstanceName(MODEL_INSTANCE_NAME); - cvnfcCustomization.setModelInvariantUUID(MODEL_INVARIANT_UUID); - cvnfcCustomization.setModelName(MODEL_NAME); - cvnfcCustomization.setModelUUID(MODEL_UUID); - cvnfcCustomization.setModelVersion(MODEL_VERSION); - cvnfcCustomization.setNfcFunction(NFC_FUNCTION); - cvnfcCustomization.setNfcNamingCode(NFC_NAMING_CODE); - cvnfcCustomization.setToscaNodeType(TOSCA_NODE_TYPE); - cvnfcCustomization.setVfModuleCustomization(setupVfModuleCustomization()); - Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizationSet = new HashSet(); - cvnfcConfigurationCustomizationSet.add(setupCvnfcConfigurationCustomization()); - cvnfcCustomization.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizationSet); + public final void testCvnfcCustomization() { + CvnfcCustomization cvnfcCustomization = new CvnfcCustomization(); + cvnfcCustomization.setDescription(DESCRIPTION); + cvnfcCustomization.setId(ID); + cvnfcCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + cvnfcCustomization.setModelInstanceName(MODEL_INSTANCE_NAME); + cvnfcCustomization.setModelInvariantUUID(MODEL_INVARIANT_UUID); + cvnfcCustomization.setModelName(MODEL_NAME); + cvnfcCustomization.setModelUUID(MODEL_UUID); + cvnfcCustomization.setModelVersion(MODEL_VERSION); + cvnfcCustomization.setNfcFunction(NFC_FUNCTION); + cvnfcCustomization.setNfcNamingCode(NFC_NAMING_CODE); + cvnfcCustomization.setToscaNodeType(TOSCA_NODE_TYPE); + cvnfcCustomization.setVfModuleCustomization(setupVfModuleCustomization()); + Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizationSet = new HashSet(); + cvnfcConfigurationCustomizationSet.add(setupCvnfcConfigurationCustomization()); + cvnfcCustomization.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizationSet); - assertTrue (cvnfcCustomization.getId().equals (new Integer(1))); - assertTrue (cvnfcCustomization.getDescription().equals (DESCRIPTION)); - assertTrue (cvnfcCustomization.getModelCustomizationUUID().equals (MODEL_CUSTOMIZATION_UUID)); - assertTrue (cvnfcCustomization.getModelInstanceName().equals (MODEL_INSTANCE_NAME)); - assertTrue (cvnfcCustomization.getModelInvariantUUID().equals (MODEL_INVARIANT_UUID)); - assertTrue (cvnfcCustomization.getModelName().equals (MODEL_NAME)); - assertTrue (cvnfcCustomization.getModelUUID().equals (MODEL_UUID)); - assertTrue (cvnfcCustomization.getModelVersion().equals (MODEL_VERSION)); - assertTrue (cvnfcCustomization.getNfcFunction().equals (NFC_FUNCTION)); - assertTrue (cvnfcCustomization.getNfcNamingCode().equals (NFC_NAMING_CODE)); - assertTrue (cvnfcCustomization.getToscaNodeType().equals (TOSCA_NODE_TYPE)); - assertTrue (cvnfcCustomization.getVfModuleCustomization().getModelCustomizationUUID().equals (MODEL_CUSTOMIZATION_UUID)); + assertTrue(cvnfcCustomization.getId().equals(new Integer(1))); + assertTrue(cvnfcCustomization.getDescription().equals(DESCRIPTION)); + assertTrue(cvnfcCustomization.getModelCustomizationUUID().equals(MODEL_CUSTOMIZATION_UUID)); + assertTrue(cvnfcCustomization.getModelInstanceName().equals(MODEL_INSTANCE_NAME)); + assertTrue(cvnfcCustomization.getModelInvariantUUID().equals(MODEL_INVARIANT_UUID)); + assertTrue(cvnfcCustomization.getModelName().equals(MODEL_NAME)); + assertTrue(cvnfcCustomization.getModelUUID().equals(MODEL_UUID)); + assertTrue(cvnfcCustomization.getModelVersion().equals(MODEL_VERSION)); + assertTrue(cvnfcCustomization.getNfcFunction().equals(NFC_FUNCTION)); + assertTrue(cvnfcCustomization.getNfcNamingCode().equals(NFC_NAMING_CODE)); + assertTrue(cvnfcCustomization.getToscaNodeType().equals(TOSCA_NODE_TYPE)); + assertTrue(cvnfcCustomization.getVfModuleCustomization().getModelCustomizationUUID() + .equals(MODEL_CUSTOMIZATION_UUID)); } - - private VfModuleCustomization setupVfModuleCustomization(){ - VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); - vfModuleCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); - return vfModuleCustomization; + + private VfModuleCustomization setupVfModuleCustomization() { + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + return vfModuleCustomization; } - - private CvnfcConfigurationCustomization setupCvnfcConfigurationCustomization(){ - CvnfcConfigurationCustomization cvnfcConfigurationCustomization = new CvnfcConfigurationCustomization(); - cvnfcConfigurationCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); - return cvnfcConfigurationCustomization; + + private CvnfcConfigurationCustomization setupCvnfcConfigurationCustomization() { + CvnfcConfigurationCustomization cvnfcConfigurationCustomization = new CvnfcConfigurationCustomization(); + cvnfcConfigurationCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + return cvnfcConfigurationCustomization; } -}
\ No newline at end of file +} diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/VnfcCustomizationTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/VnfcCustomizationTest.java index 2a315d83b6..e71c0ae272 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/VnfcCustomizationTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/VnfcCustomizationTest.java @@ -21,57 +21,56 @@ package org.onap.so.db.catalog.beans; import static org.junit.Assert.assertTrue; - import java.util.ArrayList; import java.util.List; - import org.junit.Test; public class VnfcCustomizationTest { - - private static final String DESCRIPTION = "testDescription"; - private static final String MODEL_CUSTOMIZATION_UUID = "testModelCustomizationUUID"; - private static final String MODEL_INSTANCE_NAME = "testModelInstanceName"; - private static final String MODEL_INVARIANT_UUID = "testModelInvariantUUID"; - private static final String MODEL_NAME = "testModelName"; - private static final String MODEL_UUID = "testModelUUID"; - private static final String MODEL_VERSION = "testModelVersion"; - private static final String TOSCA_NODE_TYPE = "testToscaNodeType"; - + + private static final String DESCRIPTION = "testDescription"; + private static final String MODEL_CUSTOMIZATION_UUID = "testModelCustomizationUUID"; + private static final String MODEL_INSTANCE_NAME = "testModelInstanceName"; + private static final String MODEL_INVARIANT_UUID = "testModelInvariantUUID"; + private static final String MODEL_NAME = "testModelName"; + private static final String MODEL_UUID = "testModelUUID"; + private static final String MODEL_VERSION = "testModelVersion"; + private static final String TOSCA_NODE_TYPE = "testToscaNodeType"; + @Test - public final void testVnfcCustomization () { - VnfcCustomization vnfcCustomization = new VnfcCustomization(); - vnfcCustomization.setCvnfcCustomization(setupCvnfcCustomizationList()); - vnfcCustomization.setDescription(DESCRIPTION); - vnfcCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); - vnfcCustomization.setModelInstanceName(MODEL_INSTANCE_NAME); - vnfcCustomization.setModelInvariantUUID(MODEL_INVARIANT_UUID); - vnfcCustomization.setModelName(MODEL_NAME); - vnfcCustomization.setModelUUID(MODEL_UUID); - vnfcCustomization.setModelVersion(MODEL_VERSION); - vnfcCustomization.setToscaNodeType(TOSCA_NODE_TYPE); - - assertTrue (vnfcCustomization.getDescription().equals (DESCRIPTION)); - assertTrue (vnfcCustomization.getModelCustomizationUUID().equals (MODEL_CUSTOMIZATION_UUID)); - assertTrue (vnfcCustomization.getModelInstanceName().equals (MODEL_INSTANCE_NAME)); - assertTrue (vnfcCustomization.getModelInvariantUUID().equals (MODEL_INVARIANT_UUID)); - assertTrue (vnfcCustomization.getModelName().equals (MODEL_NAME)); - assertTrue (vnfcCustomization.getModelUUID().equals (MODEL_UUID)); - assertTrue (vnfcCustomization.getModelVersion().equals (MODEL_VERSION)); - assertTrue (vnfcCustomization.getToscaNodeType().equals (TOSCA_NODE_TYPE)); - assertTrue (vnfcCustomization.getCvnfcCustomization().get(0).getModelCustomizationUUID().equals (MODEL_CUSTOMIZATION_UUID)); + public final void testVnfcCustomization() { + VnfcCustomization vnfcCustomization = new VnfcCustomization(); + vnfcCustomization.setCvnfcCustomization(setupCvnfcCustomizationList()); + vnfcCustomization.setDescription(DESCRIPTION); + vnfcCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + vnfcCustomization.setModelInstanceName(MODEL_INSTANCE_NAME); + vnfcCustomization.setModelInvariantUUID(MODEL_INVARIANT_UUID); + vnfcCustomization.setModelName(MODEL_NAME); + vnfcCustomization.setModelUUID(MODEL_UUID); + vnfcCustomization.setModelVersion(MODEL_VERSION); + vnfcCustomization.setToscaNodeType(TOSCA_NODE_TYPE); + + assertTrue(vnfcCustomization.getDescription().equals(DESCRIPTION)); + assertTrue(vnfcCustomization.getModelCustomizationUUID().equals(MODEL_CUSTOMIZATION_UUID)); + assertTrue(vnfcCustomization.getModelInstanceName().equals(MODEL_INSTANCE_NAME)); + assertTrue(vnfcCustomization.getModelInvariantUUID().equals(MODEL_INVARIANT_UUID)); + assertTrue(vnfcCustomization.getModelName().equals(MODEL_NAME)); + assertTrue(vnfcCustomization.getModelUUID().equals(MODEL_UUID)); + assertTrue(vnfcCustomization.getModelVersion().equals(MODEL_VERSION)); + assertTrue(vnfcCustomization.getToscaNodeType().equals(TOSCA_NODE_TYPE)); + assertTrue(vnfcCustomization.getCvnfcCustomization().get(0).getModelCustomizationUUID() + .equals(MODEL_CUSTOMIZATION_UUID)); + } + + private List<CvnfcCustomization> setupCvnfcCustomizationList() { + CvnfcCustomization testCvnfcCustomization = new CvnfcCustomization(); + testCvnfcCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); + testCvnfcCustomization.setDescription(DESCRIPTION); + testCvnfcCustomization.setModelVersion(MODEL_VERSION); + testCvnfcCustomization.setModelInstanceName(MODEL_INSTANCE_NAME); + testCvnfcCustomization.setToscaNodeType(TOSCA_NODE_TYPE); + List<CvnfcCustomization> testCvnfcCustomizationList = new ArrayList(); + testCvnfcCustomizationList.add(testCvnfcCustomization); + return testCvnfcCustomizationList; } - - private List<CvnfcCustomization> setupCvnfcCustomizationList(){ - CvnfcCustomization testCvnfcCustomization = new CvnfcCustomization(); - testCvnfcCustomization.setModelCustomizationUUID(MODEL_CUSTOMIZATION_UUID); - testCvnfcCustomization.setDescription(DESCRIPTION); - testCvnfcCustomization.setModelVersion(MODEL_VERSION); - testCvnfcCustomization.setModelInstanceName(MODEL_INSTANCE_NAME); - testCvnfcCustomization.setToscaNodeType(TOSCA_NODE_TYPE); - List<CvnfcCustomization> testCvnfcCustomizationList = new ArrayList(); - testCvnfcCustomizationList.add(testCvnfcCustomization); - return testCvnfcCustomizationList; - } - -}
\ No newline at end of file + +} diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudSiteRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudSiteRepositoryTest.java index 8978f38298..a6f1059ba0 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudSiteRepositoryTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudSiteRepositoryTest.java @@ -27,28 +27,27 @@ import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.exceptions.NoEntityFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; - import java.util.List; public class CloudSiteRepositoryTest extends BaseTest { - + @Autowired private CloudSiteRepository cloudSiteRepository; - + @Test public void findByClliAndAicVersionTest() throws Exception { - CloudSite cloudSite = cloudSiteRepository.findByClliAndCloudVersion("MDT13","2.5"); + CloudSite cloudSite = cloudSiteRepository.findByClliAndCloudVersion("MDT13", "2.5"); Assert.assertNotNull(cloudSite); - Assert.assertEquals("mtn13",cloudSite.getId()); + Assert.assertEquals("mtn13", cloudSite.getId()); } @Test public void findOneTest() throws Exception { - CloudSite cloudSite = cloudSiteRepository.findById("mtn13"). - orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation")); - + CloudSite cloudSite = cloudSiteRepository.findById("mtn13") + .orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation")); + Assert.assertNotNull(cloudSite); - Assert.assertEquals("mtn13",cloudSite.getId()); + Assert.assertEquals("mtn13", cloudSite.getId()); } @Test diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudifyManagerRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudifyManagerRepositoryTest.java index 1ed8c84435..3f4343952e 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudifyManagerRepositoryTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudifyManagerRepositoryTest.java @@ -35,7 +35,7 @@ public class CloudifyManagerRepositoryTest extends BaseTest { @Test public void findOneTest() throws Exception { CloudifyManager cloudifyManager = cloudifyManagerRepository.findById("mtn13") - .orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation")); + .orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation")); Assert.assertNotNull(cloudifyManager); Assert.assertEquals("mtn13", cloudifyManager.getId()); } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CollectionNetworkResourceCustomizationRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CollectionNetworkResourceCustomizationRepositoryTest.java index 90ec07f154..3740fd2058 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CollectionNetworkResourceCustomizationRepositoryTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CollectionNetworkResourceCustomizationRepositoryTest.java @@ -22,9 +22,7 @@ package org.onap.so.db.catalog.data.repository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; - import java.util.List; - import org.junit.Assert; import org.junit.Test; import org.onap.so.db.catalog.BaseTest; @@ -33,17 +31,18 @@ import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; public class CollectionNetworkResourceCustomizationRepositoryTest extends BaseTest { @Autowired private CollectionNetworkResourceCustomizationRepository cnrcRepo; - + @Test public void findAllTest() throws Exception { List<CollectionNetworkResourceCustomization> cnrcList = cnrcRepo.findAll(); Assert.assertFalse(CollectionUtils.isEmpty(cnrcList)); } - + @Test public void findOneByUuidTest() throws Exception { - CollectionNetworkResourceCustomization cnrc = cnrcRepo.findOneByModelCustomizationUUID("3bdbb104-ffff-483e-9f8b-c095b3d3068c"); - Assert.assertTrue(cnrc != null); - Assert.assertTrue("ExtVL 01".equals(cnrc.getModelInstanceName())); + CollectionNetworkResourceCustomization cnrc = + cnrcRepo.findOneByModelCustomizationUUID("3bdbb104-ffff-483e-9f8b-c095b3d3068c"); + Assert.assertTrue(cnrc != null); + Assert.assertTrue("ExtVL 01".equals(cnrc.getModelInstanceName())); } } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepositoryTest.java index 7aab47a625..371a9c13e0 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepositoryTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CvnfcCustomizationRepositoryTest.java @@ -22,12 +22,10 @@ package org.onap.so.db.catalog.data.repository; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; - import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; - import org.junit.Assert; import org.junit.Test; import org.onap.so.db.catalog.BaseTest; @@ -46,162 +44,159 @@ import org.springframework.util.CollectionUtils; public class CvnfcCustomizationRepositoryTest extends BaseTest { @Autowired private CvnfcCustomizationRepository cvnfcCustomizationRepository; - + @Test public void findAllTest() throws Exception { List<CvnfcCustomization> cvnfcCustomizationList = cvnfcCustomizationRepository.findAll(); Assert.assertFalse(CollectionUtils.isEmpty(cvnfcCustomizationList)); } - + @Test @Transactional public void createAndGetAllTest() throws Exception { - - CvnfcCustomization cvnfcCustomization = setUpCvnfcCustomization(); - cvnfcCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); - - VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); - vfModuleCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); - - VfModule vFModule = setUpVfModule(); - VnfResource vnfResource = setUpVnfResource(); - - vFModule.setVnfResources(vnfResource); - vfModuleCustomization.setVfModule(vFModule); - cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization); - - VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); - vnfResourceCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); - vnfResourceCustomization.setModelInstanceName("testModelInstanceName"); - - List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>(); - vnfResourceCustomizations.add(vnfResourceCustomization); - vnfResource.setVnfResourceCustomizations(vnfResourceCustomizations); - vnfResourceCustomization.setVnfResources(vnfResource); - - - VnfcCustomization vnfcCustomization = setUpVnfcCustomization(); - vnfcCustomization.setModelCustomizationUUID("d95d704a-9ff2-11e8-98d0-529269fb1459"); - - cvnfcCustomizationRepository.save(cvnfcCustomization); - - List<CvnfcCustomization> cvnfcCustomizationList = cvnfcCustomizationRepository.findAll(); - boolean matchFound = false; - for (CvnfcCustomization foundCvnfcCustomization : cvnfcCustomizationList) { - if (foundCvnfcCustomization.getDescription().equalsIgnoreCase(cvnfcCustomization.getDescription())) { - - assertThat(cvnfcCustomization, sameBeanAs(foundCvnfcCustomization) - .ignoring("id") - .ignoring("created") - .ignoring("vnfVfmoduleCvnfcConfigurationCustomization") - .ignoring("vnfResourceCusteModelCustomizationUUID")); - - matchFound = true; - break; - } - } - Assert.assertTrue(matchFound); + + CvnfcCustomization cvnfcCustomization = setUpCvnfcCustomization(); + cvnfcCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + + VfModule vFModule = setUpVfModule(); + VnfResource vnfResource = setUpVnfResource(); + + vFModule.setVnfResources(vnfResource); + vfModuleCustomization.setVfModule(vFModule); + cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization); + + VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); + vnfResourceCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + vnfResourceCustomization.setModelInstanceName("testModelInstanceName"); + + List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>(); + vnfResourceCustomizations.add(vnfResourceCustomization); + vnfResource.setVnfResourceCustomizations(vnfResourceCustomizations); + vnfResourceCustomization.setVnfResources(vnfResource); + + + VnfcCustomization vnfcCustomization = setUpVnfcCustomization(); + vnfcCustomization.setModelCustomizationUUID("d95d704a-9ff2-11e8-98d0-529269fb1459"); + + cvnfcCustomizationRepository.save(cvnfcCustomization); + + List<CvnfcCustomization> cvnfcCustomizationList = cvnfcCustomizationRepository.findAll(); + boolean matchFound = false; + for (CvnfcCustomization foundCvnfcCustomization : cvnfcCustomizationList) { + if (foundCvnfcCustomization.getDescription().equalsIgnoreCase(cvnfcCustomization.getDescription())) { + + assertThat(cvnfcCustomization, + sameBeanAs(foundCvnfcCustomization).ignoring("id").ignoring("created") + .ignoring("vnfVfmoduleCvnfcConfigurationCustomization") + .ignoring("vnfResourceCusteModelCustomizationUUID")); + + matchFound = true; + break; + } + } + Assert.assertTrue(matchFound); } - + @Test @Transactional public void createAndGetCvnfcCustomizationListTest() throws Exception { - - CvnfcCustomization cvnfcCustomization = setUpCvnfcCustomization(); - cvnfcCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); - - VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); - vfModuleCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); - - VfModule vFModule = setUpVfModule(); - VnfResource vnfResource = setUpVnfResource(); - - vFModule.setVnfResources(vnfResource); - vfModuleCustomization.setVfModule(vFModule); - cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization); - - VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); - vnfResourceCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); - vnfResourceCustomization.setModelInstanceName("testModelInstanceName"); - - List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>(); - vnfResourceCustomizations.add(vnfResourceCustomization); - vnfResource.setVnfResourceCustomizations(vnfResourceCustomizations); - vnfResourceCustomization.setVnfResources(vnfResource); - - - - VnfcCustomization vnfcCustomization = setUpVnfcCustomization(); - vnfcCustomization.setModelCustomizationUUID("d95d704a-9ff2-11e8-98d0-529269fb1459"); - - - - - cvnfcCustomizationRepository.save(cvnfcCustomization); - - List<CvnfcCustomization> cvnfcCustomizationList = cvnfcCustomizationRepository.findByModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); - boolean matchFound = false; - for (CvnfcCustomization foundCvnfcCustomization : cvnfcCustomizationList) { - if (foundCvnfcCustomization.getDescription().equalsIgnoreCase(cvnfcCustomization.getDescription())) { - - assertThat(cvnfcCustomization, sameBeanAs(foundCvnfcCustomization) - .ignoring("id") - .ignoring("created") - .ignoring("vnfVfmoduleCvnfcConfigurationCustomization") - .ignoring("vnfResourceCusteModelCustomizationUUID")); - - matchFound = true; - break; - } - } - Assert.assertTrue(matchFound); + + CvnfcCustomization cvnfcCustomization = setUpCvnfcCustomization(); + cvnfcCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + + VfModule vFModule = setUpVfModule(); + VnfResource vnfResource = setUpVnfResource(); + + vFModule.setVnfResources(vnfResource); + vfModuleCustomization.setVfModule(vFModule); + cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization); + + VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); + vnfResourceCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + vnfResourceCustomization.setModelInstanceName("testModelInstanceName"); + + List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>(); + vnfResourceCustomizations.add(vnfResourceCustomization); + vnfResource.setVnfResourceCustomizations(vnfResourceCustomizations); + vnfResourceCustomization.setVnfResources(vnfResource); + + + + VnfcCustomization vnfcCustomization = setUpVnfcCustomization(); + vnfcCustomization.setModelCustomizationUUID("d95d704a-9ff2-11e8-98d0-529269fb1459"); + + + + cvnfcCustomizationRepository.save(cvnfcCustomization); + + List<CvnfcCustomization> cvnfcCustomizationList = + cvnfcCustomizationRepository.findByModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + boolean matchFound = false; + for (CvnfcCustomization foundCvnfcCustomization : cvnfcCustomizationList) { + if (foundCvnfcCustomization.getDescription().equalsIgnoreCase(cvnfcCustomization.getDescription())) { + + assertThat(cvnfcCustomization, + sameBeanAs(foundCvnfcCustomization).ignoring("id").ignoring("created") + .ignoring("vnfVfmoduleCvnfcConfigurationCustomization") + .ignoring("vnfResourceCusteModelCustomizationUUID")); + + matchFound = true; + break; + } + } + Assert.assertTrue(matchFound); } - - + + @Test @Transactional public void createAndGetCvnfcCustomizationTest() throws Exception { - - CvnfcCustomization cvnfcCustomization = setUpCvnfcCustomization(); - cvnfcCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); - - VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); - vfModuleCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); - - VfModule vFModule = setUpVfModule(); - VnfResource vnfResource = setUpVnfResource(); - - vFModule.setVnfResources(vnfResource); - vfModuleCustomization.setVfModule(vFModule); - cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization); - - VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); - vnfResourceCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); - vnfResourceCustomization.setModelInstanceName("testModelInstanceName"); - - List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList(); - vnfResourceCustomizations.add(vnfResourceCustomization); - vnfResource.setVnfResourceCustomizations(vnfResourceCustomizations); - vnfResourceCustomization.setVnfResources(vnfResource); - - - - VnfcCustomization vnfcCustomization = setUpVnfcCustomization(); - vnfcCustomization.setModelCustomizationUUID("d95d704a-9ff2-11e8-98d0-529269fb1459"); - - cvnfcCustomizationRepository.save(cvnfcCustomization); - - CvnfcCustomization cvnfcCustomizationList = cvnfcCustomizationRepository.findOneByModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); - - assertThat(cvnfcCustomization, sameBeanAs(cvnfcCustomizationList) - .ignoring("id") - .ignoring("created") - .ignoring("vnfVfmoduleCvnfcConfigurationCustomization") - .ignoring("vnfResourceCusteModelCustomizationUUID")); + + CvnfcCustomization cvnfcCustomization = setUpCvnfcCustomization(); + cvnfcCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + + VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); + vfModuleCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + + VfModule vFModule = setUpVfModule(); + VnfResource vnfResource = setUpVnfResource(); + + vFModule.setVnfResources(vnfResource); + vfModuleCustomization.setVfModule(vFModule); + cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization); + + VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); + vnfResourceCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + vnfResourceCustomization.setModelInstanceName("testModelInstanceName"); + + List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList(); + vnfResourceCustomizations.add(vnfResourceCustomization); + vnfResource.setVnfResourceCustomizations(vnfResourceCustomizations); + vnfResourceCustomization.setVnfResources(vnfResource); + + + + VnfcCustomization vnfcCustomization = setUpVnfcCustomization(); + vnfcCustomization.setModelCustomizationUUID("d95d704a-9ff2-11e8-98d0-529269fb1459"); + + cvnfcCustomizationRepository.save(cvnfcCustomization); + + CvnfcCustomization cvnfcCustomizationList = + cvnfcCustomizationRepository.findOneByModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + + assertThat(cvnfcCustomization, + sameBeanAs(cvnfcCustomizationList).ignoring("id").ignoring("created") + .ignoring("vnfVfmoduleCvnfcConfigurationCustomization") + .ignoring("vnfResourceCusteModelCustomizationUUID")); } - - - - + + + } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepositoryTest.java index 0eec84f4c3..d0c621ddd0 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepositoryTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfCustomizationRepositoryTest.java @@ -1,20 +1,15 @@ /* - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix + * Foundation. ================================================================================ Licensed under the + * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may + * obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and limitations under the + * License. * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= + * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END========================================================= */ package org.onap.so.db.catalog.data.repository; @@ -22,7 +17,6 @@ package org.onap.so.db.catalog.data.repository; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; - import java.util.List; import org.junit.Test; import org.onap.so.db.catalog.BaseTest; @@ -38,16 +32,16 @@ public class PnfCustomizationRepositoryTest extends BaseTest { @Test public void findById_ValidUuid_ExpectedOutput() throws Exception { - PnfResourceCustomization pnfResourceCustomization = pnfCustomizationRepository - .findById("68dc9a92-214c-11e7-93ae-92361f002680") - .orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation")); + PnfResourceCustomization pnfResourceCustomization = + pnfCustomizationRepository.findById("68dc9a92-214c-11e7-93ae-92361f002680") + .orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation")); checkPnfResourceCustomization(pnfResourceCustomization); } @Test public void findPnfResourceCustomizationByModelUuid_ValidServiceUuidAndCustomizationUuid_ExpectedOutput() { List<PnfResourceCustomization> pnfResourceCustomizationList = pnfCustomizationRepository - .findPnfResourceCustomizationByModelUuid("5df8b6de-2083-11e7-93ae-92361f002676"); + .findPnfResourceCustomizationByModelUuid("5df8b6de-2083-11e7-93ae-92361f002676"); assertEquals("Found the matching resource entity", 1, pnfResourceCustomizationList.size()); checkPnfResourceCustomization(pnfResourceCustomizationList.get(0)); } @@ -62,7 +56,7 @@ public class PnfCustomizationRepositoryTest extends BaseTest { assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID()); assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680", - pnfResource.getModelInvariantUUID()); + pnfResource.getModelInvariantUUID()); assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion()); assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode()); } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfResourceRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfResourceRepositoryTest.java index 4dde3b25df..f0b7c20261 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfResourceRepositoryTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/PnfResourceRepositoryTest.java @@ -1,26 +1,20 @@ /* - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix + * Foundation. ================================================================================ Licensed under the + * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may + * obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and limitations under the + * License. * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= + * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END========================================================= */ package org.onap.so.db.catalog.data.repository; import static org.junit.Assert.assertEquals; - import org.junit.Test; import org.onap.so.db.catalog.BaseTest; import org.onap.so.db.catalog.beans.PnfResource; @@ -36,15 +30,15 @@ public class PnfResourceRepositoryTest extends BaseTest { public void findResourceById_validUuid_expectedOutput() throws Exception { PnfResource pnfResource = pnfResourceRepository.findById("ff2ae348-214a-11e7-93ae-92361f002680") - .orElseThrow(() -> new NoEntityFoundException("Cannot Find Entity")); + .orElseThrow(() -> new NoEntityFoundException("Cannot Find Entity")); checkPnfResource(pnfResource); } private void checkPnfResource(PnfResource pnfResource) { assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID()); assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680", - pnfResource.getModelInvariantUUID()); + pnfResource.getModelInvariantUUID()); assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion()); assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode()); } -}
\ No newline at end of file +} diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfcCustomizationRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfcCustomizationRepositoryTest.java index 1fc6617c2c..612963d35b 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfcCustomizationRepositoryTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/VnfcCustomizationRepositoryTest.java @@ -22,9 +22,7 @@ package org.onap.so.db.catalog.data.repository; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; - import java.util.List; - import org.junit.Assert; import org.junit.Test; import org.onap.so.db.catalog.BaseTest; @@ -42,24 +40,25 @@ public class VnfcCustomizationRepositoryTest extends BaseTest { public void findAllTest() throws Exception { List<VnfcCustomization> vnfcCustomizationList = vnfcCustomizationRepository.findAll(); Assert.assertFalse(CollectionUtils.isEmpty(vnfcCustomizationList)); - - VnfcCustomization vnfcCustomization = vnfcCustomizationRepository.findById("9bcce658-9b37-11e8-98d0-529269fb1459"). - orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation")); + + VnfcCustomization vnfcCustomization = + vnfcCustomizationRepository.findById("9bcce658-9b37-11e8-98d0-529269fb1459") + .orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation")); Assert.assertTrue(vnfcCustomization.getDescription().equalsIgnoreCase("testVnfcCustomizationDescription")); } - + @Test @Transactional public void createAndGetTest() throws Exception { - - VnfcCustomization vnfcCustomization = setUpVnfcCustomization(); - vnfcCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); - vnfcCustomizationRepository.save(vnfcCustomization); - - VnfcCustomization foundVnfcCustomization = vnfcCustomizationRepository.findById("cf9f6efc-9f14-11e8-98d0-529269fb1459"). - orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation")); - - assertThat(vnfcCustomization, sameBeanAs(foundVnfcCustomization) - .ignoring("created")); + + VnfcCustomization vnfcCustomization = setUpVnfcCustomization(); + vnfcCustomization.setModelCustomizationUUID("cf9f6efc-9f14-11e8-98d0-529269fb1459"); + vnfcCustomizationRepository.save(vnfcCustomization); + + VnfcCustomization foundVnfcCustomization = + vnfcCustomizationRepository.findById("cf9f6efc-9f14-11e8-98d0-529269fb1459") + .orElseThrow(() -> new NoEntityFoundException("Cannot Find Operation")); + + assertThat(vnfcCustomization, sameBeanAs(foundVnfcCustomization).ignoring("created")); } } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java index be5800608d..d541627d0e 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/WorkflowRepositoryTest.java @@ -1,20 +1,15 @@ /* - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix + * Foundation. ================================================================================ Licensed under the + * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may + * obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and limitations under the + * License. * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= + * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END========================================================= */ package org.onap.so.db.catalog.data.repository; @@ -22,7 +17,6 @@ package org.onap.so.db.catalog.data.repository; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; - import java.util.List; import org.junit.Test; import org.onap.so.db.catalog.BaseTest; @@ -39,10 +33,9 @@ public class WorkflowRepositoryTest extends BaseTest { @Test public void findByArtifactUuid_ValidUuid_ExpectedOutput() throws Exception { - Workflow workflow = workflowRepository - .findByArtifactUUID("5b0c4322-643d-4c9f-b184-4516049e99b1"); - + Workflow workflow = workflowRepository.findByArtifactUUID("5b0c4322-643d-4c9f-b184-4516049e99b1"); + assertEquals("artifactName", "testingWorkflow", workflow.getArtifactName()); } - + } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/test/RecordNotFoundExceptionTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/test/RecordNotFoundExceptionTest.java index 506a6b73c9..27990313b1 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/test/RecordNotFoundExceptionTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/test/RecordNotFoundExceptionTest.java @@ -23,10 +23,8 @@ package org.onap.so.db.catalog.test; import org.junit.Test; import org.onap.so.db.catalog.beans.VfModule; import org.onap.so.db.catalog.utils.RecordNotFoundException; - import java.util.ArrayList; import java.util.List; - import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertEquals; @@ -34,7 +32,7 @@ import static org.junit.Assert.assertEquals; public class RecordNotFoundExceptionTest { @Test - public void paramConstructor(){ + public void paramConstructor() { RecordNotFoundException ex = new RecordNotFoundException("Exceoption raised", new Exception()); assertNotNull(ex); assertNotNull(ex.getMessage()); |