From 8fdf2dee7684f4911a58a2350626300af52b6e4d Mon Sep 17 00:00:00 2001 From: "Sonsino, Ofir (os0695)" Date: Sun, 18 Mar 2018 16:06:37 +0200 Subject: Unit tests Change-Id: I9ff2a916f09856e3a79d037a8815224ddb9e7a9b Issue-ID: VID-197 Signed-off-by: Sonsino, Ofir (os0695) --- .gitignore | 14 + .../.settings/org.eclipse.core.resources.prefs | 1 + .../onap/portalapp/conf/ExternalAppConfigTest.java | 87 ++++++ .../conf/HibernateMappingLocationsTest.java | 29 ++ .../org/onap/portalapp/scheduler/RegisterTest.java | 39 +++ .../portalapp/scheduler/RegistryAdapterTest.java | 75 +++++ .../portalapp/service/AdminAuthExtensionTest.java | 45 +++ .../src/test/java/org/onap/aai/util/TestSuite.java | 11 - .../src/test/java/org/onap/vid/TestSuite.java | 11 - .../src/test/java/org/onap/vid/aai/TestSuite.java | 12 - .../java/org/onap/vid/aai/model/TestSuite.java | 11 - .../java/org/onap/vid/asdc/BaseClientTest.java | 322 +++++++++++++++++++++ .../java/org/onap/vid/asdc/InMemoryClientTest.java | 79 +++++ .../java/org/onap/vid/asdc/RestfulClientTest.java | 107 +++++++ .../java/org/onap/vid/asdc/beans/TestSuite.java | 11 - .../org/onap/vid/asdc/beans/tosca/TestSuite.java | 12 - .../test/java/org/onap/vid/client/TestSuite.java | 11 - .../vid/controller/test/TestAaiControllerTest.java | 27 ++ .../controller/test/TestAsdcControllerTest.java | 26 ++ .../vid/controller/test/TestMsoControllerTest.java | 29 ++ .../controller/test/TestPageControllerTest.java | 31 ++ .../test/java/org/onap/vid/model/TestSuite.java | 12 - .../test/java/org/onap/vid/mso/rest/TestSuite.java | 12 - .../test/java/org/onap/vid/policy/TestSuite.java | 12 - .../java/org/onap/vid/policy/rest/TestSuite.java | 11 - .../java/org/onap/vid/properties/TestSuite.java | 11 - .../test/java/org/onap/vid/roles/TestSuite.java | 11 - .../org/onap/vid/scheduler/rest/TestSuite.java | 11 - .../test/java/org/onap/vid/services/TestSuite.java | 11 - 29 files changed, 911 insertions(+), 170 deletions(-) create mode 100644 epsdk-app-onap/src/test/java/org/onap/portalapp/conf/ExternalAppConfigTest.java create mode 100644 epsdk-app-onap/src/test/java/org/onap/portalapp/conf/HibernateMappingLocationsTest.java create mode 100644 epsdk-app-onap/src/test/java/org/onap/portalapp/scheduler/RegisterTest.java create mode 100644 epsdk-app-onap/src/test/java/org/onap/portalapp/scheduler/RegistryAdapterTest.java create mode 100644 epsdk-app-onap/src/test/java/org/onap/portalapp/service/AdminAuthExtensionTest.java delete mode 100644 vid-app-common/src/test/java/org/onap/aai/util/TestSuite.java delete mode 100644 vid-app-common/src/test/java/org/onap/vid/TestSuite.java delete mode 100644 vid-app-common/src/test/java/org/onap/vid/aai/TestSuite.java delete mode 100644 vid-app-common/src/test/java/org/onap/vid/aai/model/TestSuite.java create mode 100644 vid-app-common/src/test/java/org/onap/vid/asdc/BaseClientTest.java create mode 100644 vid-app-common/src/test/java/org/onap/vid/asdc/InMemoryClientTest.java create mode 100644 vid-app-common/src/test/java/org/onap/vid/asdc/RestfulClientTest.java delete mode 100644 vid-app-common/src/test/java/org/onap/vid/asdc/beans/TestSuite.java delete mode 100644 vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/TestSuite.java delete mode 100644 vid-app-common/src/test/java/org/onap/vid/client/TestSuite.java create mode 100644 vid-app-common/src/test/java/org/onap/vid/controller/test/TestAaiControllerTest.java create mode 100644 vid-app-common/src/test/java/org/onap/vid/controller/test/TestAsdcControllerTest.java create mode 100644 vid-app-common/src/test/java/org/onap/vid/controller/test/TestMsoControllerTest.java create mode 100644 vid-app-common/src/test/java/org/onap/vid/controller/test/TestPageControllerTest.java delete mode 100644 vid-app-common/src/test/java/org/onap/vid/model/TestSuite.java delete mode 100644 vid-app-common/src/test/java/org/onap/vid/mso/rest/TestSuite.java delete mode 100644 vid-app-common/src/test/java/org/onap/vid/policy/TestSuite.java delete mode 100644 vid-app-common/src/test/java/org/onap/vid/policy/rest/TestSuite.java delete mode 100644 vid-app-common/src/test/java/org/onap/vid/properties/TestSuite.java delete mode 100644 vid-app-common/src/test/java/org/onap/vid/roles/TestSuite.java delete mode 100644 vid-app-common/src/test/java/org/onap/vid/scheduler/rest/TestSuite.java delete mode 100644 vid-app-common/src/test/java/org/onap/vid/services/TestSuite.java diff --git a/.gitignore b/.gitignore index 74296e504..774e74c60 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,17 @@ deliveries/target/ /vid-app-common/logs/EELF/policy.log /vid-app-common/logs/EELF/security.log /vid-app-common/logs/EELF/server.log +/epsdk-app-onap/catalina.base_IS_UNDEFINED/logs/ep_sdk_app/application.log +/epsdk-app-onap/catalina.base_IS_UNDEFINED/logs/ep_sdk_app/audit.log +/epsdk-app-onap/catalina.base_IS_UNDEFINED/logs/ep_sdk_app/debug.log +/epsdk-app-onap/catalina.base_IS_UNDEFINED/logs/ep_sdk_app/error.log +/epsdk-app-onap/catalina.base_IS_UNDEFINED/logs/ep_sdk_app/metrics.log +/epsdk-app-onap/debug-logs/EELF/debug.log +/epsdk-app-onap/logs/EELF/application.log +/epsdk-app-onap/logs/EELF/audit.log +/epsdk-app-onap/logs/EELF/error.log +/epsdk-app-onap/logs/EELF/metrics.log +/epsdk-app-onap/logs/EELF/performance.log +/epsdk-app-onap/logs/EELF/policy.log +/epsdk-app-onap/logs/EELF/security.log +/epsdk-app-onap/logs/EELF/server.log diff --git a/epsdk-app-onap/.settings/org.eclipse.core.resources.prefs b/epsdk-app-onap/.settings/org.eclipse.core.resources.prefs index cf6931b95..365bbd609 100755 --- a/epsdk-app-onap/.settings/org.eclipse.core.resources.prefs +++ b/epsdk-app-onap/.settings/org.eclipse.core.resources.prefs @@ -1,4 +1,5 @@ eclipse.preferences.version=1 encoding//src/main/java=UTF-8 encoding//src/main/resources=UTF-8 +encoding//src/test/java=UTF-8 encoding/=UTF-8 diff --git a/epsdk-app-onap/src/test/java/org/onap/portalapp/conf/ExternalAppConfigTest.java b/epsdk-app-onap/src/test/java/org/onap/portalapp/conf/ExternalAppConfigTest.java new file mode 100644 index 000000000..120ea25ec --- /dev/null +++ b/epsdk-app-onap/src/test/java/org/onap/portalapp/conf/ExternalAppConfigTest.java @@ -0,0 +1,87 @@ +package org.onap.portalapp.conf; + +import java.util.List; + +import org.junit.Test; +import org.onap.portalapp.scheduler.RegistryAdapter; +import org.onap.portalsdk.core.auth.LoginStrategy; +import org.onap.portalsdk.core.service.DataAccessService; +import org.springframework.jdbc.datasource.init.DataSourceInitializer; +import org.springframework.jdbc.datasource.init.DatabasePopulator; +import org.springframework.scheduling.quartz.SchedulerFactoryBean; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; + +public class ExternalAppConfigTest { + + private ExternalAppConfig createTestSubject() { + return new ExternalAppConfig(); + } + + @Test + public void testViewResolver() throws Exception { + ExternalAppConfig testSubject; + ViewResolver result; + + // default test + testSubject = createTestSubject(); + result = testSubject.viewResolver(); + } + + + + @Test + public void testDataAccessService() throws Exception { + ExternalAppConfig testSubject; + DataAccessService result; + + // default test + testSubject = createTestSubject(); + result = testSubject.dataAccessService(); + } + + @Test + public void testAddTileDefinitions() throws Exception { + ExternalAppConfig testSubject; + List result; + + // default test + testSubject = createTestSubject(); + result = testSubject.addTileDefinitions(); + } + + + + @Test + public void testCacheManager() throws Exception { + ExternalAppConfig testSubject; + //AbstractCacheManager result; + + // default test + testSubject = createTestSubject(); + testSubject.cacheManager(); + } + + + + @Test + public void testSetSchedulerRegistryAdapter() throws Exception { + ExternalAppConfig testSubject; + RegistryAdapter schedulerRegistryAdapter = null; + + // default test + testSubject = createTestSubject(); + testSubject.setSchedulerRegistryAdapter(schedulerRegistryAdapter); + } + + @Test + public void testLoginStrategy() throws Exception { + ExternalAppConfig testSubject; + LoginStrategy result; + + // default test + testSubject = createTestSubject(); + result = testSubject.loginStrategy(); + } +} \ No newline at end of file diff --git a/epsdk-app-onap/src/test/java/org/onap/portalapp/conf/HibernateMappingLocationsTest.java b/epsdk-app-onap/src/test/java/org/onap/portalapp/conf/HibernateMappingLocationsTest.java new file mode 100644 index 000000000..5daba43d3 --- /dev/null +++ b/epsdk-app-onap/src/test/java/org/onap/portalapp/conf/HibernateMappingLocationsTest.java @@ -0,0 +1,29 @@ +package org.onap.portalapp.conf; + +import org.junit.Test; + +public class HibernateMappingLocationsTest { + + private HibernateMappingLocations createTestSubject() { + return new HibernateMappingLocations(); + } + + @Test + public void testGetMappingLocations() throws Exception { + HibernateMappingLocations testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.getMappingLocations(); + } + + @Test + public void testGetPackagesToScan() throws Exception { + HibernateMappingLocations testSubject; + String[] result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getPackagesToScan(); + } +} \ No newline at end of file diff --git a/epsdk-app-onap/src/test/java/org/onap/portalapp/scheduler/RegisterTest.java b/epsdk-app-onap/src/test/java/org/onap/portalapp/scheduler/RegisterTest.java new file mode 100644 index 000000000..8fed88c55 --- /dev/null +++ b/epsdk-app-onap/src/test/java/org/onap/portalapp/scheduler/RegisterTest.java @@ -0,0 +1,39 @@ +package org.onap.portalapp.scheduler; + +import java.util.List; + +import org.junit.Test; + +public class RegisterTest { + + private Register createTestSubject() { + return new Register(); + } + + @Test + public void testGetTriggers() throws Exception { + Register testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.getTriggers(); + } + + @Test + public void testGetScheduleTriggers() throws Exception { + Register testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.getScheduleTriggers(); + } + + @Test + public void testSetScheduleTriggers() throws Exception { + Register testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.setScheduleTriggers(null); + } +} \ No newline at end of file diff --git a/epsdk-app-onap/src/test/java/org/onap/portalapp/scheduler/RegistryAdapterTest.java b/epsdk-app-onap/src/test/java/org/onap/portalapp/scheduler/RegistryAdapterTest.java new file mode 100644 index 000000000..c685fb209 --- /dev/null +++ b/epsdk-app-onap/src/test/java/org/onap/portalapp/scheduler/RegistryAdapterTest.java @@ -0,0 +1,75 @@ +package org.onap.portalapp.scheduler; + +import java.util.List; + +import org.junit.Test; +import org.onap.portalsdk.core.scheduler.Registerable; +import org.onap.portalsdk.workflow.services.WorkflowScheduleService; +import org.springframework.scheduling.quartz.SchedulerFactoryBean; + +public class RegistryAdapterTest { + + private RegistryAdapter createTestSubject() { + return new RegistryAdapter(); + } + + @Test + public void testSetSchedulerBean() throws Exception { + RegistryAdapter testSubject; + SchedulerFactoryBean schedulerBean = null; + + // default test + testSubject = createTestSubject(); + testSubject.setSchedulerBean(schedulerBean); + } + + @Test + public void testGetSchedulerBean() throws Exception { + RegistryAdapter testSubject; + SchedulerFactoryBean result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getSchedulerBean(); + } + + @Test + public void testGetRegistry() throws Exception { + RegistryAdapter testSubject; + Registerable result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getRegistry(); + } + + @Test + public void testSetRegistry() throws Exception { + RegistryAdapter testSubject; + Registerable registry = null; + + // default test + testSubject = createTestSubject(); + testSubject.setRegistry(registry); + } + + @Test + public void testGetWorkflowScheduleService() throws Exception { + RegistryAdapter testSubject; + WorkflowScheduleService result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getWorkflowScheduleService(); + } + + @Test + public void testSetWorkflowScheduleService() throws Exception { + RegistryAdapter testSubject; + WorkflowScheduleService workflowScheduleService = null; + + // default test + testSubject = createTestSubject(); + testSubject.setWorkflowScheduleService(workflowScheduleService); + } +} \ No newline at end of file diff --git a/epsdk-app-onap/src/test/java/org/onap/portalapp/service/AdminAuthExtensionTest.java b/epsdk-app-onap/src/test/java/org/onap/portalapp/service/AdminAuthExtensionTest.java new file mode 100644 index 000000000..6b1066b5e --- /dev/null +++ b/epsdk-app-onap/src/test/java/org/onap/portalapp/service/AdminAuthExtensionTest.java @@ -0,0 +1,45 @@ +package org.onap.portalapp.service; + +import java.util.Set; + +import org.junit.Test; +import org.onap.portalsdk.core.domain.Role; +import org.onap.portalsdk.core.domain.User; + +public class AdminAuthExtensionTest { + + private AdminAuthExtension createTestSubject() { + return new AdminAuthExtension(); + } + + @Test + public void testSaveUserExtension() throws Exception { + AdminAuthExtension testSubject; + User user = null; + + // default test + testSubject = createTestSubject(); + testSubject.saveUserExtension(user); + } + + @Test + public void testEditUserExtension() throws Exception { + AdminAuthExtension testSubject; + User user = null; + + // default test + testSubject = createTestSubject(); + testSubject.editUserExtension(user); + } + + @Test + public void testSaveUserRoleExtension() throws Exception { + AdminAuthExtension testSubject; + Set roles = null; + User user = null; + + // default test + testSubject = createTestSubject(); + testSubject.saveUserRoleExtension(roles, user); + } +} \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/aai/util/TestSuite.java b/vid-app-common/src/test/java/org/onap/aai/util/TestSuite.java deleted file mode 100644 index b4faaa279..000000000 --- a/vid-app-common/src/test/java/org/onap/aai/util/TestSuite.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.onap.aai.util; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses( - -{ JettyObfuscationConversionCommandLineUtilTest.class }) -public class TestSuite { // nothing -} diff --git a/vid-app-common/src/test/java/org/onap/vid/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/TestSuite.java deleted file mode 100644 index e70d7fe25..000000000 --- a/vid-app-common/src/test/java/org/onap/vid/TestSuite.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.onap.vid; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses( - -{ RelatedToTest.class, org.onap.vid.aai.TestSuite.class }) -public class TestSuite { // nothing -} diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/aai/TestSuite.java deleted file mode 100644 index eac3bdf26..000000000 --- a/vid-app-common/src/test/java/org/onap/vid/aai/TestSuite.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.onap.vid.aai; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses( - -{ SubscriberAaiResponseTest.class, AaiGetVnfResponseTest.class, ServicePropertiesTest.class, - SubscriberWithFilterTest.class, VnfResultTest.class, org.onap.vid.aai.model.TestSuite.class }) -public class TestSuite { // nothing -} diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/model/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/aai/model/TestSuite.java deleted file mode 100644 index 8d5f62e54..000000000 --- a/vid-app-common/src/test/java/org/onap/vid/aai/model/TestSuite.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.onap.vid.aai.model; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses( - -{ ServiceRelationshipsTest.class, RelationshipTest.class, RelatedToPropertyTest.class, RelationshipDataTest.class }) -public class TestSuite { // nothing -} diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/BaseClientTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/BaseClientTest.java new file mode 100644 index 000000000..40a05fd90 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/BaseClientTest.java @@ -0,0 +1,322 @@ +/*- + * ============LICENSE_START======================================================= + * VID ASDC Client + * ================================================================================ + * 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.vid.asdc; + +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.UUID; + +import javax.ws.rs.NotFoundException; + +import org.hamcrest.core.IsEqual; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ErrorCollector; +import org.onap.vid.asdc.beans.Artifact; +import org.onap.vid.asdc.beans.Resource; +import org.onap.vid.asdc.beans.Service; +import org.onap.vid.asdc.beans.Service.DistributionStatus; +import org.onap.vid.asdc.beans.tosca.Group; +import org.onap.vid.asdc.beans.tosca.Input; +import org.onap.vid.asdc.beans.tosca.NodeTemplate; +import org.onap.vid.asdc.beans.tosca.ToscaCsar; +import org.onap.vid.asdc.beans.tosca.ToscaModel; + +/** + * The Class BaseClientTest. + */ +public class BaseClientTest { + + /** The collector. */ + @Rule + public ErrorCollector collector = new ErrorCollector(); + + /** + * Run resource tests. + * + * @param client the client + * @throws AsdcCatalogException the asdc catalog exception + */ + protected void runResourceTests(AsdcClient client) throws AsdcCatalogException { + final Collection resources = client.getResources(); + + collector.checkThat("getResources() returned nothing", resources.isEmpty(), IsEqual.equalTo(false)); + + final Resource resource = resources.iterator().next(); + + testResource(resource); + + final Resource thisResource = client.getResource(UUID.fromString(resource.getUuid())); + + collector.checkThat(thisResource, IsEqual.equalTo(resource)); + + for (Resource aResource : resources) { + if (aResource.getArtifacts() != null && !aResource.getArtifacts().isEmpty()) { + + final Artifact artifact = aResource.getArtifacts().iterator().next(); + + testArtifact(artifact); + + final UUID resourceUuid = UUID.fromString(aResource.getUuid()); + final UUID artifactUuid = UUID.fromString(artifact.getArtifactUUID()); + final Artifact thisArtifact = client.getResourceArtifact(resourceUuid, artifactUuid); + + collector.checkThat(artifact, IsEqual.equalTo(thisArtifact)); + } + } + + try { + final Collection badResources = client.getResources(Collections.singletonMap("category", new String[] {"Bad Resources"})); + + for (Resource badResource : badResources) { + collector.checkThat(badResource.getCategory(), IsEqual.equalTo("Bad Resources")); + } + } catch (NotFoundException e) { + //No resources of this category were found + } + + try { + final Collection reallyBadResources = client.getResources(Collections.singletonMap("subCategory", new String[] {"Really Bad Resources"})); + + for (Resource reallyBadResource : reallyBadResources) { + collector.checkThat(reallyBadResource.getSubCategory(), IsEqual.equalTo("Really Bad Resources")); + } + } catch (NotFoundException e) { + //No resources of this subcategory were found + } + + /*final ToscaCsar toscaCsar = client.getResourceToscaModel(UUID.fromString(resource.getUuid())); + + testToscaCsar(toscaCsar);*/ + } + + /** + * Run service tests. + * + * @param client the client + * @throws AsdcCatalogException the asdc catalog exception + */ + protected void runServiceTests(AsdcClient client) throws AsdcCatalogException { + final Collection services = client.getServices(); + + collector.checkThat("getServices() returned nothing", services.isEmpty(), IsEqual.equalTo(false)); + + final Service service = services.iterator().next(); + + testService(service); + + final Service thisService = client.getService(UUID.fromString(service.getUuid())); + + collector.checkThat(thisService, IsEqual.equalTo(service)); + + for (Service aService : services) { + if (aService.getArtifacts() != null && ! aService.getArtifacts().isEmpty()) { + final Artifact artifact = aService.getArtifacts().iterator().next(); + + testArtifact(artifact); + + final UUID serviceUuid = UUID.fromString(aService.getUuid()); + final UUID artifactUuid = UUID.fromString(artifact.getArtifactUUID()); + final Artifact thisArtifact = client.getServiceArtifact(serviceUuid, artifactUuid); + + collector.checkThat(artifact, IsEqual.equalTo(thisArtifact)); + break; + } + } + + try { + final Collection distributedServices = client.getServices(Collections.singletonMap("distributionStatus", new String[] {"DISTRIBUTED"})); + + for (Service distributedService : distributedServices) { + collector.checkThat(distributedService.getDistributionStatus(), IsEqual.equalTo(DistributionStatus.DISTRIBUTED)); + } + } catch (NotFoundException e) { + //No services of this distributionStatus were found + } + + try { + final Collection badServices = client.getServices(Collections.singletonMap("category", new String[] {"Bad Services"})); + + for (Service badService : badServices) { + collector.checkThat(badService.getCategory(), IsEqual.equalTo("Bad Services")); + } + } catch (NotFoundException e) { + //No services of this category were found + } + + /*final ToscaCsar toscaCsar = client.getServiceToscaModel(UUID.fromString(service.getUuid())); + + testToscaCsar(toscaCsar);*/ + } + + /** + * Test service. + * + * @param service the service + */ + private void testService(Service service) { + service.getArtifacts(); + service.getCategory(); + service.getDistributionStatus(); + service.getInvariantUUID(); + service.getLastUpdaterUserId(); + service.getLastUpdaterFullName(); + service.getLifecycleState(); + service.getName(); + service.getResources(); + service.getToscaModelURL(); + service.getUuid(); + service.getVersion(); + } + + /** + * Test resource. + * + * @param resource the resource + */ + private void testResource(Resource resource) { + resource.getArtifacts(); + resource.getCategory(); + resource.getInvariantUUID(); + resource.getLastUpdaterUserId(); + resource.getLastUpdaterFullName(); + resource.getLifecycleState(); + resource.getName(); + resource.getResources(); + resource.getResourceType(); + resource.getSubCategory(); + resource.getToscaModel(); + resource.getToscaModelURL(); + resource.getToscaResourceName(); + resource.getUuid(); + resource.getVersion(); + } + + /** + * Test artifact. + * + * @param artifact the artifact + */ + private void testArtifact(Artifact artifact) { + artifact.getArtifactChecksum(); + artifact.getArtifactDescription(); + artifact.getArtifactName(); + artifact.getArtifactTimeout(); + artifact.getArtifactType(); + artifact.getArtifactURL(); + artifact.getArtifactUUID(); + artifact.getArtifactVersion(); + artifact.getGeneratedFromUUID(); + } + + /** + * Test tosca csar. + * + * @param toscaCsar the tosca csar + */ + private void testToscaCsar(ToscaCsar toscaCsar) { + testToscaModel(toscaCsar.getParent()); + + for (ToscaModel childModel : toscaCsar.getChildren()) { + testToscaModel(childModel); + } + } + + /** + * Test tosca model. + * + * @param toscaModel the tosca model + */ + private void testToscaModel(ToscaModel toscaModel) { + + toscaModel.getDescription(); + toscaModel.getMetadata().getCategory(); + toscaModel.getMetadata().getDescription(); + toscaModel.getMetadata().getInvariantUUID(); + toscaModel.getMetadata().getName(); + toscaModel.getMetadata().getType(); + toscaModel.getMetadata().gettemplate_name(); + toscaModel.getMetadata().getUUID(); + toscaModel.getMetadata().getVersion(); + //toscaModel.getMetadata().isServiceEcompNaming(); + toscaModel.getMetadata().isServiceHoming(); + + if (!toscaModel.gettopology_template().getInputs().isEmpty()) { + final Input input = toscaModel.gettopology_template().getInputs().values().iterator().next(); + input.getDefault(); + input.getDescription(); + input.getType(); + input.toString(); + } + + if (!toscaModel.gettopology_template().getnode_templates().isEmpty()) { + final NodeTemplate nodeTemplate = toscaModel.gettopology_template().getnode_templates().values().iterator().next(); + nodeTemplate.getMetadata(); + nodeTemplate.getProperties(); + nodeTemplate.getRequirements(); + nodeTemplate.getType(); + } + + if (!toscaModel.gettopology_template().getGroups().isEmpty()) { + final Group group = toscaModel.gettopology_template().getGroups().values().iterator().next(); + group.getMembers(); + group.getMetadata(); + group.getType(); + } + + if (!toscaModel.getImports().isEmpty()) { + for (Map> imports : toscaModel.getImports()) { + imports.values().iterator().next().get("file"); + } + } + + toscaModel.gettopology_template().getsubstitution_mappings().getnode_type(); + + if (!toscaModel.gettopology_template().getsubstitution_mappings().getCapabilities().isEmpty()) { + toscaModel.gettopology_template().getsubstitution_mappings().getCapabilities(); + } + + toscaModel.gettosca_definitions_version(); + } + + /** + * Test try catch asdc catalog exception. + */ + @Test + public void testTryCatchAsdcCatalogException() { + try { + throw new AsdcCatalogException("testing"); + } catch (AsdcCatalogException e) { + Assert.assertEquals("testing", e.getMessage()); + } + + final Exception cause = new Exception(); + + try { + throw new AsdcCatalogException("testing", cause); + } catch (AsdcCatalogException e) { + Assert.assertEquals("testing", e.getMessage()); + Assert.assertEquals(cause, e.getCause()); + } + } +} diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/InMemoryClientTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/InMemoryClientTest.java new file mode 100644 index 000000000..5687e628b --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/InMemoryClientTest.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * VID ASDC Client + * ================================================================================ + * 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.vid.asdc; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URISyntaxException; + +import org.codehaus.jackson.map.ObjectMapper; +import org.json.JSONObject; +import org.json.JSONTokener; +import org.junit.Before; +import org.junit.Test; +import org.onap.vid.asdc.memory.InMemoryAsdcClient; + +/** + * The Class InMemoryClientTest. + */ +public class InMemoryClientTest extends BaseClientTest { + + /** The catalog. */ + private JSONObject catalog; + + /** + * Sets the up. + * + * @throws URISyntaxException the URI syntax exception + * @throws IOException Signals that an I/O exception has occurred. + */ + @Before + public void setUp() throws URISyntaxException, IOException { + final InputStream asdcCatalogFile = getClass().getClassLoader().getResourceAsStream("catalog.json"); + + final JSONTokener tokener = new JSONTokener(asdcCatalogFile); + + catalog = new JSONObject(tokener); + } + + /** + * Test resources. + * + * @throws AsdcCatalogException the asdc catalog exception + */ + @Test + public void testResources() throws AsdcCatalogException { + + runResourceTests(new InMemoryAsdcClient.Builder().catalog(catalog).mapper(new ObjectMapper()).build()); + } + + /** + * Test services. + * + * @throws AsdcCatalogException the asdc catalog exception + * @throws URISyntaxException the URI syntax exception + */ + @Test + public void testServices() throws AsdcCatalogException, URISyntaxException { + + runServiceTests(new InMemoryAsdcClient.Builder().catalog(catalog).build()); + } +} diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/RestfulClientTest.java b/vid-app-common/src/test/java/org/onap/vid/asdc/RestfulClientTest.java new file mode 100644 index 000000000..ae0563420 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/asdc/RestfulClientTest.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * VID ASDC Client + * ================================================================================ + * 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.vid.asdc; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Properties; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLSession; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; + +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.onap.vid.asdc.rest.RestfulAsdcClient; + +/** + * The Class RestfulClientTest. + */ +@Ignore +public class RestfulClientTest extends BaseClientTest { + + /** The rest client. */ + private Client restClient; + + /** The uri. */ + private URI uri; + + /** The properties. */ + private Properties properties; + + /** The auth. */ + private String auth; + + /** + * Sets the up. + * + * @throws URISyntaxException the URI syntax exception + * @throws IOException Signals that an I/O exception has occurred. + */ + @Before + public void setUp() throws URISyntaxException, IOException { + final InputStream propertiesFile = getClass().getClassLoader().getResourceAsStream("asdc.properties"); + + properties = new Properties(); + properties.load(propertiesFile); + + final String protocol = properties.getProperty("protocol", "http"); + + restClient = ClientBuilder.newBuilder() + .hostnameVerifier(new HostnameVerifier() { + + @Override + public boolean verify(String arg0, SSLSession arg1) { + return true; + } + }) + .build(); + uri = new URI(protocol + "://" + properties.getProperty("host", "localhost") + ":" + properties.getProperty("port", "80") + "/"); + auth = properties.getProperty("auth"); + } + + /** + * Test resources. + * + * @throws AsdcCatalogException the asdc catalog exception + */ + @Test + public void testResources() throws AsdcCatalogException { + + runResourceTests(new RestfulAsdcClient.Builder(restClient, uri).auth(auth).build()); + } + + /** + * Test services. + * + * @throws AsdcCatalogException the asdc catalog exception + * @throws URISyntaxException the URI syntax exception + */ + @Test + public void testServices() throws AsdcCatalogException, URISyntaxException { + + runServiceTests(new RestfulAsdcClient.Builder(restClient, uri).auth(auth).build()); + } +} diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/beans/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/TestSuite.java deleted file mode 100644 index 6f0d47a2e..000000000 --- a/vid-app-common/src/test/java/org/onap/vid/asdc/beans/TestSuite.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.onap.vid.asdc.beans; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses( - -{ ArtifactTest.class, ResourceTest.class, SubResourceTest.class }) -public class TestSuite { // nothing -} diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/TestSuite.java deleted file mode 100644 index d94d33920..000000000 --- a/vid-app-common/src/test/java/org/onap/vid/asdc/beans/tosca/TestSuite.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.onap.vid.asdc.beans.tosca; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses( - -{ GroupTest.class, TopologyTemplateTest.class, ToscaModelTest.class, CapabilityTest.class, ToscaMetadataTest.class, - ConstraintTest.class, NodeTemplateTest.class }) -public class TestSuite { // nothing -} diff --git a/vid-app-common/src/test/java/org/onap/vid/client/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/client/TestSuite.java deleted file mode 100644 index 434dd5cc0..000000000 --- a/vid-app-common/src/test/java/org/onap/vid/client/TestSuite.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.onap.vid.client; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses( - -{ FakeHttpSessionTest.class }) -public class TestSuite { // nothing -} diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/test/TestAaiControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/test/TestAaiControllerTest.java new file mode 100644 index 000000000..c05db9b95 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/controller/test/TestAaiControllerTest.java @@ -0,0 +1,27 @@ +package org.onap.vid.controller.test; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Test; + +public class TestAaiControllerTest { + + private TestAaiController createTestSubject() { + return new TestAaiController(); + } + + @Test + public void testGetSubscriptionServiceTypeList() throws Exception { + TestAaiController testSubject; + String globalCustomerId = ""; + HttpServletRequest request = null; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getSubscriptionServiceTypeList(globalCustomerId, request); + } + + +} \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/test/TestAsdcControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/test/TestAsdcControllerTest.java new file mode 100644 index 000000000..0e7a6033f --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/controller/test/TestAsdcControllerTest.java @@ -0,0 +1,26 @@ +package org.onap.vid.controller.test; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Test; + +public class TestAsdcControllerTest { + + private TestAsdcController createTestSubject() { + return new TestAsdcController(); + } + + @Test + public void testGetModel() throws Exception { + TestAsdcController testSubject; + String modelId = ""; + HttpServletRequest request = null; + String result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getModel(modelId, request); + } + +} \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/test/TestMsoControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/test/TestMsoControllerTest.java new file mode 100644 index 000000000..e5d62c7d0 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/controller/test/TestMsoControllerTest.java @@ -0,0 +1,29 @@ +package org.onap.vid.controller.test; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Test; +import org.springframework.http.ResponseEntity; + +public class TestMsoControllerTest { + + private TestMsoController createTestSubject() { + return new TestMsoController(); + } + + + @Test + public void testGetOrchestrationRequests() throws Exception { + TestMsoController testSubject; + String filterString = ""; + HttpServletRequest request = null; + ResponseEntity result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getOrchestrationRequests(filterString, request); + } + + +} \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/test/TestPageControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/test/TestPageControllerTest.java new file mode 100644 index 000000000..f47eb4079 --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/controller/test/TestPageControllerTest.java @@ -0,0 +1,31 @@ +package org.onap.vid.controller.test; + +import org.junit.Test; +import org.springframework.web.servlet.ModelAndView; + +public class TestPageControllerTest { + + private TestPageController createTestSubject() { + return new TestPageController(); + } + + @Test + public void testTestMsoPage() throws Exception { + TestPageController testSubject; + ModelAndView result; + + // default test + testSubject = createTestSubject(); + result = testSubject.testMsoPage(); + } + + @Test + public void testTestViewEditPage() throws Exception { + TestPageController testSubject; + ModelAndView result; + + // default test + testSubject = createTestSubject(); + result = testSubject.testViewEditPage(); + } +} \ No newline at end of file diff --git a/vid-app-common/src/test/java/org/onap/vid/model/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/model/TestSuite.java deleted file mode 100644 index f634fbc95..000000000 --- a/vid-app-common/src/test/java/org/onap/vid/model/TestSuite.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.onap.vid.model; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses( - -{ ModelUtilTest.class, NewServiceTest.class, VolumeGroupTest.class, NewNodeTest.class, ServiceModelTest.class, - WorkflowTest.class, NewVNFTest.class }) -public class TestSuite { // nothing -} diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/TestSuite.java deleted file mode 100644 index 72633daef..000000000 --- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/TestSuite.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.onap.vid.mso.rest; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses( - -{ RelatedModelTest.class, AsyncRequestStatusTest.class, RequestDetailsTest.class, - RelatedInstanceTest.class }) -public class TestSuite { // nothing -} diff --git a/vid-app-common/src/test/java/org/onap/vid/policy/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/policy/TestSuite.java deleted file mode 100644 index 6d2a790be..000000000 --- a/vid-app-common/src/test/java/org/onap/vid/policy/TestSuite.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.onap.vid.policy; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses( - -{ RestObjectTest.class, PolicyResponseWrapperTest.class, PolicyRestIntTest.class, PolicyUtilTest.class, - PolicyRestInterfaceTest.class, org.onap.vid.policy.rest.TestSuite.class }) -public class TestSuite { // nothing -} diff --git a/vid-app-common/src/test/java/org/onap/vid/policy/rest/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/policy/rest/TestSuite.java deleted file mode 100644 index 0a8dfff91..000000000 --- a/vid-app-common/src/test/java/org/onap/vid/policy/rest/TestSuite.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.onap.vid.policy.rest; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses( - -{ RequestDetailsTest.class }) -public class TestSuite { // nothing -} diff --git a/vid-app-common/src/test/java/org/onap/vid/properties/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/properties/TestSuite.java deleted file mode 100644 index 747c1edbd..000000000 --- a/vid-app-common/src/test/java/org/onap/vid/properties/TestSuite.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.onap.vid.properties; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses( - -{ VidPropertiesTest.class }) -public class TestSuite { // nothing -} diff --git a/vid-app-common/src/test/java/org/onap/vid/roles/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/roles/TestSuite.java deleted file mode 100644 index 7966eaa1f..000000000 --- a/vid-app-common/src/test/java/org/onap/vid/roles/TestSuite.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.onap.vid.roles; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses( - -{ RoleValidatorTest.class, RoleProviderTest.class }) -public class TestSuite { // nothing -} diff --git a/vid-app-common/src/test/java/org/onap/vid/scheduler/rest/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/scheduler/rest/TestSuite.java deleted file mode 100644 index 2bdeeb307..000000000 --- a/vid-app-common/src/test/java/org/onap/vid/scheduler/rest/TestSuite.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.onap.vid.scheduler.rest; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses( - -{ RequestDetailsTest.class }) -public class TestSuite { // nothing -} diff --git a/vid-app-common/src/test/java/org/onap/vid/services/TestSuite.java b/vid-app-common/src/test/java/org/onap/vid/services/TestSuite.java deleted file mode 100644 index e43432467..000000000 --- a/vid-app-common/src/test/java/org/onap/vid/services/TestSuite.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.onap.vid.services; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses( - -{ ChangeManagementServiceImplTest.class, ChangeManagementServiceTest.class }) -public class TestSuite { // nothing -} -- cgit 1.2.3-korg