Add missing tests 03/45703/1
authorDenes Nemeth <denes.nemeth@nokia.com>
Wed, 2 May 2018 21:27:40 +0000 (23:27 +0200)
committerDenes Nemeth <denes.nemeth@nokia.com>
Wed, 2 May 2018 21:27:40 +0000 (23:27 +0200)
Change-Id: Id6d9e7112c60dbab765e66c97f6a81e466989b6a
Signed-off-by: Denes Nemeth <denes.nemeth@nokia.com>
Issue-ID: VFC-728

22 files changed:
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/NokiaSvnfmApplication.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/VnfmCredentials.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AAIExternalSystemInfoProvider.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/GenericVnfManager.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/CbamVnfdBuilder.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CatalogManager.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/CbamRestApiProvider.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Constants.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/JobManagerForSo.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManagerForSo.java
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForSo.java [new file with mode: 0644]
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForVfc.java [new file with mode: 0644]
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForSo.java [new file with mode: 0644]
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForSo.java [new file with mode: 0644]
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForVfc.java [new file with mode: 0644]
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForSo.java [new file with mode: 0644]
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForVfc.java [new file with mode: 0644]
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForSo.java [new file with mode: 0644]
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForVfc.java [new file with mode: 0644]

index 40abab1..f1c2a6f 100644 (file)
@@ -55,10 +55,6 @@ public class NokiaSvnfmApplication {
         systemFunctions().newSpringApplication(NokiaSvnfmApplication.class).run(args);
     }
 
-    private static boolean isDirect(ConfigurableApplicationContext applicationContext) {
-        return newHashSet(applicationContext.getEnvironment().getActiveProfiles()).contains("direct");
-    }
-
     /**
      * Responsible for starting the self registration process after the servlet has been started
      * and is ready to answer REST request
@@ -104,7 +100,8 @@ public class NokiaSvnfmApplication {
                 return true;
             };
             executorService.submit(() -> {
-                while (!jobManagerForVfc.isPreparingForShutDown() && !jobManagerForSo.isPreparingForShutDown()) {
+                boolean notPrepareForShutDown = !jobManagerForVfc.isPreparingForShutDown() && !jobManagerForSo.isPreparingForShutDown();
+                while (notPrepareForShutDown) {
                     try {
                         executorService.submit(singleRegistration).get();
                         //registration successful
@@ -112,11 +109,17 @@ public class NokiaSvnfmApplication {
                     } catch (Exception e) {
                         logger.warn("Unable to execute self registration process", e);
                     }
+
                     systemFunctions().sleep(5000);
                 }
+                logger.warn("Component is preparing for shutdown giving up component start");
             });
         }
 
+        private static boolean isDirect(ConfigurableApplicationContext applicationContext) {
+            return newHashSet(applicationContext.getEnvironment().getActiveProfiles()).contains("direct");
+        }
+
     }
 
     /**
index 270d004..c511064 100644 (file)
@@ -68,6 +68,7 @@ public class VnfmCredentials {
     }
 
     @Override
+    @SuppressWarnings("squid:S2068") //the password is hashed
     public String toString() {
         return "VnfmCredentials{" +
                 "username='" + username + '\'' +
index fb4de3f..ce8f744 100644 (file)
@@ -121,6 +121,6 @@ public class AAIExternalSystemInfoProvider extends GenericExternalSystemInfoProv
     @Override
     public Set<String> getVnfms() {
         EsrVnfmList esrVnfmList = aaiRestApiProvider.getExternalSystemApi().getExternalSystemEsrVnfmList().blockingFirst();
-        return newHashSet(transform(esrVnfmList.getEsrVnfm(), esr -> esr.getVnfmId()));
+        return newHashSet(transform(esrVnfmList.getEsrVnfm(), EsrVnfm::getVnfmId));
     }
 }
index 953eda9..d0df8a8 100644 (file)
@@ -99,7 +99,7 @@ public class GenericVnfManager extends AbstractManager {
             vnf.setRelationshipList(new ArrayList<>());
         }
         if (nsId.isPresent()) {
-            addSingletonRelation(vnf.getRelationshipList(), linkTo(nsId.get()));
+            addSingletonRelation(vnf.getRelationshipList(), linkToNs(nsId.get()));
         }
         aaiRestApiProvider.getNetworkApi().createOrUpdateNetworkGenericVnfsGenericVnf(vnf.getVnfId(), vnf).blockingFirst();
     }
index ec2ad27..882a164 100644 (file)
@@ -27,6 +27,8 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.child;
  */
 public class CbamVnfdBuilder {
 
+    public static final String DEFAULT = "default";
+
     /**
      * @param cbamVnfdContent the original CBAM VNFD
      * @return the modified content CBAM VNFD
@@ -36,11 +38,11 @@ public class CbamVnfdBuilder {
         JsonObject substitutionMappings = child(child(root, "topology_template"), "substitution_mappings");
         JsonObject extensions = addChild(addChild(addChild(addChild(addChild(substitutionMappings, "capabilities"), "vnf"), "properties"), "modifiable_attributes"), "extensions");
         JsonObject onapCsarId = addChild(extensions, "onapCsarId");
-        onapCsarId.add("default", new JsonPrimitive("kuku"));
+        onapCsarId.add(DEFAULT, new JsonPrimitive("kuku"));
         JsonObject externalVnfmId = addChild(extensions, "externalVnfmId");
-        externalVnfmId.add("default", new JsonPrimitive("kuku"));
+        externalVnfmId.add(DEFAULT, new JsonPrimitive("kuku"));
         JsonObject vimId = addChild(extensions, "vimId");
-        vimId.add("default", new JsonPrimitive("kuku"));
+        vimId.add(DEFAULT, new JsonPrimitive("kuku"));
         JsonObject interfaces = child(substitutionMappings, "interfaces");
         JsonObject basic = addChild(interfaces, "Basic");
         addOperationParams(addChild(basic, "instantiate"));
index 736735e..029e627 100644 (file)
@@ -44,6 +44,7 @@ import static org.springframework.web.bind.annotation.RequestMethod.POST;
 @Controller
 @RequestMapping(value = BASE_URL)
 public class LcmApi {
+    public static final String IDENTIFIER = " identifier";
     private static Logger logger = getLogger(LcmApi.class);
 
     private final LifecycleManager lifecycleManager;
@@ -84,7 +85,7 @@ public class LcmApi {
     @RequestMapping(value = "/{vnfmId}/vnfs/{vnfId}/terminate", method = POST, produces = APPLICATION_JSON_VALUE)
     @ResponseBody
     public JobInfo terminateVnf(@RequestBody VnfTerminateRequest request, @PathVariable("vnfmId") String vnfmId, @PathVariable("vnfId") String vnfId, HttpServletResponse httpResponse) {
-        logger.info("REST: Terminate VNF with " + vnfId + " identifier");
+        logger.info("REST: Terminate VNF with " + vnfId + IDENTIFIER);
         return lifecycleManager.terminateAndDelete(vnfmId, vnfId, request, httpResponse);
     }
 
@@ -99,7 +100,7 @@ public class LcmApi {
     @RequestMapping(value = "/{vnfmId}/vnfs/{vnfId}", method = GET, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
     @ResponseBody
     public VnfInfo queryVnf(@PathVariable("vnfmId") String vnfmId, @PathVariable("vnfId") String vnfId, HttpServletResponse httpResponse) {
-        logger.info("REST: Query VNF with " + vnfId + " identifier");
+        logger.info("REST: Query VNF with " + vnfId + IDENTIFIER);
         return lifecycleManager.queryVnf(vnfmId, vnfId);
     }
 
@@ -114,7 +115,7 @@ public class LcmApi {
     @RequestMapping(value = "/{vnfmId}/jobs/{jobId}", method = GET, produces = APPLICATION_JSON_VALUE)
     @ResponseBody
     public JobDetailInfo getJob(@PathVariable("vnfmId") String vnfmId, @PathVariable("jobId") String jobId, HttpServletResponse httpResponse) {
-        logger.debug("REST: Query job with " + jobId + " identifier");
+        logger.debug("REST: Query job with " + jobId + IDENTIFIER);
         return jobManager.getJob(vnfmId, jobId);
     }
 
@@ -130,7 +131,7 @@ public class LcmApi {
     @RequestMapping(value = "/{vnfmId}/vnfs/{vnfId}/scale", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
     @ResponseBody
     public JobInfo scaleVnf(@RequestBody VnfScaleRequest request, @PathVariable("vnfmId") String vnfmId, @PathVariable("vnfId") String vnfId, HttpServletResponse httpResponse) {
-        logger.info("REST: Scale VNF with " + vnfId + " identifier");
+        logger.info("REST: Scale VNF with " + vnfId + IDENTIFIER);
         return lifecycleManager.scaleVnf(vnfmId, vnfId, request, httpResponse);
     }
 
@@ -146,7 +147,7 @@ public class LcmApi {
     @RequestMapping(value = "/{vnfmId}/vnfs/{vnfId}/heal", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
     @ResponseBody
     public JobInfo healVnf(@RequestBody VnfHealRequest request, @PathVariable("vnfmId") String vnfmId, @PathVariable("vnfId") String vnfId, HttpServletResponse httpResponse) {
-        logger.info("REST: Heal VNF with " + vnfId + " identifier");
+        logger.info("REST: Heal VNF with " + vnfId + IDENTIFIER);
         return lifecycleManager.healVnf(vnfmId, vnfId, request, empty(), httpResponse);
     }
 }
index 7908d2e..aeeae42 100644 (file)
@@ -160,7 +160,7 @@ public class CatalogManager {
         }
     }
 
-    private boolean isPackageReplicatedToCbam(String cbamVnfdId, DefaultApi cbamCatalogApi) throws IOException {
+    private boolean isPackageReplicatedToCbam(String cbamVnfdId, DefaultApi cbamCatalogApi) {
         for (CatalogAdapterVnfpackage vnfPackage : cbamCatalogApi.list().blockingFirst()) {
             if (vnfPackage.getVnfdId().equals(cbamVnfdId)) {
                 return true;
index cda091c..a695df9 100644 (file)
@@ -22,7 +22,6 @@ import com.nokia.cbam.lcm.v32.api.OperationExecutionsApi;
 import com.nokia.cbam.lcm.v32.api.VnfsApi;
 import com.nokia.cbam.lcn.v32.api.SubscriptionsApi;
 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VnfmInfoProvider;
-import org.onap.vnfmdriver.model.VnfmInfo;
 
 import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.GenericExternalSystemInfoProvider.convert;
 
@@ -97,7 +96,6 @@ public class CbamRestApiProvider {
 
     @VisibleForTesting
     ApiClient buildLcmApiClient(String vnfmId) {
-        VnfmInfo vnfmInfo = vnfmInfoProvider.getVnfmInfo(vnfmId);
         ApiClient apiClient = new ApiClient();
         apiClient.getOkBuilder().sslSocketFactory(cbamSecurityProvider.buildSSLSocketFactory(), cbamSecurityProvider.buildTrustManager());
         apiClient.getOkBuilder().hostnameVerifier(cbamSecurityProvider.buildHostnameVerifier());
index 3d4ec93..1b6b4eb 100644 (file)
@@ -22,7 +22,12 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManag
  * Common constants
  */
 public class Constants {
+
     public static final String BASE_SUFFIX = "/" + SelfRegistrationManager.SERVICE_NAME + "/v1";
     public static final String BASE_URL = "/api" + BASE_SUFFIX;
     public static final String LCN_URL = "/lcn";
+
+    private Constants(){
+        //use in static way
+    }
 }
index 0fca430..7175862 100644 (file)
@@ -20,6 +20,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 
+/**
+ * Responsible for providing jobs for SO
+ */
 @Component
 public class JobManagerForSo extends JobManager {
 
index b2f2bba..70051e3 100644 (file)
@@ -24,7 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 /**
- * Responsible for executing lifecycle operation on the VNF
+ * Responsible for executing lifecycle operation on the VNF operated by SO
  */
 @Component
 public class LifecycleManagerForSo extends LifecycleManager {
index 69a74bc..8964c80 100644 (file)
@@ -96,6 +96,155 @@ public class TestNokiaSvnfmApplication extends TestBase {
         assertTrue(ApplicationReadyEvent.class.isAssignableFrom(event.getClass()));
     }
 
+    /**
+     * Assert that the self registration process is started after the servlet is up and is able to answer REST requests.
+     */
+    @Test
+    @SuppressWarnings("squid:S2925") //the execution is asynchronous no other way to wait
+    public void testRegistrationIsNotCalledIfPreparingForShutdown() throws Exception {
+        //given
+        ApplicationReadyEvent event = Mockito.mock(ApplicationReadyEvent.class);
+        useSo(event);
+        when(jobManagerForSo.isPreparingForShutDown()).thenReturn(true);
+        //when
+        selfRegistrationTriggerer.onApplicationEvent(event);
+        //verify
+        boolean success = false;
+        while (!success) {
+            try {
+                verify(logger).warn("Component is preparing for shutdown giving up component start");
+                success = true;
+            } catch (Error e) {
+
+            }
+            Thread.sleep(10);
+        }
+        verify(selfRegistrationManagerForSo, never()).register();
+        // this forces the event to be fired after the servlet is up (prevents refactor)
+        assertTrue(ApplicationReadyEvent.class.isAssignableFrom(event.getClass()));
+    }
+
+
+    /**
+     * Assert that the self registration process is started after the servlet is up and is able to answer REST requests.
+     */
+    @Test
+    @SuppressWarnings("squid:S2925") //the execution is asynchronous no other way to wait
+    public void testRegistrationIsCalledAfterComponentIsUpForSo() throws Exception {
+        //given
+        ApplicationReadyEvent event = Mockito.mock(ApplicationReadyEvent.class);
+        useSo(event);
+        //when
+        selfRegistrationTriggerer.onApplicationEvent(event);
+        //verify
+        boolean success = false;
+        while (!success) {
+            try {
+                verify(selfRegistrationManagerForSo).register();
+                verify(logger).info("Self registration started");
+                verify(logger).info("Self registration finished");
+                success = true;
+            } catch (Error e) {
+
+            }
+            Thread.sleep(10);
+        }
+        // this forces the event to be fired after the servlet is up (prevents refactor)
+        assertTrue(ApplicationReadyEvent.class.isAssignableFrom(event.getClass()));
+    }
+
+    /**
+     * Failuires in the self registration process is retried for SO
+     */
+    @Test
+    @SuppressWarnings("squid:S2925") //the execution is asynchronous no other way to wait
+    public void testFailuresInRegistrationIsRetriedForSo() throws Exception {
+        //given
+        ApplicationReadyEvent event = Mockito.mock(ApplicationReadyEvent.class);
+        RuntimeException e2 = new RuntimeException();
+        useSo(event);
+        Set<Boolean> calls = new HashSet<>();
+        doAnswer(new Answer() {
+            @Override
+            public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
+                if(calls.size() == 0){
+                    calls.add(true);
+                    throw e2;
+                }
+                return null;
+            }
+        }).when(selfRegistrationManagerForSo).register();
+        //when
+        selfRegistrationTriggerer.onApplicationEvent(event);
+        //verify
+        boolean success = false;
+        while (!success) {
+            try {
+                verify(logger).info("Self registration finished");
+                success = true;
+            } catch (Error e) {
+
+            }
+            Thread.sleep(10);
+        }
+        verify(selfRegistrationManagerForSo, times(2)).register();
+        verify(systemFunctions).sleep(5000);
+        verify(logger, times(2)).info("Self registration started");
+        verify(logger).error("Self registration failed", e2);
+        // this forces the event to be fired after the servlet is up (prevents refactor)
+        assertTrue(ApplicationReadyEvent.class.isAssignableFrom(event.getClass()));
+    }
+
+    /**
+     * Failuires in the self registration process is retried for VFC
+     */
+    @Test
+    @SuppressWarnings("squid:S2925") //the execution is asynchronous no other way to wait
+    public void testFailuresInRegistrationIsRetriedForVfc() throws Exception {
+        //given
+        ApplicationReadyEvent event = Mockito.mock(ApplicationReadyEvent.class);
+        RuntimeException e2 = new RuntimeException();
+        useVfc(event);
+        Set<Boolean> calls = new HashSet<>();
+        doAnswer(new Answer() {
+            @Override
+            public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
+                if(calls.size() == 0){
+                    calls.add(true);
+                    throw e2;
+                }
+                return null;
+            }
+        }).when(selfRegistrationManagerForVfc).register();
+        //when
+        selfRegistrationTriggerer.onApplicationEvent(event);
+        //verify
+        boolean success = false;
+        while (!success) {
+            try {
+                verify(logger).info("Self registration finished");
+                success = true;
+            } catch (Error e) {
+
+            }
+            Thread.sleep(10);
+        }
+        verify(selfRegistrationManagerForVfc, times(2)).register();
+        verify(systemFunctions).sleep(5000);
+        verify(logger, times(2)).info("Self registration started");
+        verify(logger).error("Self registration failed", e2);
+        // this forces the event to be fired after the servlet is up (prevents refactor)
+        assertTrue(ApplicationReadyEvent.class.isAssignableFrom(event.getClass()));
+    }
+
+    private void useSo(ApplicationReadyEvent event) {
+        ConfigurableApplicationContext context = Mockito.mock(ConfigurableApplicationContext.class);
+        ConfigurableEnvironment environment = Mockito.mock(ConfigurableEnvironment.class);
+        when(context.getEnvironment()).thenReturn(environment);
+        when(event.getApplicationContext()).thenReturn(context);
+        when(environment.getActiveProfiles()).thenReturn(new String[]{"direct"});
+    }
+
     private void useVfc(ApplicationReadyEvent event) {
         ConfigurableApplicationContext context = Mockito.mock(ConfigurableApplicationContext.class);
         ConfigurableEnvironment environment = Mockito.mock(ConfigurableEnvironment.class);
@@ -111,6 +260,13 @@ public class TestNokiaSvnfmApplication extends TestBase {
         when(environment.getActiveProfiles()).thenReturn(new String[]{});
     }
 
+    private void useSo(ContextClosedEvent event) {
+        ApplicationContext context = Mockito.mock(ApplicationContext.class);
+        when(context.getEnvironment()).thenReturn(environment);
+        when(event.getApplicationContext()).thenReturn(context);
+        when(environment.getActiveProfiles()).thenReturn(new String[]{"direct"});
+    }
+
     /**
      * Assert that the self de-registration process is started after the servlet has been ramped down
      */
@@ -132,6 +288,27 @@ public class TestNokiaSvnfmApplication extends TestBase {
         assertTrue(ContextClosedEvent.class.isAssignableFrom(event.getClass()));
     }
 
+    /**
+     * Assert that the self de-registration process is started after the servlet has been ramped down
+     */
+    @Test
+    public void testUnRegistrationIsCalledAfterComponentIsUpForSo() throws Exception {
+        //given
+        ContextClosedEvent event = Mockito.mock(ContextClosedEvent.class);
+        useSo(event);
+        //when
+        selfUnregistrationTriggerer.onApplicationEvent(event);
+        //verify
+        InOrder inOrder = Mockito.inOrder(jobManagerForVfc, jobManagerForSo, selfRegistrationManagerForSo);
+        inOrder.verify(jobManagerForVfc).prepareForShutdown();
+        inOrder.verify(jobManagerForSo).prepareForShutdown();
+        inOrder.verify(selfRegistrationManagerForSo).deRegister();
+        verify(logger).info("Self de-registration started");
+        verify(logger).info("Self de-registration finished");
+        // this forces the event to be fired after the servlet is down (prevents refactor)
+        assertTrue(ContextClosedEvent.class.isAssignableFrom(event.getClass()));
+    }
+
     /**
      * Assert that the self registration process is started after the servlet is up and is able to answer REST requests.
      */
@@ -151,9 +328,9 @@ public class TestNokiaSvnfmApplication extends TestBase {
      */
     @Test
     @SuppressWarnings("squid:S2925") //the execution is asynchronous no other way to wait
+
     public void failedFirstRegistration() {
         //given
-
         Set<RuntimeException> expectedException = new HashSet<>();
         doAnswer(new Answer() {
             @Override
index 347d6d2..cee26fd 100644 (file)
@@ -59,13 +59,16 @@ import org.onap.vfccatalog.api.VnfpackageApi;
 import org.onap.vnfmdriver.api.NslcmApi;
 import org.onap.vnfmdriver.model.VnfmInfo;
 import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Component;
 import org.springframework.test.util.ReflectionTestUtils;
 import retrofit2.Call;
 import retrofit2.Response;
 
 import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertNotNull;
 import static junit.framework.TestCase.assertTrue;
 import static org.mockito.Mockito.when;
 import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR;
@@ -265,4 +268,11 @@ public class TestBase {
             return s;
         }
     }
+
+    protected void assertBean(Class<?> clazz){
+        assertEquals(1, clazz.getDeclaredConstructors().length);
+        Autowired annotation = clazz.getDeclaredConstructors()[0].getAnnotation(Autowired.class);
+        assertNotNull(annotation);
+        assertNotNull(clazz.getAnnotation(Component.class));
+    }
 }
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForSo.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForSo.java
new file mode 100644 (file)
index 0000000..8d2094b
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.SdcPackageProvider;
+
+import static junit.framework.TestCase.assertNotNull;
+
+public class TestCatalogManagerForSo extends TestBase{
+    /**
+     * Test bean
+     */
+    @Test
+    public void testPojo(){
+        SdcPackageProvider sdcPackageProvider = Mockito.mock(SdcPackageProvider.class);
+        CatalogManagerForSo catalogManagerForSo = new CatalogManagerForSo(cbamRestApiProviderForSo, sdcPackageProvider);
+        assertNotNull(catalogManagerForSo);
+        assertBean(JobManagerForVfc.class);
+    }
+}
\ No newline at end of file
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCatalogManagerForVfc.java
new file mode 100644 (file)
index 0000000..1a21bd5
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.SdcPackageProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcPackageProvider;
+
+import static junit.framework.TestCase.assertNotNull;
+
+public class TestCatalogManagerForVfc extends TestBase{
+    /**
+     * Test bean
+     */
+    @Test
+    public void testPojo(){
+        VfcPackageProvider vfcPackageProvider = Mockito.mock(VfcPackageProvider.class);
+        CatalogManagerForVfc catalogManagerForVfc = new CatalogManagerForVfc(cbamRestApiProviderForVfc, vfcPackageProvider);
+        assertNotNull(catalogManagerForVfc);
+        assertBean(JobManagerForVfc.class);
+    }
+}
\ No newline at end of file
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForSo.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProviderForSo.java
new file mode 100644 (file)
index 0000000..7a7955e
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+import static org.junit.Assert.*;
+
+public class TestCbamRestApiProviderForSo {
+
+}
\ No newline at end of file
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForSo.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForSo.java
new file mode 100644 (file)
index 0000000..4777d9f
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+
+import junit.framework.TestCase;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
+
+public class TestCbamTokenProviderForSo extends TestBase {
+    @Test
+    public void testBean(){
+        CbamTokenProviderForSo cbamTokenProvider = Mockito.mock(CbamTokenProviderForSo.class);
+        AAIExternalSystemInfoProvider aaiExternalSystemInfoProvider = Mockito.mock(AAIExternalSystemInfoProvider.class);
+        CbamSecurityProvider cbamSecurityProvider = Mockito.mock(CbamSecurityProvider.class);
+        CbamRestApiProviderForSo cbamRestApiProviderForSo = new CbamRestApiProviderForSo(cbamTokenProvider, aaiExternalSystemInfoProvider, cbamSecurityProvider);
+        TestCase.assertNotNull(cbamRestApiProviderForSo);
+        assertBean(CbamRestApiProviderForSo.class);
+    }
+}
\ No newline at end of file
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProviderForVfc.java
new file mode 100644 (file)
index 0000000..59712d7
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+
+import junit.framework.TestCase;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VnfmInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider;
+
+public class TestCbamTokenProviderForVfc extends TestBase {
+    @Test
+    public void testBean(){
+        CbamTokenProviderForVfc cbamTokenProvider = Mockito.mock(CbamTokenProviderForVfc.class);
+        VfcExternalSystemInfoProvider vfcExternalSystemInfoProvider = Mockito.mock(VfcExternalSystemInfoProvider.class);
+        CbamSecurityProvider cbamSecurityProvider = Mockito.mock(CbamSecurityProvider.class);
+        CbamRestApiProviderForVfc cbamRestApiProviderForVfc = new CbamRestApiProviderForVfc(cbamTokenProvider, vfcExternalSystemInfoProvider, cbamSecurityProvider);
+        TestCase.assertNotNull(cbamRestApiProviderForSo);
+        assertBean(CbamRestApiProviderForSo.class);
+    }
+}
\ No newline at end of file
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForSo.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForSo.java
new file mode 100644 (file)
index 0000000..d25859f
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+import junit.framework.TestCase;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertNotNull;
+
+public class TestJobManagerForSo extends TestBase {
+
+    /**
+     * Test bean
+     */
+    @Test
+    public void testPojo(){
+        JobManagerForSo jobManagerForSo = new JobManagerForSo(cbamRestApiProviderForSo, selfRegistrationManagerForSo);
+        assertNotNull(jobManagerForSo);
+        assertBean(JobManagerForVfc.class);
+    }
+}
\ No newline at end of file
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManagerForVfc.java
new file mode 100644 (file)
index 0000000..1a073b5
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertNotNull;
+
+public class TestJobManagerForVfc extends TestBase {
+
+    /**
+     * Test bean
+     */
+    @Test
+    public void testPojo(){
+        JobManagerForVfc jobManagerForVfc = new JobManagerForVfc(cbamRestApiProviderForVfc, selfRegistrationManagerForVfc);
+        assertNotNull(jobManagerForVfc);
+        assertBean(JobManagerForVfc.class);
+    }
+}
\ No newline at end of file
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForSo.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForSo.java
new file mode 100644 (file)
index 0000000..ae51dc8
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+import junit.framework.TestCase;
+import org.junit.Test;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.GrantlessGrantManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForSo;
+
+import static junit.framework.TestCase.assertNotNull;
+import static org.mockito.Mockito.mock;
+
+public class TestLifecycleManagerForSo extends TestBase{
+
+    /**
+     * Test bean
+     */
+    @Test
+    public void testBean(){
+        CatalogManagerForSo catalogManager = mock(CatalogManagerForSo.class);
+        GrantlessGrantManager grantManager = mock(GrantlessGrantManager.class);
+        AAIExternalSystemInfoProvider aaiExternalSystemInfoProvider = mock(AAIExternalSystemInfoProvider.class);
+        JobManagerForSo jobManagerForSo = mock(JobManagerForSo.class);
+        LifecycleChangeNotificationManagerForSo lifecycleChangeNotificationManagerForSo = mock(LifecycleChangeNotificationManagerForSo.class);
+        LifecycleManagerForSo lifecycleManagerForSo = new LifecycleManagerForSo(catalogManager, grantManager, cbamRestApiProviderForSo, aaiExternalSystemInfoProvider, jobManagerForSo, lifecycleChangeNotificationManagerForSo);
+        assertNotNull(lifecycleManagerForSo);
+        assertBean(LifecycleChangeNotificationManagerForSo.class);
+    }
+}
\ No newline at end of file
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForVfc.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManagerForVfc.java
new file mode 100644 (file)
index 0000000..e245e58
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+import org.junit.Test;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.GrantlessGrantManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.vfc.VfcExternalSystemInfoProvider;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForSo;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.LifecycleChangeNotificationManagerForVfc;
+
+import static junit.framework.TestCase.assertNotNull;
+import static org.mockito.Mockito.mock;
+
+public class TestLifecycleManagerForVfc extends TestBase{
+    /**
+     * Test bean
+     */
+    @Test
+    public void testBean(){
+        CatalogManagerForVfc catalogManager = mock(CatalogManagerForVfc.class);
+        GrantlessGrantManager grantManager = mock(GrantlessGrantManager.class);
+        VfcExternalSystemInfoProvider aaiExternalSystemInfoProvider = mock(VfcExternalSystemInfoProvider.class);
+        JobManagerForVfc jobManagerForSo = mock(JobManagerForVfc.class);
+        LifecycleChangeNotificationManagerForVfc lifecycleChangeNotificationManagerForSo = mock(LifecycleChangeNotificationManagerForVfc.class);
+        LifecycleManagerForVfc lifecycleManagerForSo = new LifecycleManagerForVfc(catalogManager, grantManager, cbamRestApiProviderForVfc, aaiExternalSystemInfoProvider, jobManagerForSo, lifecycleChangeNotificationManagerForSo);
+        assertNotNull(lifecycleManagerForSo);
+        assertBean(LifecycleChangeNotificationManagerForVfc.class);
+    }
+}
\ No newline at end of file