summaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/test/java/org
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-07-30 15:56:09 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-07-31 11:09:25 -0400
commit5a6a6de6f1a26a1897e4917a0df613e25a24eb70 (patch)
tree59a968f27b4b603aacc9d5e7b51fb598aeec5321 /mso-catalog-db/src/test/java/org
parentb6dc38501f3b746426b42d9de4cc883d894149e8 (diff)
Containerization feature of SO
Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18 Issue-ID: SO-670 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-catalog-db/src/test/java/org')
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java60
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/TestApplication.java48
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/BuildingBlockDetailTest.java53
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/MavenVersioningTest.java (renamed from mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/MavenVersioningTest.java)10
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/NetworkTest.java47
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/OrchestrationStatusStateTransitionDirectiveTest.java54
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/ServiceTest.java79
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/TempNetworkHeatTemplateLookupTest.java (renamed from mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/TempNetworkHeatTemplateLookupTest.java)100
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/VFModuleTest.java57
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/BeansTest.java (renamed from mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/beans/BeansTest.java)52
-rw-r--r--mso-catalog-db/src/test/java/org/onap/so/db/catalog/test/RecordNotFoundExceptionTest.java (renamed from mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/RecordNotFoundExceptionTest.java)10
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/CatalogDbSessionFactoryManagerTest.java47
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/AllottedResourceCustomizationTest.java91
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java6155
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatFilesTest.java87
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatTemplateTest.java89
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelRecipeTest.java59
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelTest.java69
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkRecipeTest.java63
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkResourceCustomizationTest.java62
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkResourceTest.java68
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/RecipeTest.java55
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceMacroHolderTest.java48
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceRecipeTest.java65
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceTest.java67
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceToAllottedResourcesTest.java49
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceToResourceCustomizationTest.java49
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToStringTest.java151
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToscaCsarTest.java57
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VfModuleCustomizationTest.java70
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VfModuleTest.java63
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfRecipeTest.java63
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfResourceCustomizationTest.java56
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfResourceTest.java82
34 files changed, 494 insertions, 7741 deletions
diff --git a/mso-catalog-db/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java b/mso-catalog-db/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
new file mode 100644
index 0000000000..60f8de6c2e
--- /dev/null
+++ b/mso-catalog-db/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so;
+import ch.vorburger.exec.ManagedProcessException;
+import ch.vorburger.mariadb4j.DBConfigurationBuilder;
+import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import javax.sql.DataSource;
+
+@Configuration
+@Profile({"test","local"})
+public class EmbeddedMariaDbConfig {
+
+ @Bean
+ MariaDB4jSpringService mariaDB4jSpringService() {
+ return new MariaDB4jSpringService();
+ }
+
+ @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
+ mariaDB4jSpringService.getDB().createDB(databaseName);
+
+ DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration();
+
+ 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/TestApplication.java b/mso-catalog-db/src/test/java/org/onap/so/TestApplication.java
new file mode 100644
index 0000000000..6ee88e407d
--- /dev/null
+++ b/mso-catalog-db/src/test/java/org/onap/so/TestApplication.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+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"})
+@EnableJpaRepositories("org.onap.so.db.catalog.data.repository")
+@EntityScan("org.onap.so.db.catalog.beans")
+@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");
+ setLogsDir();
+ }
+}
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
new file mode 100644
index 0000000000..7a9fc19fcb
--- /dev/null
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BuildingBlockDetailTest.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.db.catalog;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.TestApplication;
+import org.onap.so.db.catalog.beans.BuildingBlockDetail;
+import org.onap.so.db.catalog.beans.OrchestrationAction;
+import org.onap.so.db.catalog.beans.ResourceType;
+import org.onap.so.db.catalog.data.repository.BuildingBlockDetailRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@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());
+ }
+}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/MavenVersioningTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/MavenVersioningTest.java
index c99a714b11..b5d6271f7c 100644
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/MavenVersioningTest.java
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/MavenVersioningTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.db.catalog.test;
+package org.onap.so.db.catalog;
import static org.junit.Assert.*;
@@ -29,8 +29,8 @@ import java.util.List;
import org.junit.Test;
-import org.openecomp.mso.db.catalog.utils.MavenLikeVersioningComparator;
-import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
+import org.onap.so.db.catalog.utils.MavenLikeVersioningComparator;
+import org.onap.so.db.catalog.utils.MavenLikeVersioning;
public class MavenVersioningTest {
@@ -153,7 +153,7 @@ public class MavenVersioningTest {
MavenLikeVersioning test12 = new MavenLikeVersioning();
test12.setVersion("2.0");
- List<MavenLikeVersioning> list= new LinkedList<>();
+ List<MavenLikeVersioning> list= new LinkedList<MavenLikeVersioning>();
list.add(test1);
list.add(test2);
list.add(test3);
@@ -167,7 +167,7 @@ public class MavenVersioningTest {
list.add(test11);
list.add(test12);
- list.sort(new MavenLikeVersioningComparator());
+ Collections.sort(list,new MavenLikeVersioningComparator());
//Collections.reverse(list);
assertTrue(list.get(0).getVersion().equals("0.02"));
assertTrue(list.get(1).getVersion().equals("1.1"));
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
new file mode 100644
index 0000000000..55c5c8351b
--- /dev/null
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/NetworkTest.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.db.catalog;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.TestApplication;
+import org.onap.so.db.catalog.beans.NetworkResource;
+import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@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());
+ }
+}
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
new file mode 100644
index 0000000000..52cac88402
--- /dev/null
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/OrchestrationStatusStateTransitionDirectiveTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.db.catalog;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.TestApplication;
+import org.onap.so.db.catalog.beans.OrchestrationAction;
+import org.onap.so.db.catalog.beans.OrchestrationStatus;
+import org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective;
+import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective;
+import org.onap.so.db.catalog.beans.ResourceType;
+import org.onap.so.db.catalog.data.repository.OrchestrationStatusStateTransitionDirectiveRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+public class OrchestrationStatusStateTransitionDirectiveTest {
+ @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());
+ }
+}
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
new file mode 100644
index 0000000000..0ecaa5fbba
--- /dev/null
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ServiceTest.java
@@ -0,0 +1,79 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.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.TestApplication;
+import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.data.repository.ServiceRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ActiveProfiles("test")
+public class ServiceTest {
+ @Autowired
+ private ServiceRepository serviceRepo;
+
+ @Test
+ public void Find_LatestService_Test() {
+ 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");
+ 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");
+ 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());
+ assertEquals("5df8b6de-2083-11e7-93ae-92361f002672",latestVersionService.get(3).getModelUUID());
+ assertEquals("5df8b6de-2083-11e7-93ae-92361f002671",latestVersionService.get(4).getModelUUID());
+ }
+
+ @Test
+ public void Find_LatestService_Test_4() {
+ 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");
+ assertEquals("5df8b6de-2083-11e7-93ae-92361f002675",latestVersionService.getModelUUID());
+ }
+}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/TempNetworkHeatTemplateLookupTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/TempNetworkHeatTemplateLookupTest.java
index b0ccfdd781..b09ec7193d 100644
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/TempNetworkHeatTemplateLookupTest.java
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/TempNetworkHeatTemplateLookupTest.java
@@ -1,50 +1,50 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.openecomp.mso.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);
-
- }
-
-}
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.db.catalog;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+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);
+
+ }
+
+}
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
new file mode 100644
index 0000000000..44e7a03855
--- /dev/null
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/VFModuleTest.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.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.TestApplication;
+import org.onap.so.db.catalog.beans.VfModule;
+import org.onap.so.db.catalog.data.repository.VFModuleRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@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());
+ }
+}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/beans/BeansTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/BeansTest.java
index 57bf292dd8..44439ede22 100644
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/beans/BeansTest.java
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/BeansTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,17 +18,23 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.db.catalog.beans;
+package org.onap.so.db.catalog.beans;
-import static org.hamcrest.CoreMatchers.isA;
-import static org.mockito.Matchers.eq;
+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.hamcrest.CoreMatchers;
-import org.hamcrest.Matcher;
import org.junit.Test;
-import org.openecomp.mso.openpojo.rules.EqualsAndHashCodeTester;
-import org.openecomp.mso.openpojo.rules.HasToStringRule;
-import org.openecomp.mso.openpojo.rules.ToStringTester;
+import org.onap.so.openpojo.rules.CustomSetterMustExistRule;
+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;
@@ -37,8 +43,13 @@ import com.openpojo.reflection.filters.FilterNonConcrete;
import com.openpojo.reflection.filters.FilterPackageInfo;
import com.openpojo.validation.Validator;
import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.BusinessKeyMustExistRule;
import com.openpojo.validation.rule.impl.GetterMustExistRule;
-import com.openpojo.validation.rule.impl.SetterMustExistRule;
+import com.openpojo.validation.rule.impl.NoNestedClassRule;
+import com.openpojo.validation.rule.impl.NoPrimitivesRule;
+import com.openpojo.validation.rule.impl.NoPublicFieldsExceptStaticFinalRule;
+import com.openpojo.validation.rule.impl.NoStaticExceptFinalRule;
+import com.openpojo.validation.rule.impl.SerializableMustHaveSerialVersionUIDRule;
import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
@@ -53,20 +64,29 @@ public class BeansTest {
@Test
public void pojoStructure() {
- test("org.openecomp.mso.db.catalog.beans");
+ 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 SetterMustExistRule())
+ .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 EqualsAndHashCodeTester().onlyDeclaredMethods())
+ .with(new HasEqualsAndHashCodeRule())
+
.build();
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/RecordNotFoundExceptionTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/test/RecordNotFoundExceptionTest.java
index dac5fb7f9e..506a6b73c9 100644
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/RecordNotFoundExceptionTest.java
+++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/test/RecordNotFoundExceptionTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -18,11 +18,11 @@
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.db.catalog.test;
+package org.onap.so.db.catalog.test;
import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.db.catalog.utils.RecordNotFoundException;
+import org.onap.so.db.catalog.beans.VfModule;
+import org.onap.so.db.catalog.utils.RecordNotFoundException;
import java.util.ArrayList;
import java.util.List;
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/CatalogDbSessionFactoryManagerTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/CatalogDbSessionFactoryManagerTest.java
deleted file mode 100644
index 42b93b1949..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/CatalogDbSessionFactoryManagerTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog;
-
-import org.junit.Test;
-import org.mockito.Mock;
-import org.openecomp.mso.db.catalog.CatalogDbSessionFactoryManager;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.*;
-
-
-public class CatalogDbSessionFactoryManagerTest {
- @Test
- public void testgetHibernateConfigFile() {
- CatalogDbSessionFactoryManager catalogDbSessionFactoryManager = new CatalogDbSessionFactoryManager();
- System.setProperty("mso.db", "MYSQL");
- assertNotNull(catalogDbSessionFactoryManager.getHibernateConfigFile());
- }
-
- @Test
- public void testgetHibernateConfigFileNonMSODB() {
- CatalogDbSessionFactoryManager catalogDbSessionFactoryManager = new CatalogDbSessionFactoryManager();
- System.setProperty("mso.db", "test");
- assertNull(catalogDbSessionFactoryManager.getHibernateConfigFile());
- }
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/AllottedResourceCustomizationTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/AllottedResourceCustomizationTest.java
deleted file mode 100644
index 101cd5ed0a..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/AllottedResourceCustomizationTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.AllottedResource;
-import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.sql.Timestamp;
-
-public class AllottedResourceCustomizationTest {
- @Test
- public void test(){
- AllottedResource allottedResource = new AllottedResource();
- allottedResource.setModelUuid("ModelUuid");
- allottedResource.setCreated(new Timestamp(System.currentTimeMillis()));
- allottedResource.setModelVersion("ModelVersion");
- allottedResource.setDescription("Description");
- allottedResource.setModelInvariantUuid("ModelInvariantUuid");
- allottedResource.setModelName("ModelName");
- allottedResource.setSubcategory("Subcategory");
- allottedResource.setToscaNodeType("ToscaNodeType");
- allottedResource.setVersion("Version");
-
- AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
- allottedResourceCustomization.setCreated(new Timestamp(System.currentTimeMillis()));
- allottedResourceCustomization.setAllottedResource(allottedResource);
- allottedResourceCustomization.setVersion("Version");
- allottedResourceCustomization.setArModelUuid("ArModelUuid");
- allottedResourceCustomization.setMaxInstances(100);
- allottedResourceCustomization.setMinInstances(1);
- allottedResourceCustomization.setModelCustomizationUuid("ModelCustomizationUuid");
- allottedResourceCustomization.setModelInstanceName("ModelInstanceName");
- allottedResourceCustomization.setNfFunction("NfFunction");
- allottedResourceCustomization.setNfNamingCode("NfNamingCode");
- allottedResourceCustomization.setNfRole("NfRole");
- allottedResourceCustomization.setNfType("NfType");
- allottedResourceCustomization.setTargetNetworkRole("TargetNetworkRole");
- allottedResourceCustomization.setProvidingServiceModelUuid("ProvidingServiceModelUuid");
- allottedResourceCustomization.setProvidingServiceModelInvariantUuid("ProvidingServiceModelInvariantUuid");
- allottedResourceCustomization.setProvidingServiceModelName("ProvidingServiceModelName");
-
- assertNotNull(allottedResource.getModelUuid());
- assertNotNull(allottedResource.getCreated());
- assertNotNull(allottedResource.getModelVersion());
- assertNotNull(allottedResource.getDescription());
- assertNotNull(allottedResource.getModelInvariantUuid());
- assertNotNull(allottedResource.getModelName());
- assertNotNull(allottedResource.getSubcategory());
- assertNotNull(allottedResource.getToscaNodeType());
- assertNotNull(allottedResource.getVersion());
-
- assertNotNull(allottedResourceCustomization.getAllottedResource());
- assertNotNull(allottedResourceCustomization.getVersion());
- assertNotNull(allottedResourceCustomization.getCreated());
- assertNotNull(allottedResourceCustomization.getArModelUuid());
- assertNotNull(allottedResourceCustomization.getMaxInstances());
- assertNotNull(allottedResourceCustomization.getMinInstances());
- assertNotNull(allottedResourceCustomization.getModelCustomizationUuid());
- assertNotNull(allottedResourceCustomization.getModelInstanceName());
- assertNotNull(allottedResourceCustomization.getNfFunction());
- assertNotNull(allottedResourceCustomization.getNfNamingCode());
- assertNotNull(allottedResourceCustomization.getNfRole());
- assertNotNull(allottedResourceCustomization.getNfType());
- assertNotNull(allottedResourceCustomization.getTargetNetworkRole());
- assertNotNull(allottedResourceCustomization.getProvidingServiceModelUuid());
- assertNotNull(allottedResourceCustomization.getProvidingServiceModelInvariantUuid());
- assertNotNull(allottedResourceCustomization.getProvidingServiceModelName());
- }
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java
deleted file mode 100644
index b98fb438dc..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/CatalogDatabaseTest.java
+++ /dev/null
@@ -1,6155 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.hibernate.HibernateException;
-import org.hibernate.NonUniqueResultException;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.*;
-import org.openecomp.mso.db.catalog.utils.RecordNotFoundException;
-
-import mockit.Mock;
-import mockit.MockUp;
-
-public class CatalogDatabaseTest {
-
- CatalogDatabase cd = null;
- @Rule
- public ExpectedException thrown = ExpectedException.none();
- private MockUp<CatalogDatabase> mockCd = null;
- private MockUp<Session> mockedSession = null;
- private MockUp<Query> mockUpQuery = null;
- private MockUp<Query> mockUpQuery2 = null;
- private MockUp<Query> mockUpQuery3 = null;
- private MockUp<Query> mockUpQuery4 = null;
- @Before
- public void setup(){
- cd = CatalogDatabase.getInstance();
- }
-
-
- @After
- public void tearDown() {
- if (mockCd!=null) { mockCd.tearDown(); mockCd = null; }
- if (mockedSession!=null) { mockedSession.tearDown(); mockedSession = null; }
- if (mockUpQuery!=null) { mockUpQuery.tearDown(); mockUpQuery = null; }
- if (mockUpQuery2!=null) { mockUpQuery2.tearDown(); mockUpQuery2 = null; }
- if (mockUpQuery3!=null) { mockUpQuery3.tearDown(); mockUpQuery3 = null; }
- if (mockUpQuery4!=null) { mockUpQuery4.tearDown(); mockUpQuery4 = null; }
- }
-
-
-
- @Test
- public void getAllHeatTemplatesTest(){
-
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<HeatTemplate> list() {
- HeatTemplate heatTemplate = new HeatTemplate();
- return Arrays.asList(heatTemplate);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- List <HeatTemplate> list = cd.getAllHeatTemplates();
- assertEquals(list.size(), 1);
-
-
- }
-
- @Test
- public void getHeatTemplateByIdTest(){
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Object get(Class cls, Serializable id) {
- HeatTemplate heatTemplate = new HeatTemplate();
- heatTemplate.setAsdcUuid("123-uuid");
- return heatTemplate;
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HeatTemplate ht = cd.getHeatTemplate(10);
- assertEquals("123-uuid", ht.getAsdcUuid());
-
-
- }
-
- @Test
- public void getHeatTemplateByNameEmptyListTest(){
-
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<HeatTemplate> list() {
- HeatTemplate heatTemplate = new HeatTemplate();
- return Arrays.asList();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HeatTemplate ht = cd.getHeatTemplate("heat123");
- assertEquals(null, ht);
-
-
- }
-
- @Test
- public void getHeatTemplateByNameTest(){
-
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<HeatTemplate> list() {
- HeatTemplate heatTemplate1 = new HeatTemplate();
- heatTemplate1.setAsdcUuid("123-uuid");
- heatTemplate1.setVersion("1.2");
- HeatTemplate heatTemplate2 = new HeatTemplate();
- heatTemplate2.setAsdcUuid("456-uuid");
- heatTemplate2.setVersion("1.3");
- return Arrays.asList(heatTemplate1, heatTemplate2);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HeatTemplate ht = cd.getHeatTemplate("heat123");
- assertEquals("456-uuid", ht.getAsdcUuid());
-
-
- }
-
- @Test
- public void getHeatTemplateByTemplateNameTest() {
-
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<HeatTemplate> list() {
- HeatTemplate heatTemplate = new HeatTemplate();
- heatTemplate.setAsdcUuid("1234-uuid");
- return Arrays.asList(heatTemplate);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HeatTemplate ht = cd.getHeatTemplate("heat123","v2");
- assertEquals("1234-uuid", ht.getAsdcUuid());
-
-
- }
-
- @Test
- public void getHeatTemplateByTemplateNameEmptyResultTest() {
-
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<HeatTemplate> list() {
- return Arrays.asList();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HeatTemplate ht = cd.getHeatTemplate("heat123","v2");
- assertEquals(null, ht);
-
-
- }
-
- @Test
- public void getHeatTemplateByArtifactUuidException(){
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Object get(Class cls, Serializable id) {
- HeatTemplate heatTemplate = new HeatTemplate();
- heatTemplate.setAsdcUuid("123-uuid");
- return heatTemplate;
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HeatTemplate ht = cd.getHeatTemplateByArtifactUuid("123");
- assertEquals("123-uuid", ht.getAsdcUuid());
-
-
- }
-
- @Test
- public void getHeatTemplateByArtifactUuidTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() {
- HeatTemplate heatTemplate = new HeatTemplate();
- heatTemplate.setAsdcUuid("123-uuid");
- return heatTemplate;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid");
- assertEquals("123-uuid", ht.getAsdcUuid());
-
-
- }
-
- @Test
- public void getHeatTemplateByArtifactUuidNullTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() {
- return null;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid");
- assertNull(ht);
-
-
- }
-
- @Test
- public void getHeatTemplateByArtifactUuidHibernateErrorTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() {
- throw new HibernateException("hibernate exception");
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(HibernateException.class);
- HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid");
-
-
- }
-
- @Test
- public void getHeatTemplateByArtifactUuidNonUniqueResultTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() {
- throw new NonUniqueResultException(2);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(NonUniqueResultException.class);
- HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid");
-
-
- }
-
- @Test
- public void getHeatTemplateByArtifactUuidGenericExceptionTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new Exception();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(Exception.class);
- HeatTemplate ht = cd.getHeatTemplateByArtifactUuidRegularQuery("123-uuid");
-
-
- }
-
- @Test
- public void getParametersForHeatTemplateTest(){
-
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<HeatTemplate> list() {
- HeatTemplate heatTemplate = new HeatTemplate();
- heatTemplate.setAsdcUuid("1234-uuid");
- return Arrays.asList(heatTemplate);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- List<HeatTemplateParam> htList = cd.getParametersForHeatTemplate("12l3");
- assertEquals(1, htList.size());
-
-
- }
-
- @Test
- public void getParametersForHeatTemplateHibernateExceptionTest(){
-
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<HeatTemplate> list() {
- throw new HibernateException("hibernate exception");
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(HibernateException.class);
- List<HeatTemplateParam> htList = cd.getParametersForHeatTemplate("12l3");
-
-
-
- }
-
- @Test
- public void getParametersForHeatTemplateExceptionTest(){
-
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<HeatTemplate> list() throws Exception {
- throw new Exception();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(Exception.class);
- List<HeatTemplateParam> htList = cd.getParametersForHeatTemplate("12l3");
-
-
- }
-
- @Test
- public void getHeatEnvironmentByArtifactUuidTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() {
- HeatEnvironment heatEnvironment = new HeatEnvironment();
- heatEnvironment.setArtifactUuid("123-uuid");
- return heatEnvironment;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123");
- assertEquals("123-uuid", he.getArtifactUuid());
-
-
- }
-
- @Test
- public void getHeatEnvironmentByArtifactUuidHibernateExceptionTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() {
- throw new HibernateException("hibernate exception");
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(HibernateException.class);
- HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123");
-
-
- }
-
- @Test
- public void getHeatEnvironmentByArtifactUuidExceptionTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new Exception();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(Exception.class);
- HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123");
-
-
- }
-
- @Test
- public void getHeatEnvironmentByArtifactUuidNonUniqueTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new org.hibernate.NonUniqueResultException(2);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HeatEnvironment he = cd.getHeatEnvironmentByArtifactUuid("123");
- assertNull(he);
-
- }
-
- @Test
- public void getServiceByInvariantUUIDTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<Service> list() {
- Service service = new Service();
- service.setModelUUID("123-uuid");
- return Arrays.asList(service);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- Service service = cd.getServiceByInvariantUUID("123");
- assertEquals("123-uuid", service.getModelUUID());
-
-
- }
-
- @Test
- public void getServiceByInvariantUUIDEmptyResultTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<Service> list() {
- return Arrays.asList();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- Service service = cd.getServiceByInvariantUUID("123");
- assertEquals(null, service);
-
-
- }
-
- @Test
- public void getServiceTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- Service service = new Service();
- service.setModelUUID("123-uuid");
- return service;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- Service service = cd.getService("123");
- assertEquals("123-uuid", service.getModelUUID());
-
-
- }
-
- @Test
- public void getServiceNullTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- return null;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- Service service = cd.getService("123");
- assertNull(service);
-
-
- }
-
- @Test
- public void getServiceNoUniqueResultTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new NonUniqueResultException(-1);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(NonUniqueResultException.class);
- Service service = cd.getService("123");
-
-
- }
-
- @Test
- public void getServiceHibernateExceptionTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new HibernateException("hibernate exception");
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(HibernateException.class);
- Service service = cd.getService("123");
-
-
- }
-
- @Test
- public void getServiceExceptionTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new Exception("generic exception");
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(Exception.class);
- Service service = cd.getService("123");
-
-
- }
-
- @Test
- public void getServiceByModelUUIDTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- Service service = new Service();
- service.setModelUUID("123-uuid");
- return service;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- Service service = cd.getServiceByModelUUID("123");
- assertEquals("123-uuid", service.getModelUUID());
-
-
- }
-
- @Test
- public void getService2Test(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- Service service = new Service();
- service.setModelUUID("123-uuid");
- return service;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HashMap<String, String> map = new HashMap<>();
- map.put("serviceNameVersionId", "v2");
- Service service = cd.getService(map, "123");
-
- assertEquals("123-uuid", service.getModelUUID());
-
- map.remove("serviceNameVersionId");
- service = cd.getService(map, "123");
- assertNotNull(service);
- }
-
- @Test
- public void getService2NonUniqueTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new org.hibernate.NonUniqueResultException(2);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HashMap<String, String> map = new HashMap<>();
- map.put("serviceNameVersionId", "v2");
-
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- Service service = cd.getService(map, "123");
- }
-
- @Test
- public void getService2HibernateExceptionTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new org.hibernate.HibernateException("test case");
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HashMap<String, String> map = new HashMap<>();
- map.put("serviceNameVersionId", "v2");
-
- thrown.expect(org.hibernate.HibernateException.class);
- Service service = cd.getService(map, "123");
- }
-
- @Test
- public void getService2ExceptionTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new NullPointerException();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HashMap<String, String> map = new HashMap<>();
- map.put("serviceNameVersionId", "v2");
-
- thrown.expect(NullPointerException.class);
- Service service = cd.getService(map, "123");
- }
-
- @Test
- public void getService2NullTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- return null;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- HashMap<String, String> map = new HashMap<>();
- map.put("serviceNameVersionId", "v2");
-
- Service service = cd.getService(map, "123");
- assertNull(service);
- }
-
- @Test
- public void getServiceByModelNameTest(){
-
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<Service> list() throws Exception {
- Service service = new Service();
- service.setModelUUID("123-uuid");
- return Arrays.asList(service);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- Service service = cd.getServiceByModelName("123");
- assertEquals("123-uuid", service.getModelUUID());
-
-
- }
-
- @Test
- public void getServiceByModelNameEmptyTest(){
-
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<Service> list() throws Exception {
- return Arrays.asList();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- Service service = cd.getServiceByModelName("123");
- assertEquals(null, service);
-
-
- }
-
- @Test
- public void getServiceByVersionAndInvariantIdTest() throws Exception{
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- Service service = new Service();
- service.setModelUUID("123-uuid");
- return service;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- Service service = cd.getServiceByVersionAndInvariantId("123","tetwe");
- assertEquals("123-uuid", service.getModelUUID());
-
-
- }
-
- @Test
- public void getServiceByVersionAndInvariantIdNullTest() throws Exception{
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- return null;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- Service service = cd.getServiceByVersionAndInvariantId("123","tetwe");
- assertNull(service);
-
-
- }
-
- @Test
- public void getServiceByVersionAndInvariantIdNonUniqueResultTest() throws Exception{
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new NonUniqueResultException(-1);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(Exception.class);
- Service service = cd.getServiceByVersionAndInvariantId("123","tetwe");
-
-
- }
-
- @Test
- public void getServiceRecipeTestException() throws Exception{
- thrown.expect(Exception.class);
- ServiceRecipe ht = cd.getServiceRecipe("123","tetwe");
- }
-
- @Test
- public void getServiceRecipeByServiceModelUuidTest() {
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<ServiceRecipe> list() throws Exception {
- ServiceRecipe serviceRecipe = new ServiceRecipe();
- serviceRecipe.setId(1);
- return Arrays.asList(serviceRecipe);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- ServiceRecipe serviceRecipe = cd.getServiceRecipeByServiceModelUuid("123","tetwe");
- assertEquals(1, serviceRecipe.getId());
-
- serviceRecipe = cd.getServiceRecipeByServiceModelUuid("123", null);
- assertEquals(1, serviceRecipe.getId());
- }
-
- @Test
- public void getServiceRecipeByServiceModelUuidEmptyTest() {
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<ServiceRecipe> list() throws Exception {
- return Arrays.asList();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- ServiceRecipe serviceRecipe = cd.getServiceRecipeByServiceModelUuid("123","tetwe");
- assertEquals(null, serviceRecipe);
-
-
- }
-
- @Test
- public void getServiceRecipesTestException() throws Exception{
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<ServiceRecipe> list() {
- ServiceRecipe serviceRecipe = new ServiceRecipe();
- serviceRecipe.setId(1);
- return Arrays.asList(serviceRecipe);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- List<ServiceRecipe> serviceRecipes = cd.getServiceRecipes("123");
- assertEquals(1, serviceRecipes.size());
-
-
- }
-
- @Test
- public void getServiceRecipesEmptyTest() throws Exception{
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<ServiceRecipe> list() {
- return Arrays.asList();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- List<ServiceRecipe> serviceRecipes = cd.getServiceRecipes("123");
- assertEquals(0, serviceRecipes.size());
-
-
- }
-
- @Test
- public void getVnfComponentTest() throws Exception{
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- VnfComponent vnfComponent = new VnfComponent();
- vnfComponent.setHeatTemplateId(1234);
- return vnfComponent;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VnfComponent ht = cd.getVnfComponent(123,"vnf");
- assertEquals(new Integer(1234), ht.getHeatTemplateId());
- }
-
- @Test
- public void getVnfComponentNullTest() throws Exception{
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- return null;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VnfComponent ht = cd.getVnfComponent(123,"vnf");
- assertNull(ht);
- }
-
- @Test
- public void getVnfComponentNonUniqueTest() throws Exception{
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- throw new org.hibernate.NonUniqueResultException(2);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- VnfComponent ht = cd.getVnfComponent(123,"vnf");
- }
-
- @Test
- public void getVnfComponentHibernateExceptionTest() throws Exception{
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- throw new org.hibernate.HibernateException("test case");
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- thrown.expect(org.hibernate.HibernateException.class);
- VnfComponent ht = cd.getVnfComponent(123,"vnf");
- }
-
- @Test
- public void getVnfComponentExceptionTest() throws Exception{
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- throw new NullPointerException();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- thrown.expect(NullPointerException.class);
- VnfComponent ht = cd.getVnfComponent(123,"vnf");
- }
-
- @Test
- public void getVnfResourceTest() throws Exception{
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VnfResource> list() {
- VnfResource vnfResource = new VnfResource();
- vnfResource.setModelUuid("123-uuid");
- return Arrays.asList(vnfResource);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- VnfResource vnfResource = cd.getVnfResourceByType("vnf");
- assertEquals("123-uuid", vnfResource.getModelUuid());
-
-
- }
-
- @Test
- public void getVnfResourceEmptyTest() throws Exception{
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VnfResource> list() {
- return Arrays.asList();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- VnfResource vnfResource = cd.getVnfResourceByType("vnf");
- assertEquals(null, vnfResource);
-
-
- }
-
- @Test
- public void getVnfResourceByTypeTest() {
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() {
- VnfResource vnfResource = new VnfResource();
- vnfResource.setModelUuid("123-uuid");
- return vnfResource;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- VnfResource vnfResource = cd.getVnfResource("vnf","3992");
- assertEquals("123-uuid", vnfResource.getModelUuid());
-
-
- }
-
- @Test
- public void getVnfResourceNURExceptionTest() {
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() {
- throw new NonUniqueResultException(-1);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(NonUniqueResultException.class);
- VnfResource vnfResource = cd.getVnfResource("vnf","3992");
-
-
- }
-
- @Test
- public void getVnfResourceHibernateExceptionTest() {
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() {
- throw new HibernateException("hibernate exception");
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(HibernateException.class);
- VnfResource vnfResource = cd.getVnfResource("vnf","3992");
-
-
- }
-
- @Test
- public void getVnfResourceExceptionTest() {
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new Exception();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(Exception.class);
- VnfResource vnfResource = cd.getVnfResource("vnf","3992");
-
-
- }
-
- @Test
- public void getVnfResourceByModelCustomizationIdTest() {
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- VnfResource vnfResource = new VnfResource();
- vnfResource.setModelUuid("123-uuid");
- return vnfResource;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VnfResource vnfResource = cd.getVnfResourceByModelCustomizationId("3992");
- assertEquals("123-uuid",vnfResource.getModelUuid());
-
-
- }
-
- @Test
- public void getVnfResourceByModelCustomizationIdNullTest() {
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public Object uniqueResult() throws Exception {
- return null;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VnfResource vnfResource = cd.getVnfResourceByModelCustomizationId("3992");
- assertNull(vnfResource);
- }
-
- @Test
- public void getVnfResourceByModelCustomizationIdNURExceptionTest() {
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new NonUniqueResultException(-1);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(NonUniqueResultException.class);
- VnfResource vnfResource = cd.getVnfResourceByModelCustomizationId("3992");
-
-
- }
-
- @Test
- public void getVnfResourceByModelCustomizationIdHibernateExceptionTest() {
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new HibernateException("hibernate exception");
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(HibernateException.class);
- VnfResource vnfResource = cd.getVnfResourceByModelCustomizationId("3992");
- }
-
- @Test
- public void getVnfResourceByModelCustomizationIdExceptionTest() {
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new NullPointerException();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(NullPointerException.class);
- VnfResource vnfResource = cd.getVnfResourceByModelCustomizationId("3992");
- }
-
-
- @Test
- public void getServiceRecipeTest2() throws Exception{
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List <ServiceRecipe> list() throws Exception {
- ServiceRecipe serviceRecipe = new ServiceRecipe();
- serviceRecipe.setServiceModelUUID("123-uuid");
- return Arrays.asList(serviceRecipe);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- ServiceRecipe ht = cd.getServiceRecipe(1001,"3992");
- assertEquals("123-uuid", ht.getServiceModelUUID());
-
- ht = cd.getServiceRecipe(1001, null);
- assertEquals("123-uuid", ht.getServiceModelUUID());
-
- }
-
- @Test
- public void getServiceRecipeTest2Exception() throws Exception{
- thrown.expect(Exception.class);
- ServiceRecipe ht = cd.getServiceRecipe(1001,"3992");
- }
-
- @Test
- public void getVnfResourceCustomizationByModelCustomizationNameTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VnfResourceCustomization> list() throws Exception {
- VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
- vnfResourceCustomization.setVnfResourceModelUUID("123-uuid");
- return Arrays.asList(vnfResourceCustomization);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationName("test", "test234");
- assertEquals("123-uuid", vnf.getVnfResourceModelUUID());
-
-
- }
-
- @Test
- public void getVnfResourceCustomizationByModelCustomizationNameEmptyTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VnfResourceCustomization> list() throws Exception {
- return Arrays.asList();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelCustomizationName("test", "test234");
- assertEquals(null, vnf);
-
-
- }
-
- @Test
- public void getVnfResourceByModelInvariantIdTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult(){
- VnfResource vnfResource = new VnfResource();
- vnfResource.setModelUuid("123-uuid");
- return vnfResource;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234");
- assertEquals("123-uuid", vnf.getModelUuid());
-
-
- }
-
- @Test
- public void getVnfResourceByModelInvariantIdNURExceptionTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult(){
- throw new NonUniqueResultException(-1);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(NonUniqueResultException.class);
- VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234");
-
-
- }
-
- @Test
- public void getVnfResourceByModelInvariantIdHibernateExceptionTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult(){
- throw new HibernateException("hibernate exception");
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(HibernateException.class);
- VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234");
-
-
- }
-
- @Test
- public void getVnfResourceByModelInvariantIdExceptionTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new Exception();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(Exception.class);
- VnfResource vnf = cd.getVnfResourceByModelInvariantId("test", "test234");
-
-
- }
-
- @Test
- public void getVnfResourceByIdTestException(){
- mockUpQuery = new MockUp<Query>() {
- int id = 0;
- @Mock
- public Query setParameter(String name, Object val) {
- id = (Integer)val;
- return this.getMockInstance();
- }
-
- @Mock
- public List<VnfResource> list() throws Exception {
- if (id==0) return new ArrayList<VnfResource>();
- VnfResource vm = new VnfResource();
- vm.setModelInvariantUuid(Integer.toString(id));
- return Arrays.asList(vm);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VnfResource vnf = cd.getVnfResourceById(19299);
- assertEquals("19299", vnf.getModelInvariantUuid());
-
- vnf = cd.getVnfResourceById(0);
- assertNull(vnf);
- }
-
- @Test
- public void getVfModuleModelName(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VfModule> list() throws Exception {
- VfModule vfModule = new VfModule();
- vfModule.setModelUUID("123-uuid");
- return Arrays.asList(vfModule);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- VfModule vfModule = cd.getVfModuleModelName("vfmodule");
- assertEquals("123-uuid", vfModule.getModelUUID());
-
-
- }
-
- @Test
- public void getVfModuleModelNameExceptionTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VfModule> list() throws Exception {
- return Arrays.asList();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- VfModule vfModule = cd.getVfModuleModelName("vfmodule");
- assertEquals(null, vfModule);
-
-
- }
-
- @Test
- public void getVfModuleModelNameTest() {
- mockUpQuery = new MockUp<Query>() {
- String modelVersion = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("model_version")) modelVersion = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public Object uniqueResult() {
- if (modelVersion==null || modelVersion.equals("nil")) {
- return null;
- }
- VfModule vfModule = new VfModule();
- vfModule.setModelUUID("123-uuid");
- return vfModule;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl");
- assertEquals("123-uuid", vfModule.getModelUUID());
-
- vfModule = cd.getVfModuleModelName("tetes","nil");
- assertNull(vfModule);
- }
-
- @Test
- public void getVfModuleModelNameNURExceptionTest() {
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() {
- throw new NonUniqueResultException(-1);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(NonUniqueResultException.class);
- VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl");
-
-
- }
-
- @Test
- public void getVfModuleModelNameHibernateExceptionTest() {
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() {
- throw new HibernateException("hibernate exception");
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(HibernateException.class);
- VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl");
-
-
- }
-
- @Test
- public void getVfModuleModelNameGenericExceptionTest() {
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new Exception();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(Exception.class);
- VfModule vfModule = cd.getVfModuleModelName("tetes","4kidsl");
-
-
- }
-
- @Test
- public void ggetVfModuleCustomizationByModelNameTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VfModuleCustomization> list() throws Exception {
- VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
- vfModuleCustomization.setVfModuleModelUuid("123-uuid");
- return Arrays.asList(vfModuleCustomization);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- VfModuleCustomization vfModuleCustomization = cd.getVfModuleCustomizationByModelName("tetes");
- assertEquals("123-uuid", vfModuleCustomization.getVfModuleModelUuid());
-
-
- }
-
- @Test
- public void ggetVfModuleCustomizationByModelNameEmptyTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VfModuleCustomization> list() throws Exception {
- return Arrays.asList();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- VfModuleCustomization vfModuleCustomization = cd.getVfModuleCustomizationByModelName("tetes");
- assertEquals(null, vfModuleCustomization);
-
-
- }
-
- @Test
- public void getNetworkResourceTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<NetworkResource> list() throws Exception {
- NetworkResource networkResource = new NetworkResource();
- networkResource.setModelUUID("123-uuid");
- return Arrays.asList(networkResource);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- NetworkResource networkResource = cd.getNetworkResource("tetes");
- assertEquals("123-uuid", networkResource.getModelUUID());
-
-
- }
-
- @Test
- public void getNetworkResourceTestEmptyException(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<NetworkResource> list() throws Exception {
- return Arrays.asList();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- NetworkResource networkResource = cd.getNetworkResource("tetes");
- assertEquals(null, networkResource);
-
-
- }
-
- @Test
- public void getVnfRecipeTest(){
-
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VnfRecipe> list() throws Exception {
- VnfRecipe vnfRecipe = new VnfRecipe();
- vnfRecipe.setVfModuleId("123-id");
- return Arrays.asList(vnfRecipe);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VnfRecipe vnfRecipe = cd.getVnfRecipe("tetes","ergfedrf","4993493");
- assertEquals("123-id", vnfRecipe.getVfModuleId());
-
-
- }
-
- @Test
- public void getVnfRecipeEmptyTest(){
-
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VnfRecipe> list() throws Exception {
- return Collections.emptyList();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VnfRecipe vnfRecipe = cd.getVnfRecipe("tetes","ergfedrf","4993493");
- assertEquals(null, vnfRecipe);
-
-
- }
-
- @Test
- public void getVnfRecipe2Test(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VnfRecipe> list() throws Exception {
- VnfRecipe vnfRecipe = new VnfRecipe();
- vnfRecipe.setId(1);
- return Arrays.asList(vnfRecipe);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- VnfRecipe vnfRecipe = cd.getVnfRecipe("tetes","4993493");
- assertEquals(1, vnfRecipe.getId());
-
-
- }
-
- @Test
- public void getVnfRecipe2EmptyTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VnfRecipe> list() throws Exception {
- return Collections.emptyList();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- VnfRecipe vnfRecipe = cd.getVnfRecipe("tetes","4993493");
- assertEquals(null, vnfRecipe);
-
-
- }
-
- @Test
- public void getVnfRecipeByVfModuleIdTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VnfRecipe> list() throws Exception {
- VnfRecipe vnfRecipe = new VnfRecipe();
- vnfRecipe.setId(1);
- return Arrays.asList(vnfRecipe);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VnfRecipe vnfRecipe = cd.getVnfRecipeByVfModuleId("tetes","4993493","vnf");
- assertEquals(1, vnfRecipe.getId());
-
-
- }
-
- @Test
- public void getVnfRecipeByVfModuleIdEmptyTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VnfRecipe> list() throws Exception {
- return Collections.emptyList();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VnfRecipe vnfRecipe = cd.getVnfRecipeByVfModuleId("tetes","4993493","vnf");
- assertEquals(null, vnfRecipe);
-
-
- }
-
- @Test
- public void getVfModuleTypeTestException(){
- mockUpQuery = new MockUp<Query>() {
- String type = null;
- @Mock
- public Query setParameter(String name, Object val) {
- type = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public List<VfModule> list() {
- if ("nil".equals(type)) return new ArrayList<VfModule>();
-
- VfModule vm = new VfModule();
- vm.setModelUUID("123-uuid");
- return Arrays.asList(vm);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VfModule vnf = cd.getVfModuleType("4993493");
- assertEquals("123-uuid", vnf.getModelUUID());
-
- vnf = cd.getVfModuleType("nil");
- assertNull(vnf);
- }
-
- @Test
- public void getVnfResourceByServiceUuidTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() {
- VnfResource vnfResource = new VnfResource();
- vnfResource.setModelUuid("123-uuid");
- return vnfResource;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- VnfResource vnfResource = cd.getVnfResourceByServiceUuid("4993493");
- assertEquals("123-uuid", vnfResource.getModelUuid());
-
-
- }
-
- @Test
- public void getVnfResourceByServiceUuidNURExceptionTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() {
- throw new NonUniqueResultException(-1);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(NonUniqueResultException.class);
- VnfResource vnfResource = cd.getVnfResourceByServiceUuid("4993493");
-
-
- }
-
- @Test
- public void getVnfResourceByServiceUuidHibernateExceptionTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() {
- throw new HibernateException("hibernate exception");
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(HibernateException.class);
- VnfResource vnfResource = cd.getVnfResourceByServiceUuid("4993493");
-
-
- }
-
- @Test
- public void getVnfResourceByServiceUuidExceptionTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new Exception();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(Exception.class);
- VnfResource vnfResource = cd.getVnfResourceByServiceUuid("4993493");
-
-
- }
-
- @Test
- public void getVnfResourceByVnfUuidTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() {
- VnfResource vnfResource = new VnfResource();
- vnfResource.setModelUuid("123-uuid");
- return vnfResource;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VnfResource vnfResource = cd.getVnfResourceByVnfUuid("4993493");
- assertEquals("123-uuid", vnfResource.getModelUuid());
-
-
- }
-
- @Test
- public void getVnfResourceByVnfUuidNURExceptionTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() {
- throw new NonUniqueResultException(-1);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(NonUniqueResultException.class);
- VnfResource vnfResource = cd.getVnfResourceByVnfUuid("4993493");
-
-
- }
-
- @Test
- public void getVnfResourceByVnfUuidHibernateExceptionTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() {
- throw new HibernateException("hibernate exception");
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(HibernateException.class);
- VnfResource vnfResource = cd.getVnfResourceByVnfUuid("4993493");
-
-
- }
-
- @Test
- public void getVnfResourceByVnfUuidExceptionTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- throw new Exception();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- thrown.expect(Exception.class);
- VnfResource vnfResource = cd.getVnfResourceByVnfUuid("4993493");
-
-
- }
-
- @Test
- public void getVfModuleByModelInvariantUuidTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<VfModule> list() throws Exception {
- VfModule vfModule = new VfModule();
- vfModule.setModelUUID("123-uuid");
- return Arrays.asList(vfModule);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VfModule vfModule = cd.getVfModuleByModelInvariantUuid("4993493");
- assertEquals("123-uuid", vfModule.getModelUUID());
-
-
- }
-
- @Test
- public void getVfModuleByModelInvariantUuidEmptyTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<VfModule> list() throws Exception {
- return Collections.emptyList();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VfModule vfModule = cd.getVfModuleByModelInvariantUuid("4993493");
- assertEquals(null, vfModule);
-
-
- }
-
- @Test
- public void getVfModuleByModelCustomizationUuidTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- VfModuleCustomization vc = new VfModuleCustomization();
- vc.setModelCustomizationUuid("4993493");
- return vc;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VfModuleCustomization vnf = cd.getVfModuleByModelCustomizationUuid("4993493");
- assertEquals("4993493", vnf.getModelCustomizationUuid());
- }
-
- @Test
- public void getVfModuleByModelCustomizationUuidNullTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- return null;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VfModuleCustomization vnf = cd.getVfModuleByModelCustomizationUuid("4993493");
- assertNull(vnf);
- }
-
- @Test
- public void getVfModuleByModelCustomizationUuidNonUniqueExceptionTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- throw new org.hibernate.NonUniqueResultException(2);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- VfModuleCustomization vnf = cd.getVfModuleByModelCustomizationUuid("4993493");
- }
-
- @Test
- public void getVfModuleByModelCustomizationUuidHibernateExceptionTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- throw new org.hibernate.HibernateException("test case");
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- thrown.expect(org.hibernate.HibernateException.class);
- VfModuleCustomization vnf = cd.getVfModuleByModelCustomizationUuid("4993493");
- }
-
- @Test
- public void getVfModuleByModelCustomizationUuidExceptionTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- throw new NullPointerException();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- thrown.expect(NullPointerException.class);
- VfModuleCustomization vnf = cd.getVfModuleByModelCustomizationUuid("4993493");
- }
-
- @Test
- public void getVfModuleCustomizationByModelCustomizationIdTest(){
- mockUpQuery = new MockUp<Query>() {
- String modelCustomizationUuid = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("modelCustomizationUuid")) modelCustomizationUuid = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public Object uniqueResult() {
- if ("nil".equals(modelCustomizationUuid)) return null;
- if ("multi".equals(modelCustomizationUuid)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(modelCustomizationUuid)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(modelCustomizationUuid)) throw new NullPointerException();
-
- VfModuleCustomization vm = new VfModuleCustomization();
- vm.setModelCustomizationUuid("4993493");
- return vm;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VfModuleCustomization vnf = cd.getVfModuleCustomizationByModelCustomizationId("4993493");
- assertEquals("4993493", vnf.getModelCustomizationUuid());
-
- vnf = cd.getVfModuleCustomizationByModelCustomizationId("nil");
- assertNull(vnf);
-
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- vnf = cd.getVfModuleCustomizationByModelCustomizationId("multi");
- } catch (org.hibernate.NonUniqueResultException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.HibernateException.class);
- vnf = cd.getVfModuleCustomizationByModelCustomizationId("he");
- } catch (org.hibernate.HibernateException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(NullPointerException.class);
- vnf = cd.getVfModuleCustomizationByModelCustomizationId("npe");
- } catch (NullPointerException e) {
- // noop
- }
-
- }
-
- @Test
- public void getVfModuleByModelUuidTestException(){
- mockUpQuery = new MockUp<Query>() {
- String modelUuidValue = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("modelUuidValue")) modelUuidValue = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public List<VfModule> list() {
- if ("nil".equals(modelUuidValue)) return null;
- if ("multi".equals(modelUuidValue)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(modelUuidValue)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(modelUuidValue)) throw new NullPointerException();
-
- VfModule vfModule = new VfModule();
- vfModule.setModelInvariantUuid(modelUuidValue);
- return Arrays.asList(vfModule);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VfModule vnf = cd.getVfModuleByModelUuid("4993493");
- assertEquals("4993493", vnf.getModelInvariantUuid());
-
- vnf = cd.getVfModuleByModelUuid("nil");
- assertNull(vnf);
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- vnf = cd.getVfModuleByModelUuid("multi");
- } catch (org.hibernate.NonUniqueResultException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.HibernateException.class);
- vnf = cd.getVfModuleByModelUuid("he");
- } catch (org.hibernate.HibernateException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(NullPointerException.class);
- vnf = cd.getVfModuleByModelUuid("npe");
- } catch (NullPointerException e) {
- // noop
- }
- }
-
-
- @Test
- public void getVnfResourceCustomizationByModelVersionIdTest(){
- mockUpQuery = new MockUp<Query>() {
- String modelVersionId = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("modelVersionId")) modelVersionId = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public Object uniqueResult() {
- if ("nil".equals(modelVersionId)) return null;
- if ("multi".equals(modelVersionId)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(modelVersionId)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(modelVersionId)) throw new NullPointerException();
-
- VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
- vnfResourceCustomization.setVnfResourceModelUuid(modelVersionId);
- return vnfResourceCustomization;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- public VnfResource getVnfResourceByModelUuid(String modelUuid) {
- return new VnfResource();
- }
-
- @Mock
- public ArrayList<VfModuleCustomization> getAllVfModuleCustomizations(String vnfResourceCustomizationMCU) {
- ArrayList<VfModuleCustomization> toRet = new ArrayList<VfModuleCustomization>();
- VfModuleCustomization vmc = new VfModuleCustomization();
- toRet.add(vmc);
- return toRet;
- }
-
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VnfResourceCustomization vnf = cd.getVnfResourceCustomizationByModelVersionId("4993493");
- assertEquals("4993493", vnf.getVnfResourceModelUuid());
-
- vnf = cd.getVnfResourceCustomizationByModelVersionId("nil");
- assertNull(vnf);
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- vnf = cd.getVnfResourceCustomizationByModelVersionId("multi");
- } catch (org.hibernate.NonUniqueResultException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.HibernateException.class);
- vnf = cd.getVnfResourceCustomizationByModelVersionId("he");
- } catch (org.hibernate.HibernateException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(NullPointerException.class);
- vnf = cd.getVnfResourceCustomizationByModelVersionId("npe");
- } catch (NullPointerException e) {
- // noop
- }
- }
-
-
- @Test
- public void getVfModuleByModelCustomizationIdAndVersionTestException(){
- mockUpQuery = new MockUp<Query>() {
- String modelVersionId = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("modelVersionId")) modelVersionId = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public Object uniqueResult() {
- if ("nil".equals(modelVersionId)) return null;
- if ("multi".equals(modelVersionId)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(modelVersionId)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(modelVersionId)) throw new NullPointerException();
-
- VfModule vfModule = new VfModule();
- vfModule.setModelVersion(modelVersionId);
- return vfModule;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VfModule vm = cd.getVfModuleByModelCustomizationIdAndVersion("4993493","test");
- assertEquals("test", vm.getModelVersion());
-
- vm = cd.getVfModuleByModelCustomizationIdAndVersion("4993493", "nil");
- assertNull(vm);
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- vm = cd.getVfModuleByModelCustomizationIdAndVersion("4993493", "multi");
- } catch (org.hibernate.NonUniqueResultException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.HibernateException.class);
- vm = cd.getVfModuleByModelCustomizationIdAndVersion("4993493", "he");
- } catch (org.hibernate.HibernateException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(NullPointerException.class);
- vm = cd.getVfModuleByModelCustomizationIdAndVersion("4993493", "npe");
- } catch (NullPointerException e) {
- // noop
- }
- }
-
- @Test
- public void getVfModuleCustomizationByVnfModuleCustomizationUuidTest(){
- mockUpQuery = new MockUp<Query>() {
- String modelCustomizationUuid = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("modelCustomizationUuid")) modelCustomizationUuid = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public List<VfModuleCustomization> list() {
- if ("nil".equals(modelCustomizationUuid)) return null;
- if ("multi".equals(modelCustomizationUuid)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(modelCustomizationUuid)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(modelCustomizationUuid)) throw new NullPointerException();
-
- VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
- vfModuleCustomization.setVfModuleModelUuid(modelCustomizationUuid);
- return Arrays.asList(vfModuleCustomization);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
-
- List<VfModuleCustomization> vmcl = cd.getVfModuleCustomizationByVnfModuleCustomizationUuid("4993493");
- assertEquals(1, vmcl.size());
- assertEquals("4993493", vmcl.get(0).getVfModuleModelUuid());
-
- vmcl = cd.getVfModuleCustomizationByVnfModuleCustomizationUuid("nil");
- assertEquals(0, vmcl.size());
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.HibernateException.class);
- vmcl = cd.getVfModuleCustomizationByVnfModuleCustomizationUuid("he");
- } catch (org.hibernate.HibernateException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(NullPointerException.class);
- vmcl = cd.getVfModuleCustomizationByVnfModuleCustomizationUuid("npe");
- } catch (NullPointerException e) {
- // noop
- }
- }
-
- @Test
- public void getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionIdTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<VnfResourceCustomization> list() {
- VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- assertTrue(hql.contains("SELECT vrc FROM VnfResourceCustomization as vrc WHERE vrc.vnfResourceModelUuid IN (SELECT vr.modelUuid FROM VnfResource vr WHERE vr.modelUuid = :modelVersionId)AND vrc.modelInstanceName = :modelCustomizationName"));
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- assertNotNull(cd.getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId("modelCustomizationName","modelVersionId"));
-
- VnfResourceCustomization result = cd.getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId("4993493", "test");
- assertNotNull(result);
- }
-
- @Test
- public void getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId_NullReturnTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<VnfResourceCustomization> list() {
- return Arrays.asList();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- assertTrue(hql.contains("SELECT vrc FROM VnfResourceCustomization as vrc WHERE vrc.vnfResourceModelUuid IN (SELECT vr.modelUuid FROM VnfResource vr WHERE vr.modelUuid = :modelVersionId)AND vrc.modelInstanceName = :modelCustomizationName"));
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VnfResourceCustomization result = cd.getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId("4993493", "test");
- assertNull(result);
- }
- @Test
- public void getAllVfModuleCustomizationsStrTest(){
- mockUpQuery = new MockUp<Query>() {
- String vrcMcu = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("vrc_mcu")) vrcMcu = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public List<VnfResCustomToVfModuleCustom> list() {
- if ("nil".equals(vrcMcu)) return null;
- if ("multi".equals(vrcMcu)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(vrcMcu)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(vrcMcu)) throw new NullPointerException();
-
- VnfResCustomToVfModuleCustom vnfResCustomToVfModuleCustom = new VnfResCustomToVfModuleCustom();
- vnfResCustomToVfModuleCustom.setVfModuleCustModelCustomizationUuid(vrcMcu);
- return Arrays.asList(vnfResCustomToVfModuleCustom);
- }
-
- @Mock
- public Object uniqueResult() {
- if ("nil".equals(vrcMcu)) return null;
- if ("multi".equals(vrcMcu)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(vrcMcu)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(vrcMcu)) throw new NullPointerException();
-
- VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
- vfModuleCustomization.setVfModuleModelUuid(vrcMcu);
- return vfModuleCustomization;
- }
-
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
-
- @Mock
- public VfModule getVfModuleByModelUuid(String modelUuid) {
- return new VfModule();
- }
- };
-
- ArrayList<VfModuleCustomization> vmcl = cd.getAllVfModuleCustomizations("4993493");
- assertNotNull(vmcl);
- assertEquals(1, vmcl.size());
- assertEquals("4993493", vmcl.get(0).getVfModuleModelUuid());
-
- vmcl = cd.getAllVfModuleCustomizations("nil");
- assertNotNull(vmcl);
- assertEquals(0, vmcl.size());
-
- }
- @Test
- public void getVnfResourceByModelUuidTest(){
- mockUpQuery = new MockUp<Query>() {
- String modelUuid = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("modelUuid")) modelUuid = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public Object uniqueResult() {
- if ("nil".equals(modelUuid)) return null;
- if ("multi".equals(modelUuid)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(modelUuid)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(modelUuid)) throw new NullPointerException();
-
- VnfResource vnfResource = new VnfResource();
- vnfResource.setModelUuid(modelUuid);
- return vnfResource;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VnfResource vr = cd.getVnfResourceByModelUuid("4993493");
- assertEquals("4993493", vr.getModelUuid());
-
- vr = cd.getVnfResourceByModelUuid("nil");
- assertNull(vr);
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- vr = cd.getVnfResourceByModelUuid("multi");
- } catch (org.hibernate.NonUniqueResultException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.HibernateException.class);
- vr = cd.getVnfResourceByModelUuid("he");
- } catch (org.hibernate.HibernateException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(NullPointerException.class);
- vr = cd.getVnfResourceByModelUuid("npe");
- } catch (NullPointerException e) {
- // noop
- }
- }
-
- @Test
- public void getVnfResCustomToVfModuleTest(){
- mockUpQuery = new MockUp<Query>() {
- String vfIdValue = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("vfIdValue")) vfIdValue = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public Object uniqueResult() {
- if ("nil".equals(vfIdValue)) return null;
- if ("multi".equals(vfIdValue)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(vfIdValue)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(vfIdValue)) throw new NullPointerException();
-
- VnfResCustomToVfModuleCustom vr = new VnfResCustomToVfModuleCustom();
- vr.setVfModuleCustModelCustomizationUuid(vfIdValue);
- return vr;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VnfResCustomToVfModuleCustom vm = cd.getVnfResCustomToVfModule("4993493","test");
- assertEquals("test", vm.getVfModuleCustModelCustomizationUuid());
-
- vm = vm = cd.getVnfResCustomToVfModule("4993493", "nil");
- assertNull(vm);
- }
-
- @Test
- public void getVfModulesForVnfResourceTest(){
- VnfResource vnfResource = new VnfResource();
- vnfResource.setModelUuid("48839");
- thrown.expect(Exception.class);
- cd.getVfModulesForVnfResource(vnfResource);
- }
- @Test
- public void getVfModulesForVnfResource2Test(){
- mockUpQuery = new MockUp<Query>() {
- String vnfResourceModelUUId = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("vnfResourceModelUUId")) vnfResourceModelUUId = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public List<VfModule> list() {
- if ("nil".equals(vnfResourceModelUUId)) return null;
- if ("multi".equals(vnfResourceModelUUId)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(vnfResourceModelUUId)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(vnfResourceModelUUId)) throw new NullPointerException();
-
- VfModule vfModule = new VfModule();
- vfModule.setVnfResourceModelUUId(vnfResourceModelUUId);
- return Arrays.asList(vfModule);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- List<VfModule> vm = cd.getVfModulesForVnfResource("4993493");
- assertNotNull(vm);
- assertEquals(1, vm.size());
- assertEquals("4993493", vm.get(0).getVnfResourceModelUUId());
-
- vm = cd.getVfModulesForVnfResource("nil");
- assertNotNull(vm);
- assertEquals(0, vm.size());
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.HibernateException.class);
- cd.getVfModulesForVnfResource("he");
- } catch (org.hibernate.HibernateException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(NullPointerException.class);
- cd.getVfModulesForVnfResource("npe");
- } catch (NullPointerException e) {
- // noop
- }
- }
-
- @Test
- public void getServiceByUuidTest(){
- mockUpQuery = new MockUp<Query>() {
- String serviceModelInvariantUuid = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("serviceModelInvariantUuid")) serviceModelInvariantUuid = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public Object uniqueResult() {
- if ("nil".equals(serviceModelInvariantUuid)) return null;
- if ("multi".equals(serviceModelInvariantUuid)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(serviceModelInvariantUuid)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(serviceModelInvariantUuid)) throw new NullPointerException();
-
- Service service = new Service();
- service.setModelInvariantUUID(serviceModelInvariantUuid);
- return service;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- Service s = cd.getServiceByUuid("4993493");
- assertEquals("4993493", s.getModelInvariantUUID());
-
- s = cd.getServiceByUuid("nil");
- assertNull(s);
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- s = cd.getServiceByUuid("multi");
- } catch (org.hibernate.NonUniqueResultException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.HibernateException.class);
- s = cd.getServiceByUuid("he");
- } catch (org.hibernate.HibernateException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(NullPointerException.class);
- s = cd.getServiceByUuid("npe");
- } catch (NullPointerException e) {
- // noop
- }
-
-
- thrown.expect(Exception.class);
- cd.getServiceByUuid("4993493");
- }
-
- @Test
- public void getNetworkResourceById2Test(){
- mockUpQuery = new MockUp<Query>() {
- Integer id = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("id")) id = (Integer)val;
- return this.getMockInstance();
- }
-
- @Mock
- public Object uniqueResult() {
- if (id==null || -1 == id) return null;
- if (-2 == id) throw new org.hibernate.NonUniqueResultException(2);
- if (-3 == id) throw new org.hibernate.HibernateException("test case");
- if (-4 == id) throw new NullPointerException();
-
- NetworkResource networkResource = new NetworkResource();
- networkResource.setModelUUID(Integer.toString(id));
- return networkResource;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- NetworkResource nr = cd.getNetworkResourceById(4993493);
- assertEquals("4993493", nr.getModelUUID());
-
- nr = cd.getNetworkResourceById(-1);
- assertNull(nr);
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- nr = cd.getNetworkResourceById(-2);
- } catch (org.hibernate.NonUniqueResultException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.HibernateException.class);
- nr = cd.getNetworkResourceById(-3);
- } catch (org.hibernate.HibernateException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(NullPointerException.class);
- nr = cd.getNetworkResourceById(-4);
- } catch (NullPointerException e) {
- // noop
- }
- }
-
- @Test
- public void getNetworkResourceByIdTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- VfModule vm = new VfModule();
- vm.setModelInvariantUuid("4993493");
- return vm;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VfModule vm = cd.getVfModuleTypeByUuid("4993493");
- assertEquals("4993493", vm.getModelInvariantUuid());
- }
-
- @Test
- public void getNetworkResourceByIdNullTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- return null;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VfModule vm = cd.getVfModuleTypeByUuid("4993493");
- assertNull(null);
- }
-
- @Test
- public void getNetworkResourceByIdNonUniqueTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- throw new org.hibernate.NonUniqueResultException(2);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- VfModule vm = cd.getVfModuleTypeByUuid("4993493");
- }
-
- @Test
- public void getNetworkResourceByIdHibernateExceptionTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- throw new org.hibernate.HibernateException("test case");
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- thrown.expect(org.hibernate.HibernateException.class);
- VfModule vm = cd.getVfModuleTypeByUuid("4993493");
- }
-
- @Test
- public void getNetworkResourceByIdExceptionTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public Object uniqueResult() {
- throw new NullPointerException();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- thrown.expect(NullPointerException.class);
- VfModule vm = cd.getVfModuleTypeByUuid("4993493");
- }
-
- @Test
- public void isEmptyOrNullTest(){
- boolean is = cd.isEmptyOrNull("4993493");
- assertFalse(is);
- }
- @Test
- public void getSTRTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<ServiceToResourceCustomization> list() {
- ServiceToResourceCustomization vnfResourceCustomization = new ServiceToResourceCustomization();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- List<ServiceToResourceCustomization> str = cd.getSTR("4993493", "test", "vnf");
- assertFalse(str.isEmpty());
-
- }
- @Test
- public void getVRCtoVFMCTest(){
- mockUpQuery = new MockUp<Query>() {
- String vrcMcu = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("vrc_mcu")) vrcMcu = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public List<VnfResCustomToVfModuleCustom> list() {
- if ("nil".equals(vrcMcu)) return null;
- if ("multi".equals(vrcMcu)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(vrcMcu)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(vrcMcu)) throw new NullPointerException();
-
- VnfResCustomToVfModuleCustom vnfResCustomToVfModuleCustom = new VnfResCustomToVfModuleCustom();
- vnfResCustomToVfModuleCustom.setVfModuleCustModelCustomizationUuid(vrcMcu);
- return Arrays.asList(vnfResCustomToVfModuleCustom);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- List<VnfResCustomToVfModuleCustom> vrCtoVFMC = cd.getVRCtoVFMC("", "null");
- assertNull(vrCtoVFMC);
-
- vrCtoVFMC = cd.getVRCtoVFMC("4993493", "388492");
- assertNotNull(vrCtoVFMC);
- assertEquals(1, vrCtoVFMC.size());
- assertEquals("4993493", vrCtoVFMC.get(0).getVfModuleCustModelCustomizationUuid());
-
- vrCtoVFMC = cd.getVRCtoVFMC("nil", "388492");
- assertNotNull(vrCtoVFMC);
- assertEquals(0, vrCtoVFMC.size());
-
- }
- @Test
- public void getTempNetworkHeatTemplateLookupTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<TempNetworkHeatTemplateLookup> list() {
- TempNetworkHeatTemplateLookup vnfResourceCustomization = new TempNetworkHeatTemplateLookup();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- List<TempNetworkHeatTemplateLookup> tempNetworkHeatTemplateLookup = cd.getTempNetworkHeatTemplateLookup("4993493");
- assertFalse(tempNetworkHeatTemplateLookup.isEmpty());
- }
-
- @Test
- public void getAllNetworksByServiceModelUuidTest(){
- mockUpQuery = new MockUp<Query>() {
- String smu = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("smu")) smu = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public List<ServiceToResourceCustomization> list() {
- if ("nil".equals(smu)) return null;
- if ("multi".equals(smu)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(smu)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(smu)) throw new NullPointerException();
-
- ServiceToResourceCustomization src = new ServiceToResourceCustomization();
- src.setServiceModelUUID(smu);
- return Arrays.asList(src);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
-
- @Mock
- public List<NetworkResourceCustomization> getAllNetworksByNetworkModelCustomizationUuid(String networkModelCustomizationUuid) {
- NetworkResourceCustomization nrc = new NetworkResourceCustomization();
- nrc.setNetworkResourceModelUuid(networkModelCustomizationUuid);
- return Arrays.asList(nrc);
- }
- };
-
- List<NetworkResourceCustomization> nrcl = cd.getAllNetworksByServiceModelUuid("4993493");
- assertNotNull(nrcl);
- assertEquals(1, nrcl.size());
-
- nrcl = cd.getAllNetworksByServiceModelUuid("nil");
- assertNotNull(nrcl);
- assertEquals(0, nrcl.size());
-/*
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- vm = cd.getVfModuleType("type", "multi");
- } catch (org.hibernate.NonUniqueResultException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.HibernateException.class);
- vm = cd.getVfModuleType("type", "he");
- } catch (org.hibernate.HibernateException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(NullPointerException.class);
- vm = cd.getVfModuleType("type", "npe");
- } catch (NullPointerException e) {
- // noop
- }
-
- assertEquals(cd.getAllNetworksByServiceModelUuid("4993493").size(), 0);
- */
- }
-
- @Test
- public void getAllNetworksByServiceModelInvariantUuidTest(){
- mockUpQuery = new MockUp<Query>() {
- String serviceModelInvariantUuid = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("serviceModelInvariantUuid")) serviceModelInvariantUuid = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public List<Service> list() {
- if ("nil".equals(serviceModelInvariantUuid)) return new ArrayList<Service>();
- if ("multi".equals(serviceModelInvariantUuid)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(serviceModelInvariantUuid)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(serviceModelInvariantUuid)) throw new NullPointerException();
-
- Service nrc = new Service();
- nrc.setModelInvariantUUID(serviceModelInvariantUuid);
- nrc.setModelUUID(serviceModelInvariantUuid);
- return Arrays.asList(nrc);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
-
- @Mock
- public List<NetworkResourceCustomization> getAllNetworksByServiceModelUuid(String serviceModelUuid) {
- NetworkResourceCustomization nrc = new NetworkResourceCustomization();
- nrc.setNetworkResourceModelUuid(serviceModelUuid);
- return Arrays.asList(nrc);
- }
- };
-
- List<NetworkResourceCustomization> nrcl = cd.getAllNetworksByServiceModelInvariantUuid("4993493");
- assertNotNull(nrcl);
- assertEquals(1, nrcl.size());
- assertEquals("4993493", nrcl.get(0).getNetworkResourceModelUuid());
-
- nrcl = cd.getAllNetworksByServiceModelInvariantUuid("nil");
- assertNotNull(nrcl);
- assertEquals(0, nrcl.size());
- }
- @Test
- public void getAllNetworksByServiceModelInvariantUuid2Test(){
- mockUpQuery = new MockUp<Query>() {
- String serviceModelInvariantUuid = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("serviceModelInvariantUuid")) serviceModelInvariantUuid = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public List<Service> list() {
- if ("nil".equals(serviceModelInvariantUuid)) return new ArrayList<Service>();
- if ("multi".equals(serviceModelInvariantUuid)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(serviceModelInvariantUuid)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(serviceModelInvariantUuid)) throw new NullPointerException();
-
- Service service = new Service();
- service.setModelInvariantUUID(serviceModelInvariantUuid);
- service.setModelUUID(serviceModelInvariantUuid);
- return Arrays.asList(service);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
-
- @Mock
- public List<NetworkResourceCustomization> getAllNetworksByServiceModelUuid(String serviceModelUuid) {
- NetworkResourceCustomization nrc = new NetworkResourceCustomization();
- nrc.setModelCustomizationUuid(serviceModelUuid);
- return Arrays.asList(nrc);
- }
- };
-
- List<NetworkResourceCustomization> nrcl = cd.getAllNetworksByServiceModelInvariantUuid("4993493","test");
- assertNotNull(nrcl);
- assertEquals(1, nrcl.size());
- assertEquals("4993493", nrcl.get(0).getModelCustomizationUuid());
-
- nrcl = cd.getAllNetworksByServiceModelInvariantUuid("nil","test");
- assertNotNull(nrcl);
- assertEquals(0, nrcl.size());
- }
-
- @Test
- public void getAllNetworksByNetworkModelCustomizationUuidTest(){
- mockUpQuery = new MockUp<Query>() {
- String networkModelCustomizationUuid = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("networkModelCustomizationUuid")) networkModelCustomizationUuid = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public List<NetworkResourceCustomization> list() {
- if ("nil".equals(networkModelCustomizationUuid)) return new ArrayList<NetworkResourceCustomization>();
- if ("multi".equals(networkModelCustomizationUuid)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(networkModelCustomizationUuid)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(networkModelCustomizationUuid)) throw new NullPointerException();
-
- NetworkResourceCustomization nrc = new NetworkResourceCustomization();
- nrc.setNetworkResourceModelUuid(networkModelCustomizationUuid);
- return Arrays.asList(nrc);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
-
- @Mock
- public NetworkResource getNetworkResourceById(String id) {
- NetworkResource nr = new NetworkResource ();
- return nr;
- }
- };
-
- List<NetworkResourceCustomization> nrcl = cd.getAllNetworksByNetworkModelCustomizationUuid("4993493");
- assertNotNull(nrcl);
- assertEquals(1, nrcl.size());
- assertEquals("4993493", nrcl.get(0).getNetworkResourceModelUuid());
-
- nrcl = cd.getAllNetworksByNetworkModelCustomizationUuid("nil");
- assertNotNull(nrcl);
- assertEquals(0, nrcl.size());
- }
-
- @Test
- public void getAllNetworksByNetworkTypeTest(){
- mockUpQuery = new MockUp<Query>() {
- String networkResourceId = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("networkResourceId")) networkResourceId = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public List<NetworkResourceCustomization> list() {
- if ("nil".equals(networkResourceId)) return null;
- if ("multi".equals(networkResourceId)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(networkResourceId)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(networkResourceId)) throw new NullPointerException();
-
- NetworkResourceCustomization nrc = new NetworkResourceCustomization();
- nrc.setNetworkResourceModelUuid(networkResourceId);
- return Arrays.asList(nrc);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
-
- @Mock
- public NetworkResource getNetworkResource(String networkType) {
- if ("nil".equals(networkType)) return null;
-
- NetworkResource nr = new NetworkResource();
- nr.setNeutronNetworkType(networkType);
- return nr;
- }
- };
-
- List<NetworkResourceCustomization> nrcl = cd.getAllNetworksByNetworkType("4993493");
- assertNotNull(nrcl);
- assertEquals(1, nrcl.size());
- assertEquals("4993493", nrcl.get(0).getNetworkType());
-
- nrcl = cd.getAllNetworksByNetworkType("nil");
- assertNotNull(nrcl);
- assertEquals(0, nrcl.size());
- }
- @Test
- public void getAllVfmcForVrcTest(){
- VnfResourceCustomization re = new VnfResourceCustomization();
- re.setModelCustomizationUuid("377483");
- thrown.expect(Exception.class);
- cd.getAllVfmcForVrc(re);
- }
- @Test
- public void getAllVnfsByServiceModelUuidTest(){
- thrown.expect(Exception.class);
- cd.getAllVnfsByServiceModelUuid("4993493");
- }
- @Test
- public void getAllVnfsByServiceModelInvariantUuidTest(){
- thrown.expect(Exception.class);
- cd.getAllVnfsByServiceModelInvariantUuid("4993493");
- }
- @Test
- public void getAllVnfsByServiceModelInvariantUuid2Test(){
- thrown.expect(Exception.class);
- cd.getAllVnfsByServiceModelInvariantUuid("4993493","test");
- }
- @Test
- public void getAllVnfsByServiceNameTest(){
- thrown.expect(Exception.class);
- cd.getAllVnfsByServiceName("4993493","test");
- }
- @Test
- public void getAllVnfsByServiceName2Test(){
- thrown.expect(Exception.class);
- cd.getAllVnfsByServiceName("4993493");
- }
- @Test
- public void getAllVnfsByVnfModelCustomizationUuidTest(){
- thrown.expect(Exception.class);
- cd.getAllVnfsByVnfModelCustomizationUuid("4993493");
- }
- @Test
- public void getAllAllottedResourcesByServiceModelUuidTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<ServiceToResourceCustomization> list() {
- ServiceToResourceCustomization vnfResourceCustomization = new ServiceToResourceCustomization();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
- mockUpQuery2 = new MockUp<Query>() {
-
- @Mock
- public List<AllottedResourceCustomization> list() {
- AllottedResourceCustomization vnfResourceCustomization = new AllottedResourceCustomization();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
- mockUpQuery3 = new MockUp<Query>() {
-
- @Mock
- public List<AllottedResource> list() {
- AllottedResource vnfResourceCustomization = new AllottedResource();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- if(hql.contains("ServiceToResourceCustomization")){
- return mockUpQuery.getMockInstance();
-
- }else if(hql.contains("AllottedResource " )){
- return mockUpQuery3.getMockInstance();
-
- } else{
- return mockUpQuery2.getMockInstance();
- }
-
-
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- List<AllottedResourceCustomization> allAllottedResourcesByServiceModelUuid = cd.getAllAllottedResourcesByServiceModelUuid("4993493");
- assertFalse(allAllottedResourcesByServiceModelUuid.isEmpty());
- }
- @Test
- public void getAllAllottedResourcesByServiceModelInvariantUuidTest(){
- thrown.expect(Exception.class);
- cd.getAllAllottedResourcesByServiceModelInvariantUuid("4993493");
- }
- @Test
- public void getAllAllottedResourcesByServiceModelInvariantUuid2Test(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<ServiceToResourceCustomization> list() {
- ServiceToResourceCustomization vnfResourceCustomization = new ServiceToResourceCustomization();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
- mockUpQuery2 = new MockUp<Query>() {
-
- @Mock
- public List<AllottedResourceCustomization> list() {
- AllottedResourceCustomization vnfResourceCustomization = new AllottedResourceCustomization();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
- mockUpQuery3 = new MockUp<Query>() {
-
- @Mock
- public List<AllottedResource> list() {
- AllottedResource vnfResourceCustomization = new AllottedResource();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
- mockUpQuery4 = new MockUp<Query>() {
-
- @Mock
- public List<Service> list() {
- Service vnfResourceCustomization = new Service();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- if(hql.contains("ServiceToResourceCustomization")){
- return mockUpQuery.getMockInstance();
-
- }else if(hql.contains("AllottedResource " )){
- return mockUpQuery3.getMockInstance();
-
- } else if(hql.contains(" Service ")){
- return mockUpQuery4.getMockInstance();
- }else{
- return mockUpQuery2.getMockInstance();
- }
-
-
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
-
- List<AllottedResourceCustomization> allottedResourceCustomizations = cd.getAllAllottedResourcesByServiceModelInvariantUuid("4993493", "test");
- assertFalse(allottedResourceCustomizations.isEmpty());
- }
- @Test
- public void getAllAllottedResourcesByArModelCustomizationUuidTest(){
- thrown.expect(Exception.class);
- cd.getAllAllottedResourcesByArModelCustomizationUuid("4993493");
- }
- @Test
- public void getAllottedResourceByModelUuidTest(){
- thrown.expect(Exception.class);
- cd.getAllottedResourceByModelUuid("4993493");
- }
- @Test
- public void getAllResourcesByServiceModelUuidTest(){
- thrown.expect(Exception.class);
- cd.getAllResourcesByServiceModelUuid("4993493");
- }
- @Test
- public void getAllResourcesByServiceModelInvariantUuidTest(){
- thrown.expect(Exception.class);
- cd.getAllResourcesByServiceModelInvariantUuid("4993493");
- }
-
- @Test
- public void getAllResourcesByServiceModelInvariantUuid2Test(){
- thrown.expect(Exception.class);
- cd.getAllResourcesByServiceModelInvariantUuid("4993493","test");
- }
- @Test
- public void getSingleNetworkByModelCustomizationUuidTest(){
- thrown.expect(Exception.class);
- cd.getSingleNetworkByModelCustomizationUuid("4993493");
- }
- @Test
- public void getSingleAllottedResourceByModelCustomizationUuidTest(){
- thrown.expect(Exception.class);
- cd.getSingleAllottedResourceByModelCustomizationUuid("4993493");
- }
- @Test
- public void getVfModuleRecipeTest(){
- thrown.expect(Exception.class);
- cd.getVfModuleRecipe("4993493","test","get");
- }
- @Test
- public void getVfModuleTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<VfModule> list() {
- VfModule vnfResourceCustomization = new VfModule();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- List<VfModule> vfModule = cd.getVfModule("4993493", "test", "get", "v2", "vnf");
- assertFalse(vfModule.isEmpty());
- }
- @Test
- public void getVnfComponentsRecipeTest(){
- thrown.expect(Exception.class);
- cd.getVnfComponentsRecipe("4993493","test","v2","vnf","get","3992");
- }
- @Test
- public void getVnfComponentsRecipeByVfModuleTest(){
- List <VfModule> resultList = new ArrayList<>();
- VfModule m = new VfModule();
- resultList.add(m);
- thrown.expect(Exception.class);
- cd.getVnfComponentsRecipeByVfModule(resultList,"4993493");
- }
- @Test
- public void getAllVnfResourcesTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<VnfResource> list() {
- VnfResource vnfResourceCustomization = new VnfResource();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- assertTrue(hql.contains("FROM VnfResource"));
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- List<VnfResource> allVnfResources = cd.getAllVnfResources();
- assertFalse(allVnfResources.isEmpty());
- }
- @Test
- public void getVnfResourcesByRoleTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<VnfResource> list() {
- VnfResource vnfResourceCustomization = new VnfResource();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- assertTrue(hql.contains("FROM VnfResource WHERE vnfRole = :vnfRole"));
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- List<VnfResource> vnfResourcesByRole = cd.getVnfResourcesByRole("4993493");
- assertFalse(vnfResourcesByRole.isEmpty());
- }
- @Test
- public void getVnfResourceCustomizationsByRoleTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<VnfResourceCustomization> list() {
- VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- assertTrue(hql.contains("FROM VnfResourceCustomization WHERE nfRole = :vnfRole"));
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- List<VnfResourceCustomization> vnfResourceCustomizationsByRole = cd.getVnfResourceCustomizationsByRole("4993493");
- assertFalse(vnfResourceCustomizationsByRole.isEmpty());
- }
- @Test
- public void getAllNetworkResourcesTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<NetworkResource> list() {
- NetworkResource vnfResourceCustomization = new NetworkResource();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- assertTrue(hql.contains("FROM NetworkResource"));
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- List<NetworkResource> allNetworkResources = cd.getAllNetworkResources();
- assertFalse(allNetworkResources.isEmpty());
- }
- @Test
- public void getAllNetworkResourceCustomizationsTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<NetworkResourceCustomization> list() {
- NetworkResourceCustomization vnfResourceCustomization = new NetworkResourceCustomization();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- assertTrue(hql.contains("FROM NetworkResourceCustomization"));
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- List<NetworkResourceCustomization> allNetworkResourceCustomizations = cd.getAllNetworkResourceCustomizations();
- assertFalse(allNetworkResourceCustomizations.isEmpty());
- }
- @Test
- public void getAllVfModulesTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<VfModule> list() {
- VfModule vnfResourceCustomization = new VfModule();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- assertTrue(hql.contains("FROM VfModule"));
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- List<VfModule> allVfModules = cd.getAllVfModules();
- assertFalse(allVfModules.isEmpty());
- }
- @Test
- public void getAllVfModuleCustomizationsTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<VfModuleCustomization> list() {
- VfModuleCustomization vnfResourceCustomization = new VfModuleCustomization();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- assertTrue(hql.contains("FROM VfModuleCustomization"));
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- List<VfModuleCustomization> allVfModuleCustomizations = cd.getAllVfModuleCustomizations();
- assertFalse(allVfModuleCustomizations.isEmpty());
- }
- @Test
- public void getAllHeatEnvironmentTest(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<HeatEnvironment> list() {
- HeatEnvironment vnfResourceCustomization = new HeatEnvironment();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- assertTrue(hql.contains("FROM HeatEnvironment"));
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- List<HeatEnvironment> allHeatEnvironment = cd.getAllHeatEnvironment();
- assertFalse(allHeatEnvironment.isEmpty());
- }
- @Test
- public void getHeatEnvironment2Test(){
- thrown.expect(Exception.class);
- cd.getHeatEnvironment(4993493);
- }
- @Test
- public void getNestedTemplatesTest(){
- thrown.expect(Exception.class);
- cd.getNestedTemplates(4993493);
- }
- @Test
- public void getNestedTemplates2Test(){
- thrown.expect(Exception.class);
- cd.getNestedTemplates("4993493");
- }
- @Test
- public void getHeatFilesTest(){
- thrown.expect(Exception.class);
- cd.getHeatFiles(4993493);
- }
- @Test
- public void getVfModuleToHeatFilesEntryTest(){
- thrown.expect(Exception.class);
- cd.getVfModuleToHeatFilesEntry("4993493","49959499");
- }
- @Test
- public void getServiceToResourceCustomization(){
- thrown.expect(Exception.class);
- cd.getServiceToResourceCustomization("4993493","599349","49900");
- }
- @Test
- public void getHeatFilesForVfModuleTest(){
- thrown.expect(Exception.class);
- cd.getHeatFilesForVfModule("4993493");
- }
- @Test
- public void getHeatTemplateTest(){
- thrown.expect(Exception.class);
- cd.getHeatTemplate("4993493","test","heat");
- }
-
- @Test
- public void saveHeatTemplateTest(){
- HeatTemplate heat = new HeatTemplate();
- Set <HeatTemplateParam> paramSet = new HashSet<>();
- thrown.expect(Exception.class);
- cd.saveHeatTemplate(heat,paramSet);
- }
- @Test
- public void getHeatEnvironmentTest(){
-
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public Object uniqueResult() throws Exception {
- return null;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- assertEquals(cd.getHeatEnvironment("4993493","test","heat"), null);
- }
- @Test
- public void getHeatEnvironment3Test(){
- thrown.expect(Exception.class);
- cd.getHeatEnvironment("4993493","test");
- }
- @Test
- public void saveHeatEnvironmentTest(){
- HeatEnvironment en = new HeatEnvironment();
- thrown.expect(Exception.class);
- cd.saveHeatEnvironment(en);
- }
- @Test
- public void saveHeatTemplate2Test(){
- HeatTemplate heat = new HeatTemplate();
- thrown.expect(Exception.class);
- cd.saveHeatTemplate(heat);
- }
- @Test
- public void saveHeatFileTest(){
- HeatFiles hf = new HeatFiles();
- thrown.expect(Exception.class);
- cd.saveHeatFile(hf);
- }
- @Test
- public void saveVnfRecipeTest(){
- VnfRecipe vr = new VnfRecipe();
- thrown.expect(Exception.class);
- cd.saveVnfRecipe(vr);
- }
- @Test
- public void saveVnfComponentsRecipe(){
- VnfComponentsRecipe vr = new VnfComponentsRecipe();
- thrown.expect(Exception.class);
- cd.saveVnfComponentsRecipe(vr);
- }
- @Test
- public void saveOrUpdateVnfResourceTest(){
- VnfResource vr = new VnfResource();
- thrown.expect(Exception.class);
- cd.saveOrUpdateVnfResource(vr);
- }
- @Test
- public void saveVnfResourceCustomizationTest(){
- VnfResourceCustomization vr = new VnfResourceCustomization();
- thrown.expect(Exception.class);
- cd.saveVnfResourceCustomization(vr);
- }
- @Test
- public void saveAllottedResourceCustomizationTest(){
- AllottedResourceCustomization arc = new AllottedResourceCustomization();
- thrown.expect(Exception.class);
- cd.saveAllottedResourceCustomization(arc);
- }
- @Test
- public void saveAllottedResourceTest(){
- AllottedResource ar = new AllottedResource();
- thrown.expect(Exception.class);
- cd.saveAllottedResource(ar);
- }
- @Test
- public void saveNetworkResourceTest() throws RecordNotFoundException {
- NetworkResource nr = new NetworkResource();
- thrown.expect(Exception.class);
- cd.saveNetworkResource(nr);
- }
- @Test
- public void saveToscaCsarTest()throws RecordNotFoundException {
- ToscaCsar ts = new ToscaCsar();
- thrown.expect(Exception.class);
- cd.saveToscaCsar(ts);
- }
- @Test
- public void getToscaCsar(){
- thrown.expect(Exception.class);
- cd.getToscaCsar("4993493");
- }
- @Test
- public void saveTempNetworkHeatTemplateLookupTest(){
- TempNetworkHeatTemplateLookup t = new TempNetworkHeatTemplateLookup();
- thrown.expect(Exception.class);
- cd.saveTempNetworkHeatTemplateLookup(t);
- }
- @Test
- public void saveVnfResourceToVfModuleCustomizationTest() throws RecordNotFoundException {
- VnfResourceCustomization v =new VnfResourceCustomization();
- VfModuleCustomization vm = new VfModuleCustomization();
- thrown.expect(Exception.class);
- cd.saveVnfResourceToVfModuleCustomization(v, vm);
- }
- @Test
- public void saveNetworkResourceCustomizationTest() throws RecordNotFoundException {
- NetworkResourceCustomization nrc = new NetworkResourceCustomization();
- thrown.expect(Exception.class);
- cd.saveNetworkResourceCustomization(nrc);
- }
-
- @Test
- public void saveServiceToNetworksTest(){
- AllottedResource ar = new AllottedResource();
- thrown.expect(Exception.class);
- cd.saveAllottedResource(ar);
- }
- @Test
- public void saveServiceToResourceCustomizationTest(){
- ServiceToResourceCustomization ar = new ServiceToResourceCustomization();
- thrown.expect(Exception.class);
- cd.saveServiceToResourceCustomization(ar);
- }
- @Test
- public void saveServiceTest(){
- Service ar = new Service();
- thrown.expect(Exception.class);
- cd.saveService(ar);
- }
- @Test
- public void saveOrUpdateVfModuleTest(){
- VfModule ar = new VfModule();
- thrown.expect(Exception.class);
- cd.saveOrUpdateVfModule(ar);
- }
- @Test
- public void saveOrUpdateVfModuleCustomizationTest(){
- VfModuleCustomization ar = new VfModuleCustomization();
- thrown.expect(Exception.class);
- cd.saveOrUpdateVfModuleCustomization(ar);
- }
-
- @Test
- public void getNestedHeatTemplateTest(){
- thrown.expect(Exception.class);
- cd.getNestedHeatTemplate(101,201);
- }
- @Test
- public void getNestedHeatTemplate2Test(){
- thrown.expect(Exception.class);
- cd.getNestedHeatTemplate("1002","1002");
- }
- @Test
- public void saveNestedHeatTemplateTest(){
- HeatTemplate ar = new HeatTemplate();
- thrown.expect(Exception.class);
- cd.saveNestedHeatTemplate("1001",ar,"test");
- }
- @Test
- public void getHeatFiles2Test(){
- VfModuleCustomization ar = new VfModuleCustomization();
- thrown.expect(Exception.class);
- cd.getHeatFiles(101,"test","1001","v2");
- }
- @Test
- public void getHeatFiles3Test(){
- VfModuleCustomization ar = new VfModuleCustomization();
- thrown.expect(Exception.class);
- cd.getHeatFiles("200192");
- }
- @Test
- public void saveHeatFilesTest(){
- HeatFiles ar = new HeatFiles();
- thrown.expect(Exception.class);
- cd.saveHeatFiles(ar);
- }
- @Test
- public void saveVfModuleToHeatFilesTest(){
- HeatFiles ar = new HeatFiles();
- thrown.expect(Exception.class);
- cd.saveVfModuleToHeatFiles("3772893",ar);
- }
- @Test
- public void getNetworkResourceByModelUuidTest(){
-
- cd.getNetworkResourceByModelUuid("3899291");
- }
- @Test
- public void getNetworkRecipeTest(){
- thrown.expect(Exception.class);
- cd.getNetworkRecipe("test","test1","test2");
- }
- @Test
- public void getNetworkRecipe2Test(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<NetworkRecipe> list() {
- NetworkRecipe heatTemplate = new NetworkRecipe();
- return Arrays.asList(heatTemplate);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- NetworkRecipe networkRecipe = cd.getNetworkRecipe("test","test1");assertNotNull(networkRecipe);
- assertNotNull(networkRecipe);
-
- }
- @Test
- public void getNetworkResourceByModelCustUuidTest(){
-
- cd.getNetworkResourceByModelCustUuid("test");
- }
-
- @Test
- public void getVnfComponentsRecipeByVfModuleModelUUIdTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VnfComponentsRecipe> list() {
- VnfComponentsRecipe heatTemplate = new VnfComponentsRecipe();
- return Arrays.asList(heatTemplate);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- VnfComponentsRecipe vnfComponentsRecipeByVfModuleModelUUId = cd.getVnfComponentsRecipeByVfModuleModelUUId("test1", "test2", "test3");
- assertNotNull(vnfComponentsRecipeByVfModuleModelUUId);
- }
- @Test
- public void getVnfComponentRecipesTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VnfComponentsRecipe> list() {
- VnfComponentsRecipe heatTemplate = new VnfComponentsRecipe();
- return Arrays.asList(heatTemplate);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- List<VnfComponentsRecipe> test = cd.getVnfComponentRecipes("test");
- assertNotNull(test);
- assertFalse(test.isEmpty());
- }
- @Test
- public void saveOrUpdateVnfComponentTest(){
- VnfComponent ar = new VnfComponent();
- thrown.expect(Exception.class);
- cd.saveOrUpdateVnfComponent(ar);
- }
-
- @Test
- public void getVfModule2Test(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VfModule> list() {
- VfModule heatTemplate = new VfModule();
- return Arrays.asList(heatTemplate);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- VfModule test = cd.getVfModule("test");
- assertNotNull(test);
- }
- @Test
- public void getVfModuleByModelUUIDTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VfModule> list() {
- VfModule heatTemplate = new VfModule();
- return Arrays.asList(heatTemplate);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VfModule test = cd.getVfModuleByModelUUID("test");
- assertNotNull(test);
- }
- @Test
- public void getServiceRecipeByModelUUIDTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<ServiceRecipe> list() {
- ServiceRecipe heatTemplate = new ServiceRecipe();
- return Arrays.asList(heatTemplate);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- Assert.assertNotNull(cd.getServiceRecipeByModelUUID("test1", "test2"));
- }
- @Test
- public void getModelRecipeTest(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<Object> list() {
- return new ArrayList();
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- Assert.assertNull(cd.getModelRecipe("test1", "test2", "test3"));
- }
- @Test
- @Ignore
- public void healthCheck(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<HeatTemplate> list() {
- HeatTemplate heatTemplate = new HeatTemplate();
- return Arrays.asList(heatTemplate);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createSQLQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
-
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- assertNotNull(cd.healthCheck());
- }
- @Test
- public void executeQuerySingleRow(){
- VnfComponent ar = new VnfComponent();
- HashMap<String, String> variables = new HashMap<>();
- thrown.expect(Exception.class);
- cd.executeQuerySingleRow("tets",variables,false);
- }
-
- @Test
- public void executeQueryMultipleRows(){
- HashMap<String, String> variables = new HashMap<>();
-
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<HeatTemplate> list() {
- HeatTemplate heatTemplate = new HeatTemplate();
- return Arrays.asList(heatTemplate);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
-
- List<Object> select = cd.executeQueryMultipleRows("select", variables, false);
- assertFalse(select.isEmpty());
- }
-
- @Test
- public void getArRecipeByNameVersion(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<ArRecipe> list() {
- ArRecipe arRecipe = new ArRecipe();
- return Arrays.asList(arRecipe);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- assertNotNull(cd.getArRecipeByNameVersion("select","variables","String"));
- }
- @Test
- public void getVnfComponentsRecipe(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<VnfComponentsRecipe> list() {
- VnfComponentsRecipe heatTemplate = new VnfComponentsRecipe();
- return Arrays.asList(heatTemplate);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- assertNotNull(cd.getVnfComponentsRecipe("vnfType","vnfComponentType","action","serviceType"));
- }
- @Test
- public void getNetworkRecipeByNameVersion(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<NetworkRecipe> list() {
- NetworkRecipe heatTemplate = new NetworkRecipe();
- return Arrays.asList(heatTemplate);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- assertNotNull(cd.getNetworkRecipeByNameVersion("modelName","modelVersion","action"));
- }
- @Test
- public void saveOrUpdateVfModuleCustomization(){
- mockUpQuery = new MockUp<Query>() {
- @Mock
- public List<NetworkRecipe> list() {
- NetworkRecipe heatTemplate = new NetworkRecipe();
- return Arrays.asList(heatTemplate);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
- vfModuleCustomization.setHeatEnvironmentArtifactUuid("HeatEnvironmentArtifactUuid");
- vfModuleCustomization.setVolEnvironmentArtifactUuid("VolEnvironmentArtifactUuid");
- vfModuleCustomization.setVfModuleModelUuid("VfModuleModelUuid");
- vfModuleCustomization.setModelCustomizationUuid("ModelCustomizationUuid");
- cd.saveOrUpdateVfModuleCustomization(vfModuleCustomization);
- }
- @Test
- public void saveServiceToNetworks(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<Service> list() {
- Service service = new Service();
- service.setModelUUID("123-uuid");
- return Arrays.asList(service);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- ServiceToNetworks serviceToNetworks = new ServiceToNetworks();
- cd.saveServiceToNetworks(serviceToNetworks);
- }
- @Test
- public void saveVfModuleToHeatFiles() {
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<Service> list() {
- Service service = new Service();
- service.setModelUUID("123-uuid");
- return Arrays.asList(service);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VfModuleToHeatFiles vfModuleToHeatFiles = new VfModuleToHeatFiles();
-
- cd.saveVfModuleToHeatFiles(vfModuleToHeatFiles);
- }
- @Test
- public void saveTempNetworkHeatTemplateLookup() {
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<Service> list() {
- Service service = new Service();
- service.setModelUUID("123-uuid");
- return Arrays.asList(service);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup = new TempNetworkHeatTemplateLookup();
-
- cd.saveTempNetworkHeatTemplateLookup(tempNetworkHeatTemplateLookup);
- }
- @Test
- public void getToscaCsarByServiceModelUUID() {
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<Service> list() {
- Service service = new Service();
- service.setModelUUID("123-uuid");
- return Arrays.asList(service);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
-
- assertNull(cd.getToscaCsarByServiceModelUUID("uuid-123"));
- cd.close();
- }
- @Test
- public void getVnfRecipeByNameVersion(){
- mockUpQuery = new MockUp<Query>() {
- String version = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("version")) version = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public List<VnfRecipe> list() {
- if ("nil".equals(version)) return new ArrayList<VnfRecipe>();
-
- VnfRecipe vnfRecipe = new VnfRecipe();
- vnfRecipe.setVersion(version);
- return Arrays.asList(vnfRecipe);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VnfRecipe vf = cd.getVnfRecipeByNameVersion("modelName","modelVersion","action");
- assertEquals("modelVersion", vf.getVersion());
-
- vf = cd.getVnfRecipeByNameVersion("modelName","nil","action");
- assertNull(vf);
- }
-
- @Test
- public void getVnfRecipeByModuleUuid(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<VnfRecipe> list() {
- VnfRecipe vnfRecipe = new VnfRecipe();
- return Arrays.asList(vnfRecipe);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- assertNull(cd.getVnfRecipeByModuleUuid("vnfModelUuid","action"));
- }
-
- @Test
- public void getVfModuleType(){
- mockUpQuery = new MockUp<Query>() {
- String version = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("version")) version = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public Object uniqueResult() {
- if ("nil".equals(version)) return null;
- if ("multi".equals(version)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(version)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(version)) throw new NullPointerException();
-
- VfModule vfModule = new VfModule();
- vfModule.setVersion(version);
- return vfModule;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VfModule vm = cd.getVfModuleType("type","version");
- assertEquals("version", vm.getVersion());
-
- vm = cd.getVfModuleType("type", "nil");
- assertNull(vm);
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- vm = cd.getVfModuleType("type", "multi");
- } catch (org.hibernate.NonUniqueResultException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.HibernateException.class);
- vm = cd.getVfModuleType("type", "he");
- } catch (org.hibernate.HibernateException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(NullPointerException.class);
- vm = cd.getVfModuleType("type", "npe");
- } catch (NullPointerException e) {
- // noop
- }
-
- }
- @Test
- public void getVfModuleByModelInvariantUuidAndModelVersion(){
- mockUpQuery = new MockUp<Query>() {
- String version = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("modelVersion")) version = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public Object uniqueResult() {
- if ("nil".equals(version)) return null;
- if ("multi".equals(version)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(version)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(version)) throw new NullPointerException();
-
- VfModule vfModule = new VfModule();
- vfModule.setVersion(version);
- return vfModule;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VfModule vm = cd.getVfModuleByModelInvariantUuidAndModelVersion("modelInvariantUuid","modelVersion");
- assertEquals("modelVersion", vm.getVersion());
-
- vm = cd.getVfModuleByModelInvariantUuidAndModelVersion("modelInvariantUuid","nil");
- assertNull(vm);
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- vm = cd.getVfModuleByModelInvariantUuidAndModelVersion("modelInvariantUuid","multi");
- } catch (org.hibernate.NonUniqueResultException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.HibernateException.class);
- vm = cd.getVfModuleByModelInvariantUuidAndModelVersion("modelInvariantUuid","he");
- } catch (org.hibernate.HibernateException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(NullPointerException.class);
- vm = cd.getVfModuleByModelInvariantUuidAndModelVersion("modelInvariantUuid","npe");
- } catch (NullPointerException e) {
- // noop
- }
-
- }
-
- @Test
- public void getVnfResourceCustomizationByModelCustomizationUuid(){
- mockUpQuery = new MockUp<Query>() {
- String modelCustomizationUuid = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("modelCustomizationUuid")) modelCustomizationUuid = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public Object uniqueResult() {
- if ("nil".equals(modelCustomizationUuid)) return null;
- if ("multi".equals(modelCustomizationUuid)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(modelCustomizationUuid)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(modelCustomizationUuid)) throw new NullPointerException();
-
- VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
- vnfResourceCustomization.setModelCustomizationUuid(modelCustomizationUuid);
- return vnfResourceCustomization;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
-
- @Mock
- public VnfResource getVnfResourceByModelUuid(String modelUuid) {
- VnfResource vr = new VnfResource();
- return vr;
- }
-
- @Mock
- public ArrayList<VfModuleCustomization> getAllVfModuleCustomizations(String vnfResourceCustomizationMCU) {
- VfModuleCustomization vmc = new VfModuleCustomization();
- ArrayList<VfModuleCustomization> toRet = new ArrayList<VfModuleCustomization>();
- toRet.add(vmc);
- return toRet;
- }
- };
-
- VnfResourceCustomization vrc = cd.getVnfResourceCustomizationByModelCustomizationUuid("modelCustomizationUuid");
- assertEquals("modelCustomizationUuid", vrc.getModelCustomizationUuid());
-
- vrc = cd.getVnfResourceCustomizationByModelCustomizationUuid("nil");
- assertNull(vrc);
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- vrc = cd.getVnfResourceCustomizationByModelCustomizationUuid("multi");
- } catch (org.hibernate.NonUniqueResultException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.HibernateException.class);
- vrc = cd.getVnfResourceCustomizationByModelCustomizationUuid("he");
- } catch (org.hibernate.HibernateException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(NullPointerException.class);
- vrc = cd.getVnfResourceCustomizationByModelCustomizationUuid("npe");
- } catch (NullPointerException e) {
- // noop
- }
-
- }
-
- @Test
- public void getVfModuleByModelCustomizationIdAndVersion(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<VnfRecipe> list() {
- VnfRecipe vnfRecipe = new VnfRecipe();
- return Arrays.asList(vnfRecipe);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- assertNull(cd.getVfModuleByModelCustomizationIdAndVersion("modelCustomizationUuid","modelVersionId"));
- }
- @Test
- public void getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId(){
- mockUpQuery = new MockUp<Query>() {
- String modelInvariantId = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("modelInvariantId")) modelInvariantId = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public Object uniqueResult() {
- if ("nil".equals(modelInvariantId)) return null;
- if ("multi".equals(modelInvariantId)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(modelInvariantId)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(modelInvariantId)) throw new NullPointerException();
-
- VfModule vfModule = new VfModule();
- vfModule.setModelInvariantUuid(modelInvariantId);
- return vfModule;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VfModule vm = cd.getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId("modelCustomizationUuid","modelVersion","modelInvariantId");
- assertEquals("modelInvariantId", vm.getModelInvariantUuid());
-
- vm = cd.getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId("modelCustomizationUuid","modelVersion","nil");
- assertNull(vm);
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- vm = cd.getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId("modelCustomizationUuid","modelVersion","multi");
- } catch (org.hibernate.NonUniqueResultException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.HibernateException.class);
- vm = cd.getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId("modelCustomizationUuid","modelVersion","he");
- } catch (org.hibernate.HibernateException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(NullPointerException.class);
- vm = cd.getVfModuleByModelCustomizationIdModelVersionAndModelInvariantId("modelCustomizationUuid","modelVersion", "npe");
- } catch (NullPointerException e) {
- // noop
- }
-
- }
-
- @Test
- public void getVnfResourceCustomizationByModelInvariantId(){
- mockUpQuery = new MockUp<Query>() {
- String modelInvariantId = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("modelInvariantId")) modelInvariantId = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public Object uniqueResult() {
- if ("nil".equals(modelInvariantId)) return null;
- if ("multi".equals(modelInvariantId)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(modelInvariantId)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(modelInvariantId)) throw new NullPointerException();
-
- VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
- vnfResourceCustomization.setVnfResourceModelUuid(modelInvariantId);
- return vnfResourceCustomization;
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- public VnfResource getVnfResourceByModelUuid(String modelUuid) {
- return new VnfResource();
- }
-
- @Mock
- public ArrayList<VfModuleCustomization> getAllVfModuleCustomizations(String vnfResourceCustomizationMCU) {
- return new ArrayList<VfModuleCustomization>();
- }
-
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- VnfResourceCustomization vrc = cd.getVnfResourceCustomizationByModelInvariantId("modelInvariantId","modelVersion","modelCustomizationName");
- assertEquals("modelInvariantId", vrc.getVnfResourceModelUuid());
-
- vrc = cd.getVnfResourceCustomizationByModelInvariantId("nil","modelVersion","modelCustomizationName");
- assertNull(vrc);
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- vrc = cd.getVnfResourceCustomizationByModelInvariantId("multi","modelVersion","modelCustomizationName");
- } catch (org.hibernate.NonUniqueResultException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.HibernateException.class);
- vrc = cd.getVnfResourceCustomizationByModelInvariantId("he","modelVersion","modelCustomizationName");
- } catch (org.hibernate.HibernateException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(NullPointerException.class);
- vrc = cd.getVnfResourceCustomizationByModelInvariantId("npe","modelVersion","modelCustomizationName");
- } catch (NullPointerException e) {
- // noop
- }
- }
-
- @Test
- public void getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId(){
- mockUpQuery = new MockUp<Query>() {
-
- @Mock
- public List<VnfResourceCustomization> list() {
- VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
- return Arrays.asList(vnfResourceCustomization);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
- assertNotNull(cd.getVnfResourceCustomizationByVnfModelCustomizationNameAndModelVersionId("modelCustomizationName","modelVersionId"));
- }
-
- @Test
- public void getNetworkResourceById3Test() {
- mockUpQuery = new MockUp<Query>() {
- String modelUuid = null;
-
- @Mock
- public Query setParameter(String name, Object val) {
- if (name.equals("model_uuid")) modelUuid = (String)val;
- return this.getMockInstance();
- }
-
- @Mock
- public List<NetworkResource> list() {
- if ("nil".equals(modelUuid)) return null;
- if ("multi".equals(modelUuid)) throw new org.hibernate.NonUniqueResultException(2);
- if ("he".equals(modelUuid)) throw new org.hibernate.HibernateException("test case");
- if ("npe".equals(modelUuid)) throw new NullPointerException();
-
- NetworkResource networkResource = new NetworkResource();
- networkResource.setModelUUID(modelUuid);
- return Arrays.asList(networkResource);
- }
- };
-
- mockedSession = new MockUp<Session>() {
- @Mock
- public Query createQuery(String hql) {
- return mockUpQuery.getMockInstance();
- }
- };
-
- mockCd = new MockUp<CatalogDatabase>() {
- @Mock
- private Session getSession() {
- return mockedSession.getMockInstance();
- }
- };
-
- NetworkResource nr = cd.getNetworkResourceById("test");
- assertEquals("test", nr.getModelUUID());
-
- nr = cd.getNetworkResourceById("nil");
- assertNull(nr);
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.NonUniqueResultException.class);
- nr = cd.getNetworkResourceById("multi");
- } catch (org.hibernate.NonUniqueResultException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(org.hibernate.HibernateException.class);
- nr = cd.getNetworkResourceById("he");
- } catch (org.hibernate.HibernateException e) {
- // noop
- }
-
- try {
- thrown = ExpectedException.none();
- thrown.expect(NullPointerException.class);
- nr = cd.getNetworkResourceById("npe");
- } catch (NullPointerException e) {
- // noop
- }
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatFilesTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatFilesTest.java
deleted file mode 100644
index da4e87806c..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatFilesTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.UUID;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.HeatFiles;
-
-/**
- */
-
-public class HeatFilesTest {
-
- @Test
- public final void heatFilesTest() {
-
- HeatFiles heatFiles = new HeatFiles();
- heatFiles.setFileBody("testBody");
- heatFiles.setArtifactUuid(UUID.randomUUID().toString());
- assertTrue(heatFiles.getFileBody().equals("testBody"));
- assertTrue(!heatFiles.toString().contains("8 chars"));
- heatFiles.setFileBody(null);
- assertTrue(!heatFiles.toString().contains("Not defined"));
- heatFiles.setVersion("12");
- assertTrue(heatFiles.getVersion().equals("12"));
-
- heatFiles.setFileName("File");
- assertTrue(heatFiles.getFileName().equalsIgnoreCase("File"));
-
- heatFiles.setCreated(null);
- assertTrue(heatFiles.getCreated() == null);
- heatFiles.setAsdcUuid("asdc");
-
- assertTrue(heatFiles.getAsdcUuid().equalsIgnoreCase("asdc"));
-
- heatFiles.setDescription("desc");
- assertTrue(heatFiles.getDescription().equalsIgnoreCase("desc"));
-
-
- heatFiles.setArtifactChecksum("artifactChecksum");
- assertTrue(heatFiles.getArtifactChecksum().equalsIgnoreCase("artifactChecksum"));
- File tempFile;
- try {
- tempFile = File.createTempFile("heatFiles", "test");
- tempFile.deleteOnExit();
- try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tempFile), "utf-8"))) {
- writer.write("something\n");
- writer.write("something2\n");
- }
- heatFiles.setFileBody(tempFile.getAbsolutePath());
- assertTrue(heatFiles.getFileBody().contains("test"));
- } catch (IOException e) {
- e.printStackTrace();
- fail("Exception caught");
- }
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatTemplateTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatTemplateTest.java
deleted file mode 100644
index cf79d5b0d1..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatTemplateTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-
-import static org.junit.Assert.*;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.UUID;
-
-import org.junit.Test;
-
-import org.openecomp.mso.db.catalog.beans.HeatTemplate;
-import org.openecomp.mso.db.catalog.beans.HeatTemplateParam;
-
-/**
- */
-
-public class HeatTemplateTest {
-
- @Test
- public final void heatTemplateTest () {
- HeatTemplate heatTemplate = new HeatTemplate ();
- heatTemplate.setTemplateBody ("testBody");
- heatTemplate.setArtifactUuid(UUID.randomUUID().toString());
- assertTrue (heatTemplate.getHeatTemplate ().equals ("testBody"));
- assertTrue (heatTemplate.toString ().contains ("8 chars"));
- heatTemplate.setTemplateBody (null);
- assertTrue (heatTemplate.toString ().contains ("Not defined"));
- HashSet<HeatTemplateParam> set = new HashSet<> ();
- HeatTemplateParam param = new HeatTemplateParam ();
- param.setParamName ("param name");
- param.setParamType ("string");
- param.setRequired (false);
- param.setHeatTemplateArtifactUuid(UUID.randomUUID().toString());
- set.add (param);
- HeatTemplateParam param2 = new HeatTemplateParam ();
- param2.setParamName ("param 2");
- param2.setParamType ("string");
- param2.setRequired (true);
- param2.setHeatTemplateArtifactUuid(UUID.randomUUID().toString());
- set.add (param2);
- heatTemplate.setParameters (set);
- String heatStr = heatTemplate.toString ();
- assertTrue (heatStr.contains ("param name"));
- assertTrue (heatStr.contains ("param 2(reqd)"));
-
- File tempFile;
- try {
- tempFile = File.createTempFile ("heatTemplate", "test");
- tempFile.deleteOnExit ();
- try (Writer writer = new BufferedWriter (new OutputStreamWriter (new FileOutputStream (tempFile),
- "utf-8"))) {
- writer.write ("something\n");
- writer.write ("something2\n");
- }
- heatTemplate.setTemplateBody(tempFile.getAbsolutePath ());
- assertTrue (heatTemplate.getHeatTemplate ().contains ("test"));
- } catch (IOException e) {
- e.printStackTrace ();
- fail ("Exception caught");
- }
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelRecipeTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelRecipeTest.java
deleted file mode 100644
index d70f267cc1..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelRecipeTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.ModelRecipe;
-
-/**
- */
-
-public class ModelRecipeTest {
-
- @Test
- public final void modelRecipeDataTest() {
- ModelRecipe modelRecipe = new ModelRecipe();
- modelRecipe.setAction("action");
- assertTrue(modelRecipe.getAction().equalsIgnoreCase("action"));
- modelRecipe.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(modelRecipe.getCreated() != null);
- modelRecipe.setDescription("description");
- assertTrue(modelRecipe.getDescription().equalsIgnoreCase("description"));
- modelRecipe.setId(1);
- assertTrue(modelRecipe.getId() == 1);
- modelRecipe.setModelId(1);
- assertTrue(modelRecipe.getModelId() == 1);
- modelRecipe.setModelParamXSD("modelParamXSD");
- assertTrue(modelRecipe.getModelParamXSD().equalsIgnoreCase("modelParamXSD"));
- modelRecipe.setOrchestrationUri("orchestrationUri");
- assertTrue(modelRecipe.getOrchestrationUri().equalsIgnoreCase("orchestrationUri"));
- modelRecipe.setRecipeTimeout(1);
- assertTrue(modelRecipe.getRecipeTimeout() == 1);
- modelRecipe.setSchemaVersion("schemaVersion");
- assertTrue(modelRecipe.getSchemaVersion().equalsIgnoreCase("schemaVersion"));
-// assertTrue(modelRecipe.toString() != null);
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelTest.java
deleted file mode 100644
index dcc9810042..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.Model;
-
-/**
- */
-
-public class ModelTest {
-
- @Test
- public final void modelDataTest() {
- Model model = new Model();
- model.setId(1);
- assertTrue(model.getId() == 1);
-
- model.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(model.getCreated() != null);
- model.setModelCustomizationId("modelCustomizationId");
-
- assertTrue(model.getModelCustomizationId().equalsIgnoreCase("modelCustomizationId"));
- model.setModelCustomizationName("modelCustomizationName");
- assertTrue(model.getModelCustomizationName().equalsIgnoreCase("modelCustomizationName"));
-
- model.setModelInvariantId("modelInvariantId");
- assertTrue(model.getModelInvariantId().equalsIgnoreCase("modelInvariantId"));
- model.setModelName("modelName");
- assertTrue(model.getModelName().equalsIgnoreCase("modelName"));
-
- model.setModelType("modelType");
- assertTrue(model.getModelType().equalsIgnoreCase("modelType"));
- model.setModelVersion("modelVersion");
- assertTrue(model.getModelVersion().equalsIgnoreCase("modelVersion"));
- model.setModelVersionId("modelVersionId");
- assertTrue(model.getModelVersionId().equalsIgnoreCase("modelVersionId"));
- model.setVersion("1");
- assertTrue(model.getVersion().equalsIgnoreCase("1"));
- model.setRecipes(null);
-
- assertTrue(model.getRecipes() == null);
-// assertTrue(model.toString() != null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkRecipeTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkRecipeTest.java
deleted file mode 100644
index c17b50e738..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkRecipeTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.NetworkRecipe;
-
-/**
- */
-
-public class NetworkRecipeTest {
-
- @Test
- public final void networkRecipeDataTest() {
-
- NetworkRecipe networkRecipe = new NetworkRecipe();
- networkRecipe.setAction("action");
- assertTrue(networkRecipe.getAction().equalsIgnoreCase("action"));
- networkRecipe.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(networkRecipe.getCreated() != null);
- networkRecipe.setDescription("description");
- assertTrue(networkRecipe.getDescription().equalsIgnoreCase("description"));
- networkRecipe.setId(1);
- assertTrue(networkRecipe.getId() == 1);
- networkRecipe.setModelName("modelName");
- assertTrue(networkRecipe.getModelName().equalsIgnoreCase("modelName"));
- networkRecipe.setParamXSD("networkParamXSD");
- assertTrue(networkRecipe.getParamXSD().equalsIgnoreCase("networkParamXSD"));
- networkRecipe.setOrchestrationUri("orchestrationUri");
- assertTrue(networkRecipe.getOrchestrationUri().equalsIgnoreCase("orchestrationUri"));
- networkRecipe.setRecipeTimeout(1);
- assertTrue(networkRecipe.getRecipeTimeout() == 1);
- networkRecipe.setServiceType("serviceType");
- assertTrue(networkRecipe.getServiceType().equalsIgnoreCase("serviceType"));
- networkRecipe.setVersion("version");
- assertTrue(networkRecipe.getVersion().equalsIgnoreCase("version"));
-// assertTrue(networkRecipe.toString() != null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkResourceCustomizationTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkResourceCustomizationTest.java
deleted file mode 100644
index 7b54854fd9..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkResourceCustomizationTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.NetworkResource;
-import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
-
-/**
- */
-
-public class NetworkResourceCustomizationTest {
-
- @Test
- public final void networkResourceCustomizationDataTest() {
- NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
- networkResourceCustomization.setModelCustomizationUuid("modelCustomizationUuid");
- assertTrue(networkResourceCustomization.getModelCustomizationUuid().equalsIgnoreCase("modelCustomizationUuid"));
- networkResourceCustomization.setModelInstanceName("modelInstanceName");
- assertTrue(networkResourceCustomization.getModelInstanceName().equalsIgnoreCase("modelInstanceName"));
- networkResourceCustomization.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(networkResourceCustomization.getCreated() != null);
- networkResourceCustomization.setNetworkResource(new NetworkResource());
- assertTrue(networkResourceCustomization.getNetworkResource() != null);
- networkResourceCustomization.setNetworkResourceModelUuid("networkResourceModelUuid");
- assertTrue(networkResourceCustomization.getNetworkResourceModelUuid()
- .equalsIgnoreCase("networkResourceModelUuid"));
- networkResourceCustomization.setNetworkRole("networkRole");
- assertTrue(networkResourceCustomization.getNetworkRole().equalsIgnoreCase("networkRole"));
- networkResourceCustomization.setNetworkScope("networkScope");
- assertTrue(networkResourceCustomization.getNetworkScope().equalsIgnoreCase("networkScope"));
- networkResourceCustomization.setNetworkTechnology("networkTechnology");
- assertTrue(networkResourceCustomization.getNetworkTechnology().equalsIgnoreCase("networkTechnology"));
- networkResourceCustomization.setNetworkType("networkType");
- assertTrue(networkResourceCustomization.getNetworkType().equalsIgnoreCase("networkType"));
-// assertTrue(networkResourceCustomization.toString() != null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkResourceTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkResourceTest.java
deleted file mode 100644
index 11ee57b86b..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/NetworkResourceTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.NetworkResource;
-
-/**
- */
-
-public class NetworkResourceTest {
-
- @Test
- public final void networkResourceDataTest() {
- NetworkResource networkResource = new NetworkResource();
- networkResource.setAicVersionMax("aicVersionMax");
- assertTrue(networkResource.getAicVersionMax().equalsIgnoreCase("aicVersionMax"));
- networkResource.setAicVersionMin("aicVersionMin");
- assertTrue(networkResource.getAicVersionMin().equalsIgnoreCase("aicVersionMin"));
- networkResource.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(networkResource.getCreated() != null);
- networkResource.setDescription("description");
- assertTrue(networkResource.getDescription().equalsIgnoreCase("description"));
- networkResource.setHeatTemplateArtifactUUID("heatTemplateArtifactUUID");
- assertTrue(networkResource.getHeatTemplateArtifactUUID().equalsIgnoreCase("heatTemplateArtifactUUID"));
- networkResource.setModelInvariantUUID("modelInvariantUUID");
- assertTrue(networkResource.getModelInvariantUUID().equalsIgnoreCase("modelInvariantUUID"));
- networkResource.setModelName("modelName");
- assertTrue(networkResource.getModelName().equalsIgnoreCase("modelName"));
- networkResource.setModelUUID("modelUUID");
- assertTrue(networkResource.getModelUUID().equalsIgnoreCase("modelUUID"));
- networkResource.setModelVersion("modelVersion");
- assertTrue(networkResource.getModelVersion().equalsIgnoreCase("modelVersion"));
- networkResource.setNeutronNetworkType("neutronNetworkType");
- assertTrue(networkResource.getNeutronNetworkType().equalsIgnoreCase("neutronNetworkType"));
- networkResource.setOrchestrationMode("orchestrationMode");
- assertTrue(networkResource.getOrchestrationMode().equalsIgnoreCase("orchestrationMode"));
- networkResource.setToscaNodeType("toscaNodeType");
- assertTrue(networkResource.getToscaNodeType().equalsIgnoreCase("toscaNodeType"));
- networkResource.setVersion("1");
- assertTrue(networkResource.getVersion().equalsIgnoreCase("1"));
-// assertTrue(networkResource.toString() != null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/RecipeTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/RecipeTest.java
deleted file mode 100644
index 49dc9b7079..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/RecipeTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.Recipe;
-
-/**
- */
-
-public class RecipeTest {
-
- @Test
- public final void recipeDataTest() {
- Recipe recipe = new Recipe();
- recipe.setAction("action");
- assertTrue(recipe.getAction().equalsIgnoreCase("action"));
- recipe.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(recipe.getCreated() != null);
- recipe.setDescription("description");
- assertTrue(recipe.getDescription().equalsIgnoreCase("description"));
- recipe.setId(1);
- assertTrue(recipe.getId() == 1);
- recipe.setOrchestrationUri("orchestrationUri");
- assertTrue(recipe.getOrchestrationUri().equalsIgnoreCase("orchestrationUri"));
- recipe.setRecipeTimeout(1);
- assertTrue(recipe.getRecipeTimeout() == 1);
- recipe.setServiceType("serviceType");
- assertTrue(recipe.getServiceType().equalsIgnoreCase("serviceType"));
-// assertTrue(recipe.toString() != null);
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceMacroHolderTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceMacroHolderTest.java
deleted file mode 100644
index c819079a40..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceMacroHolderTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder;
-import org.openecomp.mso.db.catalog.beans.VnfResource;
-import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
-
-/**
- */
-
-public class ServiceMacroHolderTest {
-
- @Test
- public final void serviceMacroHolderDataTest() {
- ServiceMacroHolder serviceMacroHolder = new ServiceMacroHolder();
- assertTrue(serviceMacroHolder.getService() == null);
- serviceMacroHolder.addVnfResource(new VnfResource());
- serviceMacroHolder.addVnfResourceCustomizations(new VnfResourceCustomization());
- serviceMacroHolder.addNetworkResourceCustomizations(new NetworkResourceCustomization());
- serviceMacroHolder.addAllottedResourceCustomization(new AllottedResourceCustomization());
- assertTrue(serviceMacroHolder != null);
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceRecipeTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceRecipeTest.java
deleted file mode 100644
index 4b4a5adf4a..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceRecipeTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-import java.util.Date;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.ServiceRecipe;
-
-/**
- */
-
-public class ServiceRecipeTest {
-
- @Test
- public final void serviceRecipeDataTest() {
-
- ServiceRecipe serviceRecipe = new ServiceRecipe();
- serviceRecipe.setAction("action");
- assertTrue(serviceRecipe.getAction().equalsIgnoreCase("action"));
- serviceRecipe.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(serviceRecipe.getCreated() != null);
- serviceRecipe.setDescription("description");
- assertTrue(serviceRecipe.getDescription().equalsIgnoreCase("description"));
- serviceRecipe.setId(1);
- assertTrue(serviceRecipe.getId() == 1);
- serviceRecipe.setOrchestrationUri("orchestrationUri");
- assertTrue(serviceRecipe.getOrchestrationUri().equalsIgnoreCase("orchestrationUri"));
- serviceRecipe.setRecipeTimeout(1);
- assertTrue(serviceRecipe.getRecipeTimeout() == 1);
- serviceRecipe.setVersion("version");
- assertTrue(serviceRecipe.getVersion().equalsIgnoreCase("version"));
- serviceRecipe.setServiceTimeoutInterim(1);
- assertTrue(serviceRecipe.getServiceTimeoutInterim() == 1);
- serviceRecipe.setServiceParamXSD("serviceParamXSD");
- assertTrue(serviceRecipe.getServiceParamXSD().equalsIgnoreCase("serviceParamXSD"));
- assertTrue(serviceRecipe.toString() != null);
- ServiceRecipe serviceRecipeWithValue = new ServiceRecipe(1, "string", "string", "string", "string", "string", 1,
- 1, new Date());
- assertTrue(serviceRecipeWithValue.toString() != null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceTest.java
deleted file mode 100644
index 12c55e7a48..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.Service;
-
-/**
- */
-
-public class ServiceTest {
-
- @Test
- public final void recipeDataTest() {
- Service service = new Service();
- service.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(service.getCreated() != null);
- service.setDescription("description");
- assertTrue(service.getDescription().equalsIgnoreCase("description"));
-
- service.setModelInvariantUUID("action");
- assertTrue(service.getModelInvariantUUID().equalsIgnoreCase("action"));
-
- service.setModelName("modelName");
- assertTrue(service.getModelName().equalsIgnoreCase("modelName"));
-
- service.setModelUUID("modelUUID");
- assertTrue(service.getModelUUID().equalsIgnoreCase("modelUUID"));
- service.setModelVersion("modelVersion");
- assertTrue(service.getModelVersion().equalsIgnoreCase("modelVersion"));
- service.setServiceRole("serviceRole");
- assertTrue(service.getServiceRole().equalsIgnoreCase("serviceRole"));
- service.setToscaCsarArtifactUUID("toscaCsarArtifactUUID");
- assertTrue(service.getToscaCsarArtifactUUID().equalsIgnoreCase("toscaCsarArtifactUUID"));
-
- service.setServiceType("serviceType");
- assertTrue(service.getServiceType().equalsIgnoreCase("serviceType"));
- service.setRecipes(null);
- assertTrue(service.getRecipes() == null);
- service.setServiceResourceCustomizations(null);
- assertTrue(service.getServiceResourceCustomizations() == null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceToAllottedResourcesTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceToAllottedResourcesTest.java
deleted file mode 100644
index b2aaeeed4e..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceToAllottedResourcesTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources;
-
-/**
- */
-
-public class ServiceToAllottedResourcesTest {
-
- @Test
- public final void serviceToAllottedResourcesDataTest() {
- ServiceToAllottedResources serviceToAllottedResources = new ServiceToAllottedResources();
- serviceToAllottedResources.setArModelCustomizationUuid("arModelCustomizationUuid");
- assertTrue(
- serviceToAllottedResources.getArModelCustomizationUuid().equalsIgnoreCase("arModelCustomizationUuid"));
- serviceToAllottedResources.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(serviceToAllottedResources.getCreated() != null);
- serviceToAllottedResources.setServiceModelUuid("serviceModelUuid");
- assertTrue(serviceToAllottedResources.getServiceModelUuid().equalsIgnoreCase("serviceModelUuid"));
-// assertTrue(serviceToAllottedResources.toString() != null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceToResourceCustomizationTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceToResourceCustomizationTest.java
deleted file mode 100644
index 337cf4b574..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ServiceToResourceCustomizationTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.ServiceToAllottedResources;
-
-/**
- */
-
-public class ServiceToResourceCustomizationTest {
-
- @Test
- public final void serviceToResourceCustomizationDataTest() {
- ServiceToAllottedResources serviceToResourceCustomization = new ServiceToAllottedResources();
- serviceToResourceCustomization.setArModelCustomizationUuid("arModelCustomizationUuid");
- assertTrue(
- serviceToResourceCustomization.getArModelCustomizationUuid().equalsIgnoreCase("arModelCustomizationUuid"));
- serviceToResourceCustomization.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(serviceToResourceCustomization.getCreated() != null);
- serviceToResourceCustomization.setServiceModelUuid("serviceModelUuid");
- assertTrue(serviceToResourceCustomization.getServiceModelUuid().equalsIgnoreCase("serviceModelUuid"));
-// assertTrue(serviceToResourceCustomization.toString() != null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToStringTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToStringTest.java
deleted file mode 100644
index 162073cc76..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToStringTest.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.HeatFiles;
-import org.openecomp.mso.db.catalog.beans.Model;
-import org.openecomp.mso.db.catalog.beans.ModelRecipe;
-import org.openecomp.mso.db.catalog.beans.NetworkResource;
-import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.Service;
-import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder;
-import org.openecomp.mso.db.catalog.beans.ServiceRecipe;
-import org.openecomp.mso.db.catalog.beans.ServiceToResourceCustomization;
-import org.openecomp.mso.db.catalog.beans.TempNetworkHeatTemplateLookup;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.db.catalog.beans.VnfComponent;
-import org.openecomp.mso.db.catalog.beans.VnfResource;
-import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
-
-public class ToStringTest {
-
- @Test
- public void testTModelRecipeToString(){
- ModelRecipe mr = new ModelRecipe();
- mr.setCreated(new Timestamp(10001));
- mr.setModelId(102);
- mr.setRecipeTimeout(100);
- String str = mr.toString();
- assertTrue(str != null);
- }
-
- @Test
- public void networkResourcetoStringTest(){
- NetworkResource nr = new NetworkResource();
- nr.setCreated(new Timestamp(10000));
- String str = nr.toString();
- assertTrue(str != null);
- }
-
- @Test
- public void modelTestToString(){
- Model m = new Model();
- m.setCreated(new Timestamp(100000));
- m.setId(1001);
- m.setModelCustomizationId("10012");
- String str = m.toString();
- assertTrue(str != null);
- }
-
- @Test
- public void serviceMacroHolderTest(){
- ServiceMacroHolder smh = new ServiceMacroHolder();
- Service service = new Service();
- Map<String,ServiceRecipe> recipes = new HashMap<>();
- recipes.put("test", new ServiceRecipe());
- service.setRecipes(recipes);
-
- Set<ServiceToResourceCustomization> serviceResourceCustomizations = new HashSet<>();
- ServiceToResourceCustomization sr = new ServiceToResourceCustomization();
- serviceResourceCustomizations.add(sr);
- service.setServiceResourceCustomizations(serviceResourceCustomizations);
- smh.setService(service);
-
- ArrayList<VnfResource> vnflist = new ArrayList<>();
- smh.setVnfResources(vnflist);
-
- VnfResource vr = new VnfResource();
- Set<VnfResourceCustomization> vnfResourceCustomization = new HashSet<>();
- vnfResourceCustomization.add(new VnfResourceCustomization());
- vr.setVnfResourceCustomizations(vnfResourceCustomization);
-
- Set<VfModule> vfModules = new HashSet<>();
- vfModules.add(new VfModule());
- vr.setVfModules(vfModules);
- smh.addVnfResource(vr);
-
- ArrayList<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>();
- smh.setVnfResourceCustomizations(vnfResourceCustomizations);
-
- VnfResourceCustomization vrc = new VnfResourceCustomization();
- smh.addVnfResourceCustomizations(vrc);
-
- ArrayList<NetworkResourceCustomization> networkResourceCustomizations = new ArrayList<>();
- smh.setNetworkResourceCustomization(networkResourceCustomizations);
-
- NetworkResourceCustomization nrc = new NetworkResourceCustomization();
- smh.addNetworkResourceCustomizations(nrc);
-
- ArrayList<AllottedResourceCustomization> allottedResourceCustomizations = new ArrayList<>();
- smh.setAllottedResourceCustomization(allottedResourceCustomizations);
-
- AllottedResourceCustomization arc = new AllottedResourceCustomization();
- smh.addAllottedResourceCustomization(arc);
-
- String str = smh.toString();
- assertTrue(str != null);
- }
-
- @Test
- public void heatFilesTest(){
- HeatFiles hf = new HeatFiles();
- String str = hf.toString();
- assertTrue(str != null);
-
- }
-
- @Test
- public void testVnfConponent(){
- VnfComponent vnf = new VnfComponent();
- String str = vnf.toString();
- assertTrue(str != null);
- }
-
- @Test
- public void testTempNetworkHeatTemplateLookup(){
- TempNetworkHeatTemplateLookup tn =new TempNetworkHeatTemplateLookup();
- String str = tn.toString();
- assertTrue(str != null);
- }
-
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToscaCsarTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToscaCsarTest.java
deleted file mode 100644
index 9cbfaa4d2c..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ToscaCsarTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.ToscaCsar;
-
-/**
- */
-
-public class ToscaCsarTest {
-
- @Test
- public final void toscaCsarDataTest() {
- ToscaCsar toscaCsar = new ToscaCsar();
- toscaCsar.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(toscaCsar.getCreated() != null);
- toscaCsar.setDescription("description");
- assertTrue(toscaCsar.getDescription().equalsIgnoreCase("description"));
-
- toscaCsar.setArtifactChecksum("artifactChecksum");
- assertTrue(toscaCsar.getArtifactChecksum().equalsIgnoreCase("artifactChecksum"));
-
- toscaCsar.setArtifactUUID("artifactUUID");
- assertTrue(toscaCsar.getArtifactUUID().equalsIgnoreCase("artifactUUID"));
-
- toscaCsar.setName("name");
- assertTrue(toscaCsar.getName().equalsIgnoreCase("name"));
- toscaCsar.setUrl("url");
- assertTrue(toscaCsar.getUrl().equalsIgnoreCase("url"));
-// assertTrue(toscaCsar.toString() != null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VfModuleCustomizationTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VfModuleCustomizationTest.java
deleted file mode 100644
index 52d15ee597..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VfModuleCustomizationTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
-
-/**
- */
-
-public class VfModuleCustomizationTest {
-
- @Test
- public final void vfModuleCustomizationDataTest() {
- VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
- vfModuleCustomization.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(vfModuleCustomization.getCreated() != null);
- vfModuleCustomization.setAvailabilityZoneCount(1);
- assertTrue(vfModuleCustomization.getAvailabilityZoneCount() == 1);
- vfModuleCustomization.hashCode();
- vfModuleCustomization.setVolEnvironmentArtifactUuid("volEnvironmentArtifactUuid");
- assertTrue(
- vfModuleCustomization.getVolEnvironmentArtifactUuid().equalsIgnoreCase("volEnvironmentArtifactUuid"));
-
- vfModuleCustomization.setHeatEnvironmentArtifactUuid("heatEnvironmentArtifactUuid");
- assertTrue(
- vfModuleCustomization.getHeatEnvironmentArtifactUuid().equalsIgnoreCase("heatEnvironmentArtifactUuid"));
-
- vfModuleCustomization.setInitialCount(1);
- assertTrue(vfModuleCustomization.getInitialCount() == 1);
-
- vfModuleCustomization.setLabel("label");
- assertTrue(vfModuleCustomization.getLabel().equalsIgnoreCase("label"));
- vfModuleCustomization.setMaxInstances(2);
- assertTrue(vfModuleCustomization.getMaxInstances() == 2);
- vfModuleCustomization.setMinInstances(1);
- assertTrue(vfModuleCustomization.getMinInstances() == 1);
- vfModuleCustomization.setModelCustomizationUuid("modelCustomizationUuid");
- assertTrue(vfModuleCustomization.getModelCustomizationUuid().equalsIgnoreCase("modelCustomizationUuid"));
- vfModuleCustomization.setVfModule(new VfModule());
- assertTrue(vfModuleCustomization.getVfModule() != null);
-
-// assertTrue(vfModuleCustomization.toString() == null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VfModuleTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VfModuleTest.java
deleted file mode 100644
index 9409a642ec..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VfModuleTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-
-/**
- */
-
-public class VfModuleTest {
-
- @Test
- public final void vfModuleDataTest() {
- VfModule vfModule = new VfModule();
- vfModule.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(vfModule.getCreated() != null);
- vfModule.setDescription("description");
- assertTrue(vfModule.getDescription().equalsIgnoreCase("description"));
-
- vfModule.setModelInvariantUUID("action");
- assertTrue(vfModule.getModelInvariantUUID().equalsIgnoreCase("action"));
-
- vfModule.setModelName("modelName");
- assertTrue(vfModule.getModelName().equalsIgnoreCase("modelName"));
-
- vfModule.setModelUUID("modelUUID");
- assertTrue(vfModule.getModelUUID().equalsIgnoreCase("modelUUID"));
- vfModule.setModelVersion("modelVersion");
- assertTrue(vfModule.getModelVersion().equalsIgnoreCase("modelVersion"));
- vfModule.setHeatTemplateArtifactUUId("heatTemplateArtifactUUId");
- assertTrue(vfModule.getHeatTemplateArtifactUUId().equalsIgnoreCase("heatTemplateArtifactUUId"));
- vfModule.setVnfResourceModelUUId("vnfResourceModelUUId");
- assertTrue(vfModule.getVnfResourceModelUUId().equalsIgnoreCase("vnfResourceModelUUId"));
- vfModule.setIsBase(1);
- assertTrue(vfModule.isBase());
-// assertTrue(vfModule.toString() == null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfRecipeTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfRecipeTest.java
deleted file mode 100644
index 3f707871a6..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfRecipeTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.VnfRecipe;
-
-/**
- */
-
-public class VnfRecipeTest {
-
- @Test
- public final void vnfRecipeDataTest() {
- VnfRecipe vnfRecipe = new VnfRecipe();
- vnfRecipe.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(vnfRecipe.getCreated() != null);
- vnfRecipe.setDescription("description");
- assertTrue(vnfRecipe.getDescription().equalsIgnoreCase("description"));
-
- vnfRecipe.setOrchestrationUri("orchestrationUri");
- assertTrue(vnfRecipe.getOrchestrationUri().equalsIgnoreCase("orchestrationUri"));
-
- vnfRecipe.setRecipeTimeout(1);
- assertTrue(vnfRecipe.getRecipeTimeout() == 1);
- vnfRecipe.setVnfType("vnfType");
- assertTrue(vnfRecipe.getVnfType().equalsIgnoreCase("vnfType"));
-
- vnfRecipe.setServiceType("serviceType");
- assertTrue(vnfRecipe.getServiceType().equalsIgnoreCase("serviceType"));
- vnfRecipe.setVersion("version");
- assertTrue(vnfRecipe.getVersion().equalsIgnoreCase("version"));
- vnfRecipe.setParamXSD("vnfParamXSD");
- assertTrue(vnfRecipe.getParamXSD().equalsIgnoreCase("vnfParamXSD"));
- vnfRecipe.setVfModuleId("vfModuleId");
- assertTrue(vnfRecipe.getVfModuleId().equalsIgnoreCase("vfModuleId"));
-// assertTrue(vnfRecipe.toString() == null);
-
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfResourceCustomizationTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfResourceCustomizationTest.java
deleted file mode 100644
index 816461f203..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfResourceCustomizationTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-
-import static org.junit.Assert.*;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.UUID;
-
-import org.junit.Test;
-
-import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
-
-/**
- */
-
-public class VnfResourceCustomizationTest {
-
- @Test
- public final void vnfResourceCustomizationTest () {
- VnfResourceCustomization vrc = new VnfResourceCustomization();
- vrc.setModelCustomizationUuid("004fccad-a9d1-4b34-b50b-ccb9800a178b");
- vrc.setModelInstanceName("testName");
- vrc.setMultiStageDesign("sampleDesign");
-
- assertTrue(vrc.getModelCustomizationUuid().equals("004fccad-a9d1-4b34-b50b-ccb9800a178b"));
- assertTrue(vrc.getModelInstanceName().equals("testName"));
- assertTrue(vrc.getMultiStageDesign().equals("sampleDesign"));
- }
-
-}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfResourceTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfResourceTest.java
deleted file mode 100644
index 68749e397e..0000000000
--- a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/VnfResourceTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.db.catalog.test;
-
-import static org.junit.Assert.assertTrue;
-
-import java.sql.Timestamp;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.junit.Test;
-import org.openecomp.mso.db.catalog.beans.VfModule;
-import org.openecomp.mso.db.catalog.beans.VnfResource;
-import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
-
-/**
- */
-
-public class VnfResourceTest {
-
- @Test
- public final void vnfResourceDataTest() {
-
- VnfResource vnfResource = new VnfResource();
- vnfResource.setCreated(new Timestamp(System.currentTimeMillis()));
- assertTrue(vnfResource.getCreated() != null);
- vnfResource.setDescription("description");
- assertTrue(vnfResource.getDescription().equalsIgnoreCase("description"));
-
- vnfResource.setAicVersionMax("aicVersionMax");
- assertTrue(vnfResource.getAicVersionMax().equalsIgnoreCase("aicVersionMax"));
-
- vnfResource.setAicVersionMin("aicVersionMin");
- assertTrue(vnfResource.getAicVersionMin().equalsIgnoreCase("aicVersionMin"));
- vnfResource.setHeatTemplateArtifactUUId("heatTemplateArtifactUUId");
- assertTrue(vnfResource.getHeatTemplateArtifactUUId().equalsIgnoreCase("heatTemplateArtifactUUId"));
-
- vnfResource.setModelInvariantUuid("modelInvariantUuid");
- assertTrue(vnfResource.getModelInvariantUuid().equalsIgnoreCase("modelInvariantUuid"));
- vnfResource.setModelName("modelName");
- assertTrue(vnfResource.getModelName().equalsIgnoreCase("modelName"));
- vnfResource.setModelUuid("modelUuid");
- assertTrue(vnfResource.getModelUuid().equalsIgnoreCase("modelUuid"));
- vnfResource.setModelVersion("modelVersion");
- assertTrue(vnfResource.getModelVersion().equalsIgnoreCase("modelVersion"));
- vnfResource.setOrchestrationMode("orchestrationMode");
- assertTrue(vnfResource.getOrchestrationMode().equalsIgnoreCase("orchestrationMode"));
- vnfResource.setTemplateId("heatTemplateArtifactUUId");
- assertTrue(vnfResource.getHeatTemplateArtifactUUId().equalsIgnoreCase("heatTemplateArtifactUUId"));
- vnfResource.setModelInvariantUuid("modelInvariantUuid");
- assertTrue(vnfResource.getModelInvariantUuid().equalsIgnoreCase("modelInvariantUuid"));
- Set<VnfResourceCustomization> list = new HashSet<>();
- list.add(new VnfResourceCustomization());
- vnfResource.setVnfResourceCustomizations(list);
- assertTrue(vnfResource.getVfModuleCustomizations() != null);
- Set<VfModule> vfModules = new HashSet<>();
- vfModules.add(new VfModule());
- vnfResource.setVfModules(vfModules);
- assertTrue(vnfResource.getVfModules() != null);
-// assertTrue(vnfResource.toString() != null);
-
- }
-
-}