JUnit tests for BBInputSetup 46/83046/1
authorr.bogacki <r.bogacki@samsung.com>
Fri, 22 Mar 2019 14:43:49 +0000 (15:43 +0100)
committerr.bogacki <r.bogacki@samsung.com>
Fri, 22 Mar 2019 14:44:59 +0000 (15:44 +0100)
Increase junit tests coverage according to Sonar analyses.
Fix imports.

Change-Id: Ia6c3f4a3178f5293ee6750f7581cd7107c8ced84
Issue-ID: SO-1692
Signed-off-by: Robert Bogacki <r.bogacki@samsung.com>
bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java

index df9f225..eb26bf3 100644 (file)
@@ -4,6 +4,8 @@
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * 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
@@ -43,6 +45,7 @@ import java.util.Map;
 import java.util.Optional;
 
 import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -2712,5 +2715,24 @@ public class BBInputSetupTest {
                assertEquals("Lookup Key Map populated with VfModule Id", vfModuleId, lookupKeyMap.get(ResourceKey.VF_MODULE_ID));
                assertEquals("Lookup Key Map populated with VolumeGroup Id", volumeGroupId, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID));
        }
+
+       @Test
+       public void testGettingVnfcToConfiguration() throws Exception {
+
+               String vnfcName = "vnfcName";
+               org.onap.aai.domain.yang.Configuration expectedAAI = new org.onap.aai.domain.yang.Configuration();
+               AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, vnfcName);
+               AAIResultWrapper configurationWrapper =
+                       new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
+
+               doReturn(new AAIResultWrapper(null)).when(SPY_bbInputSetupUtils).getAAIResourceDepthOne(aaiResourceUri);
+               Vnfc vnfc = SPY_bbInputSetup.getVnfcToConfiguration(vnfcName);
+               Assert.assertNull(vnfc);
+
+               doReturn(configurationWrapper).when(SPY_bbInputSetupUtils).getAAIResourceDepthOne(aaiResourceUri);
+               vnfc = SPY_bbInputSetup.getVnfcToConfiguration(vnfcName);
+               Assert.assertNotNull(vnfc);
+       }
+
        
 }