aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test/java')
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/AllBaseTaskTestSuite.java8
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/AllGroovyTestSuites.java6
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/AllTestSuites.java6
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseTest.java168
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseUnitTest.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java960
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java28
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/NonSpringSuite.java1
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/SerializableChecker.java66
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/TestApplication.java18
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/TestApplicationConfig.java114
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/appc/payload/PayloadClientTest.java100
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/BeansTest.java60
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DefaultToShortClassNameBeanNameGeneratorTest.java52
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java3
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MSOCommonApplication.java73
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java20
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java45
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java522
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/SPIPropertiesTest.java65
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/WorkflowContextHolderTest.java62
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/WorkflowTestTransformer.java13
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/baseclient/BaseClientTest.java52
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnParamTest.java49
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnRestClientTest.java23
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/ResourceInputTest.java94
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/ResourceRecipeRequestTest.java76
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java610
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/util/CryptoHandlerTest.java55
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java84
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyDisabledValidator.java19
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java17
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java19
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java17
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java18
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/ValidationConfig.java3
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java19
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java18
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java82
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/FileUtil.java85
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java2047
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAPPC.java49
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseDatabase.java145
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseNetworkAdapter.java137
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseOof.java20
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponsePolicy.java141
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSDNCAdapter.java133
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSNIRO.java46
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseVNFAdapter.java244
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/BBDecompPojoTest.java32
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/BBPojoTest.java51
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java379
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/SerializationTest.java86
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/entities/exceptions/InvalidBuildingBlockInputExceptionTest.java79
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java1296
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java5280
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java1480
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java207
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java407
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundExceptionTest.java77
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundExceptionTest.java77
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/ResponseExceptionMapperImplTest.java100
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerActionTest.java858
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java160
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerSupportTest.java78
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/avpn/dmaap/beans/AVPNDmaapBeansTest.java37
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java15
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForPnfTest.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForVnfTest.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignRequestPnfTest.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignRequestVnfTest.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnfTest.java3
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForVnfTest.java1
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployRequestPnfTest.java1
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployRequestVnfTest.java1
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java102
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java35
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java87
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/AAIPropertiesImplTest.java38
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/PolicyRestPropertiesImplTest.java44
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/ThreadedReadTest.java122
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/test/categories/SpringAware.java2
82 files changed, 8720 insertions, 9117 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/AllBaseTaskTestSuite.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/AllBaseTaskTestSuite.java
index cd9bdc9532..f56256fac8 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/AllBaseTaskTestSuite.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/AllBaseTaskTestSuite.java
@@ -21,13 +21,13 @@
package org.onap.so;
import org.junit.runner.RunWith;
-
import com.googlecode.junittoolbox.SuiteClasses;
import com.googlecode.junittoolbox.WildcardPatternSuite;
@RunWith(WildcardPatternSuite.class)
-@SuiteClasses({"**/common/aai/tasks/*Test.class", "**/bpmn/sdno/tasks/*Test.class", "**/buildingblock/SniroHomingV2Test.class"})
+@SuiteClasses({"**/common/aai/tasks/*Test.class", "**/bpmn/sdno/tasks/*Test.class",
+ "**/buildingblock/SniroHomingV2Test.class"})
public class AllBaseTaskTestSuite {
- // the class remains empty,
- // used only as a holder for the above annotations
+ // the class remains empty,
+ // used only as a holder for the above annotations
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/AllGroovyTestSuites.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/AllGroovyTestSuites.java
index 696323c4ad..2608fad987 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/AllGroovyTestSuites.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/AllGroovyTestSuites.java
@@ -19,14 +19,14 @@
*/
package org.onap.so;
-import org.junit.runner.RunWith;
+import org.junit.runner.RunWith;
import com.googlecode.junittoolbox.SuiteClasses;
import com.googlecode.junittoolbox.WildcardPatternSuite;
@RunWith(WildcardPatternSuite.class)
@SuiteClasses({"**/bpmn/common/scripts/**/*Test.class"})
public class AllGroovyTestSuites {
- // the class remains empty,
- // used only as a holder for the above annotations
+ // the class remains empty,
+ // used only as a holder for the above annotations
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/AllTestSuites.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/AllTestSuites.java
index fa70ccf23d..0bcae3f4cf 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/AllTestSuites.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/AllTestSuites.java
@@ -19,14 +19,14 @@
*/
package org.onap.so;
-import org.junit.runner.RunWith;
+import org.junit.runner.RunWith;
import com.googlecode.junittoolbox.SuiteClasses;
import com.googlecode.junittoolbox.WildcardPatternSuite;
@RunWith(WildcardPatternSuite.class)
@SuiteClasses({"**/*Test.class", "!**/bpmn/common/scripts/**/*Test.class"})
public class AllTestSuites {
- // the class remains empty,
- // used only as a holder for the above annotations
+ // the class remains empty,
+ // used only as a holder for the above annotations
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseTest.java
index 0f702fca2d..e7395b716e 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseTest.java
@@ -26,7 +26,6 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
-
import org.camunda.bpm.engine.RepositoryService;
import org.camunda.bpm.engine.RuntimeService;
import org.junit.Before;
@@ -51,7 +50,6 @@ import org.springframework.http.HttpHeaders;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
-
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.tomakehurst.wiremock.WireMockServer;
@@ -63,88 +61,86 @@ import com.github.tomakehurst.wiremock.WireMockServer;
@AutoConfigureWireMock(port = 0)
@Category(SpringAware.class)
public abstract class BaseTest extends BuildingBlockTestDataSetup {
-
-
- protected Map<String, Object> variables = new HashMap<>();
-
- protected TestRestTemplate restTemplate = new TestRestTemplate();
-
- protected HttpHeaders headers = new HttpHeaders();
-
-
- @Autowired
- protected RuntimeService runtimeService;
-
- @Autowired
- private RepositoryService repositoryService;
-
- @Autowired
- protected WireMockServer wireMockServer;
- /*
- * Mocked for injection via autowiring
- */
-
- @Value("${mso.catalog.db.spring.endpoint}")
- protected String endpoint;
-
- @Value("${wiremock.server.port}")
- protected String wireMockPort;
-
- @MockBean
- protected CatalogDbClient MOCK_catalogDbClient;
-
- @SpyBean
- protected InjectionHelper MOCK_injectionHelper;
-
- @SpyBean
- protected ExceptionBuilder exceptionUtil;
-
- /*
- * Classes that cannot be simply mocked because they are both
- * needed for testing another class, and must be autowired when
- * being tested themselves....or classes with private methods that
- * must be stubbed during testing
- */
-
- @SpyBean
- protected BBInputSetupMapperLayer SPY_bbInputSetupMapperLayer;
- @SpyBean
- protected BBInputSetupUtils SPY_bbInputSetupUtils;
- @SpyBean
- protected BBInputSetup SPY_bbInputSetup;
-
- /*
- * Mocked for injection via the IntectionHelper
- */
-
-
-
- @Before
- public void baseTestBefore() {
- wireMockServer.resetAll();
- variables.put("gBuildingBlockExecution", execution);
- }
-
- @LocalServerPort
- private int port;
-
- protected String readFile(String path) throws IOException {
- return readFile(path, Charset.defaultCharset());
- }
-
- protected String readFile(String path, Charset encoding) throws IOException {
- byte[] encoded = Files.readAllBytes(Paths.get(path));
- return new String(encoded, encoding);
- }
-
- protected String readJsonFileAsString(String fileLocation) throws IOException{
- ObjectMapper mapper = new ObjectMapper();
- JsonNode jsonNode = mapper.readTree(new File(fileLocation));
- return jsonNode.asText();
- }
-
- protected String createURLWithPort(String uri) {
- return "http://localhost:" + port + uri;
- }
-
+
+
+ protected Map<String, Object> variables = new HashMap<>();
+
+ protected TestRestTemplate restTemplate = new TestRestTemplate();
+
+ protected HttpHeaders headers = new HttpHeaders();
+
+
+ @Autowired
+ protected RuntimeService runtimeService;
+
+ @Autowired
+ private RepositoryService repositoryService;
+
+ @Autowired
+ protected WireMockServer wireMockServer;
+ /*
+ * Mocked for injection via autowiring
+ */
+
+ @Value("${mso.catalog.db.spring.endpoint}")
+ protected String endpoint;
+
+ @Value("${wiremock.server.port}")
+ protected String wireMockPort;
+
+ @MockBean
+ protected CatalogDbClient MOCK_catalogDbClient;
+
+ @SpyBean
+ protected InjectionHelper MOCK_injectionHelper;
+
+ @SpyBean
+ protected ExceptionBuilder exceptionUtil;
+
+ /*
+ * Classes that cannot be simply mocked because they are both needed for testing another class, and must be
+ * autowired when being tested themselves....or classes with private methods that must be stubbed during testing
+ */
+
+ @SpyBean
+ protected BBInputSetupMapperLayer SPY_bbInputSetupMapperLayer;
+ @SpyBean
+ protected BBInputSetupUtils SPY_bbInputSetupUtils;
+ @SpyBean
+ protected BBInputSetup SPY_bbInputSetup;
+
+ /*
+ * Mocked for injection via the IntectionHelper
+ */
+
+
+
+ @Before
+ public void baseTestBefore() {
+ wireMockServer.resetAll();
+ variables.put("gBuildingBlockExecution", execution);
+ }
+
+ @LocalServerPort
+ private int port;
+
+ protected String readFile(String path) throws IOException {
+ return readFile(path, Charset.defaultCharset());
+ }
+
+ protected String readFile(String path, Charset encoding) throws IOException {
+ byte[] encoded = Files.readAllBytes(Paths.get(path));
+ return new String(encoded, encoding);
+ }
+
+ protected String readJsonFileAsString(String fileLocation) throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode jsonNode = mapper.readTree(new File(fileLocation));
+ return jsonNode.asText();
+ }
+
+ protected String createURLWithPort(String uri) {
+ return "http://localhost:" + port + uri;
+ }
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseUnitTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseUnitTest.java
index 5719ce15e2..fc5709d1be 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseUnitTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BaseUnitTest.java
@@ -20,6 +20,6 @@
package org.onap.so;
-public abstract class BaseUnitTest extends BuildingBlockTestDataSetup{
+public abstract class BaseUnitTest extends BuildingBlockTestDataSetup {
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java
index bf98648dbc..79a94d5298 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java
@@ -21,13 +21,11 @@ package org.onap.so;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
-
import org.assertj.core.util.Arrays;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl;
@@ -71,511 +69,513 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoAllottedResource;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy;
-public class BuildingBlockTestDataSetup{
- private int collectionCounter;
- private int configurationCounter;
- private int customerCounter;
- private int genericVnfCounter;
- private int instanceGroupCounter;
- private int l3NetworkCounter;
- private int owningEntityCounter;
- private int pnfCounter;
- private int projectCounter;
- private int serviceInstanceCounter;
- private int serviceProxyCounter;
- private int serviceSubscriptionCounter;
- private int vfModuleCounter;
- private int volumeGroupCounter;
- private int vpnBindingCounter;
- private int vpnBondingLinkCounter;
-
- protected BuildingBlockExecution execution;
-
- protected GeneralBuildingBlock gBBInput;
-
- protected HashMap<ResourceKey, String> lookupKeyMap;
-
- protected ExtractPojosForBB extractPojosForBB = new ExtractPojosForBB();
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- protected DelegateExecution delegateExecution;
-
- @Before
- public void buildingBlockTestDataSetupBefore() {
- collectionCounter = 0;
- configurationCounter = 0;
- customerCounter = 0;
- genericVnfCounter = 0;
- instanceGroupCounter = 0;
- l3NetworkCounter = 0;
- owningEntityCounter = 0;
- pnfCounter = 0;
- projectCounter = 0;
- serviceInstanceCounter = 0;
- serviceProxyCounter = 0;
- serviceSubscriptionCounter = 0;
- vfModuleCounter = 0;
- volumeGroupCounter = 0;
- vpnBindingCounter = 0;
- vpnBondingLinkCounter = 0;
-
- execution = new DelegateExecutionImpl(new ExecutionImpl());
- execution.setVariable("testProcessKey", "testProcessKeyValue");
-
- gBBInput = new GeneralBuildingBlock();
- execution.setVariable("gBBInput", gBBInput);
-
- lookupKeyMap = new HashMap<ResourceKey, String>();
- execution.setVariable("lookupKeyMap", lookupKeyMap);
-
- ExecutionImpl mockExecutionImpl = mock(ExecutionImpl.class);
- doReturn("test").when(mockExecutionImpl).getProcessInstanceId();
-
- ExecutionImpl executionImpl = new ExecutionImpl();
- executionImpl.setProcessInstance(mockExecutionImpl);
-
- delegateExecution = (DelegateExecution) executionImpl;
- delegateExecution.setVariable("testProcessKey", "testProcessKeyValue");
- }
-
- public Map<String, String> buildUserInput() {
- Map<String, String> userInput = new HashMap<>();
- userInput.put("testUserInputKey", "testUserInputValue");
-
- return userInput;
- }
-
- public Map<String, String> setUserInput() {
- Map<String, String> userInput = buildUserInput();
-
- gBBInput.setUserInput(userInput);
-
- return userInput;
- }
-
- public RequestContext buildRequestContext() {
- RequestContext requestContext = new RequestContext();
- requestContext.setMsoRequestId(UUID.randomUUID().toString());
- requestContext.setProductFamilyId("testProductFamilyId");
- requestContext.setRequestorId("testRequestorId");
-
- requestContext.setUserParams(new HashMap<>());
-
- Map<String,Object> dataMap = new HashMap<>();
- dataMap.put("vpnId","testVpnId");
- dataMap.put("vpnRegion","testVpnRegion");
- dataMap.put("vpnRt","testVpnRt");
- dataMap.put("vpnName","vpnName");
+public class BuildingBlockTestDataSetup {
+ private int collectionCounter;
+ private int configurationCounter;
+ private int customerCounter;
+ private int genericVnfCounter;
+ private int instanceGroupCounter;
+ private int l3NetworkCounter;
+ private int owningEntityCounter;
+ private int pnfCounter;
+ private int projectCounter;
+ private int serviceInstanceCounter;
+ private int serviceProxyCounter;
+ private int serviceSubscriptionCounter;
+ private int vfModuleCounter;
+ private int volumeGroupCounter;
+ private int vpnBindingCounter;
+ private int vpnBondingLinkCounter;
+
+ protected BuildingBlockExecution execution;
+
+ protected GeneralBuildingBlock gBBInput;
+
+ protected HashMap<ResourceKey, String> lookupKeyMap;
+
+ protected ExtractPojosForBB extractPojosForBB = new ExtractPojosForBB();
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ protected DelegateExecution delegateExecution;
+
+ @Before
+ public void buildingBlockTestDataSetupBefore() {
+ collectionCounter = 0;
+ configurationCounter = 0;
+ customerCounter = 0;
+ genericVnfCounter = 0;
+ instanceGroupCounter = 0;
+ l3NetworkCounter = 0;
+ owningEntityCounter = 0;
+ pnfCounter = 0;
+ projectCounter = 0;
+ serviceInstanceCounter = 0;
+ serviceProxyCounter = 0;
+ serviceSubscriptionCounter = 0;
+ vfModuleCounter = 0;
+ volumeGroupCounter = 0;
+ vpnBindingCounter = 0;
+ vpnBondingLinkCounter = 0;
+
+ execution = new DelegateExecutionImpl(new ExecutionImpl());
+ execution.setVariable("testProcessKey", "testProcessKeyValue");
+
+ gBBInput = new GeneralBuildingBlock();
+ execution.setVariable("gBBInput", gBBInput);
+
+ lookupKeyMap = new HashMap<ResourceKey, String>();
+ execution.setVariable("lookupKeyMap", lookupKeyMap);
+
+ ExecutionImpl mockExecutionImpl = mock(ExecutionImpl.class);
+ doReturn("test").when(mockExecutionImpl).getProcessInstanceId();
+
+ ExecutionImpl executionImpl = new ExecutionImpl();
+ executionImpl.setProcessInstance(mockExecutionImpl);
+
+ delegateExecution = (DelegateExecution) executionImpl;
+ delegateExecution.setVariable("testProcessKey", "testProcessKeyValue");
+ }
+
+ public Map<String, String> buildUserInput() {
+ Map<String, String> userInput = new HashMap<>();
+ userInput.put("testUserInputKey", "testUserInputValue");
+
+ return userInput;
+ }
+
+ public Map<String, String> setUserInput() {
+ Map<String, String> userInput = buildUserInput();
+
+ gBBInput.setUserInput(userInput);
+
+ return userInput;
+ }
+
+ public RequestContext buildRequestContext() {
+ RequestContext requestContext = new RequestContext();
+ requestContext.setMsoRequestId(UUID.randomUUID().toString());
+ requestContext.setProductFamilyId("testProductFamilyId");
+ requestContext.setRequestorId("testRequestorId");
+
+ requestContext.setUserParams(new HashMap<>());
+
+ Map<String, Object> dataMap = new HashMap<>();
+ dataMap.put("vpnId", "testVpnId");
+ dataMap.put("vpnRegion", "testVpnRegion");
+ dataMap.put("vpnRt", "testVpnRt");
+ dataMap.put("vpnName", "vpnName");
ArrayList<String> vpnRegions = new ArrayList<String>();
vpnRegions.add("USA");
vpnRegions.add("EMEA");
vpnRegions.add("APAC");
dataMap.put("vpnRegion", vpnRegions);
- HashMap<String,Object> userParams = new HashMap<>();
- userParams.put("vpnData",dataMap);
+ HashMap<String, Object> userParams = new HashMap<>();
+ userParams.put("vpnData", dataMap);
- List<Map<String,Object>> userParamsList = new ArrayList<>();
- userParamsList.add(userParams);
+ List<Map<String, Object>> userParamsList = new ArrayList<>();
+ userParamsList.add(userParams);
- RequestParameters requestParameters = new RequestParameters();
- requestParameters.setUserParams(userParamsList);
- requestContext.setRequestParameters(requestParameters);
+ RequestParameters requestParameters = new RequestParameters();
+ requestParameters.setUserParams(userParamsList);
+ requestContext.setRequestParameters(requestParameters);
- return requestContext;
- }
+ return requestContext;
+ }
- public RequestContext setRequestContext() {
- RequestContext requestContext = buildRequestContext();
+ public RequestContext setRequestContext() {
+ RequestContext requestContext = buildRequestContext();
- gBBInput.setRequestContext(requestContext);
+ gBBInput.setRequestContext(requestContext);
- return requestContext;
- }
+ return requestContext;
+ }
- public CloudRegion buildCloudRegion() {
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("testLcpCloudRegionId");
- cloudRegion.setTenantId("testTenantId");
- cloudRegion.setCloudOwner("testCloudOwner");
+ public CloudRegion buildCloudRegion() {
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("testLcpCloudRegionId");
+ cloudRegion.setTenantId("testTenantId");
+ cloudRegion.setCloudOwner("testCloudOwner");
- return cloudRegion;
- }
+ return cloudRegion;
+ }
- public CloudRegion setCloudRegion() {
- CloudRegion cloudRegion = buildCloudRegion();
+ public CloudRegion setCloudRegion() {
+ CloudRegion cloudRegion = buildCloudRegion();
- gBBInput.setCloudRegion(cloudRegion);
+ gBBInput.setCloudRegion(cloudRegion);
- return cloudRegion;
- }
+ return cloudRegion;
+ }
- public OrchestrationContext buildOrchestrationContext() {
- OrchestrationContext orchestrationContext = new OrchestrationContext();
+ public OrchestrationContext buildOrchestrationContext() {
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
- return orchestrationContext;
- }
+ return orchestrationContext;
+ }
- public OrchestrationContext setOrchestrationContext() {
- OrchestrationContext orchestrationContext = buildOrchestrationContext();
+ public OrchestrationContext setOrchestrationContext() {
+ OrchestrationContext orchestrationContext = buildOrchestrationContext();
- gBBInput.setOrchContext(orchestrationContext);
+ gBBInput.setOrchContext(orchestrationContext);
- return orchestrationContext;
- }
+ return orchestrationContext;
+ }
- public Collection buildCollection() {
- collectionCounter++;
+ public Collection buildCollection() {
+ collectionCounter++;
- Collection collection = new Collection();
- collection.setId("testId" + collectionCounter);
- collection.setInstanceGroup(buildInstanceGroup());
+ Collection collection = new Collection();
+ collection.setId("testId" + collectionCounter);
+ collection.setInstanceGroup(buildInstanceGroup());
- return collection;
- }
+ return collection;
+ }
- public Configuration buildConfiguration() {
- configurationCounter++;
+ public Configuration buildConfiguration() {
+ configurationCounter++;
- Configuration configuration = new Configuration();
- configuration.setConfigurationId("testConfigurationId" + configurationCounter);
- configuration.setConfigurationName("testConfigurationName" + configurationCounter);
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationId("testConfigurationId" + configurationCounter);
+ configuration.setConfigurationName("testConfigurationName" + configurationCounter);
- ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
- modelInfoConfiguration.setModelVersionId("testModelVersionId" + configurationCounter);
- modelInfoConfiguration.setModelInvariantId("testModelInvariantId" + configurationCounter);
- modelInfoConfiguration.setModelCustomizationId("testModelCustomizationId" + configurationCounter);
+ ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
+ modelInfoConfiguration.setModelVersionId("testModelVersionId" + configurationCounter);
+ modelInfoConfiguration.setModelInvariantId("testModelInvariantId" + configurationCounter);
+ modelInfoConfiguration.setModelCustomizationId("testModelCustomizationId" + configurationCounter);
- configuration.setModelInfoConfiguration(modelInfoConfiguration);
+ configuration.setModelInfoConfiguration(modelInfoConfiguration);
- return configuration;
- }
+ return configuration;
+ }
- public OwningEntity buildOwningEntity() {
- owningEntityCounter++;
+ public OwningEntity buildOwningEntity() {
+ owningEntityCounter++;
- OwningEntity owningEntity = new OwningEntity();
- owningEntity.setOwningEntityId("testOwningEntityId" + owningEntityCounter);
- owningEntity.setOwningEntityName("testOwningEntityName" + owningEntityCounter);
+ OwningEntity owningEntity = new OwningEntity();
+ owningEntity.setOwningEntityId("testOwningEntityId" + owningEntityCounter);
+ owningEntity.setOwningEntityName("testOwningEntityName" + owningEntityCounter);
- return owningEntity;
- }
+ return owningEntity;
+ }
- public Project buildProject() {
- projectCounter++;
+ public Project buildProject() {
+ projectCounter++;
- Project project = new Project();
- project.setProjectName("testProjectName" + projectCounter);
+ Project project = new Project();
+ project.setProjectName("testProjectName" + projectCounter);
- return project;
- }
+ return project;
+ }
- public ServiceSubscription buildServiceSubscription() {
- serviceSubscriptionCounter++;
+ public ServiceSubscription buildServiceSubscription() {
+ serviceSubscriptionCounter++;
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- serviceSubscription.setTempUbSubAccountId("testTempUbSubAccountId" + serviceSubscriptionCounter);
- serviceSubscription.setServiceType("testServiceType" + serviceSubscriptionCounter);
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setTempUbSubAccountId("testTempUbSubAccountId" + serviceSubscriptionCounter);
+ serviceSubscription.setServiceType("testServiceType" + serviceSubscriptionCounter);
- return serviceSubscription;
- }
+ return serviceSubscription;
+ }
- public Customer buildCustomer() {
- customerCounter++;
+ public Customer buildCustomer() {
+ customerCounter++;
- Customer customer = new Customer();
- customer.setGlobalCustomerId("testGlobalCustomerId" + customerCounter);
- customer.setSubscriberType("testSubscriberType" + customerCounter);
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("testGlobalCustomerId" + customerCounter);
+ customer.setSubscriberType("testSubscriberType" + customerCounter);
- customer.setServiceSubscription(buildServiceSubscription());
+ customer.setServiceSubscription(buildServiceSubscription());
- return customer;
- }
+ return customer;
+ }
- public ServiceInstance buildServiceInstance() {
- serviceInstanceCounter++;
+ public ServiceInstance buildServiceInstance() {
+ serviceInstanceCounter++;
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("testServiceInstanceId" + serviceInstanceCounter);
- serviceInstance.setServiceInstanceName("testServiceInstanceName" + serviceInstanceCounter);
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("testServiceInstanceId" + serviceInstanceCounter);
+ serviceInstance.setServiceInstanceName("testServiceInstanceName" + serviceInstanceCounter);
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelInvariantUuid("testModelInvariantUUID" + serviceInstanceCounter);
- modelInfoServiceInstance.setModelUuid("testModelUUID" + serviceInstanceCounter);
- modelInfoServiceInstance.setModelVersion("testModelVersion" + serviceInstanceCounter);
- modelInfoServiceInstance.setModelName("testModelName" + serviceInstanceCounter);
- modelInfoServiceInstance.setServiceType("testServiceType" + serviceInstanceCounter);
- serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelInvariantUuid("testModelInvariantUUID" + serviceInstanceCounter);
+ modelInfoServiceInstance.setModelUuid("testModelUUID" + serviceInstanceCounter);
+ modelInfoServiceInstance.setModelVersion("testModelVersion" + serviceInstanceCounter);
+ modelInfoServiceInstance.setModelName("testModelName" + serviceInstanceCounter);
+ modelInfoServiceInstance.setServiceType("testServiceType" + serviceInstanceCounter);
+ serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
- serviceInstance.setProject(buildProject());
+ serviceInstance.setProject(buildProject());
- serviceInstance.setOwningEntity(buildOwningEntity());
+ serviceInstance.setOwningEntity(buildOwningEntity());
- serviceInstance.setCollection(buildCollection());
+ serviceInstance.setCollection(buildCollection());
- serviceInstance.getConfigurations().add(buildConfiguration());
+ serviceInstance.getConfigurations().add(buildConfiguration());
- return serviceInstance;
- }
+ return serviceInstance;
+ }
- public ServiceInstance setServiceInstance() {
- ServiceInstance serviceInstance = buildServiceInstance();
+ public ServiceInstance setServiceInstance() {
+ ServiceInstance serviceInstance = buildServiceInstance();
- if(gBBInput.getCustomer() == null) {
- gBBInput.setCustomer(buildCustomer());
- }
- gBBInput.getCustomer().getServiceSubscription().getServiceInstances().add(serviceInstance);
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId());
+ if (gBBInput.getCustomer() == null) {
+ gBBInput.setCustomer(buildCustomer());
+ }
+ gBBInput.getCustomer().getServiceSubscription().getServiceInstances().add(serviceInstance);
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId());
- return serviceInstance;
- }
+ return serviceInstance;
+ }
- public Customer setCustomer() {
- if(gBBInput.getCustomer() != null) return gBBInput.getCustomer();
- Customer customer = new Customer();
- customer.setGlobalCustomerId("testGlobalCustomerId");
- customer.setSubscriberType("testSubscriberType");
+ public Customer setCustomer() {
+ if (gBBInput.getCustomer() != null)
+ return gBBInput.getCustomer();
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("testGlobalCustomerId");
+ customer.setSubscriberType("testSubscriberType");
- customer.setServiceSubscription(buildServiceSubscription());
+ customer.setServiceSubscription(buildServiceSubscription());
- gBBInput.setCustomer(customer);
+ gBBInput.setCustomer(customer);
- return customer;
- }
+ return customer;
+ }
- public Collection setCollection() {
- Collection collection = new Collection();
- collection.setId("testId");
+ public Collection setCollection() {
+ Collection collection = new Collection();
+ collection.setId("testId");
- ServiceInstance serviceInstance = null;
+ ServiceInstance serviceInstance = null;
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ } catch (BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
- serviceInstance.setCollection(collection);
+ serviceInstance.setCollection(collection);
- return collection;
- }
+ return collection;
+ }
- public InstanceGroup setInstanceGroup() {
- InstanceGroup instanceGroup = new InstanceGroup();
- instanceGroup.setId("testId");
- instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction");
+ public InstanceGroup setInstanceGroup() {
+ InstanceGroup instanceGroup = new InstanceGroup();
+ instanceGroup.setId("testId");
+ instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction");
- Collection collection = null;
+ Collection collection = null;
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- collection = serviceInstance.getCollection();
+ try {
+ ServiceInstance serviceInstance =
+ extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ collection = serviceInstance.getCollection();
- if (collection == null) {
- collection = setCollection();
- }
- } catch(BBObjectNotFoundException e) {
- collection = setCollection();
- }
+ if (collection == null) {
+ collection = setCollection();
+ }
+ } catch (BBObjectNotFoundException e) {
+ collection = setCollection();
+ }
- collection.setInstanceGroup(instanceGroup);
+ collection.setInstanceGroup(instanceGroup);
- return instanceGroup;
- }
+ return instanceGroup;
+ }
- public VpnBinding buildVpnBinding() {
- vpnBindingCounter++;
+ public VpnBinding buildVpnBinding() {
+ vpnBindingCounter++;
- VpnBinding vpnBinding = new VpnBinding();
- vpnBinding.setVpnId("testVpnId" + vpnBindingCounter);
- vpnBinding.setVpnName("testVpnName" + vpnBindingCounter);
- vpnBinding.setCustomerVpnId("testCustomerVpnId" + vpnBindingCounter);
+ VpnBinding vpnBinding = new VpnBinding();
+ vpnBinding.setVpnId("testVpnId" + vpnBindingCounter);
+ vpnBinding.setVpnName("testVpnName" + vpnBindingCounter);
+ vpnBinding.setCustomerVpnId("testCustomerVpnId" + vpnBindingCounter);
- return vpnBinding;
- }
+ return vpnBinding;
+ }
- public VpnBinding setVpnBinding() {
- VpnBinding vpnBinding = buildVpnBinding();
+ public VpnBinding setVpnBinding() {
+ VpnBinding vpnBinding = buildVpnBinding();
- Customer customer = gBBInput.getCustomer();
+ Customer customer = gBBInput.getCustomer();
- if(customer == null){
- customer = buildCustomer();
- }
+ if (customer == null) {
+ customer = buildCustomer();
+ }
- customer.getVpnBindings().add(vpnBinding);
- lookupKeyMap.put(ResourceKey.VPN_ID, vpnBinding.getVpnId());
+ customer.getVpnBindings().add(vpnBinding);
+ lookupKeyMap.put(ResourceKey.VPN_ID, vpnBinding.getVpnId());
- return vpnBinding;
- }
+ return vpnBinding;
+ }
- public InstanceGroup buildInstanceGroup() {
- instanceGroupCounter++;
+ public InstanceGroup buildInstanceGroup() {
+ instanceGroupCounter++;
- InstanceGroup instanceGroup = new InstanceGroup();
- instanceGroup.setId("testId" + instanceGroupCounter);
- instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction" + instanceGroupCounter);
+ InstanceGroup instanceGroup = new InstanceGroup();
+ instanceGroup.setId("testId" + instanceGroupCounter);
+ instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction" + instanceGroupCounter);
- return instanceGroup;
- }
+ return instanceGroup;
+ }
- public L3Network buildL3Network() {
- l3NetworkCounter++;
+ public L3Network buildL3Network() {
+ l3NetworkCounter++;
- L3Network network = new L3Network();
- network.setNetworkId("testNetworkId" + l3NetworkCounter);
- network.setNetworkName("testNetworkName" + l3NetworkCounter);
- network.setNetworkType("testNetworkType" + l3NetworkCounter);
+ L3Network network = new L3Network();
+ network.setNetworkId("testNetworkId" + l3NetworkCounter);
+ network.setNetworkName("testNetworkName" + l3NetworkCounter);
+ network.setNetworkType("testNetworkType" + l3NetworkCounter);
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- modelInfoNetwork.setModelInvariantUUID("testModelInvariantUUID" + l3NetworkCounter);
- modelInfoNetwork.setModelName("testModelName" + l3NetworkCounter);
- modelInfoNetwork.setModelVersion("testModelVersion" + l3NetworkCounter);
- modelInfoNetwork.setModelUUID("testModelUUID" + l3NetworkCounter);
- network.setModelInfoNetwork(modelInfoNetwork);
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ modelInfoNetwork.setModelInvariantUUID("testModelInvariantUUID" + l3NetworkCounter);
+ modelInfoNetwork.setModelName("testModelName" + l3NetworkCounter);
+ modelInfoNetwork.setModelVersion("testModelVersion" + l3NetworkCounter);
+ modelInfoNetwork.setModelUUID("testModelUUID" + l3NetworkCounter);
+ network.setModelInfoNetwork(modelInfoNetwork);
- return network;
- }
+ return network;
+ }
- public L3Network setL3Network() {
- L3Network network = buildL3Network();
+ public L3Network setL3Network() {
+ L3Network network = buildL3Network();
- ServiceInstance serviceInstance = null;
+ ServiceInstance serviceInstance = null;
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ } catch (BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
- serviceInstance.getNetworks().add(network);
- lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId());
+ serviceInstance.getNetworks().add(network);
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId());
- return network;
- }
+ return network;
+ }
- public GenericVnf buildGenericVnf() {
- genericVnfCounter++;
+ public GenericVnf buildGenericVnf() {
+ genericVnfCounter++;
- GenericVnf genericVnf = new GenericVnf();
- genericVnf.setVnfId("testVnfId" + genericVnfCounter);
- genericVnf.setVnfName("testVnfName" + genericVnfCounter);
- genericVnf.setVnfType("testVnfType" + genericVnfCounter);
+ GenericVnf genericVnf = new GenericVnf();
+ genericVnf.setVnfId("testVnfId" + genericVnfCounter);
+ genericVnf.setVnfName("testVnfName" + genericVnfCounter);
+ genericVnf.setVnfType("testVnfType" + genericVnfCounter);
- Platform platform = new Platform();
- platform.setPlatformName("testPlatformName");
- genericVnf.setPlatform(platform);
+ Platform platform = new Platform();
+ platform.setPlatformName("testPlatformName");
+ genericVnf.setPlatform(platform);
- LineOfBusiness lob = new LineOfBusiness();
- lob.setLineOfBusinessName("testLineOfBusinessName");
- genericVnf.setLineOfBusiness(lob);
+ LineOfBusiness lob = new LineOfBusiness();
+ lob.setLineOfBusinessName("testLineOfBusinessName");
+ genericVnf.setLineOfBusiness(lob);
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- modelInfoGenericVnf.setModelName("testModelName" + genericVnfCounter);
- modelInfoGenericVnf.setModelCustomizationUuid("testModelCustomizationUUID" + genericVnfCounter);
- modelInfoGenericVnf.setModelInvariantUuid("testModelInvariantUUID" + genericVnfCounter);
- modelInfoGenericVnf.setModelVersion("testModelVersion" + genericVnfCounter);
- modelInfoGenericVnf.setModelUuid("testModelUUID" + genericVnfCounter);
- modelInfoGenericVnf.setModelInstanceName("testModelInstanceName" + genericVnfCounter);
- genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ modelInfoGenericVnf.setModelName("testModelName" + genericVnfCounter);
+ modelInfoGenericVnf.setModelCustomizationUuid("testModelCustomizationUUID" + genericVnfCounter);
+ modelInfoGenericVnf.setModelInvariantUuid("testModelInvariantUUID" + genericVnfCounter);
+ modelInfoGenericVnf.setModelVersion("testModelVersion" + genericVnfCounter);
+ modelInfoGenericVnf.setModelUuid("testModelUUID" + genericVnfCounter);
+ modelInfoGenericVnf.setModelInstanceName("testModelInstanceName" + genericVnfCounter);
+ genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
- return genericVnf;
- }
+ return genericVnf;
+ }
- public GenericVnf setGenericVnf() {
- GenericVnf genericVnf = buildGenericVnf();
+ public GenericVnf setGenericVnf() {
+ GenericVnf genericVnf = buildGenericVnf();
- ServiceInstance serviceInstance = null;
+ ServiceInstance serviceInstance = null;
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ } catch (BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
- serviceInstance.getVnfs().add(genericVnf);
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, genericVnf.getVnfId());
+ serviceInstance.getVnfs().add(genericVnf);
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, genericVnf.getVnfId());
- return genericVnf;
- }
+ return genericVnf;
+ }
- public VfModule buildVfModule() {
- vfModuleCounter++;
+ public VfModule buildVfModule() {
+ vfModuleCounter++;
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("testVfModuleId" + vfModuleCounter);
- vfModule.setVfModuleName("testVfModuleName" + vfModuleCounter);
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("testVfModuleId" + vfModuleCounter);
+ vfModule.setVfModuleName("testVfModuleName" + vfModuleCounter);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID" + vfModuleCounter);
- modelInfoVfModule.setModelVersion("testModelVersion" + vfModuleCounter);
- modelInfoVfModule.setModelUUID("testModelUUID" + vfModuleCounter);
- modelInfoVfModule.setModelName("testModelName" + vfModuleCounter);
- modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID" + vfModuleCounter);
- vfModule.setModelInfoVfModule(modelInfoVfModule);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID" + vfModuleCounter);
+ modelInfoVfModule.setModelVersion("testModelVersion" + vfModuleCounter);
+ modelInfoVfModule.setModelUUID("testModelUUID" + vfModuleCounter);
+ modelInfoVfModule.setModelName("testModelName" + vfModuleCounter);
+ modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID" + vfModuleCounter);
+ vfModule.setModelInfoVfModule(modelInfoVfModule);
- return vfModule;
- }
+ return vfModule;
+ }
- public VfModule setVfModule() {
- VfModule vfModule = buildVfModule();
+ public VfModule setVfModule() {
+ VfModule vfModule = buildVfModule();
- GenericVnf genericVnf = null;
+ GenericVnf genericVnf = null;
- try {
- genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- } catch(BBObjectNotFoundException e) {
- genericVnf = setGenericVnf();
- }
+ try {
+ genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ } catch (BBObjectNotFoundException e) {
+ genericVnf = setGenericVnf();
+ }
- genericVnf.getVfModules().add(vfModule);
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModule.getVfModuleId());
+ genericVnf.getVfModules().add(vfModule);
+ lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModule.getVfModuleId());
- return vfModule;
- }
+ return vfModule;
+ }
- public VolumeGroup buildVolumeGroup() {
- volumeGroupCounter++;
+ public VolumeGroup buildVolumeGroup() {
+ volumeGroupCounter++;
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("testVolumeGroupId" + volumeGroupCounter);
- volumeGroup.setVolumeGroupName("testVolumeGroupName" + volumeGroupCounter);
- volumeGroup.setHeatStackId("testHeatStackId" + volumeGroupCounter);
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("testVolumeGroupId" + volumeGroupCounter);
+ volumeGroup.setVolumeGroupName("testVolumeGroupName" + volumeGroupCounter);
+ volumeGroup.setHeatStackId("testHeatStackId" + volumeGroupCounter);
- return volumeGroup;
- }
+ return volumeGroup;
+ }
- public VolumeGroup setVolumeGroup() {
- VolumeGroup volumeGroup = buildVolumeGroup();
+ public VolumeGroup setVolumeGroup() {
+ VolumeGroup volumeGroup = buildVolumeGroup();
- GenericVnf genericVnf = null;
+ GenericVnf genericVnf = null;
- try {
- genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- } catch(BBObjectNotFoundException e) {
- genericVnf = setGenericVnf();
- }
+ try {
+ genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ } catch (BBObjectNotFoundException e) {
+ genericVnf = setGenericVnf();
+ }
- genericVnf.getVolumeGroups().add(volumeGroup);
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId());
+ genericVnf.getVolumeGroups().add(volumeGroup);
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId());
- return volumeGroup;
- }
+ return volumeGroup;
+ }
- public Pnf buildPnf() {
- pnfCounter++;
+ public Pnf buildPnf() {
+ pnfCounter++;
- Pnf pnf = new Pnf();
- pnf.setPnfId("testPnfId" + pnfCounter);
- pnf.setPnfName("testPnfName" + pnfCounter);
+ Pnf pnf = new Pnf();
+ pnf.setPnfId("testPnfId" + pnfCounter);
+ pnf.setPnfName("testPnfName" + pnfCounter);
- return pnf;
- }
+ return pnf;
+ }
- public ServiceProxy buildServiceProxy() {
- serviceProxyCounter++;
+ public ServiceProxy buildServiceProxy() {
+ serviceProxyCounter++;
ServiceProxy serviceProxy = new ServiceProxy();
serviceProxy.setServiceInstance(buildServiceInstance());
@@ -590,106 +590,106 @@ public class BuildingBlockTestDataSetup{
serviceProxy.getServiceInstance().getPnfs().add(secondaryPnf);
return serviceProxy;
- }
+ }
- public VpnBondingLink buildVpnBondingLink() {
- vpnBondingLinkCounter++;
+ public VpnBondingLink buildVpnBondingLink() {
+ vpnBondingLinkCounter++;
- VpnBondingLink vpnBondingLink = new VpnBondingLink();
- vpnBondingLink.setVpnBondingLinkId("testVpnBondingLinkId" + vpnBondingLinkCounter);
+ VpnBondingLink vpnBondingLink = new VpnBondingLink();
+ vpnBondingLink.setVpnBondingLinkId("testVpnBondingLinkId" + vpnBondingLinkCounter);
- Configuration vnrConfiguration = buildConfiguration();
- vnrConfiguration.setNetwork(buildL3Network());
- vpnBondingLink.setVnrConfiguration(vnrConfiguration);
+ Configuration vnrConfiguration = buildConfiguration();
+ vnrConfiguration.setNetwork(buildL3Network());
+ vpnBondingLink.setVnrConfiguration(vnrConfiguration);
- vpnBondingLink.setVrfConfiguration(buildConfiguration());
+ vpnBondingLink.setVrfConfiguration(buildConfiguration());
vpnBondingLink.setInfrastructureServiceProxy(buildServiceProxy());
vpnBondingLink.setTransportServiceProxy(buildServiceProxy());
- return vpnBondingLink;
- }
-
- public VpnBondingLink setVpnBondingLink() {
- VpnBondingLink vpnBondingLink = buildVpnBondingLink();
-
- ServiceInstance serviceInstance = null;
-
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
-
- serviceInstance.getVpnBondingLinks().add(vpnBondingLink);
- lookupKeyMap.put(ResourceKey.VPN_BONDING_LINK_ID, vpnBondingLink.getVpnBondingLinkId());
-
-
- return vpnBondingLink;
- }
-
- public Customer setAvpnCustomer() {
- Customer customer = buildCustomer();
-
- gBBInput.setCustomer(customer);
-
- return customer;
- }
-
- public ServiceProxy setServiceProxy(String uniqueIdentifier, String type) {
- ServiceProxy serviceProxy = new ServiceProxy();
- serviceProxy.setId("testProxyId" + uniqueIdentifier);
- serviceProxy.setType(type);
-
- ModelInfoServiceProxy modelInfo = new ModelInfoServiceProxy();
- modelInfo.setModelInvariantUuid("testProxyModelInvariantUuid" + uniqueIdentifier);
- modelInfo.setModelName("testProxyModelName" + uniqueIdentifier);
- modelInfo.setModelUuid("testProxyModelUuid" + uniqueIdentifier);
- modelInfo.setModelVersion("testProxyModelVersion" + uniqueIdentifier);
- modelInfo.setModelInstanceName("testProxyInstanceName" + uniqueIdentifier);
-
- serviceProxy.setModelInfoServiceProxy(modelInfo);
-
- return serviceProxy;
- }
-
- public AllottedResource setAllottedResource(String uniqueIdentifier) {
- AllottedResource ar = new AllottedResource();
- ar.setId("testAllottedResourceId" + uniqueIdentifier);
-
- ModelInfoAllottedResource modelInfo = new ModelInfoAllottedResource();
- modelInfo.setModelInvariantUuid("testAllottedModelInvariantUuid" + uniqueIdentifier);
- modelInfo.setModelName("testAllottedModelName" + uniqueIdentifier);
- modelInfo.setModelUuid("testAllottedModelUuid" + uniqueIdentifier);
- modelInfo.setModelVersion("testAllottedModelVersion" + uniqueIdentifier);
- modelInfo.setModelInstanceName("testAllottedInstanceName" + uniqueIdentifier);
-
- ar.setModelInfoAllottedResource(modelInfo);
-
- return ar;
- }
-
- public Configuration setConfiguration () {
- Configuration config = new Configuration();
- config.setConfigurationId("testConfigurationId");
- ModelInfoConfiguration modelInfoConfig = new ModelInfoConfiguration();
- modelInfoConfig.setModelCustomizationId("modelCustomizationId");
- modelInfoConfig.setModelVersionId("modelVersionId");
- modelInfoConfig.setModelInvariantId("modelInvariantId");
- modelInfoConfig.setPolicyName("policyName");
- config.setModelInfoConfiguration(modelInfoConfig);
-
- List<Configuration> configurations = new ArrayList<>();
- configurations.add(config);
- ServiceInstance serviceInstance = new ServiceInstance();
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
- lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "testConfigurationId");
- serviceInstance.setConfigurations(configurations);
- return config;
- }
-} \ No newline at end of file
+ return vpnBondingLink;
+ }
+
+ public VpnBondingLink setVpnBondingLink() {
+ VpnBondingLink vpnBondingLink = buildVpnBondingLink();
+
+ ServiceInstance serviceInstance = null;
+
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ } catch (BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
+
+ serviceInstance.getVpnBondingLinks().add(vpnBondingLink);
+ lookupKeyMap.put(ResourceKey.VPN_BONDING_LINK_ID, vpnBondingLink.getVpnBondingLinkId());
+
+
+ return vpnBondingLink;
+ }
+
+ public Customer setAvpnCustomer() {
+ Customer customer = buildCustomer();
+
+ gBBInput.setCustomer(customer);
+
+ return customer;
+ }
+
+ public ServiceProxy setServiceProxy(String uniqueIdentifier, String type) {
+ ServiceProxy serviceProxy = new ServiceProxy();
+ serviceProxy.setId("testProxyId" + uniqueIdentifier);
+ serviceProxy.setType(type);
+
+ ModelInfoServiceProxy modelInfo = new ModelInfoServiceProxy();
+ modelInfo.setModelInvariantUuid("testProxyModelInvariantUuid" + uniqueIdentifier);
+ modelInfo.setModelName("testProxyModelName" + uniqueIdentifier);
+ modelInfo.setModelUuid("testProxyModelUuid" + uniqueIdentifier);
+ modelInfo.setModelVersion("testProxyModelVersion" + uniqueIdentifier);
+ modelInfo.setModelInstanceName("testProxyInstanceName" + uniqueIdentifier);
+
+ serviceProxy.setModelInfoServiceProxy(modelInfo);
+
+ return serviceProxy;
+ }
+
+ public AllottedResource setAllottedResource(String uniqueIdentifier) {
+ AllottedResource ar = new AllottedResource();
+ ar.setId("testAllottedResourceId" + uniqueIdentifier);
+
+ ModelInfoAllottedResource modelInfo = new ModelInfoAllottedResource();
+ modelInfo.setModelInvariantUuid("testAllottedModelInvariantUuid" + uniqueIdentifier);
+ modelInfo.setModelName("testAllottedModelName" + uniqueIdentifier);
+ modelInfo.setModelUuid("testAllottedModelUuid" + uniqueIdentifier);
+ modelInfo.setModelVersion("testAllottedModelVersion" + uniqueIdentifier);
+ modelInfo.setModelInstanceName("testAllottedInstanceName" + uniqueIdentifier);
+
+ ar.setModelInfoAllottedResource(modelInfo);
+
+ return ar;
+ }
+
+ public Configuration setConfiguration() {
+ Configuration config = new Configuration();
+ config.setConfigurationId("testConfigurationId");
+ ModelInfoConfiguration modelInfoConfig = new ModelInfoConfiguration();
+ modelInfoConfig.setModelCustomizationId("modelCustomizationId");
+ modelInfoConfig.setModelVersionId("modelVersionId");
+ modelInfoConfig.setModelInvariantId("modelInvariantId");
+ modelInfoConfig.setPolicyName("policyName");
+ config.setModelInfoConfiguration(modelInfoConfig);
+
+ List<Configuration> configurations = new ArrayList<>();
+ configurations.add(config);
+ ServiceInstance serviceInstance = new ServiceInstance();
+ try {
+ serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ } catch (BBObjectNotFoundException e) {
+ serviceInstance = setServiceInstance();
+ }
+ lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "testConfigurationId");
+ serviceInstance.setConfigurations(configurations);
+ return config;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
index fb08e5e830..62d9ecee44 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java
@@ -19,6 +19,7 @@
*/
package org.onap.so;
+
import ch.vorburger.exec.ManagedProcessException;
import ch.vorburger.mariadb4j.DBConfigurationBuilder;
import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
@@ -35,30 +36,25 @@ public class EmbeddedMariaDbConfig {
@Bean
MariaDB4jSpringService mariaDB4jSpringService() {
- MariaDB4jSpringService service = new MariaDB4jSpringService();
-
-
- service.getConfiguration().addArg("--lower_case_table_names=1");
+ MariaDB4jSpringService service = new MariaDB4jSpringService();
+
+
+ service.getConfiguration().addArg("--lower_case_table_names=1");
return service;
}
@Bean
DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService,
- @Value("${mariaDB4j.databaseName}") String databaseName,
- @Value("${spring.datasource.username}") String datasourceUsername,
- @Value("${spring.datasource.password}") String datasourcePassword,
- @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
- //Create our database with default root user and no password
+ @Value("${mariaDB4j.databaseName}") String databaseName,
+ @Value("${spring.datasource.username}") String datasourceUsername,
+ @Value("${spring.datasource.password}") String datasourcePassword,
+ @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
+ // Create our database with default root user and no password
mariaDB4jSpringService.getDB().createDB(databaseName);
DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration();
- return DataSourceBuilder
- .create()
- .username(datasourceUsername)
- .password(datasourcePassword)
- .url(config.getURL(databaseName))
- .driverClassName(datasourceDriver)
- .build();
+ return DataSourceBuilder.create().username(datasourceUsername).password(datasourcePassword)
+ .url(config.getURL(databaseName)).driverClassName(datasourceDriver).build();
}
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/NonSpringSuite.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/NonSpringSuite.java
index ee2848cf3a..4a9b3e1775 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/NonSpringSuite.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/NonSpringSuite.java
@@ -22,7 +22,6 @@ package org.onap.so;
import org.junit.runner.RunWith;
import org.onap.so.test.categories.SpringAware;
-
import com.googlecode.junittoolbox.ExcludeCategories;
import com.googlecode.junittoolbox.SuiteClasses;
import com.googlecode.junittoolbox.WildcardPatternSuite;
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/SerializableChecker.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/SerializableChecker.java
index 97c17d5238..47ddea1b4f 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/SerializableChecker.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/SerializableChecker.java
@@ -29,78 +29,65 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-public final class SerializableChecker
-{
- public static class SerializationFailure
- {
+public final class SerializableChecker {
+ public static class SerializationFailure {
private final String mContainingClass;
private final String mMemberName;
- public SerializationFailure(String inNonSerializableClass, String inMemberName)
- {
+ public SerializationFailure(String inNonSerializableClass, String inMemberName) {
mContainingClass = inNonSerializableClass;
mMemberName = inMemberName;
}
- public String getContainingClass()
- {
+ public String getContainingClass() {
return mContainingClass;
}
- public String getMemberName()
- {
+ public String getMemberName() {
return mMemberName;
}
- public String getBadMemberString()
- {
+ public String getBadMemberString() {
if (mMemberName == null)
return mContainingClass;
return mContainingClass + "." + mMemberName;
}
@Override
- public String toString()
- {
- return "SerializationFailure [mNonSerializableClass=" + mContainingClass + ", mMemberName=" + mMemberName + "]";
+ public String toString() {
+ return "SerializationFailure [mNonSerializableClass=" + mContainingClass + ", mMemberName=" + mMemberName
+ + "]";
}
}
- private static class SerializationCheckerData
- {
+ private static class SerializationCheckerData {
private Set<Class<?>> mSerializableClasses;
- SerializationCheckerData()
- {
+ SerializationCheckerData() {
mSerializableClasses = new HashSet<Class<?>>();
}
- boolean isAlreadyChecked(Class<?> inClass)
- {
+ boolean isAlreadyChecked(Class<?> inClass) {
return mSerializableClasses.contains(inClass);
}
- void addSerializableClass(Class<?> inClass)
- {
+ void addSerializableClass(Class<?> inClass) {
mSerializableClasses.add(inClass);
}
}
- private SerializableChecker()
- { }
+ private SerializableChecker() {}
- public static SerializationFailure isFullySerializable(Class<?> inClass)
- {
+ public static SerializationFailure isFullySerializable(Class<?> inClass) {
if (!isSerializable(inClass))
return new SerializationFailure(inClass.getName(), null);
return isFullySerializable(inClass, new SerializationCheckerData());
}
- private static SerializationFailure isFullySerializable(Class<?> inClass, SerializationCheckerData inSerializationCheckerData)
- {
- for (Field field : declaredFields(inClass))
- {
+ private static SerializationFailure isFullySerializable(Class<?> inClass,
+ SerializationCheckerData inSerializationCheckerData) {
+ for (Field field : declaredFields(inClass)) {
Class<?> fieldDeclaringClass = field.getType();
if (field.getType() == Object.class)
@@ -121,8 +108,7 @@ public final class SerializableChecker
if (inSerializationCheckerData.isAlreadyChecked(fieldDeclaringClass))
continue;
- if (isSerializable(fieldDeclaringClass))
- {
+ if (isSerializable(fieldDeclaringClass)) {
inSerializationCheckerData.addSerializableClass(inClass);
SerializationFailure failure = isFullySerializable(field.getType(), inSerializationCheckerData);
@@ -140,8 +126,7 @@ public final class SerializableChecker
return null;
}
- private static boolean isSerializable(Class<?> inClass)
- {
+ private static boolean isSerializable(Class<?> inClass) {
Set<Class<?>> interfaces = getInterfaces(inClass);
if (interfaces == null)
return false;
@@ -149,8 +134,7 @@ public final class SerializableChecker
if (isSerializable)
return true;
- for (Class<?> classInterface : interfaces)
- {
+ for (Class<?> classInterface : interfaces) {
if (isSerializable(classInterface))
return true;
}
@@ -161,13 +145,11 @@ public final class SerializableChecker
return false;
}
- private static Set<Class<?>> getInterfaces(Class<?> inFieldDeclaringClass)
- {
+ private static Set<Class<?>> getInterfaces(Class<?> inFieldDeclaringClass) {
return new HashSet<Class<?>>(Arrays.asList(inFieldDeclaringClass.getInterfaces()));
}
- private static List<Field> declaredFields(Class<?> inClass)
- {
+ private static List<Field> declaredFields(Class<?> inClass) {
List<Field> fields = new ArrayList<Field>(Arrays.asList(inClass.getDeclaredFields()));
Class<?> parentClasses = inClass.getSuperclass();
@@ -177,5 +159,5 @@ public final class SerializableChecker
fields.addAll(declaredFields(parentClasses));
return fields;
- }
}
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/TestApplication.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/TestApplication.java
index 11309914ef..029b77319b 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/TestApplication.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/TestApplication.java
@@ -30,14 +30,14 @@ import org.springframework.context.annotation.Profile;
@SpringBootApplication
@Profile("test")
-@ComponentScan(basePackages = {"org.onap.so"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class, excludeFilters = {
- @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
+@ComponentScan(basePackages = {"org.onap.so"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class,
+ excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
public class TestApplication {
- public static void main(String... args) {
- SpringApplication.run(TestApplication.class, args);
- System.getProperties().setProperty("mso.db", "MARIADB");
- System.getProperties().setProperty("server.name", "Springboot");
-
-
- }
+ public static void main(String... args) {
+ SpringApplication.run(TestApplication.class, args);
+ System.getProperties().setProperty("mso.db", "MARIADB");
+ System.getProperties().setProperty("server.name", "Springboot");
+
+
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/TestApplicationConfig.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/TestApplicationConfig.java
index c483f13887..d2bc728eb2 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/TestApplicationConfig.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/TestApplicationConfig.java
@@ -24,73 +24,71 @@ import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
-
import org.onap.so.bpmn.common.WorkflowTestTransformer;
import org.springframework.cloud.contract.wiremock.WireMockConfigurationCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
-
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
import com.github.tomakehurst.wiremock.extension.ResponseTransformer;
@Configuration
@Profile({"test"})
public class TestApplicationConfig {
-
- @Bean
- protected ResponseTransformer[] transformerArray() {
- // Process WorkflowTestTransformer annotations
- List<ResponseTransformer> transformerList = new ArrayList<ResponseTransformer>();
-
- for (Field field : getClass().getFields()) {
- WorkflowTestTransformer annotation = field.getAnnotation(WorkflowTestTransformer.class);
-
- if (annotation == null) {
- continue;
- }
-
- if (!Modifier.isStatic(field.getModifiers())) {
- throw new RuntimeException(field.getDeclaringClass().getName()
- + "#" + field.getName() + " has a @WorkflowTestTransformer "
- + " annotation but it is not declared static");
- }
-
- ResponseTransformer transformer;
-
- try {
- transformer = (ResponseTransformer) field.get(null);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(field.getDeclaringClass().getName()
- + "#" + field.getName() + " is not accessible", e);
- } catch (ClassCastException e) {
- throw new RuntimeException(field.getDeclaringClass().getName()
- + "#" + field.getName() + " is not a ResponseTransformer", e);
- }
-
- if (transformer == null) {
- continue;
- }
-
- transformerList.add(transformer);
- }
-
- ResponseTransformer[] transformerArray =
- transformerList.toArray(new ResponseTransformer[transformerList.size()]);
-
- optionsCustomizer(transformerArray);
-
- return transformerArray;
- }
-
- @Bean
- WireMockConfigurationCustomizer optionsCustomizer(ResponseTransformer[] transformerArray) {
- return new WireMockConfigurationCustomizer() {
- @Override
- public void customize(WireMockConfiguration options) {
- options.extensions(transformerArray);
- }
- };
- }
-
+
+ @Bean
+ protected ResponseTransformer[] transformerArray() {
+ // Process WorkflowTestTransformer annotations
+ List<ResponseTransformer> transformerList = new ArrayList<ResponseTransformer>();
+
+ for (Field field : getClass().getFields()) {
+ WorkflowTestTransformer annotation = field.getAnnotation(WorkflowTestTransformer.class);
+
+ if (annotation == null) {
+ continue;
+ }
+
+ if (!Modifier.isStatic(field.getModifiers())) {
+ throw new RuntimeException(field.getDeclaringClass().getName() + "#" + field.getName()
+ + " has a @WorkflowTestTransformer " + " annotation but it is not declared static");
+ }
+
+ ResponseTransformer transformer;
+
+ try {
+ transformer = (ResponseTransformer) field.get(null);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(
+ field.getDeclaringClass().getName() + "#" + field.getName() + " is not accessible", e);
+ } catch (ClassCastException e) {
+ throw new RuntimeException(
+ field.getDeclaringClass().getName() + "#" + field.getName() + " is not a ResponseTransformer",
+ e);
+ }
+
+ if (transformer == null) {
+ continue;
+ }
+
+ transformerList.add(transformer);
+ }
+
+ ResponseTransformer[] transformerArray =
+ transformerList.toArray(new ResponseTransformer[transformerList.size()]);
+
+ optionsCustomizer(transformerArray);
+
+ return transformerArray;
+ }
+
+ @Bean
+ WireMockConfigurationCustomizer optionsCustomizer(ResponseTransformer[] transformerArray) {
+ return new WireMockConfigurationCustomizer() {
+ @Override
+ public void customize(WireMockConfiguration options) {
+ options.extensions(transformerArray);
+ }
+ };
+ }
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/appc/payload/PayloadClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/appc/payload/PayloadClientTest.java
index 20c69fafe3..2ecf741869 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/appc/payload/PayloadClientTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/appc/payload/PayloadClientTest.java
@@ -21,61 +21,61 @@
package org.onap.so.bpmn.appc.payload;
import static org.junit.Assert.assertEquals;
-
import java.util.Optional;
-
import org.json.JSONObject;
import org.junit.Test;
public class PayloadClientTest {
- @Test
- public void upgradeFormatTest() throws Exception {
- String payloadResult = "{\"configuration-parameters\":{\"vnf_name\":\"vnfName1\",\"existing_software_version\":\"existingVersion\",\"new_software_version\":\"newVersion\"}}";
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("existing_software_version", "existingVersion");
- jsonObject.put("new_software_version", "newVersion");
- Optional<String> payload = Optional.of(jsonObject.toString());
- Optional<String> payloadClient = PayloadClient.upgradeFormat(payload, "vnfName1");
- assertEquals(payloadResult, payloadClient.get());
- }
+ @Test
+ public void upgradeFormatTest() throws Exception {
+ String payloadResult =
+ "{\"configuration-parameters\":{\"vnf_name\":\"vnfName1\",\"existing_software_version\":\"existingVersion\",\"new_software_version\":\"newVersion\"}}";
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("existing_software_version", "existingVersion");
+ jsonObject.put("new_software_version", "newVersion");
+ Optional<String> payload = Optional.of(jsonObject.toString());
+ Optional<String> payloadClient = PayloadClient.upgradeFormat(payload, "vnfName1");
+ assertEquals(payloadResult, payloadClient.get());
+ }
+
+ @Test
+ public void resumeTrafficFormatTest() throws Exception {
+ String payloadResult = "{\"configuration-parameters\":{\"vnf_name\":\"vnfName1\"}}";
+ Optional<String> payloadClient = PayloadClient.resumeTrafficFormat("vnfName1");
+ assertEquals(payloadResult, payloadClient.get());
+ }
+
+ @Test
+ public void quiesceTrafficFormatTest() throws Exception {
+ String payloadResult =
+ "{\"configuration-parameters\":{\"vnf_name\":\"vnfName1\",\"operations_timeout\":\"operationTimeout\"}}";
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("operations_timeout", "operationTimeout");
+ Optional<String> payload = Optional.of(jsonObject.toString());
+ Optional<String> payloadClient = PayloadClient.quiesceTrafficFormat(payload, "vnfName1");
+ assertEquals(payloadResult, payloadClient.get());
+ }
+
+ @Test
+ public void startStopFormatTest() throws Exception {
+ String payloadResult = "{\" AICIdentity \":\"aicIdentity1\"}";
+ Optional<String> payloadClient = PayloadClient.startStopFormat("aicIdentity1");
+ assertEquals(payloadResult, payloadClient.get());
+ }
+
+ @Test
+ public void healthCheckFormatTest() throws Exception {
+ String payloadResult = "{\"request-parameters\":{\"host-ip-address\":\"hostIpAddress1\"}}";
+ Optional<String> payloadClient = PayloadClient.healthCheckFormat("vnfName1", "hostIpAddress1");
+ assertEquals(payloadResult, payloadClient.get());
+ }
+
+ @Test
+ public void snapshotFormatTest() throws Exception {
+ String payloadResult = "{\"vm-id\":\"vmId1\",\"identity-url\":\"identityUrl1\"}";
+ Optional<String> payloadClient = PayloadClient.snapshotFormat("vmId1", "identityUrl1");
+ assertEquals(payloadResult, payloadClient.get());
+ }
- @Test
- public void resumeTrafficFormatTest() throws Exception {
- String payloadResult = "{\"configuration-parameters\":{\"vnf_name\":\"vnfName1\"}}";
- Optional<String> payloadClient = PayloadClient.resumeTrafficFormat("vnfName1");
- assertEquals(payloadResult, payloadClient.get());
- }
-
- @Test
- public void quiesceTrafficFormatTest() throws Exception {
- String payloadResult = "{\"configuration-parameters\":{\"vnf_name\":\"vnfName1\",\"operations_timeout\":\"operationTimeout\"}}";
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("operations_timeout", "operationTimeout");
- Optional<String> payload = Optional.of(jsonObject.toString());
- Optional<String> payloadClient = PayloadClient.quiesceTrafficFormat(payload, "vnfName1");
- assertEquals(payloadResult, payloadClient.get());
- }
-
- @Test
- public void startStopFormatTest() throws Exception {
- String payloadResult = "{\" AICIdentity \":\"aicIdentity1\"}";
- Optional<String> payloadClient = PayloadClient.startStopFormat("aicIdentity1");
- assertEquals(payloadResult, payloadClient.get());
- }
-
- @Test
- public void healthCheckFormatTest() throws Exception {
- String payloadResult = "{\"request-parameters\":{\"host-ip-address\":\"hostIpAddress1\"}}";
- Optional<String> payloadClient = PayloadClient.healthCheckFormat("vnfName1", "hostIpAddress1");
- assertEquals(payloadResult, payloadClient.get());
- }
-
- @Test
- public void snapshotFormatTest() throws Exception {
- String payloadResult = "{\"vm-id\":\"vmId1\",\"identity-url\":\"identityUrl1\"}";
- Optional<String> payloadClient = PayloadClient.snapshotFormat("vmId1", "identityUrl1");
- assertEquals(payloadResult, payloadClient.get());
- }
-
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/BeansTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/BeansTest.java
index 7949fd26e6..3f0d01d649 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/BeansTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/BeansTest.java
@@ -22,7 +22,6 @@ package org.onap.so.bpmn.common;
import org.junit.Test;
import org.onap.so.openpojo.rules.ToStringTester;
-
import com.openpojo.reflection.PojoClass;
import com.openpojo.reflection.PojoClassFilter;
import com.openpojo.reflection.filters.FilterEnum;
@@ -38,37 +37,34 @@ import com.openpojo.validation.test.impl.SetterTester;
public class BeansTest {
- private PojoClassFilter filterTestClasses = new FilterTestClasses();
-
- private PojoClassFilter enumFilter = new FilterEnum();
-
+ private PojoClassFilter filterTestClasses = new FilterTestClasses();
+
+ private PojoClassFilter enumFilter = new FilterEnum();
+
+
+ @Test
+ public void pojoStructure() {
+ test("org.onap.so.bpmn.appc.payload.beans");
+ }
+
+ private void test(String pojoPackage) {
+ Validator validator = ValidatorBuilder.create().with(new GetterMustExistRule()).with(new SetterMustExistRule())
+
+ .with(new SetterTester()).with(new GetterTester())
+
+ .with(new SetterTester()).with(new GetterTester()).with(new ToStringTester())
+
+ .build();
+
- @Test
- public void pojoStructure() {
- test("org.onap.so.bpmn.appc.payload.beans");
- }
+ validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses, enumFilter,
+ new FilterNonConcrete());
+ }
- private void test(String pojoPackage) {
- Validator validator = ValidatorBuilder.create()
- .with(new GetterMustExistRule())
- .with(new SetterMustExistRule())
-
- .with(new SetterTester())
- .with(new GetterTester())
-
- .with(new SetterTester())
- .with(new GetterTester())
- .with(new ToStringTester())
-
- .build();
-
-
- validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses,enumFilter,new FilterNonConcrete());
- }
- private static class FilterTestClasses implements PojoClassFilter {
- @Override
- public boolean include(PojoClass pojoClass) {
- return !pojoClass.getSourcePath().contains("/test-classes/");
- }
- }
+ private static class FilterTestClasses implements PojoClassFilter {
+ @Override
+ public boolean include(PojoClass pojoClass) {
+ return !pojoClass.getSourcePath().contains("/test-classes/");
+ }
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DefaultToShortClassNameBeanNameGeneratorTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DefaultToShortClassNameBeanNameGeneratorTest.java
index 8a2c8fbfdd..d18170f828 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DefaultToShortClassNameBeanNameGeneratorTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DefaultToShortClassNameBeanNameGeneratorTest.java
@@ -23,9 +23,7 @@ package org.onap.so.bpmn.common;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-
import java.util.HashSet;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@@ -37,29 +35,31 @@ import org.springframework.core.type.AnnotationMetadata;
public class DefaultToShortClassNameBeanNameGeneratorTest {
- @Mock
- private BeanDefinitionRegistry beanDefinitionRegistry;
-
- private DefaultToShortClassNameBeanNameGenerator customBeanNameGenerator = new DefaultToShortClassNameBeanNameGenerator();
-
- @Before
- public void before() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void test_generateBeanName_notAnnotatedBeanDefinition() {
- String expectedBeanName = "BeanName";
-
- AnnotatedBeanDefinition annotatedBeanDefinition = mock(AnnotatedBeanDefinition.class);
- AnnotationMetadata metadata = mock(AnnotationMetadata.class);
- when(metadata.getAnnotationTypes()).thenReturn(new HashSet<String>());
- when(annotatedBeanDefinition.getBeanClassName()).thenReturn("org.onap.so.BeanName");
- when(annotatedBeanDefinition.getMetadata()).thenReturn(metadata);
- String actualBeanName = customBeanNameGenerator.generateBeanName(annotatedBeanDefinition, beanDefinitionRegistry);
-
- assertEquals(expectedBeanName, actualBeanName);
- }
-
+ @Mock
+ private BeanDefinitionRegistry beanDefinitionRegistry;
+
+ private DefaultToShortClassNameBeanNameGenerator customBeanNameGenerator =
+ new DefaultToShortClassNameBeanNameGenerator();
+
+ @Before
+ public void before() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void test_generateBeanName_notAnnotatedBeanDefinition() {
+ String expectedBeanName = "BeanName";
+
+ AnnotatedBeanDefinition annotatedBeanDefinition = mock(AnnotatedBeanDefinition.class);
+ AnnotationMetadata metadata = mock(AnnotationMetadata.class);
+ when(metadata.getAnnotationTypes()).thenReturn(new HashSet<String>());
+ when(annotatedBeanDefinition.getBeanClassName()).thenReturn("org.onap.so.BeanName");
+ when(annotatedBeanDefinition.getMetadata()).thenReturn(metadata);
+ String actualBeanName =
+ customBeanNameGenerator.generateBeanName(annotatedBeanDefinition, beanDefinitionRegistry);
+
+ assertEquals(expectedBeanName, actualBeanName);
+ }
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java
index a30aadc1f8..44b6f35dae 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/DelegateExecutionImplTest.java
@@ -25,13 +25,11 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
-
import java.io.Serializable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.hamcrest.collection.IsIterableContainingInOrder;
import org.junit.Rule;
@@ -41,7 +39,6 @@ import org.onap.so.bpmn.common.exceptions.MalformedBuildingBlockInputException;
import org.onap.so.bpmn.common.exceptions.MissingBuildingBlockInputException;
import org.onap.so.bpmn.common.exceptions.RequiredExecutionVariableExeception;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
-
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MSOCommonApplication.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MSOCommonApplication.java
index 63e5ccbbf3..58ac7cacca 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MSOCommonApplication.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MSOCommonApplication.java
@@ -24,7 +24,6 @@ package org.onap.so.bpmn.common;
import java.util.List;
import java.util.concurrent.Executor;
-
import org.camunda.bpm.application.PostDeploy;
import org.camunda.bpm.application.PreUndeploy;
import org.camunda.bpm.application.ProcessApplicationInfo;
@@ -48,54 +47,52 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@SpringBootApplication
@EnableAsync
-@ComponentScan(basePackages = { "org.onap" }, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class, excludeFilters = {
- @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
+@ComponentScan(basePackages = {"org.onap"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class,
+ excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
public class MSOCommonApplication {
- private static final Logger logger = LoggerFactory.getLogger(MSOCommonApplication.class);
+ private static final Logger logger = LoggerFactory.getLogger(MSOCommonApplication.class);
- @Value("${mso.async.core-pool-size}")
- private int corePoolSize;
+ @Value("${mso.async.core-pool-size}")
+ private int corePoolSize;
- @Value("${mso.async.max-pool-size}")
- private int maxPoolSize;
+ @Value("${mso.async.max-pool-size}")
+ private int maxPoolSize;
- @Value("${mso.async.queue-capacity}")
- private int queueCapacity;
+ @Value("${mso.async.queue-capacity}")
+ private int queueCapacity;
- private static final String LOGS_DIR = "logs_dir";
+ private static final String LOGS_DIR = "logs_dir";
- private static void setLogsDir() {
- if (System.getProperty(LOGS_DIR) == null) {
- System.getProperties().setProperty(LOGS_DIR, "./logs/bpmn/");
- }
- }
+ private static void setLogsDir() {
+ if (System.getProperty(LOGS_DIR) == null) {
+ System.getProperties().setProperty(LOGS_DIR, "./logs/bpmn/");
+ }
+ }
- public static void main(String... args) {
- SpringApplication.run(MSOCommonApplication.class, args);
- System.getProperties().setProperty("mso.config.path", ".");
- setLogsDir();
- }
+ public static void main(String... args) {
+ SpringApplication.run(MSOCommonApplication.class, args);
+ System.getProperties().setProperty("mso.config.path", ".");
+ setLogsDir();
+ }
- @PostDeploy
- public void postDeploy(ProcessEngine processEngineInstance) {
- }
+ @PostDeploy
+ public void postDeploy(ProcessEngine processEngineInstance) {}
- @PreUndeploy
- public void cleanup(ProcessEngine processEngine, ProcessApplicationInfo processApplicationInfo,
- List<ProcessEngine> processEngines) {
- }
+ @PreUndeploy
+ public void cleanup(ProcessEngine processEngine, ProcessApplicationInfo processApplicationInfo,
+ List<ProcessEngine> processEngines) {}
- @Bean
- public Executor asyncExecutor() {
- ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+ @Bean
+ public Executor asyncExecutor() {
+ ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
- executor.setCorePoolSize(corePoolSize);
- executor.setMaxPoolSize(maxPoolSize);
- executor.setQueueCapacity(queueCapacity);
- executor.setThreadNamePrefix("Camunda-");
- executor.initialize();
- return executor;
- }
+ executor.setCorePoolSize(corePoolSize);
+ executor.setMaxPoolSize(maxPoolSize);
+ executor.setQueueCapacity(queueCapacity);
+ executor.setThreadNamePrefix("Camunda-");
+ executor.initialize();
+ return executor;
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java
index 052fd5dc94..45ef0add2b 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteGenericVnf.java
@@ -23,18 +23,16 @@ package org.onap.so.bpmn.common;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-
import com.github.tomakehurst.wiremock.WireMockServer;
public class MockAAIDeleteGenericVnf {
- public MockAAIDeleteGenericVnf(WireMockServer wireMockServer){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/[?]resource-version=0000021"))
- .willReturn(aResponse()
- .withStatus(200)));
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/[?]resource-version=0000018"))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("aaiFault.xml")));
- }
+ public MockAAIDeleteGenericVnf(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/[?]resource-version=0000021"))
+ .willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/[?]resource-version=0000018"))
+ .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "text/xml")
+ .withBodyFile("aaiFault.xml")));
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java
index 1cbe0b9244..f405fc943b 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIDeleteVfModule.java
@@ -24,31 +24,30 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-
import com.github.tomakehurst.wiremock.WireMockServer;
public class MockAAIDeleteVfModule {
-
- public MockAAIDeleteVfModule(WireMockServer wireMockServer)
- {
- wireMockServer.stubFor(delete(urlMatching(
- "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73/[?]resource-version=0000073"))
- .willReturn(aResponse().withStatus(200)));
- wireMockServer.stubFor(delete(urlMatching(
- "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a75/[?]resource-version=0000075"))
- .willReturn(aResponse().withStatus(200)));
- wireMockServer.stubFor(delete(urlMatching(
- "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a78/[?]resource-version=0000078"))
- .willReturn(aResponse().withStatus(200)));
- wireMockServer.stubFor(delete(urlMatching(
- "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a77/[?]resource-version=0000077"))
- .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "text/xml")
- .withBodyFile("aaiFault.xml")));
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*"))
- .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
- .withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml")));
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
- .willReturn(aResponse().withStatus(200)));
- }
+ public MockAAIDeleteVfModule(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73/[?]resource-version=0000073"))
+ .willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a75/[?]resource-version=0000075"))
+ .willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a78/[?]resource-version=0000078"))
+ .willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a77/[?]resource-version=0000077"))
+ .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "text/xml")
+ .withBodyFile("aaiFault.xml")));
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml")));
+
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
+ .willReturn(aResponse().withStatus(200)));
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java
index 1d6337ffc4..a33268efbe 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/MockAAIGenericVnfSearch.java
@@ -23,319 +23,219 @@ package org.onap.so.bpmn.common;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-
import com.github.tomakehurst.wiremock.WireMockServer;
public class MockAAIGenericVnfSearch {
-
- private static final String EOL = "\n";
- public MockAAIGenericVnfSearch(WireMockServer wireMockServer){
- String body;
-
- // The following stubs are for CreateAAIVfModule and UpdateAAIVfModule
-
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC23&depth=1"))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("aaiFault.xml")));
-
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC22&depth=1"))
- .willReturn(aResponse()
- .withStatus(404)
- .withHeader("Content-Type", "text/xml")
- .withBody("Generic VNF Not Found")));
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/768073c7-f41f-4822-9323-b75962763d74[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(404)
- .withHeader("Content-Type", "text/xml")
- .withBody("Generic VNF Not Found")));
-
- body =
- "<generic-vnf xmlns=\"http://com.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>1508691</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>1508692</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC21&depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>1508691</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>1508692</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>false</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>1508692</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC20&depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- // The following stubs are for DeleteAAIVfModule
-
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c723[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("aaiFault.xml")));
-
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c722[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(404)
- .withHeader("Content-Type", "text/xml")
- .withBody("Generic VNF Not Found")));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>0000021</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000073</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>0000020</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000074</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>false</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000075</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c719</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC19</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>0000019</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC19-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000076</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC19-MMSC::module-1-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>false</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000077</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c718</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC18</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>0000018</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC18-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000078</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>0000021</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000073</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- }
+ private static final String EOL = "\n";
+
+ public MockAAIGenericVnfSearch(WireMockServer wireMockServer) {
+ String body;
+
+ // The following stubs are for CreateAAIVfModule and UpdateAAIVfModule
+
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC23&depth=1"))
+ .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "text/xml")
+ .withBodyFile("aaiFault.xml")));
+
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC22&depth=1"))
+ .willReturn(aResponse().withStatus(404).withHeader("Content-Type", "text/xml")
+ .withBody("Generic VNF Not Found")));
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/768073c7-f41f-4822-9323-b75962763d74[?]depth=1"))
+ .willReturn(aResponse().withStatus(404).withHeader("Content-Type", "text/xml")
+ .withBody("Generic VNF Not Found")));
+
+ body = "<generic-vnf xmlns=\"http://com.aai.inventory/v7\">" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL + " <vnf-type>mmsc-capacity</vnf-type>" + EOL
+ + " <service-id>SDN-MOBILITY</service-id>" + EOL + " <equipment-role>vMMSC</equipment-role>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL + " <in-maint>false</in-maint>"
+ + EOL + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL
+ + " <resource-version>1508691</resource-version>" + EOL + " <vf-modules>" + EOL + " <vf-module>"
+ + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>true</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>1508692</resource-version>" + EOL + " </vf-module>" + EOL
+ + " </vf-modules>" + EOL + " <relationship-list/>" + EOL + " <l-interfaces/>" + EOL
+ + " <lag-interfaces/>" + EOL + "</generic-vnf>" + EOL;
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC21&depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+
+ body = "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL
+ + " <vnf-id>2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL + " <vnf-type>mmsc-capacity</vnf-type>" + EOL
+ + " <service-id>SDN-MOBILITY</service-id>" + EOL + " <equipment-role>vMMSC</equipment-role>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL + " <in-maint>false</in-maint>"
+ + EOL + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL
+ + " <resource-version>1508691</resource-version>" + EOL + " <vf-modules>" + EOL + " <vf-module>"
+ + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>true</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>1508692</resource-version>" + EOL + " </vf-module>" + EOL
+ + " <vf-module>" + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>"
+ + EOL + " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>false</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>1508692</resource-version>" + EOL + " </vf-module>" + EOL
+ + " </vf-modules>" + EOL + " <relationship-list/>" + EOL + " <l-interfaces/>" + EOL
+ + " <lag-interfaces/>" + EOL + "</generic-vnf>" + EOL;
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC20&depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4[?]depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+
+ // The following stubs are for DeleteAAIVfModule
+
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c723[?]depth=1"))
+ .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "text/xml")
+ .withBodyFile("aaiFault.xml")));
+
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c722[?]depth=1"))
+ .willReturn(aResponse().withStatus(404).withHeader("Content-Type", "text/xml")
+ .withBody("Generic VNF Not Found")));
+
+ body = "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL + " <vnf-type>mmsc-capacity</vnf-type>" + EOL
+ + " <service-id>SDN-MOBILITY</service-id>" + EOL + " <equipment-role>vMMSC</equipment-role>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL + " <in-maint>false</in-maint>"
+ + EOL + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL
+ + " <resource-version>0000021</resource-version>" + EOL + " <vf-modules>" + EOL + " <vf-module>"
+ + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>true</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>0000073</resource-version>" + EOL + " </vf-module>" + EOL
+ + " </vf-modules>" + EOL + " <relationship-list/>" + EOL + " <l-interfaces/>" + EOL
+ + " <lag-interfaces/>" + EOL + "</generic-vnf>" + EOL;
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+
+ body = "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL + " <vnf-type>mmsc-capacity</vnf-type>" + EOL
+ + " <service-id>SDN-MOBILITY</service-id>" + EOL + " <equipment-role>vMMSC</equipment-role>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL + " <in-maint>false</in-maint>"
+ + EOL + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL
+ + " <resource-version>0000020</resource-version>" + EOL + " <vf-modules>" + EOL + " <vf-module>"
+ + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>true</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>0000074</resource-version>" + EOL + " </vf-module>" + EOL
+ + " <vf-module>" + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</vf-module-id>"
+ + EOL + " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>false</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>0000075</resource-version>" + EOL + " </vf-module>" + EOL
+ + " </vf-modules>" + EOL + " <relationship-list/>" + EOL + " <l-interfaces/>" + EOL
+ + " <lag-interfaces/>" + EOL + "</generic-vnf>" + EOL;
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720[?]depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+
+ body = "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c719</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC19</vnf-name>" + EOL + " <vnf-type>mmsc-capacity</vnf-type>" + EOL
+ + " <service-id>SDN-MOBILITY</service-id>" + EOL + " <equipment-role>vMMSC</equipment-role>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL + " <in-maint>false</in-maint>"
+ + EOL + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL
+ + " <resource-version>0000019</resource-version>" + EOL + " <vf-modules>" + EOL + " <vf-module>"
+ + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC19-MMSC::module-0-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>true</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>0000076</resource-version>" + EOL + " </vf-module>" + EOL
+ + " <vf-module>" + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</vf-module-id>"
+ + EOL + " <vf-module-name>STMTN5MMSC19-MMSC::module-1-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>false</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>0000077</resource-version>" + EOL + " </vf-module>" + EOL
+ + " </vf-modules>" + EOL + " <relationship-list/>" + EOL + " <l-interfaces/>" + EOL
+ + " <lag-interfaces/>" + EOL + "</generic-vnf>" + EOL;
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719[?]depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+
+ body = "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c718</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC18</vnf-name>" + EOL + " <vnf-type>mmsc-capacity</vnf-type>" + EOL
+ + " <service-id>SDN-MOBILITY</service-id>" + EOL + " <equipment-role>vMMSC</equipment-role>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL + " <in-maint>false</in-maint>"
+ + EOL + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL
+ + " <resource-version>0000018</resource-version>" + EOL + " <vf-modules>" + EOL + " <vf-module>"
+ + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC18-MMSC::module-0-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>true</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>0000078</resource-version>" + EOL + " </vf-module>" + EOL
+ + " </vf-modules>" + EOL + " <relationship-list/>" + EOL + " <l-interfaces/>" + EOL
+ + " <lag-interfaces/>" + EOL + "</generic-vnf>" + EOL;
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718[?]depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+
+ body = "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL
+ + " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL
+ + " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL + " <vnf-type>mmsc-capacity</vnf-type>" + EOL
+ + " <service-id>SDN-MOBILITY</service-id>" + EOL + " <equipment-role>vMMSC</equipment-role>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL + " <in-maint>false</in-maint>"
+ + EOL + " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL
+ + " <resource-version>0000021</resource-version>" + EOL + " <vf-modules>" + EOL + " <vf-module>"
+ + EOL + " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL
+ + " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL
+ + " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL
+ + " <persona-model-version>1.0</persona-model-version>" + EOL
+ + " <is-base-vf-module>true</is-base-vf-module>" + EOL
+ + " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL
+ + " <orchestration-status>pending-create</orchestration-status>" + EOL
+ + " <resource-version>0000073</resource-version>" + EOL + " </vf-module>" + EOL
+ + " </vf-modules>" + EOL + " <relationship-list/>" + EOL + " <l-interfaces/>" + EOL
+ + " <lag-interfaces/>" + EOL + "</generic-vnf>" + EOL;
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(body)));
+
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/SPIPropertiesTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/SPIPropertiesTest.java
index 9239889f28..96ea1cad9b 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/SPIPropertiesTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/SPIPropertiesTest.java
@@ -22,10 +22,8 @@ package org.onap.so.bpmn.common;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
-
import java.io.FileNotFoundException;
import java.io.IOException;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.so.client.RestPropertiesLoader;
@@ -36,34 +34,37 @@ import org.onap.so.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer;
public class SPIPropertiesTest {
- @BeforeClass
- public static void beforeClass() {
- System.setProperty("mso.config.path", "src/test/resources");
- }
-
- @Test
- public void notEqual() {
- DmaapProperties one = DmaapPropertiesLoader.getInstance().getNewImpl();
- DmaapProperties two = DmaapPropertiesLoader.getInstance().getNewImpl();
- assertNotEquals(one, two);
- }
- @Test
- public void equal() {
- DmaapProperties one = DmaapPropertiesLoader.getInstance().getImpl();
- DmaapProperties two = DmaapPropertiesLoader.getInstance().getImpl();
- assertEquals(one, two);
- }
- @Test
- public void restNotEqual() {
- AAIProperties one = RestPropertiesLoader.getInstance().getNewImpl(AAIProperties.class);
- AAIProperties two = RestPropertiesLoader.getInstance().getNewImpl(AAIProperties.class);
- assertNotEquals(one, two);
- }
- @Test
- public void restEqual() {
- AAIProperties one = RestPropertiesLoader.getInstance().getImpl(AAIProperties.class);
- AAIProperties two = RestPropertiesLoader.getInstance().getImpl(AAIProperties.class);
- assertEquals(one, two);
- }
-
+ @BeforeClass
+ public static void beforeClass() {
+ System.setProperty("mso.config.path", "src/test/resources");
+ }
+
+ @Test
+ public void notEqual() {
+ DmaapProperties one = DmaapPropertiesLoader.getInstance().getNewImpl();
+ DmaapProperties two = DmaapPropertiesLoader.getInstance().getNewImpl();
+ assertNotEquals(one, two);
+ }
+
+ @Test
+ public void equal() {
+ DmaapProperties one = DmaapPropertiesLoader.getInstance().getImpl();
+ DmaapProperties two = DmaapPropertiesLoader.getInstance().getImpl();
+ assertEquals(one, two);
+ }
+
+ @Test
+ public void restNotEqual() {
+ AAIProperties one = RestPropertiesLoader.getInstance().getNewImpl(AAIProperties.class);
+ AAIProperties two = RestPropertiesLoader.getInstance().getNewImpl(AAIProperties.class);
+ assertNotEquals(one, two);
+ }
+
+ @Test
+ public void restEqual() {
+ AAIProperties one = RestPropertiesLoader.getInstance().getImpl(AAIProperties.class);
+ AAIProperties two = RestPropertiesLoader.getInstance().getImpl(AAIProperties.class);
+ assertEquals(one, two);
+ }
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/WorkflowContextHolderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/WorkflowContextHolderTest.java
index 4a51d34c3e..23f9818669 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/WorkflowContextHolderTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/WorkflowContextHolderTest.java
@@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.common;
@@ -34,35 +34,35 @@ import org.onap.so.bpmn.common.workflow.context.WorkflowResponse;
public class WorkflowContextHolderTest {
- @Test
- public void testProcessCallback() throws Exception {
- String requestId = UUID.randomUUID().toString();
- String message = "TEST MESSATGE";
- String responseMessage = "Successfully processed request";
- int testCode = 200;
-
-
- WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance();
-
- WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse();
- callbackResponse.setMessage(message);
- callbackResponse.setResponse(responseMessage);
- callbackResponse.setStatusCode(testCode);
-
- contextHolder.processCallback("testAsyncProcess","process-instance-id",requestId,callbackResponse);
-
- //same object returned
- WorkflowContext contextFound = contextHolder.getWorkflowContext(requestId);
- if(contextFound == null)
- throw new Exception("Expected to find Context Object");
-
- WorkflowResponse testResponse = contextFound.getWorkflowResponse();
- Assert.assertEquals(200,testResponse.getMessageCode());
- Assert.assertEquals(message, testResponse.getMessage());
- Assert.assertEquals(responseMessage, testResponse.getResponse());
-
-
-
- }
+ @Test
+ public void testProcessCallback() throws Exception {
+ String requestId = UUID.randomUUID().toString();
+ String message = "TEST MESSATGE";
+ String responseMessage = "Successfully processed request";
+ int testCode = 200;
+
+
+ WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance();
+
+ WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse();
+ callbackResponse.setMessage(message);
+ callbackResponse.setResponse(responseMessage);
+ callbackResponse.setStatusCode(testCode);
+
+ contextHolder.processCallback("testAsyncProcess", "process-instance-id", requestId, callbackResponse);
+
+ // same object returned
+ WorkflowContext contextFound = contextHolder.getWorkflowContext(requestId);
+ if (contextFound == null)
+ throw new Exception("Expected to find Context Object");
+
+ WorkflowResponse testResponse = contextFound.getWorkflowResponse();
+ Assert.assertEquals(200, testResponse.getMessageCode());
+ Assert.assertEquals(message, testResponse.getMessage());
+ Assert.assertEquals(responseMessage, testResponse.getResponse());
+
+
+
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/WorkflowTestTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/WorkflowTestTransformer.java
index dbad35a6a4..794e772dcd 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/WorkflowTestTransformer.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/WorkflowTestTransformer.java
@@ -26,16 +26,15 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * Allows a subclass of WorkflowTest to specify one or more WireMock
- * response transformers. A transformer must be declared as a public
- * static field in the subclass. For example:
+ * Allows a subclass of WorkflowTest to specify one or more WireMock response transformers. A transformer must be
+ * declared as a public static field in the subclass. For example:
+ *
* <pre>
- * @WorkflowTestTransformer
- * public static final ResponseTransformer sdncAdapterMockTransformer =
- * new SDNCAdapterMockTransformer();
+ * &#64;WorkflowTestTransformer
+ * public static final ResponseTransformer sdncAdapterMockTransformer = new SDNCAdapterMockTransformer();
* </pre>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface WorkflowTestTransformer {
-} \ No newline at end of file
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/baseclient/BaseClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/baseclient/BaseClientTest.java
index 1be7c652b9..ee2c10ca4b 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/baseclient/BaseClientTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/baseclient/BaseClientTest.java
@@ -25,41 +25,39 @@ import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
-
import java.util.Map;
-
import javax.ws.rs.core.UriBuilder;
-
import org.junit.Test;
import org.onap.so.BaseTest;
import org.springframework.core.ParameterizedTypeReference;
-
import wiremock.org.apache.http.entity.ContentType;
public class BaseClientTest extends BaseTest {
- @Test
- public void verifyString() {
- BaseClient<String, String> client = new BaseClient<>();
- String response = "{\"hello\" : \"world\"}";
- client.setTargetUrl(UriBuilder.fromUri("http://localhost/test").port(Integer.parseInt(wireMockPort)).build().toString());
- wireMockServer.stubFor(get(urlEqualTo("/test"))
- .willReturn(aResponse().withStatus(200).withBody(response).withHeader("Content-Type", ContentType.APPLICATION_JSON.toString())));
-
- String result = client.get("", new ParameterizedTypeReference<String>() {});
- assertThat(result, equalTo(response));
- }
-
- @Test
- public void verifyMap() {
- BaseClient<String, Map<String, Object>> client = new BaseClient<>();
- String response = "{\"hello\" : \"world\"}";
- client.setTargetUrl(UriBuilder.fromUri("http://localhost/test").port(Integer.parseInt(wireMockPort)).build().toString());
- wireMockServer.stubFor(get(urlEqualTo("/test"))
- .willReturn(aResponse().withStatus(200).withBody(response).withHeader("Content-Type", ContentType.APPLICATION_JSON.toString())));
-
- Map<String, Object> result = client.get("", new ParameterizedTypeReference<Map<String, Object>>() {});
- assertThat("world", equalTo(result.get("hello")));
- }
+ @Test
+ public void verifyString() {
+ BaseClient<String, String> client = new BaseClient<>();
+ String response = "{\"hello\" : \"world\"}";
+ client.setTargetUrl(
+ UriBuilder.fromUri("http://localhost/test").port(Integer.parseInt(wireMockPort)).build().toString());
+ wireMockServer.stubFor(get(urlEqualTo("/test")).willReturn(aResponse().withStatus(200).withBody(response)
+ .withHeader("Content-Type", ContentType.APPLICATION_JSON.toString())));
+
+ String result = client.get("", new ParameterizedTypeReference<String>() {});
+ assertThat(result, equalTo(response));
+ }
+
+ @Test
+ public void verifyMap() {
+ BaseClient<String, Map<String, Object>> client = new BaseClient<>();
+ String response = "{\"hello\" : \"world\"}";
+ client.setTargetUrl(
+ UriBuilder.fromUri("http://localhost/test").port(Integer.parseInt(wireMockPort)).build().toString());
+ wireMockServer.stubFor(get(urlEqualTo("/test")).willReturn(aResponse().withStatus(200).withBody(response)
+ .withHeader("Content-Type", ContentType.APPLICATION_JSON.toString())));
+
+ Map<String, Object> result = client.get("", new ParameterizedTypeReference<Map<String, Object>>() {});
+ assertThat("world", equalTo(result.get("hello")));
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnParamTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnParamTest.java
index 5510e21b31..94320b75d7 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnParamTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnParamTest.java
@@ -1,41 +1,36 @@
/*
-* ============LICENSE_START=======================================================
- * ONAP : SO
- * ================================================================================
- * Copyright (C) 2018 TechMahindra
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * ============LICENSE_START======================================================= ONAP : SO
+ * ================================================================================ Copyright (C) 2018 TechMahindra
+ * ================================================================================ 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
+ * 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.
+ * 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.bpmn.common.recipe;
import static org.junit.Assert.assertEquals;
-
import org.junit.Test;
public class BpmnParamTest {
- BpmnParam bp=new BpmnParam();
-
- @Test
- public void test() {
- bp.setValue("testdata");
- assertEquals(bp.getValue(),"testdata");
- }
- @Test
- public void testToString(){
- assert(bp.toString()!=null);
- }
+ BpmnParam bp = new BpmnParam();
+
+ @Test
+ public void test() {
+ bp.setValue("testdata");
+ assertEquals(bp.getValue(), "testdata");
+ }
+
+ @Test
+ public void testToString() {
+ assert (bp.toString() != null);
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnRestClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnRestClientTest.java
index 465ec416b5..730915a60c 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnRestClientTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/BpmnRestClientTest.java
@@ -25,36 +25,29 @@ import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import java.io.IOException;
-
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.junit.Test;
import org.onap.so.BaseTest;
import org.springframework.beans.factory.annotation.Autowired;
-public class BpmnRestClientTest extends BaseTest{
+public class BpmnRestClientTest extends BaseTest {
@Autowired
private BpmnRestClient bpmnRestClient;
@Test
- public void postTest() throws IOException, Exception{
+ public void postTest() throws IOException, Exception {
wireMockServer.stubFor(post(urlPathMatching("/testRecipeUri"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(org.springframework.http.HttpStatus.OK.value()).withBody("{}")));
+ .willReturn(aResponse().withHeader("Content-Type", "application/json")
+ .withStatus(org.springframework.http.HttpStatus.OK.value()).withBody("{}")));
- HttpResponse httpResponse = bpmnRestClient.post(
- "http://localhost:" + wireMockPort +"/testRecipeUri",
- "test-req-id",
- 1000,
- "testRequestAction",
- "1234",
- "testServiceType",
- "testRequestDetails",
- "testRecipeparamXsd");
+ HttpResponse httpResponse =
+ bpmnRestClient.post("http://localhost:" + wireMockPort + "/testRecipeUri", "test-req-id", 1000,
+ "testRequestAction", "1234", "testServiceType", "testRequestDetails", "testRecipeparamXsd");
assertNotNull(httpResponse);
- assertEquals(HttpStatus.SC_OK,httpResponse.getStatusLine().getStatusCode());
+ assertEquals(HttpStatus.SC_OK, httpResponse.getStatusLine().getStatusCode());
}
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/ResourceInputTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/ResourceInputTest.java
index 5da47c973e..d25e4437ce 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/ResourceInputTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/ResourceInputTest.java
@@ -1,66 +1,62 @@
/*
-* ============LICENSE_START=======================================================
- * ONAP : SO
- * ================================================================================
- * Copyright (C) 2018 TechMahindra
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * ============LICENSE_START======================================================= ONAP : SO
+ * ================================================================================ Copyright (C) 2018 TechMahindra
+ * ================================================================================ 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
+ * 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.
+ * 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.bpmn.common.recipe;
import static org.junit.Assert.assertEquals;
-
import org.junit.Test;
import org.onap.so.bpmn.core.domain.ModelInfo;
import org.onap.so.BaseTest;
-public class ResourceInputTest extends BaseTest{
-
- ResourceInput ri=new ResourceInput();
- @Test
- public void test() {
- ri.setResourceInstanceName("resourceInstanceName");
- ri.setResourceInstanceDes("resourceInstanceDes");
- ri.setGlobalSubscriberId("globalSubscriberId");
- ri.setServiceType("serviceType");
- ri.setServiceInstanceId("serviceId");
- ri.setOperationId("operationId");
- ModelInfo serviceModelInfo = new ModelInfo();
- serviceModelInfo.setModelCustomizationUuid("modelCustomizationUuid");
- serviceModelInfo.setModelInvariantUuid("modelInvariantUuid");
- serviceModelInfo.setModelUuid("modelUuid");
- ri.setServiceModelInfo(serviceModelInfo);
+public class ResourceInputTest extends BaseTest {
+
+ ResourceInput ri = new ResourceInput();
+
+ @Test
+ public void test() {
+ ri.setResourceInstanceName("resourceInstanceName");
+ ri.setResourceInstanceDes("resourceInstanceDes");
+ ri.setGlobalSubscriberId("globalSubscriberId");
+ ri.setServiceType("serviceType");
+ ri.setServiceInstanceId("serviceId");
+ ri.setOperationId("operationId");
+ ModelInfo serviceModelInfo = new ModelInfo();
+ serviceModelInfo.setModelCustomizationUuid("modelCustomizationUuid");
+ serviceModelInfo.setModelInvariantUuid("modelInvariantUuid");
+ serviceModelInfo.setModelUuid("modelUuid");
+ ri.setServiceModelInfo(serviceModelInfo);
ModelInfo resourceModelInfo = new ModelInfo();
resourceModelInfo.setModelCustomizationUuid("modelCustomizationUuid");
resourceModelInfo.setModelInvariantUuid("modelInvariantUuid");
resourceModelInfo.setModelUuid("modelUuid");
ri.setResourceModelInfo(resourceModelInfo);
- ri.setResourceInstancenUuid("resourceInstancenUuid");
- ri.setResourceParameters("resourceParameters");
- ri.setOperationType("operationType");
- assertEquals(ri.getResourceInstanceName(), "resourceInstanceName");
- assertEquals(ri.getResourceInstanceDes(), "resourceInstanceDes");
- assertEquals(ri.getGlobalSubscriberId(), "globalSubscriberId");
- assertEquals(ri.getServiceType(), "serviceType");
- assertEquals(ri.getServiceInstanceId(), "serviceId");
- assertEquals(ri.getOperationId(), "operationId");
- assertEquals(ri.getResourceInstancenUuid(), "resourceInstancenUuid");
- assertEquals(ri.getResourceParameters(), "resourceParameters");
- assertEquals(ri.getOperationType(), "operationType");
- }
- @Test
- public void testToString(){
- assert(ri.toString()!=null);
- }
+ ri.setResourceInstancenUuid("resourceInstancenUuid");
+ ri.setResourceParameters("resourceParameters");
+ ri.setOperationType("operationType");
+ assertEquals(ri.getResourceInstanceName(), "resourceInstanceName");
+ assertEquals(ri.getResourceInstanceDes(), "resourceInstanceDes");
+ assertEquals(ri.getGlobalSubscriberId(), "globalSubscriberId");
+ assertEquals(ri.getServiceType(), "serviceType");
+ assertEquals(ri.getServiceInstanceId(), "serviceId");
+ assertEquals(ri.getOperationId(), "operationId");
+ assertEquals(ri.getResourceInstancenUuid(), "resourceInstancenUuid");
+ assertEquals(ri.getResourceParameters(), "resourceParameters");
+ assertEquals(ri.getOperationType(), "operationType");
+ }
+
+ @Test
+ public void testToString() {
+ assert (ri.toString() != null);
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/ResourceRecipeRequestTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/ResourceRecipeRequestTest.java
index f0f6fa79e0..7008791dd0 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/ResourceRecipeRequestTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/recipe/ResourceRecipeRequestTest.java
@@ -1,52 +1,48 @@
/*
-* ============LICENSE_START=======================================================
- * ONAP : SO
- * ================================================================================
- * Copyright (C) 2018 TechMahindra
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * ============LICENSE_START======================================================= ONAP : SO
+ * ================================================================================ Copyright (C) 2018 TechMahindra
+ * ================================================================================ 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
+ * 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.
+ * 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.bpmn.common.recipe;
import static org.junit.Assert.*;
-
import org.junit.Test;
import org.onap.so.BaseTest;
-public class ResourceRecipeRequestTest extends BaseTest{
+public class ResourceRecipeRequestTest extends BaseTest {
+
+ ResourceRecipeRequest rr = new ResourceRecipeRequest();
+ BpmnParam bp = new BpmnParam();
+
+ @Test
+ public void test() {
+ rr.setResourceInput(bp);
+ rr.setHost(bp);
+ rr.setRequestId(bp);
+ rr.setRequestAction(bp);
+ rr.setServiceInstanceId(bp);
+ rr.setServiceType(bp);
+ rr.setRecipeParams(bp);
+ assertEquals(rr.getResourceInput(), bp);
+ assertEquals(rr.getHost(), bp);
+ assertEquals(rr.getRequestId(), bp);
+ assertEquals(rr.getRequestAction(), bp);
+ assertEquals(rr.getServiceInstanceId(), bp);
+ assertEquals(rr.getServiceType(), bp);
+ assertEquals(rr.getRecipeParams(), bp);
+ }
- ResourceRecipeRequest rr=new ResourceRecipeRequest();
- BpmnParam bp=new BpmnParam();
- @Test
- public void test() {
- rr.setResourceInput(bp);
- rr.setHost(bp);
- rr.setRequestId(bp);
- rr.setRequestAction(bp);
- rr.setServiceInstanceId(bp);
- rr.setServiceType(bp);
- rr.setRecipeParams(bp);
- assertEquals(rr.getResourceInput(),bp);
- assertEquals(rr.getHost(),bp);
- assertEquals(rr.getRequestId(),bp);
- assertEquals(rr.getRequestAction(),bp);
- assertEquals(rr.getServiceInstanceId(),bp);
- assertEquals(rr.getServiceType(),bp);
- assertEquals(rr.getRecipeParams(),bp);
- }
- @Test
- public void testToString(){
- assert(rr.toString()!=null);
- }
+ @Test
+ public void testToString() {
+ assert (rr.toString() != null);
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java
index a074174f6e..0c2862bf91 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilderTest.java
@@ -23,11 +23,9 @@ import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.ok;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static org.junit.Assert.assertEquals;
-
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.junit.Test;
import org.onap.so.BaseTest;
@@ -39,362 +37,283 @@ public class ResourceRequestBuilderTest extends BaseTest {
- wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
- .willReturn(ok("{ \"serviceResources\" : {\n" +
- "\t\"modelInfo\" : {\n" +
- "\t\t\"modelName\" : \"demoVFWCL\",\n" +
- "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" +
- "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" +
- "\t\t\"modelVersion\" : \"1.0\"\n" +
- "\t},\n" +
- "\t\"serviceType\" : \"\",\n" +
- "\t\"serviceRole\" : \"\",\n" +
- "\t\"environmentContext\" : null,\n" +
- "\t\"resourceOrder\" : \"res1,res2\",\n" +
- "\t\"workloadContext\" : \"Production\",\n" +
- "\t\"serviceVnfs\": [\n" +
- "\t\n" +
- "\t\t{ \"modelInfo\" : {\n" +
- "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n" +
- "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n" +
- "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n" +
- "\t\t\t\"modelVersion\" : \"1.0\",\n" +
- "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n" +
- "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" +
- "\t\t\t},\n" +
- "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n" +
- "\t\t\"nfFunction\" \t: null,\n" +
- "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\"," +
- "\t\t\"nfType\" \t\t: null,\n" +
- "\t\t\"nfRole\" \t\t: null,\n" +
- "\t\t\"nfNamingCode\" \t: null,\n" +
- "\t\t\"multiStageDesign\" : \"false\",\n" +
- "\t\t\t\"vfModules\": [\n" +
- "\t\t\t\t{\n" +
- "\t\t\t\t\t\"modelInfo\" : { \n" +
- "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n" +
- "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n" +
- "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n" +
- "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" +
- "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n" +
- "\t\t\t\t\t},\t\t\"isBase\" : true,\n" +
- "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n" +
- "\t\t\t\t\t\"initialCount\" : 1,\n" +
- "\t\t\t\t\t\"hasVolumeGroup\" : true\n" +
- "\t\t\t\t}\n" +
- "\t\t\t]\n" +
- "\t\t},\n" +
- "\t\n" +
- "\t\t{ \"modelInfo\" : {\n" +
- "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n" +
- "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n" +
- "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n" +
- "\t\t\t\"modelVersion\" : \"1.0\",\n" +
- "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n" +
- "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" +
- "\t\t\t},\n" +
- "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n" +
- "\t\t\"nfFunction\" \t: null,\n" +
- "\t\t\"nfType\" \t\t: null,\n" +
- "\t\t\"nfRole\" \t\t: null,\n" +
- "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\"," +
- "\t\t\"nfNamingCode\" \t: null,\n" +
- "\t\t\"multiStageDesign\" : \"false\",\n" +
- "\t\t\t\"vfModules\": [\n" +
- "\t\t\t\t{\n" +
- "\t\t\t\t\t\"modelInfo\" : { \n" +
- "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n" +
- "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n" +
- "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n" +
- "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" +
- "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n" +
- "\t\t\t\t\t},\t\t\"isBase\" : true,\n" +
- "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n" +
- "\t\t\t\t\t\"initialCount\" : 1,\n" +
- "\t\t\t\t\t\"hasVolumeGroup\" : true\n" +
- "\t\t\t\t}\n" +
- "\t\t\t]\n" +
- "\t\t}\n" +
- "\t],\n" +
- "\t\"serviceNetworks\": [],\n" +
- "\t\"serviceAllottedResources\": []\n" +
- "\t}}")));
+ wireMockServer.stubFor(get(urlEqualTo(
+ "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
+ .willReturn(ok("{ \"serviceResources\" : {\n" + "\t\"modelInfo\" : {\n"
+ + "\t\t\"modelName\" : \"demoVFWCL\",\n"
+ + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n"
+ + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n"
+ + "\t\t\"modelVersion\" : \"1.0\"\n" + "\t},\n"
+ + "\t\"serviceType\" : \"\",\n" + "\t\"serviceRole\" : \"\",\n"
+ + "\t\"environmentContext\" : null,\n" + "\t\"resourceOrder\" : \"res1,res2\",\n"
+ + "\t\"workloadContext\" : \"Production\",\n" + "\t\"serviceVnfs\": [\n" + "\t\n"
+ + "\t\t{ \"modelInfo\" : {\n"
+ + "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n"
+ + "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n"
+ + "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n"
+ + "\t\t\t\"modelVersion\" : \"1.0\",\n"
+ + "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n"
+ + "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" + "\t\t\t},\n"
+ + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n"
+ + "\t\t\"nfFunction\" \t: null,\n"
+ + "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\","
+ + "\t\t\"nfType\" \t\t: null,\n"
+ + "\t\t\"nfRole\" \t\t: null,\n"
+ + "\t\t\"nfNamingCode\" \t: null,\n"
+ + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n"
+ + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n"
+ + "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n"
+ + "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n"
+ + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n"
+ + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n"
+ + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n"
+ + "\t\t\t\t\t},\t\t\"isBase\" : true,\n"
+ + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n"
+ + "\t\t\t\t\t\"initialCount\" : 1,\n"
+ + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n"
+ + "\t\t},\n" + "\t\n" + "\t\t{ \"modelInfo\" : {\n"
+ + "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n"
+ + "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n"
+ + "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n"
+ + "\t\t\t\"modelVersion\" : \"1.0\",\n"
+ + "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n"
+ + "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" + "\t\t\t},\n"
+ + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n"
+ + "\t\t\"nfFunction\" \t: null,\n"
+ + "\t\t\"nfType\" \t\t: null,\n"
+ + "\t\t\"nfRole\" \t\t: null,\n"
+ + "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\","
+ + "\t\t\"nfNamingCode\" \t: null,\n"
+ + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n"
+ + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n"
+ + "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n"
+ + "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n"
+ + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n"
+ + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n"
+ + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n"
+ + "\t\t\t\t\t},\t\t\"isBase\" : true,\n"
+ + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n"
+ + "\t\t\t\t\t\"initialCount\" : 1,\n"
+ + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n"
+ + "\t\t}\n" + "\t],\n" + "\t\"serviceNetworks\": [],\n"
+ + "\t\"serviceAllottedResources\": []\n" + "\t}}")));
-// when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080");
+ // when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080");
HashMap serviceInput = new HashMap();
serviceInput.put("key", "value");
- Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
- "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput);
+ Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(
+ "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput);
assertEquals(stringObjectMap.get("a"), "value");
}
@Test
public void getResourceInputDefaultValueTest() throws Exception {
- wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
- .willReturn(ok("{ \"serviceResources\" : {\n" +
- "\t\"modelInfo\" : {\n" +
- "\t\t\"modelName\" : \"demoVFWCL\",\n" +
- "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" +
- "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" +
- "\t\t\"modelVersion\" : \"1.0\"\n" +
- "\t},\n" +
- "\t\"serviceType\" : \"\",\n" +
- "\t\"serviceRole\" : \"\",\n" +
- "\t\"environmentContext\" : null,\n" +
- "\t\"workloadContext\" : \"Production\",\n" +
- "\t\"serviceVnfs\": [\n" +
- "\t\n" +
- "\t\t{ \"modelInfo\" : {\n" +
- "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n" +
- "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n" +
- "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n" +
- "\t\t\t\"modelVersion\" : \"1.0\",\n" +
- "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n" +
- "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" +
- "\t\t\t},\n" +
- "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n" +
- "\t\t\"nfFunction\" \t: null,\n" +
- "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\"," +
- "\t\t\"nfType\" \t\t: null,\n" +
- "\t\t\"nfRole\" \t\t: null,\n" +
- "\t\t\"nfNamingCode\" \t: null,\n" +
- "\t\t\"multiStageDesign\" : \"false\",\n" +
- "\t\t\t\"vfModules\": [\n" +
- "\t\t\t\t{\n" +
- "\t\t\t\t\t\"modelInfo\" : { \n" +
- "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n" +
- "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n" +
- "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n" +
- "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" +
- "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n" +
- "\t\t\t\t\t},\t\t\"isBase\" : true,\n" +
- "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n" +
- "\t\t\t\t\t\"initialCount\" : 1,\n" +
- "\t\t\t\t\t\"hasVolumeGroup\" : true\n" +
- "\t\t\t\t}\n" +
- "\t\t\t]\n" +
- "\t\t},\n" +
- "\t\n" +
- "\t\t{ \"modelInfo\" : {\n" +
- "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n" +
- "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n" +
- "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n" +
- "\t\t\t\"modelVersion\" : \"1.0\",\n" +
- "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n" +
- "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" +
- "\t\t\t},\n" +
- "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n" +
- "\t\t\"nfFunction\" \t: null,\n" +
- "\t\t\"nfType\" \t\t: null,\n" +
- "\t\t\"nfRole\" \t\t: null,\n" +
- "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\"," +
- "\t\t\"nfNamingCode\" \t: null,\n" +
- "\t\t\"multiStageDesign\" : \"false\",\n" +
- "\t\t\t\"vfModules\": [\n" +
- "\t\t\t\t{\n" +
- "\t\t\t\t\t\"modelInfo\" : { \n" +
- "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n" +
- "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n" +
- "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n" +
- "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" +
- "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n" +
- "\t\t\t\t\t},\t\t\"isBase\" : true,\n" +
- "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n" +
- "\t\t\t\t\t\"initialCount\" : 1,\n" +
- "\t\t\t\t\t\"hasVolumeGroup\" : true\n" +
- "\t\t\t\t}\n" +
- "\t\t\t]\n" +
- "\t\t}\n" +
- "\t],\n" +
- "\t\"serviceNetworks\": [],\n" +
- "\t\"serviceAllottedResources\": []\n" +
- "\t}}")));
+ wireMockServer.stubFor(get(urlEqualTo(
+ "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
+ .willReturn(ok("{ \"serviceResources\" : {\n" + "\t\"modelInfo\" : {\n"
+ + "\t\t\"modelName\" : \"demoVFWCL\",\n"
+ + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n"
+ + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n"
+ + "\t\t\"modelVersion\" : \"1.0\"\n" + "\t},\n"
+ + "\t\"serviceType\" : \"\",\n" + "\t\"serviceRole\" : \"\",\n"
+ + "\t\"environmentContext\" : null,\n" + "\t\"workloadContext\" : \"Production\",\n"
+ + "\t\"serviceVnfs\": [\n" + "\t\n" + "\t\t{ \"modelInfo\" : {\n"
+ + "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n"
+ + "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n"
+ + "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n"
+ + "\t\t\t\"modelVersion\" : \"1.0\",\n"
+ + "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n"
+ + "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" + "\t\t\t},\n"
+ + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n"
+ + "\t\t\"nfFunction\" \t: null,\n"
+ + "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\","
+ + "\t\t\"nfType\" \t\t: null,\n"
+ + "\t\t\"nfRole\" \t\t: null,\n"
+ + "\t\t\"nfNamingCode\" \t: null,\n"
+ + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n"
+ + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n"
+ + "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n"
+ + "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n"
+ + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n"
+ + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n"
+ + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n"
+ + "\t\t\t\t\t},\t\t\"isBase\" : true,\n"
+ + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n"
+ + "\t\t\t\t\t\"initialCount\" : 1,\n"
+ + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n"
+ + "\t\t},\n" + "\t\n" + "\t\t{ \"modelInfo\" : {\n"
+ + "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n"
+ + "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n"
+ + "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n"
+ + "\t\t\t\"modelVersion\" : \"1.0\",\n"
+ + "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n"
+ + "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" + "\t\t\t},\n"
+ + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n"
+ + "\t\t\"nfFunction\" \t: null,\n"
+ + "\t\t\"nfType\" \t\t: null,\n"
+ + "\t\t\"nfRole\" \t\t: null,\n"
+ + "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\","
+ + "\t\t\"nfNamingCode\" \t: null,\n"
+ + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n"
+ + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n"
+ + "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n"
+ + "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n"
+ + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n"
+ + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n"
+ + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n"
+ + "\t\t\t\t\t},\t\t\"isBase\" : true,\n"
+ + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n"
+ + "\t\t\t\t\t\"initialCount\" : 1,\n"
+ + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n"
+ + "\t\t}\n" + "\t],\n" + "\t\"serviceNetworks\": [],\n"
+ + "\t\"serviceAllottedResources\": []\n" + "\t}}")));
-// when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080");
+ // when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080");
HashMap serviceInput = new HashMap();
serviceInput.put("key1", "value");
- Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
- "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput);
+ Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(
+ "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput);
assertEquals(stringObjectMap.get("a"), "default_value");
}
@Test
public void getResourceInputValueNoDefaultTest() throws Exception {
- wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
- .willReturn(ok("{ \"serviceResources\" : {\n" +
- "\t\"modelInfo\" : {\n" +
- "\t\t\"modelName\" : \"demoVFWCL\",\n" +
- "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" +
- "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" +
- "\t\t\"modelVersion\" : \"1.0\"\n" +
- "\t},\n" +
- "\t\"serviceType\" : \"\",\n" +
- "\t\"serviceRole\" : \"\",\n" +
- "\t\"environmentContext\" : null,\n" +
- "\t\"workloadContext\" : \"Production\",\n" +
- "\t\"serviceVnfs\": [\n" +
- "\t\n" +
- "\t\t{ \"modelInfo\" : {\n" +
- "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n" +
- "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n" +
- "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n" +
- "\t\t\t\"modelVersion\" : \"1.0\",\n" +
- "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n" +
- "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" +
- "\t\t\t},\n" +
- "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n" +
- "\t\t\"nfFunction\" \t: null,\n" +
- "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\"," +
- "\t\t\"nfType\" \t\t: null,\n" +
- "\t\t\"nfRole\" \t\t: null,\n" +
- "\t\t\"nfNamingCode\" \t: null,\n" +
- "\t\t\"multiStageDesign\" : \"false\",\n" +
- "\t\t\t\"vfModules\": [\n" +
- "\t\t\t\t{\n" +
- "\t\t\t\t\t\"modelInfo\" : { \n" +
- "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n" +
- "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n" +
- "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n" +
- "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" +
- "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n" +
- "\t\t\t\t\t},\t\t\"isBase\" : true,\n" +
- "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n" +
- "\t\t\t\t\t\"initialCount\" : 1,\n" +
- "\t\t\t\t\t\"hasVolumeGroup\" : true\n" +
- "\t\t\t\t}\n" +
- "\t\t\t]\n" +
- "\t\t},\n" +
- "\t\n" +
- "\t\t{ \"modelInfo\" : {\n" +
- "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n" +
- "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n" +
- "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n" +
- "\t\t\t\"modelVersion\" : \"1.0\",\n" +
- "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n" +
- "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" +
- "\t\t\t},\n" +
- "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n" +
- "\t\t\"nfFunction\" \t: null,\n" +
- "\t\t\"nfType\" \t\t: null,\n" +
- "\t\t\"nfRole\" \t\t: null,\n" +
- "\"resourceInput\":\"{\\\"a\\\":\\\"value\\\"}\"," +
- "\t\t\"nfNamingCode\" \t: null,\n" +
- "\t\t\"multiStageDesign\" : \"false\",\n" +
- "\t\t\t\"vfModules\": [\n" +
- "\t\t\t\t{\n" +
- "\t\t\t\t\t\"modelInfo\" : { \n" +
- "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n" +
- "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n" +
- "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n" +
- "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" +
- "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n" +
- "\t\t\t\t\t},\t\t\"isBase\" : true,\n" +
- "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n" +
- "\t\t\t\t\t\"initialCount\" : 1,\n" +
- "\t\t\t\t\t\"hasVolumeGroup\" : true\n" +
- "\t\t\t\t}\n" +
- "\t\t\t]\n" +
- "\t\t}\n" +
- "\t],\n" +
- "\t\"serviceNetworks\": [],\n" +
- "\t\"serviceAllottedResources\": []\n" +
- "\t}}")));
+ wireMockServer.stubFor(get(urlEqualTo(
+ "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
+ .willReturn(ok("{ \"serviceResources\" : {\n" + "\t\"modelInfo\" : {\n"
+ + "\t\t\"modelName\" : \"demoVFWCL\",\n"
+ + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n"
+ + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n"
+ + "\t\t\"modelVersion\" : \"1.0\"\n" + "\t},\n"
+ + "\t\"serviceType\" : \"\",\n" + "\t\"serviceRole\" : \"\",\n"
+ + "\t\"environmentContext\" : null,\n" + "\t\"workloadContext\" : \"Production\",\n"
+ + "\t\"serviceVnfs\": [\n" + "\t\n" + "\t\t{ \"modelInfo\" : {\n"
+ + "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n"
+ + "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n"
+ + "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n"
+ + "\t\t\t\"modelVersion\" : \"1.0\",\n"
+ + "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n"
+ + "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" + "\t\t\t},\n"
+ + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n"
+ + "\t\t\"nfFunction\" \t: null,\n"
+ + "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\","
+ + "\t\t\"nfType\" \t\t: null,\n"
+ + "\t\t\"nfRole\" \t\t: null,\n"
+ + "\t\t\"nfNamingCode\" \t: null,\n"
+ + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n"
+ + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n"
+ + "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n"
+ + "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n"
+ + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n"
+ + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n"
+ + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n"
+ + "\t\t\t\t\t},\t\t\"isBase\" : true,\n"
+ + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n"
+ + "\t\t\t\t\t\"initialCount\" : 1,\n"
+ + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n"
+ + "\t\t},\n" + "\t\n" + "\t\t{ \"modelInfo\" : {\n"
+ + "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n"
+ + "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n"
+ + "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n"
+ + "\t\t\t\"modelVersion\" : \"1.0\",\n"
+ + "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n"
+ + "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" + "\t\t\t},\n"
+ + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n"
+ + "\t\t\"nfFunction\" \t: null,\n"
+ + "\t\t\"nfType\" \t\t: null,\n"
+ + "\t\t\"nfRole\" \t\t: null,\n"
+ + "\"resourceInput\":\"{\\\"a\\\":\\\"value\\\"}\","
+ + "\t\t\"nfNamingCode\" \t: null,\n"
+ + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n"
+ + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n"
+ + "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n"
+ + "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n"
+ + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n"
+ + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n"
+ + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n"
+ + "\t\t\t\t\t},\t\t\"isBase\" : true,\n"
+ + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n"
+ + "\t\t\t\t\t\"initialCount\" : 1,\n"
+ + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n"
+ + "\t\t}\n" + "\t],\n" + "\t\"serviceNetworks\": [],\n"
+ + "\t\"serviceAllottedResources\": []\n" + "\t}}")));
-// when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080");
+ // when(UrnPropertiesReader.getVariable(anyString())).thenReturn("http://localhost:8080");
HashMap serviceInput = new HashMap();
serviceInput.put("key1", "value");
- Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
- "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput);
+ Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(
+ "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput);
assertEquals(stringObjectMap.get("a"), "value");
}
@Test
public void getResourceSequenceTest() throws Exception {
- wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
- .willReturn(ok("{ \"serviceResources\" : {\n" +
- "\t\"modelInfo\" : {\n" +
- "\t\t\"modelName\" : \"demoVFWCL\",\n" +
- "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" +
- "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" +
- "\t\t\"modelVersion\" : \"1.0\"\n" +
- "\t},\n" +
- "\t\"serviceType\" : \"\",\n" +
- "\t\"serviceRole\" : \"\",\n" +
- "\t\"environmentContext\" : null,\n" +
- "\t\"resourceOrder\" : \"res1,res2\",\n" +
- "\t\"workloadContext\" : \"Production\",\n" +
- "\t\"serviceVnfs\": [\n" +
- "\t\n" +
- "\t\t{ \"modelInfo\" : {\n" +
- "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n" +
- "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n" +
- "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n" +
- "\t\t\t\"modelVersion\" : \"1.0\",\n" +
- "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n" +
- "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" +
- "\t\t\t},\n" +
- "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n" +
- "\t\t\"nfFunction\" \t: null,\n" +
- "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\"," +
- "\t\t\"nfType\" \t\t: null,\n" +
- "\t\t\"nfRole\" \t\t: null,\n" +
- "\t\t\"nfNamingCode\" \t: null,\n" +
- "\t\t\"multiStageDesign\" : \"false\",\n" +
- "\t\t\t\"vfModules\": [\n" +
- "\t\t\t\t{\n" +
- "\t\t\t\t\t\"modelInfo\" : { \n" +
- "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n" +
- "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n" +
- "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n" +
- "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" +
- "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n" +
- "\t\t\t\t\t},\t\t\"isBase\" : true,\n" +
- "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n" +
- "\t\t\t\t\t\"initialCount\" : 1,\n" +
- "\t\t\t\t\t\"hasVolumeGroup\" : true\n" +
- "\t\t\t\t}\n" +
- "\t\t\t]\n" +
- "\t\t},\n" +
- "\t\n" +
- "\t\t{ \"modelInfo\" : {\n" +
- "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n" +
- "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n" +
- "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n" +
- "\t\t\t\"modelVersion\" : \"1.0\",\n" +
- "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n" +
- "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" +
- "\t\t\t},\n" +
- "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n" +
- "\t\t\"nfFunction\" \t: null,\n" +
- "\t\t\"nfType\" \t\t: null,\n" +
- "\t\t\"nfRole\" \t\t: null,\n" +
- "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\"," +
- "\t\t\"nfNamingCode\" \t: null,\n" +
- "\t\t\"multiStageDesign\" : \"false\",\n" +
- "\t\t\t\"vfModules\": [\n" +
- "\t\t\t\t{\n" +
- "\t\t\t\t\t\"modelInfo\" : { \n" +
- "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n" +
- "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n" +
- "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n" +
- "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n" +
- "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n" +
- "\t\t\t\t\t},\t\t\"isBase\" : true,\n" +
- "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n" +
- "\t\t\t\t\t\"initialCount\" : 1,\n" +
- "\t\t\t\t\t\"hasVolumeGroup\" : true\n" +
- "\t\t\t\t}\n" +
- "\t\t\t]\n" +
- "\t\t}\n" +
- "\t],\n" +
- "\t\"serviceNetworks\": [],\n" +
- "\t\"serviceAllottedResources\": []\n" +
- "\t}}")));
+ wireMockServer.stubFor(get(urlEqualTo(
+ "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
+ .willReturn(ok("{ \"serviceResources\" : {\n" + "\t\"modelInfo\" : {\n"
+ + "\t\t\"modelName\" : \"demoVFWCL\",\n"
+ + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n"
+ + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n"
+ + "\t\t\"modelVersion\" : \"1.0\"\n" + "\t},\n"
+ + "\t\"serviceType\" : \"\",\n" + "\t\"serviceRole\" : \"\",\n"
+ + "\t\"environmentContext\" : null,\n" + "\t\"resourceOrder\" : \"res1,res2\",\n"
+ + "\t\"workloadContext\" : \"Production\",\n" + "\t\"serviceVnfs\": [\n" + "\t\n"
+ + "\t\t{ \"modelInfo\" : {\n"
+ + "\t\t\t\"modelName\" : \"15968a6e-2fe5-41bf-a481\",\n"
+ + "\t\t\t\"modelUuid\" : \"808abda3-2023-4105-92d2-e62644b61d53\",\n"
+ + "\t\t\t\"modelInvariantUuid\" : \"6e4ffc7c-497e-4a77-970d-af966e642d31\",\n"
+ + "\t\t\t\"modelVersion\" : \"1.0\",\n"
+ + "\t\t\t\"modelCustomizationUuid\" : \"a00404d5-d7eb-4c46-b6b6-9cf2d087e545\",\n"
+ + "\t\t\t\"modelInstanceName\" : \"15968a6e-2fe5-41bf-a481 0\"\n" + "\t\t\t},\n"
+ + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.15968a6e2fe541bfA481\",\n"
+ + "\t\t\"nfFunction\" \t: null,\n"
+ + "\"resourceInput\":\"{\\\"a\\\":\\\"b\\\"}\","
+ + "\t\t\"nfType\" \t\t: null,\n"
+ + "\t\t\"nfRole\" \t\t: null,\n"
+ + "\t\t\"nfNamingCode\" \t: null,\n"
+ + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n"
+ + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n"
+ + "\t\t\t\t\t\t\"modelName\" : \"15968a6e2fe541bfA481..base_vfw..module-0\",\n"
+ + "\t\t\t\t\t\t\"modelUuid\" : \"ec7fadde-1e5a-42f7-8255-cb19e475ff45\",\n"
+ + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"61ab8b64-a014-4cf3-8a5a-b5ef388f8819\",\n"
+ + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n"
+ + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"123aff6b-854f-4026-ae1e-cc74a3924576\"\n"
+ + "\t\t\t\t\t},\t\t\"isBase\" : true,\n"
+ + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vfw\",\n"
+ + "\t\t\t\t\t\"initialCount\" : 1,\n"
+ + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n"
+ + "\t\t},\n" + "\t\n" + "\t\t{ \"modelInfo\" : {\n"
+ + "\t\t\t\"modelName\" : \"f971106a-248f-4202-9d1f\",\n"
+ + "\t\t\t\"modelUuid\" : \"4fbc08a4-35ed-4a59-9e47-79975e4add7e\",\n"
+ + "\t\t\t\"modelInvariantUuid\" : \"c669799e-adf1-46ae-8c70-48b326fe89f3\",\n"
+ + "\t\t\t\"modelVersion\" : \"1.0\",\n"
+ + "\t\t\t\"modelCustomizationUuid\" : \"e776449e-2b10-45c5-9217-2775c88ca1a0\",\n"
+ + "\t\t\t\"modelInstanceName\" : \"f971106a-248f-4202-9d1f 0\"\n" + "\t\t\t},\n"
+ + "\t\t\"toscaNodeType\" : \"org.openecomp.resource.vf.F971106a248f42029d1f\",\n"
+ + "\t\t\"nfFunction\" \t: null,\n"
+ + "\t\t\"nfType\" \t\t: null,\n"
+ + "\t\t\"nfRole\" \t\t: null,\n"
+ + "\"resourceInput\":\"{\\\"a\\\":\\\"key|default_value\\\"}\","
+ + "\t\t\"nfNamingCode\" \t: null,\n"
+ + "\t\t\"multiStageDesign\" : \"false\",\n" + "\t\t\t\"vfModules\": [\n"
+ + "\t\t\t\t{\n" + "\t\t\t\t\t\"modelInfo\" : { \n"
+ + "\t\t\t\t\t\t\"modelName\" : \"F971106a248f42029d1f..base_vpkg..module-0\",\n"
+ + "\t\t\t\t\t\t\"modelUuid\" : \"47d5273a-7456-4786-9035-b3911944cc35\",\n"
+ + "\t\t\t\t\t\t\"modelInvariantUuid\" : \"0ea3e57e-ac7a-425a-928b-b4aee8806c15\",\n"
+ + "\t\t\t\t\t\t\"modelVersion\" : \"1\",\n"
+ + "\t\t\t\t\t\t\"modelCustomizationUuid\" : \"9ed9fef6-d3f8-4433-9807-7e23393a16bc\"\n"
+ + "\t\t\t\t\t},\t\t\"isBase\" : true,\n"
+ + "\t\t\t\t\t\"vfModuleLabel\" : \"base_vpkg\",\n"
+ + "\t\t\t\t\t\"initialCount\" : 1,\n"
+ + "\t\t\t\t\t\"hasVolumeGroup\" : true\n" + "\t\t\t\t}\n" + "\t\t\t]\n"
+ + "\t\t}\n" + "\t],\n" + "\t\"serviceNetworks\": [],\n"
+ + "\t\"serviceAllottedResources\": []\n" + "\t}}")));
- List<String> resourceSequence = ResourceRequestBuilder.getResourceSequence("c3954379-4efe-431c-8258-f84905b158e5");
+ List<String> resourceSequence =
+ ResourceRequestBuilder.getResourceSequence("c3954379-4efe-431c-8258-f84905b158e5");
assertEquals(resourceSequence.size(), 2);
assertEquals(resourceSequence.get(0), "res1");
assertEquals(resourceSequence.get(1), "res2");
@@ -403,27 +322,22 @@ public class ResourceRequestBuilderTest extends BaseTest {
@Test
public void getResourceInputWithEmptyServiceResourcesTest() throws Exception {
- wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
- .willReturn(ok("{ \"serviceResources\" : {\n" +
- "\t\"modelInfo\" : {\n" +
- "\t\t\"modelName\" : \"demoVFWCL\",\n" +
- "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n" +
- "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n" +
- "\t\t\"modelVersion\" : \"1.0\"\n" +
- "\t},\n" +
- "\t\"serviceType\" : \"\",\n" +
- "\t\"serviceRole\" : \"\",\n" +
- "\t\"environmentContext\" : null,\n" +
- "\t\"workloadContext\" : \"Production\",\n" +
- "\t\"serviceVnfs\": [], \n" +
- "\t\"serviceNetworks\": [],\n" +
- "\t\"serviceAllottedResources\": []\n" +
- "\t}}")));
+ wireMockServer.stubFor(get(urlEqualTo(
+ "/ecomp/mso/catalog/v2/serviceResources?serviceModelUuid=c3954379-4efe-431c-8258-f84905b158e5"))
+ .willReturn(ok("{ \"serviceResources\" : {\n" + "\t\"modelInfo\" : {\n"
+ + "\t\t\"modelName\" : \"demoVFWCL\",\n"
+ + "\t\t\"modelUuid\" : \"c3954379-4efe-431c-8258-f84905b158e5\",\n"
+ + "\t\t\"modelInvariantUuid\" : \"0cbff61e-3b0a-4eed-97ce-b1b4faa03493\",\n"
+ + "\t\t\"modelVersion\" : \"1.0\"\n" + "\t},\n"
+ + "\t\"serviceType\" : \"\",\n" + "\t\"serviceRole\" : \"\",\n"
+ + "\t\"environmentContext\" : null,\n" + "\t\"workloadContext\" : \"Production\",\n"
+ + "\t\"serviceVnfs\": [], \n" + "\t\"serviceNetworks\": [],\n"
+ + "\t\"serviceAllottedResources\": []\n" + "\t}}")));
HashMap serviceInput = new HashMap();
serviceInput.put("key1", "value");
- Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest("c3954379-4efe-431c-8258-f84905b158e5",
- "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput);
+ Map<String, Object> stringObjectMap = ResourceRequestBuilder.buildResouceRequest(
+ "c3954379-4efe-431c-8258-f84905b158e5", "e776449e-2b10-45c5-9217-2775c88ca1a0", serviceInput);
assertEquals(0, stringObjectMap.size());
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/util/CryptoHandlerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/util/CryptoHandlerTest.java
index 76bc830d26..273e9f0e3c 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/util/CryptoHandlerTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/util/CryptoHandlerTest.java
@@ -23,34 +23,33 @@ package org.onap.so.bpmn.common.util;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
-
import static org.junit.Assert.assertEquals;
public class CryptoHandlerTest {
- private static final String plainPswd = "mso0206";
- private CryptoHandler cryptoHandler;
- private static String encryptPwd;
-
-
- @Before
- public void setup() {
- cryptoHandler = new CryptoHandler();
- encryptPwd = cryptoHandler.encryptMsoPassword(plainPswd);
- }
-
- @Test
- @Ignore // ignored until we can mock the properties file.
- public void getMsoAaiPasswordTest() {
- assertEquals(plainPswd, cryptoHandler.getMsoAaiPassword());
- }
-
- @Test
- public void encryptMsoPasswordTest() {
- assertEquals(plainPswd,cryptoHandler.decryptMsoPassword(cryptoHandler.encryptMsoPassword(plainPswd)));
- }
-
- @Test
- public void decryptMsoPasswordTest() {
- assertEquals(plainPswd, cryptoHandler.decryptMsoPassword(encryptPwd));
- }
-} \ No newline at end of file
+ private static final String plainPswd = "mso0206";
+ private CryptoHandler cryptoHandler;
+ private static String encryptPwd;
+
+
+ @Before
+ public void setup() {
+ cryptoHandler = new CryptoHandler();
+ encryptPwd = cryptoHandler.encryptMsoPassword(plainPswd);
+ }
+
+ @Test
+ @Ignore // ignored until we can mock the properties file.
+ public void getMsoAaiPasswordTest() {
+ assertEquals(plainPswd, cryptoHandler.getMsoAaiPassword());
+ }
+
+ @Test
+ public void encryptMsoPasswordTest() {
+ assertEquals(plainPswd, cryptoHandler.decryptMsoPassword(cryptoHandler.encryptMsoPassword(plainPswd)));
+ }
+
+ @Test
+ public void decryptMsoPasswordTest() {
+ assertEquals(plainPswd, cryptoHandler.decryptMsoPassword(encryptPwd));
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java
index 617f63f6f8..f13bcb8a93 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunnerTest.java
@@ -24,10 +24,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
-
import java.util.Arrays;
import java.util.List;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Rule;
@@ -45,46 +43,48 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ContextConfiguration(classes = {ValidationConfig.class})
public class BuildingBlockValidatorRunnerTest {
- @Rule
- public ExpectedException thrown= ExpectedException.none();
-
- @Autowired
- private BuildingBlockValidatorRunner runner;
-
- @Test
- public void filterValidatorTest() {
-
- MyPreValidatorOne one = new MyPreValidatorOne();
- MyPreValidatorTwo two = new MyPreValidatorTwo();
- MyPreValidatorThree three = new MyPreValidatorThree();
- List<FlowValidator> validators = Arrays.asList(one, two, three);
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Autowired
+ private BuildingBlockValidatorRunner runner;
+
+ @Test
+ public void filterValidatorTest() {
+
+ MyPreValidatorOne one = new MyPreValidatorOne();
+ MyPreValidatorTwo two = new MyPreValidatorTwo();
+ MyPreValidatorThree three = new MyPreValidatorThree();
+ List<FlowValidator> validators = Arrays.asList(one, two, three);
+
+ List<FlowValidator> result = runner.filterValidators(validators, "test");
+
+ List<FlowValidator> expected = Arrays.asList(two, one);
+
+ assertEquals(expected, result);
+ }
+
+ @Test
+ public void testValidate() {
+
+ BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
+ execution.setVariable("testProcessKey", "1234");
+ try {
+ runner.preValidate("test", execution);
+ fail("exception not thrown");
+ } catch (BpmnError e) {
+ WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException");
+ assertEquals(
+ "Failed Validations:\norg.onap.so.bpmn.common.validation.MyPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.validation.MyPreValidatorOne: my-error-one",
+ workflowException.getErrorMessage());
+ }
+ runner.preValidate("test2", mock(BuildingBlockExecution.class));
+ }
- List<FlowValidator> result = runner.filterValidators(validators, "test");
+ @Test
+ public void testEmptyList() {
+ boolean result = runner.preValidate("test3", mock(BuildingBlockExecution.class));
- List<FlowValidator> expected = Arrays.asList(two, one);
-
- assertEquals(expected, result);
- }
-
- @Test
- public void testValidate() {
-
- BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake());
- execution.setVariable("testProcessKey", "1234");
- try {
- runner.preValidate("test", execution);
- fail("exception not thrown");
- } catch (BpmnError e) {
- WorkflowException workflowException = (WorkflowException)execution.getVariable("WorkflowException");
- assertEquals("Failed Validations:\norg.onap.so.bpmn.common.validation.MyPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.validation.MyPreValidatorOne: my-error-one", workflowException.getErrorMessage());
- }
- runner.preValidate("test2", mock(BuildingBlockExecution.class));
- }
-
- @Test
- public void testEmptyList() {
- boolean result = runner.preValidate("test3", mock(BuildingBlockExecution.class));
-
- assertTrue(result);
- }
+ assertTrue(result);
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyDisabledValidator.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyDisabledValidator.java
index 78e4791b1c..7572e930cd 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyDisabledValidator.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyDisabledValidator.java
@@ -22,7 +22,6 @@ package org.onap.so.bpmn.common.validation;
import java.util.Collections;
import java.util.Optional;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.springframework.stereotype.Component;
@@ -30,15 +29,15 @@ import org.springframework.stereotype.Component;
@Skip
public class MyDisabledValidator implements PreBuildingBlockValidator {
- @Override
- public boolean shouldRunFor(String bbName) {
-
- return Collections.singleton("test").contains(bbName);
- }
+ @Override
+ public boolean shouldRunFor(String bbName) {
+
+ return Collections.singleton("test").contains(bbName);
+ }
- @Override
- public Optional<String> validate(BuildingBlockExecution exeuction) {
- return Optional.of("my-disabled-validator");
- }
+ @Override
+ public Optional<String> validate(BuildingBlockExecution exeuction) {
+ return Optional.of("my-disabled-validator");
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java
index af45a129e2..85531719d5 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorFour.java
@@ -23,21 +23,20 @@ package org.onap.so.bpmn.common.validation;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.springframework.stereotype.Component;
@Component
public class MyPreValidatorFour implements PreBuildingBlockValidator {
- @Override
- public boolean shouldRunFor(String bbName) {
- return Collections.singleton("test2").contains(bbName);
- }
+ @Override
+ public boolean shouldRunFor(String bbName) {
+ return Collections.singleton("test2").contains(bbName);
+ }
- @Override
- public Optional<String> validate(BuildingBlockExecution exeuction) {
- return Optional.of("my-error-four");
- }
+ @Override
+ public Optional<String> validate(BuildingBlockExecution exeuction) {
+ return Optional.of("my-error-four");
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java
index d1d50e2a89..989a65fe47 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorOne.java
@@ -23,22 +23,21 @@ package org.onap.so.bpmn.common.validation;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.springframework.stereotype.Component;
@Component
public class MyPreValidatorOne implements PreBuildingBlockValidator {
- @Override
- public boolean shouldRunFor(String bbName) {
-
- return Collections.singleton("test").contains(bbName);
- }
+ @Override
+ public boolean shouldRunFor(String bbName) {
+
+ return Collections.singleton("test").contains(bbName);
+ }
- @Override
- public Optional<String> validate(BuildingBlockExecution exeuction) {
- return Optional.of("my-error-one");
- }
+ @Override
+ public Optional<String> validate(BuildingBlockExecution exeuction) {
+ return Optional.of("my-error-one");
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java
index 363020de71..a51d3836da 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorThree.java
@@ -23,21 +23,20 @@ package org.onap.so.bpmn.common.validation;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.springframework.stereotype.Component;
@Component
public class MyPreValidatorThree implements PreBuildingBlockValidator {
- @Override
- public boolean shouldRunFor(String bbName) {
- return Collections.singleton("test2").contains(bbName);
- }
+ @Override
+ public boolean shouldRunFor(String bbName) {
+ return Collections.singleton("test2").contains(bbName);
+ }
- @Override
- public Optional<String> validate(BuildingBlockExecution exeuction) {
- return Optional.of("my-error-three");
- }
+ @Override
+ public Optional<String> validate(BuildingBlockExecution exeuction) {
+ return Optional.of("my-error-three");
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java
index 4d78f4e458..1276d8f1d2 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/MyPreValidatorTwo.java
@@ -23,9 +23,7 @@ package org.onap.so.bpmn.common.validation;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
-
import javax.annotation.Priority;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.springframework.stereotype.Component;
@@ -33,14 +31,14 @@ import org.springframework.stereotype.Component;
@Component
public class MyPreValidatorTwo implements PreBuildingBlockValidator {
- @Override
- public boolean shouldRunFor(String bbName) {
- return Collections.singleton("test").contains(bbName);
- }
+ @Override
+ public boolean shouldRunFor(String bbName) {
+ return Collections.singleton("test").contains(bbName);
+ }
- @Override
- public Optional<String> validate(BuildingBlockExecution exeuction) {
- return Optional.of("my-error-two");
- }
+ @Override
+ public Optional<String> validate(BuildingBlockExecution exeuction) {
+ return Optional.of("my-error-two");
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/ValidationConfig.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/ValidationConfig.java
index 7570e4c915..90d094ce41 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/ValidationConfig.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/ValidationConfig.java
@@ -27,7 +27,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
@Configuration
-@ComponentScan(basePackages = {"org.onap.so.bpmn.common.validation"}, basePackageClasses = {ExceptionBuilder.class}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class)
+@ComponentScan(basePackages = {"org.onap.so.bpmn.common.validation"}, basePackageClasses = {ExceptionBuilder.class},
+ nameGenerator = DefaultToShortClassNameBeanNameGenerator.class)
public class ValidationConfig {
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java
index 891496fa2b..485aae2fcc 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorOne.java
@@ -23,22 +23,21 @@ package org.onap.so.bpmn.common.validation;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.springframework.stereotype.Component;
@Component
public class WorkflowPreValidatorOne implements PreWorkflowValidator {
- @Override
- public boolean shouldRunFor(String bbName) {
-
- return Collections.singleton("test").contains(bbName);
- }
+ @Override
+ public boolean shouldRunFor(String bbName) {
+
+ return Collections.singleton("test").contains(bbName);
+ }
- @Override
- public Optional<String> validate(BuildingBlockExecution exeuction) {
- return Optional.of("my-error-one");
- }
+ @Override
+ public Optional<String> validate(BuildingBlockExecution exeuction) {
+ return Optional.of("my-error-one");
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java
index 80b55df8f5..9596524a56 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowPreValidatorTwo.java
@@ -23,9 +23,7 @@ package org.onap.so.bpmn.common.validation;
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
-
import javax.annotation.Priority;
-
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.springframework.stereotype.Component;
@@ -33,14 +31,14 @@ import org.springframework.stereotype.Component;
@Component
public class WorkflowPreValidatorTwo implements PreWorkflowValidator {
- @Override
- public boolean shouldRunFor(String bbName) {
- return Collections.singleton("test").contains(bbName);
- }
+ @Override
+ public boolean shouldRunFor(String bbName) {
+ return Collections.singleton("test").contains(bbName);
+ }
- @Override
- public Optional<String> validate(BuildingBlockExecution exeuction) {
- return Optional.of("my-error-two");
- }
+ @Override
+ public Optional<String> validate(BuildingBlockExecution exeuction) {
+ return Optional.of("my-error-two");
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java
index 5629f99feb..07cd790ed1 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunnerTest.java
@@ -24,10 +24,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
-
import java.util.Arrays;
import java.util.List;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
@@ -45,45 +43,47 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ContextConfiguration(classes = {ValidationConfig.class})
public class WorkflowValidatorRunnerTest {
- @Rule
- public ExpectedException thrown= ExpectedException.none();
-
- @Autowired
- private WorkflowValidatorRunner runner;
-
- @Test
- public void filterValidatorTest() {
-
- WorkflowPreValidatorOne one = new WorkflowPreValidatorOne();
- WorkflowPreValidatorTwo two = new WorkflowPreValidatorTwo();
- List<FlowValidator> validators = Arrays.asList(one, two);
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Autowired
+ private WorkflowValidatorRunner runner;
+
+ @Test
+ public void filterValidatorTest() {
+
+ WorkflowPreValidatorOne one = new WorkflowPreValidatorOne();
+ WorkflowPreValidatorTwo two = new WorkflowPreValidatorTwo();
+ List<FlowValidator> validators = Arrays.asList(one, two);
+
+ List<FlowValidator> result = runner.filterValidators(validators, "test");
+
+ List<FlowValidator> expected = Arrays.asList(two, one);
+
+ assertEquals(expected, result);
+ }
+
+ @Test
+ public void testValidate() {
+
+ DelegateExecution execution = new DelegateExecutionFake();
+ execution.setVariable("testProcessKey", "1234");
+ try {
+ runner.preValidate("test", execution);
+ fail("exception not thrown");
+ } catch (BpmnError e) {
+ WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException");
+ assertEquals(
+ "Failed Validations:\norg.onap.so.bpmn.common.validation.WorkflowPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.validation.WorkflowPreValidatorOne: my-error-one",
+ workflowException.getErrorMessage());
+ }
+ runner.preValidate("test2", mock(DelegateExecution.class));
+ }
- List<FlowValidator> result = runner.filterValidators(validators, "test");
+ @Test
+ public void testEmptyList() {
+ boolean result = runner.preValidate("test3", mock(DelegateExecution.class));
- List<FlowValidator> expected = Arrays.asList(two, one);
-
- assertEquals(expected, result);
- }
-
- @Test
- public void testValidate() {
-
- DelegateExecution execution = new DelegateExecutionFake();
- execution.setVariable("testProcessKey", "1234");
- try {
- runner.preValidate("test", execution);
- fail("exception not thrown");
- } catch (BpmnError e) {
- WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException");
- assertEquals("Failed Validations:\norg.onap.so.bpmn.common.validation.WorkflowPreValidatorTwo: my-error-two\norg.onap.so.bpmn.common.validation.WorkflowPreValidatorOne: my-error-one", workflowException.getErrorMessage());
- }
- runner.preValidate("test2", mock(DelegateExecution.class));
- }
-
- @Test
- public void testEmptyList() {
- boolean result = runner.preValidate("test3", mock(DelegateExecution.class));
-
- assertTrue(result);
- }
+ assertTrue(result);
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/FileUtil.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/FileUtil.java
index 6a3668b175..e74dece785 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/FileUtil.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/FileUtil.java
@@ -34,51 +34,50 @@ import org.slf4j.LoggerFactory;
* </p>
*
* @author
- * @version ONAP Sep 15, 2017
+ * @version ONAP Sep 15, 2017
*/
public class FileUtil {
private static final Logger logger = LoggerFactory.getLogger(FileUtil.class);
-
- /**
- * Read the specified resource file and return the contents as a String.
- *
- * @param fileName Name of the resource file
- * @return the contents of the resource file as a String
- * @throws IOException if there is a problem reading the file
- */
- public static String readResourceFile(String fileName) {
- InputStream stream;
- try {
- stream = getResourceAsStream(fileName);
- byte[] bytes;
- bytes = new byte[stream.available()];
- if(stream.read(bytes) > 0) {
- stream.close();
- return new String(bytes);
- } else {
- stream.close();
- return "";
- }
- } catch (IOException e) {
- logger.debug("Exception:", e);
- return "";
- }
- }
-
- /**
- * Get an InputStream for the resource specified.
- *
- * @param resourceName Name of resource for which to get InputStream.
- * @return an InputStream for the resource specified.
- * @throws IOException If we can't get the InputStream for whatever reason.
- */
- private static InputStream getResourceAsStream(String resourceName) throws IOException {
- InputStream stream =
- FileUtil.class.getClassLoader().getResourceAsStream(resourceName);
- if (stream == null) {
- throw new IOException("Can't access resource '" + resourceName + "'");
- }
- return stream;
- }
+
+ /**
+ * Read the specified resource file and return the contents as a String.
+ *
+ * @param fileName Name of the resource file
+ * @return the contents of the resource file as a String
+ * @throws IOException if there is a problem reading the file
+ */
+ public static String readResourceFile(String fileName) {
+ InputStream stream;
+ try {
+ stream = getResourceAsStream(fileName);
+ byte[] bytes;
+ bytes = new byte[stream.available()];
+ if (stream.read(bytes) > 0) {
+ stream.close();
+ return new String(bytes);
+ } else {
+ stream.close();
+ return "";
+ }
+ } catch (IOException e) {
+ logger.debug("Exception:", e);
+ return "";
+ }
+ }
+
+ /**
+ * Get an InputStream for the resource specified.
+ *
+ * @param resourceName Name of resource for which to get InputStream.
+ * @return an InputStream for the resource specified.
+ * @throws IOException If we can't get the InputStream for whatever reason.
+ */
+ private static InputStream getResourceAsStream(String resourceName) throws IOException {
+ InputStream stream = FileUtil.class.getClassLoader().getResourceAsStream(resourceName);
+ if (stream == null) {
+ throw new IOException("Can't access resource '" + resourceName + "'");
+ }
+ return stream;
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java
index 80625dd4d5..0d09a72edd 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAAI.java
@@ -30,7 +30,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-
import com.github.tomakehurst.wiremock.WireMockServer;
@@ -40,1059 +39,1027 @@ import com.github.tomakehurst.wiremock.WireMockServer;
*/
public class StubResponseAAI {
- public static void setupAllMocks() {
-
- }
-
-
- /**
- * Allotted Resource Mock StubResponses below
- */
- public static void MockGetAllottedResource(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId, String responseFile) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockPutAllottedResource(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) {
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
- public static void MockPutAllottedResource_500(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) {
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
- .willReturn(aResponse()
- .withStatus(500)));
- }
-
- public static void MockDeleteAllottedResource(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId, String resourceVersion) {
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId + "[?]resource-version=" + resourceVersion))
- .willReturn(aResponse()
- .withStatus(204)));
- }
-
- public static void MockPatchAllottedResource(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) {
- wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
- public static void MockQueryAllottedResourceById(WireMockServer wireMockServer, String allottedResourceId, String responseFile){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=allotted-resource[&]filter=id:EQUALS:" + allottedResourceId))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
-
- /**
- * Service Instance Mock StubResponses below
- */
- public static void MockGetServiceInstance(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")));
- }
-
- /**
- * Service Instance Mock StubResponses below
- */
- public static void MockGetServiceInstance(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String responseFile) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetServiceInstance_404(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
- .willReturn(aResponse()
- .withStatus(404)));
- }
-
- public static void MockGetServiceInstance_500(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
- .willReturn(aResponse()
- .withStatus(500)));
- }
-
- public static void MockGetServiceInstance_500(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String responseFile){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockNodeQueryServiceInstanceByName(WireMockServer wireMockServer, String serviceInstanceName, String responseFile){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-name:EQUALS:" + serviceInstanceName))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockNodeQueryServiceInstanceByName_404(WireMockServer wireMockServer, String serviceInstanceName){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:" + serviceInstanceName))
- .willReturn(aResponse()
- .withStatus(404)));
- }
-
- public static void MockNodeQueryServiceInstanceByName_500(WireMockServer wireMockServer, String serviceInstanceName){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:" + serviceInstanceName))
- .willReturn(aResponse()
- .withStatus(500)));
- }
-
- public static void MockNodeQueryServiceInstanceById(WireMockServer wireMockServer, String serviceInstanceId, String responseFile){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-id:EQUALS:" + serviceInstanceId))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockNodeQueryServiceInstanceById_404(WireMockServer wireMockServer, String serviceInstanceId){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:" + serviceInstanceId))
- .willReturn(aResponse()
- .withStatus(404)));
- }
-
- public static void MockNodeQueryServiceInstanceById_500(WireMockServer wireMockServer, String serviceInstanceId){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:" + serviceInstanceId))
- .willReturn(aResponse()
- .withStatus(500)));
- }
-
- public static void MockDeleteServiceInstance(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
- .willReturn(aResponse()
- .withStatus(204)));
- }
-
- public static void MockGetServiceInstance(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
- .willReturn(aResponse()
- .withStatus(statusCode)));
- }
-
- public static void MockGetServiceInstance(WireMockServer wireMockServer, String customer, String serviceSubscription, int statusCode){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")));
- }
-
- public static void MockDeleteServiceInstance(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
- .willReturn(aResponse()
- .withStatus(statusCode)));
- }
-
- public static void MockDeleteServiceInstance(WireMockServer wireMockServer, String customer, String serviceSubscription, String resourceVersion, int statusCode){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "[?]resource-version=" +1234))
- .willReturn(aResponse()
- .withStatus(statusCode)));
- }
-
- public static void MockDeleteServiceInstance_404(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
- .willReturn(aResponse()
- .withStatus(404)));
- }
-
- public static void MockDeleteServiceInstance_500(WireMockServer wireMockServer, String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion))
- .willReturn(aResponse()
- .withStatus(500)));
- }
-
- public static void MockPutServiceInstance(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId, String responseFile) {
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockPutServiceInstance_500(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId) {
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
- .willReturn(aResponse()
- .withStatus(500)));
- }
-
- /**
- * Service-Subscription Mock StubResponses below
- */
- public static void MockGetServiceSubscription(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String responseFile) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockDeleteServiceSubscription(WireMockServer wireMockServer, String globalCustId, String subscriptionType, int statusCode) {
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
- .willReturn(aResponse()
- .withStatus(statusCode)));
- }
-
- public static void MockDeleteServiceInstanceId(WireMockServer wireMockServer, String globalCustId, String subscriptionType, String serviceInstanceId) {
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
- public static void MockPutServiceSubscription(WireMockServer wireMockServer, String globalCustId, String subscriptionType) {
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
- public static void MockGetServiceSubscription(WireMockServer wireMockServer, String globalCustId, String subscriptionType, int statusCode) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType))
- .willReturn(aResponse()
- .withStatus(statusCode)));
- }
-
- /**
- * Customer Mock StubResponses below
- */
- public static void MockGetCustomer(WireMockServer wireMockServer, String globalCustId, String responseFile) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockDeleteCustomer(WireMockServer wireMockServer, String globalCustId) {
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
- public static void MockPutCustomer(WireMockServer wireMockServer, String globalCustId) {
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
- public static void MockPutCustomer_500(WireMockServer wireMockServer, String globalCustId) {
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
- .willReturn(aResponse()
- .withStatus(500)));
- }
-
-
- /**
- * Generic-Vnf Mock StubResponses below
- */
-
- public static void MockGetGenericVnfById(WireMockServer wireMockServer, String vnfId, String responseFile){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetGenericVnfById(WireMockServer wireMockServer, String vnfId, String responseFile, int statusCode){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetGenericVnfByIdWithPriority(WireMockServer wireMockServer, String vnfId, int statusCode, String responseFile) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
- .atPriority(1)
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetGenericVnfByIdWithPriority(WireMockServer wireMockServer, String vnfId, String vfModuleId, int statusCode, String responseFile, int priority) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
- .atPriority(priority)
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetGenericVnfByIdWithDepth(WireMockServer wireMockServer, String vnfId, int depth, String responseFile){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=" + depth))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetGenericVnfById_404(WireMockServer wireMockServer, String vnfId){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
- .willReturn(aResponse()
- .withStatus(404)));
- }
-
- public static void MockGetGenericVnfById_500(WireMockServer wireMockServer, String vnfId){
- wireMockServer.stubFor(get(urlMatching("/aai/v9/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=1"))
- .withQueryParam("depth", equalTo("1"))
- .willReturn(aResponse()
- .withStatus(500)));
- }
-
- public static void MockGetGenericVnfByName(WireMockServer wireMockServer, String vnfName, String responseFile){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetGenericVnfByNameWithDepth(WireMockServer wireMockServer, String vnfName, int depth, String responseFile){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName + "[&]depth=" + depth))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetGenericVnfByName_404(WireMockServer wireMockServer, String vnfName){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName))
- .willReturn(aResponse()
- .withStatus(404)));
- }
-
- public static void MockDeleteGenericVnf(WireMockServer wireMockServer, String vnfId, String resourceVersion){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
- .willReturn(aResponse()
- .withStatus(204)));
- }
-
- public static void MockDeleteGenericVnf(WireMockServer wireMockServer, String vnfId, String resourceVersion, int statusCode){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
- .willReturn(aResponse()
- .withStatus(statusCode)));
- }
-
- public static void MockDeleteGenericVnf_500(WireMockServer wireMockServer, String vnfId, String resourceVersion){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
- .willReturn(aResponse()
- .withStatus(500)));
- }
-
- public static void MockPutGenericVnf(WireMockServer wireMockServer, String vnfId){
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
- public static void MockPutGenericVnf(WireMockServer wireMockServer, String vnfId, String requestBodyContaining, int statusCode) {
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
- .withRequestBody(containing(requestBodyContaining))
- .willReturn(aResponse()
- .withStatus(statusCode)));
- }
-
- public static void MockPutGenericVnf(WireMockServer wireMockServer, String vnfId, int statusCode) {
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
- .willReturn(aResponse()
- .withStatus(statusCode)));
- }
-
- public static void MockPutGenericVnf_Bad(WireMockServer wireMockServer, String vnfId, int statusCode){
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
- .willReturn(aResponse()
- .withStatus(statusCode)));
- }
-
- public static void MockPatchGenericVnf(WireMockServer wireMockServer, String vnfId){
- wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
- .willReturn(aResponse()
- .withStatus(200)));
- }
- /**
- * Vce Mock StubResponses below
- */
- public static void MockGetVceById(WireMockServer wireMockServer, String vnfId, String responseFile){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetVceByName(WireMockServer wireMockServer, String vnfName, String responseFile){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockDeleteVce(WireMockServer wireMockServer, String vnfId, String resourceVersion, int statusCode){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId + "[?]resource-version=" + resourceVersion))
- .willReturn(aResponse()
- .withStatus(statusCode)));
- }
-
- public static void MockPutVce(WireMockServer wireMockServer, String vnfId){
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
- public static void MockGetGenericVceByNameWithDepth(WireMockServer wireMockServer, String vnfName, int depth, String responseFile){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName + "[&]depth=" + depth))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetVceGenericQuery(WireMockServer wireMockServer, String serviceInstanceName, int depth, int statusCode, String responseFile){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=service-instance.service-instance-name:" + serviceInstanceName + "[&]start-node-type=service-instance[&]include=vce[&]depth=" + depth))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- /**
- * Tenant Mock StubResponses below
- */
- public static void MockGetTenantGenericQuery(WireMockServer wireMockServer, String customer, String serviceType, String responseFile) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=customer.global-customer-id:" + customer + "&key=service-subscription.service-type:" + serviceType + "&start-node-type=service-subscription&include=tenant&include=service-subscription&depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetTenant(WireMockServer wireMockServer, String tenantId, String responseFile) {
- wireMockServer.stubFor(get(urlEqualTo("/aai/v2/cloud-infrastructure/tenants/tenant/" + tenantId))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- /**
- * Network Mock StubResponses below
- */
- public static void MockGetNetwork(WireMockServer wireMockServer, String networkId, String responseFile, int statusCode) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetNetworkByIdWithDepth(WireMockServer wireMockServer, String networkId, String responseFile, String depth) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId + "[?]depth=" + depth))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetNetworkCloudRegion(WireMockServer wireMockServer, String responseFile, String cloudRegion) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"+cloudRegion))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetNetworkByName(WireMockServer wireMockServer, String networkName, String responseFile) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name="+networkName))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetNetworkByName_404(WireMockServer wireMockServer, String responseFile, String networkName) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name="+networkName))
- .willReturn(aResponse()
- .withStatus(404)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetNetworkCloudRegion_404(WireMockServer wireMockServer, String cloudRegion) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"+cloudRegion))
- .willReturn(aResponse()
- .withStatus(404)));
- }
-
- public static void MockPutNetwork(WireMockServer wireMockServer, String networkId, int statusCode, String responseFile) {
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockPutNetwork(WireMockServer wireMockServer, String networkPolicyId, String responseFile, int statusCode) {
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicyId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
+ public static void setupAllMocks() {
+
+ }
+
+
+ /**
+ * Allotted Resource Mock StubResponses below
+ */
+ public static void MockGetAllottedResource(WireMockServer wireMockServer, String globalCustId,
+ String subscriptionType, String serviceInstanceId, String allottedResourceId, String responseFile) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
+ + "/service-subscriptions/service-subscription/" + subscriptionType
+ + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/"
+ + allottedResourceId)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockPutAllottedResource(WireMockServer wireMockServer, String globalCustId,
+ String subscriptionType, String serviceInstanceId, String allottedResourceId) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
+ + "/service-subscriptions/service-subscription/" + subscriptionType
+ + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/"
+ + allottedResourceId)).willReturn(aResponse().withStatus(200)));
+ }
+
+ public static void MockPutAllottedResource_500(WireMockServer wireMockServer, String globalCustId,
+ String subscriptionType, String serviceInstanceId, String allottedResourceId) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
+ + "/service-subscriptions/service-subscription/" + subscriptionType
+ + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/"
+ + allottedResourceId)).willReturn(aResponse().withStatus(500)));
+ }
+
+ public static void MockDeleteAllottedResource(WireMockServer wireMockServer, String globalCustId,
+ String subscriptionType, String serviceInstanceId, String allottedResourceId, String resourceVersion) {
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
+ + "/service-subscriptions/service-subscription/" + subscriptionType
+ + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/"
+ + allottedResourceId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse().withStatus(204)));
+ }
+
+ public static void MockPatchAllottedResource(WireMockServer wireMockServer, String globalCustId,
+ String subscriptionType, String serviceInstanceId, String allottedResourceId) {
+ wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
+ + "/service-subscriptions/service-subscription/" + subscriptionType
+ + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/"
+ + allottedResourceId)).willReturn(aResponse().withStatus(200)));
+ }
+
+ public static void MockQueryAllottedResourceById(WireMockServer wireMockServer, String allottedResourceId,
+ String responseFile) {
+ wireMockServer.stubFor(get(
+ urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=allotted-resource[&]filter=id:EQUALS:"
+ + allottedResourceId))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+
+ /**
+ * Service Instance Mock StubResponses below
+ */
+ public static void MockGetServiceInstance(WireMockServer wireMockServer, String globalCustId,
+ String subscriptionType, String serviceInstanceId) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
+ + "/service-subscriptions/service-subscription/" + subscriptionType
+ + "/service-instances/service-instance/" + serviceInstanceId))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")));
+ }
+
+ /**
+ * Service Instance Mock StubResponses below
+ */
+ public static void MockGetServiceInstance(WireMockServer wireMockServer, String globalCustId,
+ String subscriptionType, String serviceInstanceId, String responseFile) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
+ + "/service-subscriptions/service-subscription/" + subscriptionType
+ + "/service-instances/service-instance/" + serviceInstanceId)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockGetServiceInstance_404(WireMockServer wireMockServer, String customer,
+ String serviceSubscription, String serviceInstanceId) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/"
+ + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
+ .willReturn(aResponse().withStatus(404)));
+ }
+
+ public static void MockGetServiceInstance_500(WireMockServer wireMockServer, String customer,
+ String serviceSubscription, String serviceInstanceId) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/"
+ + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
+ .willReturn(aResponse().withStatus(500)));
+ }
+
+ public static void MockGetServiceInstance_500(WireMockServer wireMockServer, String customer,
+ String serviceSubscription, String serviceInstanceId, String responseFile) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/"
+ + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId))
+ .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockNodeQueryServiceInstanceByName(WireMockServer wireMockServer, String serviceInstanceName,
+ String responseFile) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-name:EQUALS:"
+ + serviceInstanceName))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockNodeQueryServiceInstanceByName_404(WireMockServer wireMockServer,
+ String serviceInstanceName) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:"
+ + serviceInstanceName)).willReturn(aResponse().withStatus(404)));
+ }
+
+ public static void MockNodeQueryServiceInstanceByName_500(WireMockServer wireMockServer,
+ String serviceInstanceName) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:"
+ + serviceInstanceName)).willReturn(aResponse().withStatus(500)));
+ }
+
+ public static void MockNodeQueryServiceInstanceById(WireMockServer wireMockServer, String serviceInstanceId,
+ String responseFile) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-id:EQUALS:"
+ + serviceInstanceId))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockNodeQueryServiceInstanceById_404(WireMockServer wireMockServer, String serviceInstanceId) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:"
+ + serviceInstanceId)).willReturn(aResponse().withStatus(404)));
+ }
+
+ public static void MockNodeQueryServiceInstanceById_500(WireMockServer wireMockServer, String serviceInstanceId) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:"
+ + serviceInstanceId)).willReturn(aResponse().withStatus(500)));
+ }
+
+ public static void MockDeleteServiceInstance(WireMockServer wireMockServer, String customer,
+ String serviceSubscription, String serviceInstanceId, String resourceVersion) {
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/"
+ + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId
+ + "[?]resource-version=" + resourceVersion)).willReturn(aResponse().withStatus(204)));
+ }
+
+ public static void MockGetServiceInstance(WireMockServer wireMockServer, String customer,
+ String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/"
+ + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId
+ + "[?]resource-version=" + resourceVersion)).willReturn(aResponse().withStatus(statusCode)));
+ }
+
+ public static void MockGetServiceInstance(WireMockServer wireMockServer, String customer,
+ String serviceSubscription, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer
+ + "/service-subscriptions/service-subscription/" + serviceSubscription))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")));
+ }
+
+ public static void MockDeleteServiceInstance(WireMockServer wireMockServer, String customer,
+ String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode) {
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/"
+ + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId
+ + "[?]resource-version=" + resourceVersion)).willReturn(aResponse().withStatus(statusCode)));
+ }
+
+ public static void MockDeleteServiceInstance(WireMockServer wireMockServer, String customer,
+ String serviceSubscription, String resourceVersion, int statusCode) {
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer
+ + "/service-subscriptions/service-subscription/" + serviceSubscription + "[?]resource-version=" + 1234))
+ .willReturn(aResponse().withStatus(statusCode)));
+ }
+
+ public static void MockDeleteServiceInstance_404(WireMockServer wireMockServer, String customer,
+ String serviceSubscription, String serviceInstanceId, String resourceVersion) {
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/"
+ + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId
+ + "[?]resource-version=" + resourceVersion)).willReturn(aResponse().withStatus(404)));
+ }
+
+ public static void MockDeleteServiceInstance_500(WireMockServer wireMockServer, String customer,
+ String serviceSubscription, String serviceInstanceId, String resourceVersion) {
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/"
+ + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId
+ + "[?]resource-version=" + resourceVersion)).willReturn(aResponse().withStatus(500)));
+ }
+
+ public static void MockPutServiceInstance(WireMockServer wireMockServer, String globalCustId,
+ String subscriptionType, String serviceInstanceId, String responseFile) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
+ + "/service-subscriptions/service-subscription/" + subscriptionType
+ + "/service-instances/service-instance/" + serviceInstanceId)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockPutServiceInstance_500(WireMockServer wireMockServer, String globalCustId,
+ String subscriptionType, String serviceInstanceId) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
+ + "/service-subscriptions/service-subscription/" + subscriptionType
+ + "/service-instances/service-instance/" + serviceInstanceId)).willReturn(aResponse().withStatus(500)));
+ }
+
+ /**
+ * Service-Subscription Mock StubResponses below
+ */
+ public static void MockGetServiceSubscription(WireMockServer wireMockServer, String globalCustId,
+ String subscriptionType, String responseFile) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
+ + "/service-subscriptions/service-subscription/" + subscriptionType)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockDeleteServiceSubscription(WireMockServer wireMockServer, String globalCustId,
+ String subscriptionType, int statusCode) {
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
+ + "/service-subscriptions/service-subscription/" + subscriptionType))
+ .willReturn(aResponse().withStatus(statusCode)));
+ }
+
+ public static void MockDeleteServiceInstanceId(WireMockServer wireMockServer, String globalCustId,
+ String subscriptionType, String serviceInstanceId) {
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
+ + "/service-subscriptions/service-subscription/" + subscriptionType
+ + "/service-instances/service-instance/" + serviceInstanceId)).willReturn(aResponse().withStatus(200)));
+ }
+
+ public static void MockPutServiceSubscription(WireMockServer wireMockServer, String globalCustId,
+ String subscriptionType) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
+ + "/service-subscriptions/service-subscription/" + subscriptionType))
+ .willReturn(aResponse().withStatus(200)));
+ }
+
+ public static void MockGetServiceSubscription(WireMockServer wireMockServer, String globalCustId,
+ String subscriptionType, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId
+ + "/service-subscriptions/service-subscription/" + subscriptionType))
+ .willReturn(aResponse().withStatus(statusCode)));
+ }
+
+ /**
+ * Customer Mock StubResponses below
+ */
+ public static void MockGetCustomer(WireMockServer wireMockServer, String globalCustId, String responseFile) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockDeleteCustomer(WireMockServer wireMockServer, String globalCustId) {
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
+ .willReturn(aResponse().withStatus(200)));
+ }
+
+ public static void MockPutCustomer(WireMockServer wireMockServer, String globalCustId) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
+ .willReturn(aResponse().withStatus(200)));
+ }
+
+ public static void MockPutCustomer_500(WireMockServer wireMockServer, String globalCustId) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId))
+ .willReturn(aResponse().withStatus(500)));
+ }
+
+
+ /**
+ * Generic-Vnf Mock StubResponses below
+ */
+
+ public static void MockGetGenericVnfById(WireMockServer wireMockServer, String vnfId, String responseFile) {
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=1")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockGetGenericVnfById(WireMockServer wireMockServer, String vnfId, String responseFile,
+ int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId)).willReturn(
+ aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockGetGenericVnfByIdWithPriority(WireMockServer wireMockServer, String vnfId, int statusCode,
+ String responseFile) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId)).atPriority(1)
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetGenericVnfByIdWithPriority(WireMockServer wireMockServer, String vnfId, String vfModuleId,
+ int statusCode, String responseFile, int priority) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ .atPriority(priority).willReturn(aResponse().withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockGetGenericVnfByIdWithDepth(WireMockServer wireMockServer, String vnfId, int depth,
+ String responseFile) {
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=" + depth))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetGenericVnfById_404(WireMockServer wireMockServer, String vnfId) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
+ .willReturn(aResponse().withStatus(404)));
+ }
+
+ public static void MockGetGenericVnfById_500(WireMockServer wireMockServer, String vnfId) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v9/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=1"))
+ .withQueryParam("depth", equalTo("1")).willReturn(aResponse().withStatus(500)));
+ }
+
+ public static void MockGetGenericVnfByName(WireMockServer wireMockServer, String vnfName, String responseFile) {
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockGetGenericVnfByNameWithDepth(WireMockServer wireMockServer, String vnfName, int depth,
+ String responseFile) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName + "[&]depth=" + depth))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetGenericVnfByName_404(WireMockServer wireMockServer, String vnfName) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName))
+ .willReturn(aResponse().withStatus(404)));
+ }
+
+ public static void MockDeleteGenericVnf(WireMockServer wireMockServer, String vnfId, String resourceVersion) {
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse().withStatus(204)));
+ }
+
+ public static void MockDeleteGenericVnf(WireMockServer wireMockServer, String vnfId, String resourceVersion,
+ int statusCode) {
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse().withStatus(statusCode)));
+ }
+
+ public static void MockDeleteGenericVnf_500(WireMockServer wireMockServer, String vnfId, String resourceVersion) {
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse().withStatus(500)));
+ }
+
+ public static void MockPutGenericVnf(WireMockServer wireMockServer, String vnfId) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
+ .willReturn(aResponse().withStatus(200)));
+ }
+
+ public static void MockPutGenericVnf(WireMockServer wireMockServer, String vnfId, String requestBodyContaining,
+ int statusCode) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
+ .withRequestBody(containing(requestBodyContaining)).willReturn(aResponse().withStatus(statusCode)));
+ }
+
+ public static void MockPutGenericVnf(WireMockServer wireMockServer, String vnfId, int statusCode) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId))
+ .willReturn(aResponse().withStatus(statusCode)));
+ }
+
+ public static void MockPutGenericVnf_Bad(WireMockServer wireMockServer, String vnfId, int statusCode) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
+ .willReturn(aResponse().withStatus(statusCode)));
+ }
+
+ public static void MockPatchGenericVnf(WireMockServer wireMockServer, String vnfId) {
+ wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId))
+ .willReturn(aResponse().withStatus(200)));
+ }
+
+ /**
+ * Vce Mock StubResponses below
+ */
+ public static void MockGetVceById(WireMockServer wireMockServer, String vnfId, String responseFile) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockGetVceByName(WireMockServer wireMockServer, String vnfName, String responseFile) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockDeleteVce(WireMockServer wireMockServer, String vnfId, String resourceVersion,
+ int statusCode) {
+ wireMockServer.stubFor(
+ delete(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse().withStatus(statusCode)));
+ }
+
+ public static void MockPutVce(WireMockServer wireMockServer, String vnfId) {
+ wireMockServer.stubFor(
+ put(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId)).willReturn(aResponse().withStatus(200)));
+ }
+
+ public static void MockGetGenericVceByNameWithDepth(WireMockServer wireMockServer, String vnfName, int depth,
+ String responseFile) {
+ wireMockServer
+ .stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName + "[&]depth=" + depth))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetVceGenericQuery(WireMockServer wireMockServer, String serviceInstanceName, int depth,
+ int statusCode, String responseFile) {
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=service-instance.service-instance-name:"
+ + serviceInstanceName + "[&]start-node-type=service-instance[&]include=vce[&]depth=" + depth))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ /**
+ * Tenant Mock StubResponses below
+ */
+ public static void MockGetTenantGenericQuery(WireMockServer wireMockServer, String customer, String serviceType,
+ String responseFile) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=customer.global-customer-id:"
+ + customer + "&key=service-subscription.service-type:" + serviceType
+ + "&start-node-type=service-subscription&include=tenant&include=service-subscription&depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetTenant(WireMockServer wireMockServer, String tenantId, String responseFile) {
+ wireMockServer.stubFor(get(urlEqualTo("/aai/v2/cloud-infrastructure/tenants/tenant/" + tenantId)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ /**
+ * Network Mock StubResponses below
+ */
+ public static void MockGetNetwork(WireMockServer wireMockServer, String networkId, String responseFile,
+ int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId)).willReturn(
+ aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkByIdWithDepth(WireMockServer wireMockServer, String networkId, String responseFile,
+ String depth) {
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId + "[?]depth=" + depth))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkCloudRegion(WireMockServer wireMockServer, String responseFile,
+ String cloudRegion) {
+ wireMockServer.stubFor(get(
+ urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegion))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkByName(WireMockServer wireMockServer, String networkName, String responseFile) {
+ wireMockServer
+ .stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name=" + networkName))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkByName_404(WireMockServer wireMockServer, String responseFile,
+ String networkName) {
+ wireMockServer
+ .stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name=" + networkName))
+ .willReturn(aResponse().withStatus(404).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkCloudRegion_404(WireMockServer wireMockServer, String cloudRegion) {
+ wireMockServer.stubFor(get(
+ urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegion))
+ .willReturn(aResponse().withStatus(404)));
+ }
+
+ public static void MockPutNetwork(WireMockServer wireMockServer, String networkId, int statusCode,
+ String responseFile) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId)).willReturn(
+ aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockPutNetwork(WireMockServer wireMockServer, String networkPolicyId, String responseFile,
+ int statusCode) {
+ wireMockServer
+ .stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicyId))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
public static void MockPostNetwork(WireMockServer wireMockServer, String networkId) {
wireMockServer.stubFor(post(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId))
- .willReturn(aResponse()
- .withStatus(201)
- .withHeader("Content-Type", "text/xml")));
+ .willReturn(aResponse().withStatus(201).withHeader("Content-Type", "text/xml")));
}
public static void MockPostNetworkSubnet(WireMockServer wireMockServer, String networkId, String subnetId) {
- wireMockServer.stubFor(post(urlMatching(
- "/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId + "/subnets/subnet/" + subnetId))
- .willReturn(aResponse()
- .withStatus(201)
- .withHeader("Content-Type", "text/xml")));
+ wireMockServer.stubFor(post(
+ urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId + "/subnets/subnet/" + subnetId))
+ .willReturn(aResponse().withStatus(201).withHeader("Content-Type", "text/xml")));
}
- public static void MockGetNetworkName(WireMockServer wireMockServer, String networkPolicyName, String responseFile, int statusCode) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name=" + networkPolicyName))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
+ public static void MockGetNetworkName(WireMockServer wireMockServer, String networkPolicyName, String responseFile,
+ int statusCode) {
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name=" + networkPolicyName))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
public static void MockGetNetworkVpnBinding(WireMockServer wireMockServer, String responseFile, String vpnBinding) {
MockGetNetworkVpnBindingWithDepth(wireMockServer, responseFile, vpnBinding, "all");
}
public static void MockGetNetworkVpnBindingWithDepth(WireMockServer wireMockServer, String responseFile,
- String vpnBinding, String depth) {
+ String vpnBinding, String depth) {
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/" + vpnBinding + "[?]depth=" + depth))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkPolicy(WireMockServer wireMockServer, String responseFile, String policy) {
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + policy + "[?]depth=all"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkVpnBinding(WireMockServer wireMockServer, String networkBindingId,
+ String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/" + networkBindingId))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkPolicy(WireMockServer wireMockServer, String networkPolicy, String responseFile,
+ int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicy))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkTableReference(WireMockServer wireMockServer, String responseFile,
+ String tableReference) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/route-table-references/route-table-reference/" + tableReference + "[?]depth=all"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockPutNetworkIdWithDepth(WireMockServer wireMockServer, String responseFile, String networkId,
+ String depth) {
+ wireMockServer.stubFor(
+ put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId + "[?]depth=" + depth))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkPolicyfqdn(WireMockServer wireMockServer, String networkPolicy,
+ String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/network-policies/network-policy[?]network-policy-fqdn=" + networkPolicy))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetNetworkRouteTable(WireMockServer wireMockServer, String networkRouteId,
+ String responseFile, int statusCode) {
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/" + networkRouteId))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockPatchVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId) {
+ wireMockServer.stubFor(patch(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ .willReturn(aResponse().withStatus(200)));
+ }
+
+ /////////////
+
+ public static void MockVNFAdapterRestVfModule(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(put(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules/supercool"))
+ .willReturn(aResponse().withStatus(202).withHeader("Content-Type", "application/xml")));
+ wireMockServer.stubFor(post(urlMatching("/vnfs/v1/vnfs/.*/vf-modules"))
+ .willReturn(aResponse().withStatus(202).withHeader("Content-Type", "application/xml")));
+ wireMockServer.stubFor(post(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules"))
+ .willReturn(aResponse().withStatus(202).withHeader("Content-Type", "application/xml")));
+ wireMockServer.stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/78987"))
+ .willReturn(aResponse().withStatus(202).withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void MockDBUpdateVfModule(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter")).willReturn(aResponse().withStatus(200)
+ .withHeader("Content-Type", "text/xml").withBodyFile("VfModularity/DBUpdateResponse.xml")));
+ }
+
+ // start of mocks used locally and by other VF Module unit tests
+ public static void MockSDNCAdapterVfModule(WireMockServer wireMockServer) {
+ // simplified the implementation to return "success" for all requests
+ wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
+ // .withRequestBody(containing("SvcInstanceId><"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/StandardSDNCSynchResponse.xml")));
+
+ }
+
+ // start of mocks used locally and by other VF Module unit tests
+ public static void MockAAIVfModule(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))
+ .atPriority(1).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/VfModule-supercool.xml")));
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/lukewarm"))
+ .atPriority(2).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/VfModule-lukewarm.xml")));
+ wireMockServer
+ .stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
+ .atPriority(5).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/VfModule-new.xml")));
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask[?]depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/GenericVnf.xml")));
+ wireMockServer.stubFor(
+ patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))
+ // .withRequestBody(containing("PCRF"))
+ .willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(
+ patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
+ // .withRequestBody(containing("PCRF"))
+ .willReturn(aResponse().withStatus(200)));
+ // HTTP PUT stub still used by CreateAAIvfModuleVolumeGroup
+ wireMockServer
+ .stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
+ .withRequestBody(containing("PCRF")).willReturn(aResponse().withStatus(200)));
+ // HTTP PUT stub still used by DoCreateVfModuleTest
+ wireMockServer
+ .stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
+ .withRequestBody(containing("MODULELABEL")).willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml")));
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml")));
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/MDTWNJ21/volume-groups/volume-group/78987"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/VolumeGroup.xml")));
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/AAIAIC25/volume-groups/volume-group/78987"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/VolumeGroup.xml")));
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group/78987[?]resource-version=0000020"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("DeleteCinderVolumeV1/DeleteVolumeId_AAIResponse_Success.xml")));
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("VfModularity/AddNetworkPolicy_AAIResponse_Success.xml")));
+ wireMockServer.stubFor(patch(
+ urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/NEWvBNGModuleId"))
+ .withRequestBody(containing("NEWvBNGModuleId")).willReturn(aResponse().withStatus(200)));
+ }
+
+
+
+ //////////////
+
+ /**
+ * Cloud infrastructure below
+ */
+
+ public static void MockGetCloudRegion(WireMockServer wireMockServer, String cloudRegionId, int statusCode,
+ String responseFile) {
+ wireMockServer.stubFor(get(
+ urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ /**
+ * Volume Group StubResponse below
+ */
+ public static void MockGetVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId,
+ String responseFile) {
+ MockGetVolumeGroupById(wireMockServer, cloudRegionId, volumeGroupId, responseFile, 200);
+ }
+
+ public static void MockGetVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId,
+ String responseFile, int responseCode) {
+ wireMockServer
+ .stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"
+ + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
+ .willReturn(aResponse().withStatus(responseCode).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockPutVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId,
+ String responseFile, int statusCode) {
+ wireMockServer
+ .stubFor(put(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"
+ + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetVolumeGroupByName(WireMockServer wireMockServer, String cloudRegionId,
+ String volumeGroupName, String responseFile, int statusCode) {
+ wireMockServer
+ .stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"
+ + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockDeleteVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId,
+ String volumeGroupId, String resourceVersion, int statusCode) {
+ wireMockServer.stubFor(delete(
+ urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId
+ + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse().withStatus(statusCode)));
+ }
+
+ public static void MockGetVolumeGroupByName_404(WireMockServer wireMockServer, String cloudRegionId,
+ String volumeGroupName) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"
+ + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
+ .willReturn(aResponse().withStatus(404)));
+ }
+
+ public static void MockDeleteVolumeGroup(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId,
+ String resourceVersion) {
+ wireMockServer.stubFor(delete(
+ urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId
+ + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse().withStatus(200)));
+ }
+
+ /**
+ * VF-Module StubResponse below
+ *
+ * @param statusCode TODO
+ */
+ public static void MockGetVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId,
+ String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetVfModuleByNameWithDepth(WireMockServer wireMockServer, String vnfId, String vfModuleName,
+ int depth, String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId
+ + "/vf-modules/vf-module[?]vf-module-name=" + vfModuleName + "[?]depth=" + depth))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetVfModuleByName(WireMockServer wireMockServer, String vnfId, String vfModuleName,
+ String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId
+ + "/vf-modules/vf-module[?]vf-module-name=" + vfModuleName))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetVfModuleIdNoResponse(WireMockServer wireMockServer, String vnfId,
+ String requestContaining, String vfModuleId) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ .withRequestBody(containing(requestContaining))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")));
+ }
+
+ public static void MockPutVfModuleIdNoResponse(WireMockServer wireMockServer, String vnfId,
+ String requestContaining, String vfModuleId) {
+ wireMockServer.stubFor(put(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ .withRequestBody(containing(requestContaining)).willReturn(aResponse().withStatus(200)));
+ }
+
+ public static void MockPutVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId) {
+ wireMockServer.stubFor(put(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ .willReturn(aResponse().withStatus(200)));
+ }
+
+ public static void MockPutVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId,
+ int returnCode) {
+ wireMockServer.stubFor(put(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
+ .willReturn(aResponse().withStatus(returnCode)));
+ }
+
+ public static void MockDeleteVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId,
+ String resourceVersion, int returnCode) {
+ wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId
+ + "/vf-modules/vf-module/" + vfModuleId + "/[?]resource-version=" + resourceVersion))
+ .willReturn(aResponse().withStatus(returnCode)));
+ }
+
+ public static void MockAAIVfModuleBadPatch(WireMockServer wireMockServer, String endpoint, int statusCode) {
+ wireMockServer.stubFor(patch(urlMatching(endpoint)).willReturn(aResponse().withStatus(statusCode)));
+ }
+
+ /* AAI Pserver Queries */
+ public static void MockGetPserverByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile,
+ int statusCode) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v1[0-9]/query.*")).willReturn(aResponse().withStatus(statusCode)
+ .withHeader("Content-Type", "application/json").withBodyFile(responseFile)));
+ }
+
+ public static void MockGetGenericVnfsByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile,
+ int statusCode) {
+ wireMockServer.stubFor(
+ get(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*")).willReturn(aResponse().withStatus(statusCode)
+ .withHeader("Content-Type", "application/json; charset=utf-8").withBodyFile(responseFile)));
+ }
+
+ public static void MockSetInMaintFlagByVnfId(WireMockServer wireMockServer, String vnfId, int statusCode) {
+ wireMockServer.stubFor(patch(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
+ .willReturn(aResponse().withStatus(statusCode)));
+ }
+
+ public static void MockSetInMaintFlagByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile,
+ int statusCode) {
+ wireMockServer.stubFor(post(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
+ .willReturn(aResponse().withStatus(statusCode).withBodyFile(responseFile)));
+ }
+
+ public static void MockGetDefaultCloudRegionByCloudRegionId(WireMockServer wireMockServer, String cloudRegionId,
+ String responseFile, int statusCode) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v1[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + ".*"))
+ .willReturn(aResponse().withStatus(statusCode)
+ .withHeader("Content-Type", "application/json; charset=utf-8")
+ .withBodyFile(responseFile)));
+ }
+
+ //// Deprecated Stubs below - to be deleted once unit test that reference them are refactored to use common ones
+ //// above ////
+ @Deprecated
+ public static void MockGetVceById(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123?depth=1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericFlows/getVceResponse.xml")));
+ }
+
+ @Deprecated
+ public static void MockGetVceByName(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=testVnfName123"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericFlows/getVceByNameResponse.xml")));
+ }
+
+ @Deprecated
+ public static void MockPutVce(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(
+ put(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123")).willReturn(aResponse().withStatus(200)));
+ }
+
+ @Deprecated
+ public static void MockDeleteVce(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(
+ delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))
+ .willReturn(aResponse().withStatus(204)));
+ }
+
+ @Deprecated
+ public static void MockDeleteVce_404(WireMockServer wireMockServer) {
wireMockServer.stubFor(
- get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/" + vpnBinding + "[?]depth=" + depth))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetNetworkPolicy(WireMockServer wireMockServer, String responseFile, String policy) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/"+policy + "[?]depth=all"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetNetworkVpnBinding(WireMockServer wireMockServer, String networkBindingId, String responseFile, int statusCode) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/" + networkBindingId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetNetworkPolicy(WireMockServer wireMockServer, String networkPolicy, String responseFile, int statusCode) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicy))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetNetworkTableReference(WireMockServer wireMockServer, String responseFile, String tableReference) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/"+tableReference + "[?]depth=all"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockPutNetworkIdWithDepth(WireMockServer wireMockServer, String responseFile, String networkId, String depth) {
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/"+networkId+"[?]depth="+depth ))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetNetworkPolicyfqdn(WireMockServer wireMockServer, String networkPolicy, String responseFile, int statusCode) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy[?]network-policy-fqdn=" + networkPolicy))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetNetworkRouteTable(WireMockServer wireMockServer, String networkRouteId, String responseFile, int statusCode) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/" + networkRouteId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockPatchVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId) {
- wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
- /////////////
-
- public static void MockVNFAdapterRestVfModule(WireMockServer wireMockServer) {
- wireMockServer.stubFor(put(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules/supercool"))
- .willReturn(aResponse()
- .withStatus(202)
- .withHeader("Content-Type", "application/xml")));
- wireMockServer.stubFor(post(urlMatching("/vnfs/v1/vnfs/.*/vf-modules"))
- .willReturn(aResponse()
- .withStatus(202)
- .withHeader("Content-Type", "application/xml")));
- wireMockServer.stubFor(post(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules"))
- .willReturn(aResponse()
- .withStatus(202)
- .withHeader("Content-Type", "application/xml")));
- wireMockServer.stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/78987"))
- .willReturn(aResponse()
- .withStatus(202)
- .withHeader("Content-Type", "application/xml")));
- }
-
- public static void MockDBUpdateVfModule(WireMockServer wireMockServer){
- wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("VfModularity/DBUpdateResponse.xml")));
- }
-
- // start of mocks used locally and by other VF Module unit tests
- public static void MockSDNCAdapterVfModule(WireMockServer wireMockServer) {
- // simplified the implementation to return "success" for all requests
- wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
-// .withRequestBody(containing("SvcInstanceId><"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("VfModularity/StandardSDNCSynchResponse.xml")));
-
- }
-
- // start of mocks used locally and by other VF Module unit tests
- public static void MockAAIVfModule(WireMockServer wireMockServer) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))
- .atPriority(1)
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("VfModularity/VfModule-supercool.xml")));
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/lukewarm"))
- .atPriority(2)
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("VfModularity/VfModule-lukewarm.xml")));
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
- .atPriority(5)
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("VfModularity/VfModule-new.xml")));
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("VfModularity/GenericVnf.xml")));
- wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool"))
-// .withRequestBody(containing("PCRF"))
- .willReturn(aResponse()
- .withStatus(200)));
- wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
-// .withRequestBody(containing("PCRF"))
- .willReturn(aResponse()
- .withStatus(200)));
- // HTTP PUT stub still used by CreateAAIvfModuleVolumeGroup
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
- .withRequestBody(containing("PCRF"))
- .willReturn(aResponse()
- .withStatus(200)));
- // HTTP PUT stub still used by DoCreateVfModuleTest
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*"))
- .withRequestBody(containing("MODULELABEL"))
- .willReturn(aResponse()
- .withStatus(200)));
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml")));
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml")));
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/MDTWNJ21/volume-groups/volume-group/78987"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("VfModularity/VolumeGroup.xml")));
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/AAIAIC25/volume-groups/volume-group/78987"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("VfModularity/VolumeGroup.xml")));
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group/78987[?]resource-version=0000020"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("DeleteCinderVolumeV1/DeleteVolumeId_AAIResponse_Success.xml")));
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("VfModularity/AddNetworkPolicy_AAIResponse_Success.xml")));
- wireMockServer.stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/NEWvBNGModuleId"))
- .withRequestBody(containing("NEWvBNGModuleId"))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
-
-
- //////////////
-
- /**
- * Cloud infrastructure below
- */
-
- public static void MockGetCloudRegion(WireMockServer wireMockServer, String cloudRegionId, int statusCode, String responseFile) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- /**
- * Volume Group StubResponse below
- */
- public static void MockGetVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String responseFile) {
- MockGetVolumeGroupById(wireMockServer, cloudRegionId, volumeGroupId, responseFile, 200);
- }
-
- public static void MockGetVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String responseFile, int responseCode) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
- .willReturn(aResponse()
- .withStatus(responseCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockPutVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String responseFile, int statusCode) {
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetVolumeGroupByName(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupName, String responseFile, int statusCode) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockDeleteVolumeGroupById(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String resourceVersion, int statusCode) {
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
- .willReturn(aResponse()
- .withStatus(statusCode)));
- }
-
- public static void MockGetVolumeGroupByName_404(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupName) {
- wireMockServer.stubFor(get(urlMatching("/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName))
- .willReturn(aResponse()
- .withStatus(404)));
- }
-
- public static void MockDeleteVolumeGroup(WireMockServer wireMockServer, String cloudRegionId, String volumeGroupId, String resourceVersion) {
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
- /**
- * VF-Module StubResponse below
- * @param statusCode TODO
- */
- public static void MockGetVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId, String responseFile, int statusCode) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetVfModuleByNameWithDepth(WireMockServer wireMockServer, String vnfId, String vfModuleName, int depth, String responseFile, int statusCode) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module[?]vf-module-name=" + vfModuleName + "[?]depth=" + depth))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetVfModuleByName(WireMockServer wireMockServer, String vnfId, String vfModuleName, String responseFile, int statusCode) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module[?]vf-module-name=" + vfModuleName))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetVfModuleIdNoResponse(WireMockServer wireMockServer, String vnfId, String requestContaining, String vfModuleId) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
- .withRequestBody(containing(requestContaining))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")));
- }
-
- public static void MockPutVfModuleIdNoResponse(WireMockServer wireMockServer, String vnfId, String requestContaining, String vfModuleId) {
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId +"/vf-modules/vf-module/" +vfModuleId))
- .withRequestBody(containing(requestContaining))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
- public static void MockPutVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId) {
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
- public static void MockPutVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId, int returnCode) {
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId))
- .willReturn(aResponse()
- .withStatus(returnCode)));
- }
-
- public static void MockDeleteVfModuleId(WireMockServer wireMockServer, String vnfId, String vfModuleId, String resourceVersion, int returnCode) {
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId + "/[?]resource-version=" + resourceVersion))
- .willReturn(aResponse()
- .withStatus(returnCode)));
- }
-
- public static void MockAAIVfModuleBadPatch(WireMockServer wireMockServer, String endpoint, int statusCode) {
- wireMockServer.stubFor(patch(urlMatching(endpoint))
- .willReturn(aResponse()
- .withStatus(statusCode)));
- }
-
- /* AAI Pserver Queries */
- public static void MockGetPserverByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile, int statusCode) {
- wireMockServer.stubFor(put(urlMatching("/aai/v1[0-9]/query.*"))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/json")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetGenericVnfsByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile, int statusCode) {
- wireMockServer.stubFor(get(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/json; charset=utf-8")
- .withBodyFile(responseFile)));
- }
-
- public static void MockSetInMaintFlagByVnfId(WireMockServer wireMockServer, String vnfId, int statusCode) {
- wireMockServer.stubFor(patch(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
- .willReturn(aResponse()
- .withStatus(statusCode)
- ));
- }
-
- public static void MockSetInMaintFlagByVnfId(WireMockServer wireMockServer, String vnfId, String responseFile, int statusCode) {
- wireMockServer.stubFor(post(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*"))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withBodyFile(responseFile)
- ));
- }
-
- public static void MockGetDefaultCloudRegionByCloudRegionId(WireMockServer wireMockServer, String cloudRegionId, String responseFile, int statusCode) {
- wireMockServer.stubFor(get(urlMatching("/aai/v1[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/"+cloudRegionId + ".*"))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/json; charset=utf-8")
- .withBodyFile(responseFile)));
- }
-
- //// Deprecated Stubs below - to be deleted once unit test that reference them are refactored to use common ones above ////
- @Deprecated
- public static void MockGetVceById(WireMockServer wireMockServer){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123?depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("GenericFlows/getVceResponse.xml")));
- }
- @Deprecated
- public static void MockGetVceByName(WireMockServer wireMockServer){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=testVnfName123"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("GenericFlows/getVceByNameResponse.xml")));
- }
- @Deprecated
- public static void MockPutVce(WireMockServer wireMockServer){
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123"))
- .willReturn(aResponse()
- .withStatus(200)));
- }
- @Deprecated
- public static void MockDeleteVce(WireMockServer wireMockServer){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))
- .willReturn(aResponse()
- .withStatus(204)));
- }
- @Deprecated
- public static void MockDeleteVce_404(WireMockServer wireMockServer){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))
- .willReturn(aResponse()
- .withStatus(404)));
- }
-
- @Deprecated
- public static void MockDeleteServiceSubscription(WireMockServer wireMockServer){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))
- .willReturn(aResponse()
- .withStatus(204)));
- }
- @Deprecated
- public static void MockGetServiceSubscription(WireMockServer wireMockServer){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("GenericFlows/getServiceSubscription.xml")));
- }
- @Deprecated
- public static void MockGetServiceSubscription_200Empty(WireMockServer wireMockServer){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(" ")));
- }
- @Deprecated
- public static void MockGetServiceSubscription_404(WireMockServer wireMockServer) {
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))
- .willReturn(aResponse()
- .withStatus(404)));
- }
-
- @Deprecated
- public static void MockGetGenericVnfById(WireMockServer wireMockServer){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("GenericFlows/getGenericVnfByNameResponse.xml")));
- }
- @Deprecated
- public static void MockGetGenericVnfById_404(WireMockServer wireMockServer){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
- .willReturn(aResponse()
- .withStatus(404)));
- }
- @Deprecated
- public static void MockGetGenericVnfByName(WireMockServer wireMockServer){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("GenericFlows/getGenericVnfResponse.xml")));
- }
- @Deprecated
- public static void MockGetGenericVnfByName_hasRelationships(WireMockServer wireMockServer){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml")));
- }
- @Deprecated
- public static void MockGetGenericVnfById_hasRelationships(WireMockServer wireMockServer){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml")));
- }
- @Deprecated
- public static void MockGetGenericVnfById_500(WireMockServer wireMockServer){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
- .willReturn(aResponse()
- .withStatus(500)));
- }
- @Deprecated
- public static void MockGetGenericVnfByName_404(WireMockServer wireMockServer){
- wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
- .willReturn(aResponse()
- .withStatus(404)));
- }
- @Deprecated
- public static void MockPutGenericVnf(WireMockServer wireMockServer){
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
- .willReturn(aResponse()
- .withStatus(200)));
- }
- @Deprecated
- public static void MockPutGenericVnf_400(WireMockServer wireMockServer){
- wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
- .willReturn(aResponse()
- .withStatus(400)));
- }
- @Deprecated
- public static void MockDeleteGenericVnf(WireMockServer wireMockServer){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
- .willReturn(aResponse()
- .withStatus(204)));
- }
- @Deprecated
- public static void MockDeleteGenericVnf_404(WireMockServer wireMockServer){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
- .willReturn(aResponse()
- .withStatus(404)));
- }
- @Deprecated
- public static void MockDeleteGenericVnf_500(WireMockServer wireMockServer){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
- .willReturn(aResponse()
- .withStatus(500)));
- }
- @Deprecated
- public static void MockDeleteGenericVnf_412(WireMockServer wireMockServer){
- wireMockServer.stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[[?]]resource-version=testReVer123"))
- .willReturn(aResponse()
- .withStatus(412)));
- }
+ delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123"))
+ .willReturn(aResponse().withStatus(404)));
+ }
+
+ @Deprecated
+ public static void MockDeleteServiceSubscription(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))
+ .willReturn(aResponse().withStatus(204)));
+ }
+
+ @Deprecated
+ public static void MockGetServiceSubscription(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericFlows/getServiceSubscription.xml")));
+ }
+
+ @Deprecated
+ public static void MockGetServiceSubscription_200Empty(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBody(" ")));
+ }
+
+ @Deprecated
+ public static void MockGetServiceSubscription_404(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlMatching(
+ "/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET"))
+ .willReturn(aResponse().withStatus(404)));
+ }
+
+ @Deprecated
+ public static void MockGetGenericVnfById(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericFlows/getGenericVnfByNameResponse.xml")));
+ }
+
+ @Deprecated
+ public static void MockGetGenericVnfById_404(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ .willReturn(aResponse().withStatus(404)));
+ }
+
+ @Deprecated
+ public static void MockGetGenericVnfByName(WireMockServer wireMockServer) {
+ wireMockServer
+ .stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericFlows/getGenericVnfResponse.xml")));
+ }
+
+ @Deprecated
+ public static void MockGetGenericVnfByName_hasRelationships(WireMockServer wireMockServer) {
+ wireMockServer
+ .stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml")));
+ }
+
+ @Deprecated
+ public static void MockGetGenericVnfById_hasRelationships(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml")));
+ }
+
+ @Deprecated
+ public static void MockGetGenericVnfById_500(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ .willReturn(aResponse().withStatus(500)));
+ }
+
+ @Deprecated
+ public static void MockGetGenericVnfByName_404(WireMockServer wireMockServer) {
+ wireMockServer
+ .stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123"))
+ .willReturn(aResponse().withStatus(404)));
+ }
+
+ @Deprecated
+ public static void MockPutGenericVnf(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ .willReturn(aResponse().withStatus(200)));
+ }
+
+ @Deprecated
+ public static void MockPutGenericVnf_400(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123"))
+ .willReturn(aResponse().withStatus(400)));
+ }
+
+ @Deprecated
+ public static void MockDeleteGenericVnf(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
+ .willReturn(aResponse().withStatus(204)));
+ }
+
+ @Deprecated
+ public static void MockDeleteGenericVnf_404(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
+ .willReturn(aResponse().withStatus(404)));
+ }
+
+ @Deprecated
+ public static void MockDeleteGenericVnf_500(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123"))
+ .willReturn(aResponse().withStatus(500)));
+ }
+
+ @Deprecated
+ public static void MockDeleteGenericVnf_412(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(delete(urlMatching(
+ "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[[?]]resource-version=testReVer123"))
+ .willReturn(aResponse().withStatus(412)));
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAPPC.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAPPC.java
index 2f2cf45814..53c08a3d6c 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAPPC.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseAPPC.java
@@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ */
package org.onap.so.bpmn.mock;
@@ -24,7 +24,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-
import com.github.tomakehurst.wiremock.WireMockServer;
/**
@@ -33,29 +32,25 @@ import com.github.tomakehurst.wiremock.WireMockServer;
*/
public class StubResponseAPPC {
- public static void setupAllMocks() {
-
- }
-
- // start of Policy mocks
- public static void MockAppcError(WireMockServer wireMockServer) {
- wireMockServer.stubFor(get(urlMatching("/events/.*"))
- // .withRequestBody(containing("APPC"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile("APPC/appc_error.json")));
- wireMockServer.stubFor(put(urlMatching("/events/.*"))
- // .withRequestBody(containing("APPC"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile("APPC/appc_error.json")));
-
-
-
- }
-
-
-
+ public static void setupAllMocks() {
+
+ }
+
+ // start of Policy mocks
+ public static void MockAppcError(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(get(urlMatching("/events/.*"))
+ // .withRequestBody(containing("APPC"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
+ .withBodyFile("APPC/appc_error.json")));
+ wireMockServer.stubFor(put(urlMatching("/events/.*"))
+ // .withRequestBody(containing("APPC"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
+ .withBodyFile("APPC/appc_error.json")));
+
+
+
+ }
+
+
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseDatabase.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseDatabase.java
index 8fd745d765..241b549101 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseDatabase.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseDatabase.java
@@ -24,96 +24,79 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-
import com.github.tomakehurst.wiremock.WireMockServer;
/**
- * Stub response class for Database stubs
- * including database adapter, catalog db,
- * and other databases.
+ * Stub response class for Database stubs including database adapter, catalog db, and other databases.
*/
public class StubResponseDatabase {
- public static void setupAllMocks() {
+ public static void setupAllMocks() {
+
+ }
+
+ public static void MockUpdateRequestDB(WireMockServer wireMockServer, String fileName) {
+ wireMockServer.stubFor(post(urlEqualTo("/services/RequestsDbAdapter"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(fileName)));
+ }
+
+ public static void mockUpdateRequestDB(WireMockServer wireMockServer, int statusCode, String reponseFile) {
+ wireMockServer.stubFor(post(urlEqualTo("/services/RequestsDbAdapter")).willReturn(
+ aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml").withBodyFile(reponseFile)));
+ }
+
+ public static void MockGetAllottedResourcesByModelInvariantId(WireMockServer wireMockServer,
+ String modelInvariantId, String responseFile) {
+ wireMockServer
+ .stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
+ .withBodyFile(responseFile)));
+ }
+
+ public static void MockGetAllottedResourcesByModelInvariantId_500(WireMockServer wireMockServer,
+ String modelInvariantId, String responseFile) {
+ wireMockServer
+ .stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
+ .willReturn(aResponse().withStatus(500)));
+ }
+
+ public static void MockGetVnfCatalogDataCustomizationUuid(WireMockServer wireMockServer,
+ String vnfModelCustomizationUuid, String responseFile) {
+ wireMockServer.stubFor(get(urlEqualTo("/v2/serviceVnfs?vnfModelCustomizationUuid=" + vnfModelCustomizationUuid))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
+ .withBodyFile(responseFile)));
+ }
- }
+ public static void MockGetVfModuleByModelNameCatalogData(WireMockServer wireMockServer, String vfModuleModelName,
+ String responseFile) {
+ wireMockServer.stubFor(get(urlEqualTo("/v2/vfModules?vfModuleModelName=" + vfModuleModelName)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBodyFile(responseFile)));
+ }
- public static void MockUpdateRequestDB(WireMockServer wireMockServer, String fileName){
- wireMockServer.stubFor(post(urlEqualTo("/services/RequestsDbAdapter"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(fileName)));
- }
-
- public static void mockUpdateRequestDB(WireMockServer wireMockServer, int statusCode, String reponseFile) {
- wireMockServer.stubFor(post(urlEqualTo("/services/RequestsDbAdapter"))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(reponseFile)));
- }
+ public static void MockGetServiceResourcesCatalogData(WireMockServer wireMockServer,
+ String serviceModelInvariantUuid, String serviceModelVersion, String responseFile) {
+ wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelInvariantUuid="
+ + serviceModelInvariantUuid + "&serviceModelVersion=" + serviceModelVersion))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
+ .withBodyFile(responseFile)));
+ }
- public static void MockGetAllottedResourcesByModelInvariantId(WireMockServer wireMockServer, String modelInvariantId, String responseFile){
- wireMockServer.stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile(responseFile)));
- }
+ public static void MockGetServiceResourcesCatalogData(WireMockServer wireMockServer,
+ String serviceModelInvariantUuid, String responseFile) {
+ wireMockServer.stubFor(get(urlEqualTo(
+ "/ecomp/mso/catalog/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
+ .withBodyFile(responseFile)));
+ }
- public static void MockGetAllottedResourcesByModelInvariantId_500(WireMockServer wireMockServer, String modelInvariantId, String responseFile){
- wireMockServer.stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId))
- .willReturn(aResponse()
- .withStatus(500)));
- }
-
- public static void MockGetVnfCatalogDataCustomizationUuid(WireMockServer wireMockServer, String vnfModelCustomizationUuid, String responseFile){
- wireMockServer.stubFor(get(urlEqualTo("/v2/serviceVnfs?vnfModelCustomizationUuid=" + vnfModelCustomizationUuid))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile(responseFile)));
- }
+ public static void MockGetServiceResourcesCatalogDataByModelUuid(WireMockServer wireMockServer,
+ String serviceModelUuid, String responseFile) {
+ wireMockServer.stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=" + serviceModelUuid)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBodyFile(responseFile)));
+ }
- public static void MockGetVfModuleByModelNameCatalogData(WireMockServer wireMockServer, String vfModuleModelName, String responseFile){
- wireMockServer.stubFor(get(urlEqualTo("/v2/vfModules?vfModuleModelName=" + vfModuleModelName))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetServiceResourcesCatalogData(WireMockServer wireMockServer, String serviceModelInvariantUuid, String serviceModelVersion, String responseFile){
- wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelInvariantUuid=" +
- serviceModelInvariantUuid +
- "&serviceModelVersion=" + serviceModelVersion))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetServiceResourcesCatalogData(WireMockServer wireMockServer, String serviceModelInvariantUuid, String responseFile){
- wireMockServer.stubFor(get(urlEqualTo("/ecomp/mso/catalog/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile(responseFile)));
- }
-
- public static void MockGetServiceResourcesCatalogDataByModelUuid(WireMockServer wireMockServer, String serviceModelUuid, String responseFile){
- wireMockServer.stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=" + serviceModelUuid))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile(responseFile)));
- }
-
- public static void MockPostRequestDB(WireMockServer wireMockServer){
- wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")));
- }
+ public static void MockPostRequestDB(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml")));
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseNetworkAdapter.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseNetworkAdapter.java
index 3e1567412a..19c1a76f52 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseNetworkAdapter.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseNetworkAdapter.java
@@ -26,7 +26,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-
import com.github.tomakehurst.wiremock.WireMockServer;
/**
@@ -35,82 +34,62 @@ import com.github.tomakehurst.wiremock.WireMockServer;
*/
public class StubResponseNetworkAdapter {
- private static final String EOL = "\n";
-
- public static void setupAllMocks() {
-
- }
-
-
- public static void MockNetworkAdapter(WireMockServer wireMockServer) {
- wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
- public static void MockNetworkAdapter(WireMockServer wireMockServer, String response) {
- wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(response)));
- }
-
- public static void MockNetworkAdapter_500(WireMockServer wireMockServer) {
- wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
- .willReturn(aResponse()
- .withStatus(500)));
- }
-
- public static void MockNetworkAdapterPost(WireMockServer wireMockServer, String responseFile, String requestContaining) {
- wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
- .withRequestBody(containing(requestContaining))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockNetworkAdapter(WireMockServer wireMockServer, String networkId, int statusCode, String responseFile) {
- wireMockServer.stubFor(delete(urlEqualTo("/networks/NetworkAdapter/" + networkId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockNetworkAdapterContainingRequest(WireMockServer wireMockServer, String requestContaining, int statusCode, String responseFile) {
- wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
- .withRequestBody(containing(requestContaining))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockPutNetworkAdapter(WireMockServer wireMockServer, String networkId, String requestContaining, int statusCode, String responseFile) {
- wireMockServer.stubFor(put(urlEqualTo("/networks/NetworkAdapter/" + networkId))
- .withRequestBody(containing(requestContaining))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockNetworkAdapterRestRollbackDelete(WireMockServer wireMockServer, String responseFile, String networkId) {
- wireMockServer.stubFor(delete(urlEqualTo("/networks/NetworkAdapter/"+networkId+"/rollback"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void MockNetworkAdapterRestPut(WireMockServer wireMockServer, String responseFile, String networkId) {
- wireMockServer.stubFor(put(urlEqualTo("/networks/NetworkAdapter/"+networkId))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
+ private static final String EOL = "\n";
+
+ public static void setupAllMocks() {
+
+ }
+
+
+ public static void MockNetworkAdapter(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter")).willReturn(aResponse().withStatus(200)));
+ }
+
+ public static void MockNetworkAdapter(WireMockServer wireMockServer, String response) {
+ wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(response)));
+ }
+
+ public static void MockNetworkAdapter_500(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter")).willReturn(aResponse().withStatus(500)));
+ }
+
+ public static void MockNetworkAdapterPost(WireMockServer wireMockServer, String responseFile,
+ String requestContaining) {
+ wireMockServer.stubFor(
+ post(urlEqualTo("/networks/NetworkAdapter")).withRequestBody(containing(requestContaining)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockNetworkAdapter(WireMockServer wireMockServer, String networkId, int statusCode,
+ String responseFile) {
+ wireMockServer.stubFor(delete(urlEqualTo("/networks/NetworkAdapter/" + networkId)).willReturn(aResponse()
+ .withStatus(statusCode).withHeader("Content-Type", "application/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockNetworkAdapterContainingRequest(WireMockServer wireMockServer, String requestContaining,
+ int statusCode, String responseFile) {
+ wireMockServer.stubFor(post(urlEqualTo("/networks/NetworkAdapter"))
+ .withRequestBody(containing(requestContaining)).willReturn(aResponse().withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockPutNetworkAdapter(WireMockServer wireMockServer, String networkId, String requestContaining,
+ int statusCode, String responseFile) {
+ wireMockServer.stubFor(put(urlEqualTo("/networks/NetworkAdapter/" + networkId))
+ .withRequestBody(containing(requestContaining)).willReturn(aResponse().withStatus(statusCode)
+ .withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockNetworkAdapterRestRollbackDelete(WireMockServer wireMockServer, String responseFile,
+ String networkId) {
+ wireMockServer.stubFor(delete(urlEqualTo("/networks/NetworkAdapter/" + networkId + "/rollback")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void MockNetworkAdapterRestPut(WireMockServer wireMockServer, String responseFile, String networkId) {
+ wireMockServer.stubFor(put(urlEqualTo("/networks/NetworkAdapter/" + networkId)).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseOof.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseOof.java
index fe6c6a1396..aab2d38b35 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseOof.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseOof.java
@@ -23,7 +23,6 @@ package org.onap.so.bpmn.mock;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-
import com.github.tomakehurst.wiremock.WireMockServer;
/**
@@ -37,31 +36,22 @@ public class StubResponseOof {
public static void mockOof(WireMockServer wireMockServer) {
wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
- .willReturn(aResponse()
- .withStatus(202)
- .withHeader("Content-Type", "application/json")));
+ .willReturn(aResponse().withStatus(202).withHeader("Content-Type", "application/json")));
}
public static void mockOof(WireMockServer wireMockServer, String responseFile) {
- wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
- .willReturn(aResponse()
- .withStatus(202)
- .withHeader("Content-Type", "application/json")
- .withBodyFile(responseFile)));
+ wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement")).willReturn(
+ aResponse().withStatus(202).withHeader("Content-Type", "application/json").withBodyFile(responseFile)));
}
public static void mockOof_400(WireMockServer wireMockServer) {
wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
- .willReturn(aResponse()
- .withStatus(400)
- .withHeader("Content-Type", "application/json")));
+ .willReturn(aResponse().withStatus(400).withHeader("Content-Type", "application/json")));
}
public static void mockOof_500(WireMockServer wireMockServer) {
wireMockServer.stubFor(post(urlEqualTo("/api/oof/v1/placement"))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "application/json")));
+ .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "application/json")));
}
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponsePolicy.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponsePolicy.java
index a6c7fa57f0..bf3df503f3 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponsePolicy.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponsePolicy.java
@@ -24,7 +24,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.containing;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-
import com.github.tomakehurst.wiremock.WireMockServer;
/**
@@ -33,89 +32,59 @@ import com.github.tomakehurst.wiremock.WireMockServer;
*/
public class StubResponsePolicy {
- public static void setupAllMocks() {
-
- }
-
- // start of Policy mocks
- public static void MockPolicyAbort(WireMockServer wireMockServer) {
- wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
- .withRequestBody(containing("BB1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile("policyAbortResponse.json")));
-
- wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
- .withRequestBody(containing("UPDVnfI"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile("policyAbortResponse.json")));
-
- wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
- .withRequestBody(containing("RPLVnfI"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile("policyAbortResponse.json")));
-
- wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
- .withRequestBody(containing("VnfIPU"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile("policyAbortResponse.json")));
-
- wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
- .withRequestBody(containing("VnfCU"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile("policyAbortResponse.json")));
-
-
-
- }
-
- public static void MockPolicySkip(WireMockServer wireMockServer) {
- wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
- .withRequestBody(containing("BB1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile("Policy/policySkipResponse.json")));
-
- wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
- .withRequestBody(containing("UPDVnfI"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile("Policy/policySkipResponse.json")));
-
- wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
- .withRequestBody(containing("RPLVnfI"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile("Policy/policySkipResponse.json")));
-
- wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
- .withRequestBody(containing("VnfIPU"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile("Policy/policySkipResponse.json")));
-
- wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision"))
- .withRequestBody(containing("VnfCU"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")
- .withBodyFile("Policy/policySkipResponse.json")));
-
-
- }
-
-
+ public static void setupAllMocks() {
+
+ }
+
+ // start of Policy mocks
+ public static void MockPolicyAbort(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision")).withRequestBody(containing("BB1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
+ .withBodyFile("policyAbortResponse.json")));
+
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision")).withRequestBody(containing("UPDVnfI"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
+ .withBodyFile("policyAbortResponse.json")));
+
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision")).withRequestBody(containing("RPLVnfI"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
+ .withBodyFile("policyAbortResponse.json")));
+
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision")).withRequestBody(containing("VnfIPU"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
+ .withBodyFile("policyAbortResponse.json")));
+
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision")).withRequestBody(containing("VnfCU"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
+ .withBodyFile("policyAbortResponse.json")));
+
+
+
+ }
+
+ public static void MockPolicySkip(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision")).withRequestBody(containing("BB1"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
+ .withBodyFile("Policy/policySkipResponse.json")));
+
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision")).withRequestBody(containing("UPDVnfI"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
+ .withBodyFile("Policy/policySkipResponse.json")));
+
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision")).withRequestBody(containing("RPLVnfI"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
+ .withBodyFile("Policy/policySkipResponse.json")));
+
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision")).withRequestBody(containing("VnfIPU"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
+ .withBodyFile("Policy/policySkipResponse.json")));
+
+ wireMockServer.stubFor(post(urlEqualTo("/pdp/api/getDecision")).withRequestBody(containing("VnfCU"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")
+ .withBodyFile("Policy/policySkipResponse.json")));
+
+
+ }
+
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSDNCAdapter.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSDNCAdapter.java
index 10557ce091..9196e6a58c 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSDNCAdapter.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSDNCAdapter.java
@@ -25,7 +25,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.containing;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-
import com.github.tomakehurst.wiremock.WireMockServer;
/**
@@ -33,82 +32,60 @@ import com.github.tomakehurst.wiremock.WireMockServer;
*/
public class StubResponseSDNCAdapter {
- public static void setupAllMocks() {
-
- }
-
- public static void mockSDNCAdapter_500(WireMockServer wireMockServer) {
- wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
- .willReturn(aResponse()
- .withStatus(500)));
- }
-
- public static void mockSDNCAdapter_500(WireMockServer wireMockServer, String requestContaining) {
- wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
- .withRequestBody(containing(requestContaining))
- .willReturn(aResponse()
- .withStatus(500)));
- }
-
- public static void mockSDNCAdapter(WireMockServer wireMockServer, int statusCode) {
- wireMockServer.stubFor(post(urlMatching(".*/SDNCAdapter"))
- .willReturn(aResponse()
- .withStatus(statusCode)));
- }
-
- public static void mockSDNCAdapter(WireMockServer wireMockServer, String endpoint, int statusCode, String responseFile) {
- wireMockServer.stubFor(post(urlEqualTo(endpoint))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void mockSDNCAdapter(WireMockServer wireMockServer, String responseFile) {
- wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void mockSDNCAdapter(WireMockServer wireMockServer, String endpoint, String requestContaining, int statusCode, String responseFile) {
- wireMockServer.stubFor(post(urlEqualTo(endpoint))
- .withRequestBody(containing(requestContaining))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void mockSDNCAdapterRest(WireMockServer wireMockServer) {
- wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
- .willReturn(aResponse()
- .withStatus(202)
- .withHeader("Content-Type", "application/json")));
- }
-
- public static void mockSDNCAdapterRest_500(WireMockServer wireMockServer) {
- wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "application/json")));
- }
-
- public static void mockSDNCAdapterRest(WireMockServer wireMockServer, String requestContaining) {
- wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
- .withRequestBody(containing(requestContaining))
- .willReturn(aResponse()
- .withStatus(202)
- .withHeader("Content-Type", "application/json")));
- }
-
- public static void mockSDNCAdapterRest_500(WireMockServer wireMockServer, String requestContaining) {
- wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
- .withRequestBody(containing(requestContaining))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "application/json")));
- }
+ public static void setupAllMocks() {
+
+ }
+
+ public static void mockSDNCAdapter_500(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter")).willReturn(aResponse().withStatus(500)));
+ }
+
+ public static void mockSDNCAdapter_500(WireMockServer wireMockServer, String requestContaining) {
+ wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter")).withRequestBody(containing(requestContaining))
+ .willReturn(aResponse().withStatus(500)));
+ }
+
+ public static void mockSDNCAdapter(WireMockServer wireMockServer, int statusCode) {
+ wireMockServer.stubFor(post(urlMatching(".*/SDNCAdapter")).willReturn(aResponse().withStatus(statusCode)));
+ }
+
+ public static void mockSDNCAdapter(WireMockServer wireMockServer, String endpoint, int statusCode,
+ String responseFile) {
+ wireMockServer.stubFor(post(urlEqualTo(endpoint)).willReturn(
+ aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void mockSDNCAdapter(WireMockServer wireMockServer, String responseFile) {
+ wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void mockSDNCAdapter(WireMockServer wireMockServer, String endpoint, String requestContaining,
+ int statusCode, String responseFile) {
+ wireMockServer.stubFor(post(urlEqualTo(endpoint)).withRequestBody(containing(requestContaining)).willReturn(
+ aResponse().withStatus(statusCode).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void mockSDNCAdapterRest(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
+ .willReturn(aResponse().withStatus(202).withHeader("Content-Type", "application/json")));
+ }
+
+ public static void mockSDNCAdapterRest_500(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
+ .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "application/json")));
+ }
+
+ public static void mockSDNCAdapterRest(WireMockServer wireMockServer, String requestContaining) {
+ wireMockServer.stubFor(
+ post(urlEqualTo("/SDNCAdapter/v1/sdnc/services")).withRequestBody(containing(requestContaining))
+ .willReturn(aResponse().withStatus(202).withHeader("Content-Type", "application/json")));
+ }
+
+ public static void mockSDNCAdapterRest_500(WireMockServer wireMockServer, String requestContaining) {
+ wireMockServer.stubFor(
+ post(urlEqualTo("/SDNCAdapter/v1/sdnc/services")).withRequestBody(containing(requestContaining))
+ .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "application/json")));
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSNIRO.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSNIRO.java
index f040a0973c..e0ebf7d356 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSNIRO.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseSNIRO.java
@@ -23,7 +23,6 @@ package org.onap.so.bpmn.mock;
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-
import com.github.tomakehurst.wiremock.WireMockServer;
/**
@@ -32,37 +31,28 @@ import com.github.tomakehurst.wiremock.WireMockServer;
*/
public class StubResponseSNIRO {
- public static void setupAllMocks() {
+ public static void setupAllMocks() {
- }
+ }
- public static void mockSNIRO(WireMockServer wireMockServer) {
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
- .willReturn(aResponse()
- .withStatus(202)
- .withHeader("Content-Type", "application/json")));
- }
+ public static void mockSNIRO(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
+ .willReturn(aResponse().withStatus(202).withHeader("Content-Type", "application/json")));
+ }
- public static void mockSNIRO(WireMockServer wireMockServer, String responseFile) {
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
- .willReturn(aResponse()
- .withStatus(202)
- .withHeader("Content-Type", "application/json")
- .withBodyFile(responseFile)));
- }
+ public static void mockSNIRO(WireMockServer wireMockServer, String responseFile) {
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/v2/placement")).willReturn(
+ aResponse().withStatus(202).withHeader("Content-Type", "application/json").withBodyFile(responseFile)));
+ }
- public static void mockSNIRO_400(WireMockServer wireMockServer) {
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
- .willReturn(aResponse()
- .withStatus(400)
- .withHeader("Content-Type", "application/json")));
- }
+ public static void mockSNIRO_400(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
+ .willReturn(aResponse().withStatus(400).withHeader("Content-Type", "application/json")));
+ }
- public static void mockSNIRO_500(WireMockServer wireMockServer) {
- wireMockServer.stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "application/json")));
- }
+ public static void mockSNIRO_500(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/sniro/api/v2/placement"))
+ .willReturn(aResponse().withStatus(500).withHeader("Content-Type", "application/json")));
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseVNFAdapter.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseVNFAdapter.java
index e90d358ba8..2501a8acd3 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseVNFAdapter.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/mock/StubResponseVNFAdapter.java
@@ -26,7 +26,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.post;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-
import com.github.tomakehurst.wiremock.WireMockServer;
/**
@@ -34,150 +33,101 @@ import com.github.tomakehurst.wiremock.WireMockServer;
*/
public class StubResponseVNFAdapter {
- public static void mockVNFAdapter(WireMockServer wireMockServer) {
- wireMockServer.stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
- public static void mockVNFAdapter(WireMockServer wireMockServer, String responseFile) {
- wireMockServer.stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile(responseFile)));
- }
-
- public static void mockVNFAdapter_500(WireMockServer wireMockServer) {
- wireMockServer.stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync"))
- .willReturn(aResponse()
- .withStatus(500)));
- }
-
- public static void mockVNFPost(WireMockServer wireMockServer, String vfModuleId, int statusCode, String vnfId) {
- wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules" + vfModuleId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- }
-
- public static void mockVNFPut(WireMockServer wireMockServer, String vfModuleId, int statusCode) {
- wireMockServer.stubFor(put(urlEqualTo("/services/rest/v1/vnfsvnfId/vf-modules" + vfModuleId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- wireMockServer.stubFor(put(urlEqualTo("/services/rest/v1/vnfs/vnfId/vf-modules" + vfModuleId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- }
-
- public static void mockVNFPut(WireMockServer wireMockServer, String vnfId, String vfModuleId, int statusCode) {
- wireMockServer.stubFor(put(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules" + vfModuleId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- wireMockServer.stubFor(put(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- }
-
- public static void mockVNFDelete(WireMockServer wireMockServer, String vnfId, String vfModuleId, int statusCode) {
- wireMockServer.stubFor(delete(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules" + vfModuleId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- wireMockServer.stubFor(delete(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- }
-
- public static void mockVNFRollbackDelete(WireMockServer wireMockServer, String vfModuleId, int statusCode) {
- wireMockServer.stubFor(delete(urlEqualTo("/services/rest/v1/vnfsvnfId/vf-modules" + vfModuleId + "/rollback"))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- wireMockServer.stubFor(delete(urlEqualTo("/services/rest/v1/vnfs/vnfId/vf-modules" + vfModuleId + "/rollback"))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- }
-
- public static void mockPutVNFVolumeGroup(WireMockServer wireMockServer, String volumeGroupId, int statusCode) {
- wireMockServer.stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/" + volumeGroupId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- wireMockServer.stubFor(put(urlEqualTo("/vnfs/rest/v1/volume-groups/" + volumeGroupId))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- }
-
- public static void mockPutVNFVolumeGroupRollback(WireMockServer wireMockServer, String volumeGroupId, int statusCode) {
- wireMockServer.stubFor(delete(urlMatching("/vnfs/v1/volume-groups/" + volumeGroupId + "/rollback"))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- wireMockServer.stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/" + volumeGroupId + "/rollback"))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- }
- public static void mockPostVNFVolumeGroup(WireMockServer wireMockServer, int statusCode) {
- wireMockServer.stubFor(post(urlEqualTo("/vnfs/v1/volume-groups"))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- wireMockServer.stubFor(post(urlEqualTo("/vnfs/rest/v1/volume-groups"))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- }
-
- public static void mockVNFAdapterRest(WireMockServer wireMockServer, String vnfId) {
- wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules"))
- .willReturn(aResponse()
- .withStatus(200)));
- wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules"))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
- public static void mockVNFAdapterRest_500(WireMockServer wireMockServer, String vnfId) {
- wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules"))
- .willReturn(aResponse()
- .withStatus(500)));
- wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules"))
- .willReturn(aResponse()
- .withStatus(500)));
- }
-
- public static void mockVfModuleDelete(WireMockServer wireMockServer, String volumeGroupId) {
- wireMockServer.stubFor(delete(urlMatching("/vnfs/v1/volume-groups/"+ volumeGroupId))
- .willReturn(aResponse()
- .withStatus(202)
- .withHeader("Content-Type", "application/xml")));
- wireMockServer.stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/"+ volumeGroupId))
- .willReturn(aResponse()
- .withStatus(202)
- .withHeader("Content-Type", "application/xml")));
- }
-
- public static void mockVfModuleDelete(WireMockServer wireMockServer, String volumeGroupId, int statusCode) {
- wireMockServer.stubFor(delete(urlMatching("/vnfs/v1/volume-groups/78987"))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- wireMockServer.stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/78987"))
- .willReturn(aResponse()
- .withStatus(statusCode)
- .withHeader("Content-Type", "application/xml")));
- }
+ public static void mockVNFAdapter(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync")).willReturn(aResponse().withStatus(200)));
+ }
+
+ public static void mockVNFAdapter(WireMockServer wireMockServer, String responseFile) {
+ wireMockServer.stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync")).willReturn(
+ aResponse().withStatus(200).withHeader("Content-Type", "text/xml").withBodyFile(responseFile)));
+ }
+
+ public static void mockVNFAdapter_500(WireMockServer wireMockServer) {
+ wireMockServer.stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync")).willReturn(aResponse().withStatus(500)));
+ }
+
+ public static void mockVNFPost(WireMockServer wireMockServer, String vfModuleId, int statusCode, String vnfId) {
+ wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules" + vfModuleId))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void mockVNFPut(WireMockServer wireMockServer, String vfModuleId, int statusCode) {
+ wireMockServer.stubFor(put(urlEqualTo("/services/rest/v1/vnfsvnfId/vf-modules" + vfModuleId))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ wireMockServer.stubFor(put(urlEqualTo("/services/rest/v1/vnfs/vnfId/vf-modules" + vfModuleId))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void mockVNFPut(WireMockServer wireMockServer, String vnfId, String vfModuleId, int statusCode) {
+ wireMockServer.stubFor(put(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules" + vfModuleId))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ wireMockServer.stubFor(put(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void mockVNFDelete(WireMockServer wireMockServer, String vnfId, String vfModuleId, int statusCode) {
+ wireMockServer.stubFor(delete(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules" + vfModuleId))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ wireMockServer.stubFor(delete(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void mockVNFRollbackDelete(WireMockServer wireMockServer, String vfModuleId, int statusCode) {
+ wireMockServer.stubFor(delete(urlEqualTo("/services/rest/v1/vnfsvnfId/vf-modules" + vfModuleId + "/rollback"))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ wireMockServer.stubFor(delete(urlEqualTo("/services/rest/v1/vnfs/vnfId/vf-modules" + vfModuleId + "/rollback"))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void mockPutVNFVolumeGroup(WireMockServer wireMockServer, String volumeGroupId, int statusCode) {
+ wireMockServer.stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/" + volumeGroupId))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ wireMockServer.stubFor(put(urlEqualTo("/vnfs/rest/v1/volume-groups/" + volumeGroupId))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void mockPutVNFVolumeGroupRollback(WireMockServer wireMockServer, String volumeGroupId,
+ int statusCode) {
+ wireMockServer.stubFor(delete(urlMatching("/vnfs/v1/volume-groups/" + volumeGroupId + "/rollback"))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ wireMockServer.stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/" + volumeGroupId + "/rollback"))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void mockPostVNFVolumeGroup(WireMockServer wireMockServer, int statusCode) {
+ wireMockServer.stubFor(post(urlEqualTo("/vnfs/v1/volume-groups"))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ wireMockServer.stubFor(post(urlEqualTo("/vnfs/rest/v1/volume-groups"))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void mockVNFAdapterRest(WireMockServer wireMockServer, String vnfId) {
+ wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules"))
+ .willReturn(aResponse().withStatus(200)));
+ wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules"))
+ .willReturn(aResponse().withStatus(200)));
+ }
+
+ public static void mockVNFAdapterRest_500(WireMockServer wireMockServer, String vnfId) {
+ wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs" + vnfId + "/vf-modules"))
+ .willReturn(aResponse().withStatus(500)));
+ wireMockServer.stubFor(post(urlEqualTo("/services/rest/v1/vnfs/" + vnfId + "/vf-modules"))
+ .willReturn(aResponse().withStatus(500)));
+ }
+
+ public static void mockVfModuleDelete(WireMockServer wireMockServer, String volumeGroupId) {
+ wireMockServer.stubFor(delete(urlMatching("/vnfs/v1/volume-groups/" + volumeGroupId))
+ .willReturn(aResponse().withStatus(202).withHeader("Content-Type", "application/xml")));
+ wireMockServer.stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/" + volumeGroupId))
+ .willReturn(aResponse().withStatus(202).withHeader("Content-Type", "application/xml")));
+ }
+
+ public static void mockVfModuleDelete(WireMockServer wireMockServer, String volumeGroupId, int statusCode) {
+ wireMockServer.stubFor(delete(urlMatching("/vnfs/v1/volume-groups/78987"))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ wireMockServer.stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/78987"))
+ .willReturn(aResponse().withStatus(statusCode).withHeader("Content-Type", "application/xml")));
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/BBDecompPojoTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/BBDecompPojoTest.java
index a72db062aa..7498044c53 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/BBDecompPojoTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/BBDecompPojoTest.java
@@ -32,24 +32,22 @@ import org.onap.so.openpojo.rules.HasEqualsAndHashCodeRule;
public class BBDecompPojoTest {
- private PojoClassFilter filterTestClasses = new FilterTestClasses();
+ private PojoClassFilter filterTestClasses = new FilterTestClasses();
- @Test
- public void pojoStructure() {
- test("org.onap.so.bpmn.servicedecomposition.bbobjects");
- }
+ @Test
+ public void pojoStructure() {
+ test("org.onap.so.bpmn.servicedecomposition.bbobjects");
+ }
- private void test(String pojoPackage) {
- Validator validator = ValidatorBuilder.create()
- .with(new EqualsAndHashCodeTester())
- .with(new HasEqualsAndHashCodeRule())
- .build();
- validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses, new FilterNonConcrete());
- }
+ private void test(String pojoPackage) {
+ Validator validator = ValidatorBuilder.create().with(new EqualsAndHashCodeTester())
+ .with(new HasEqualsAndHashCodeRule()).build();
+ validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses, new FilterNonConcrete());
+ }
- private static class FilterTestClasses implements PojoClassFilter {
- public boolean include(PojoClass pojoClass) {
- return !pojoClass.getSourcePath().contains("/test-classes/");
- }
- }
+ private static class FilterTestClasses implements PojoClassFilter {
+ public boolean include(PojoClass pojoClass) {
+ return !pojoClass.getSourcePath().contains("/test-classes/");
+ }
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/BBPojoTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/BBPojoTest.java
index eac6c0a8b7..d7c5ec9d55 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/BBPojoTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/BBPojoTest.java
@@ -21,7 +21,6 @@
package org.onap.so.bpmn.servicedecomposition;
import org.junit.Test;
-
import com.openpojo.reflection.PojoClass;
import com.openpojo.reflection.PojoClassFilter;
import com.openpojo.reflection.filters.FilterNonConcrete;
@@ -36,31 +35,27 @@ import com.openpojo.validation.test.impl.SetterTester;
public class BBPojoTest {
- private PojoClassFilter filterTestClasses = new FilterTestClasses();
-
- @Test
- public void pojoStructure() {
- test("org.onap.so.bpmn.servicedecomposition.bbobjects");
- test("org.onap.so.bpmn.servicedecomposition.modelinfo");
- test("org.onap.so.bpmn.servicedecomposition.entities");
- test("org.onap.so.bpmn.servicedecomposition.homingobjects");
- test("org.onap.so.bpmn.servicedecomposition.generalobjects");
- }
-
- private void test(String pojoPackage) {
- Validator validator = ValidatorBuilder.create()
- .with(new GetterMustExistRule())
- .with(new SetterTester())
- .with(new GetterTester())
- .with(new NoPrimitivesRule())
- .with(new SerializableMustHaveSerialVersionUIDRule())
- .build();
- validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses, new FilterNonConcrete());
- }
-
- private static class FilterTestClasses implements PojoClassFilter {
- public boolean include(PojoClass pojoClass) {
- return !pojoClass.getSourcePath().contains("/test-classes/");
- }
- }
+ private PojoClassFilter filterTestClasses = new FilterTestClasses();
+
+ @Test
+ public void pojoStructure() {
+ test("org.onap.so.bpmn.servicedecomposition.bbobjects");
+ test("org.onap.so.bpmn.servicedecomposition.modelinfo");
+ test("org.onap.so.bpmn.servicedecomposition.entities");
+ test("org.onap.so.bpmn.servicedecomposition.homingobjects");
+ test("org.onap.so.bpmn.servicedecomposition.generalobjects");
+ }
+
+ private void test(String pojoPackage) {
+ Validator validator = ValidatorBuilder.create().with(new GetterMustExistRule()).with(new SetterTester())
+ .with(new GetterTester()).with(new NoPrimitivesRule())
+ .with(new SerializableMustHaveSerialVersionUIDRule()).build();
+ validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses, new FilterNonConcrete());
+ }
+
+ private static class FilterTestClasses implements PojoClassFilter {
+ public boolean include(PojoClass pojoClass) {
+ return !pojoClass.getSourcePath().contains("/test-classes/");
+ }
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java
index 5de0903d65..8ab2c8e155 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/ExtractPojosForBBTest.java
@@ -21,10 +21,8 @@
package org.onap.so.bpmn.servicedecomposition;
import static org.junit.Assert.assertEquals;
-
import java.util.HashMap;
import java.util.List;
-
import org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl;
import org.junit.Before;
import org.junit.Rule;
@@ -39,191 +37,194 @@ import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.BaseTest;
-public class ExtractPojosForBBTest extends BaseTest{
- ExtractPojosForBB extractPojos = new ExtractPojosForBB();
- private BuildingBlockExecution execution;
- private GeneralBuildingBlock gBBInput;
- private HashMap<ResourceKey, String> lookupKeyMap;
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void before() {
- execution = new DelegateExecutionImpl(new ExecutionImpl());
- execution.setVariable("testProcessKey", "AAICreateTasksTests");
- gBBInput = new GeneralBuildingBlock();
- execution.setVariable("gBBInput", gBBInput);
- lookupKeyMap = new HashMap<>();
- execution.setVariable("lookupKeyMap", lookupKeyMap);
- }
-
- @Test
- public void get() throws BBObjectNotFoundException {
- ServiceInstance serviceInstancePend = new ServiceInstance();
- serviceInstancePend.setServiceInstanceId("abc");
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstancePend.getServiceInstanceId());
-
- VpnBondingLink vpnBondingLinkPend = new VpnBondingLink();
- vpnBondingLinkPend.setVpnBondingLinkId("testVpnBondingLink");
- serviceInstancePend.getVpnBondingLinks().add(vpnBondingLinkPend);
- lookupKeyMap.put(ResourceKey.VPN_BONDING_LINK_ID, vpnBondingLinkPend.getVpnBondingLinkId());
-
- Customer customer = new Customer();
- customer.setServiceSubscription(new ServiceSubscription());
- VpnBinding vpnBinding = new VpnBinding();
- vpnBinding.setVpnId("abc");
- customer.getVpnBindings().add(vpnBinding);
- lookupKeyMap.put(ResourceKey.VPN_ID, vpnBinding.getVpnId());
-
- List<GenericVnf> vnfsPend = serviceInstancePend.getVnfs();
- GenericVnf vnfPend = new GenericVnf();
- vnfPend.setVnfId("abc");
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfPend.getVnfId());
-
- List<VfModule> vfModulesPend = vnfPend.getVfModules();
- VfModule vfModulePend = new VfModule();
- vfModulePend.setVfModuleId("abc");
- vfModulesPend.add(vfModulePend);
- vnfsPend.add(vnfPend);
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModulePend.getVfModuleId());
-
- List<L3Network> networksPend = serviceInstancePend.getNetworks();
- L3Network networkPend = new L3Network();
- networkPend.setNetworkId("abc");
- networksPend.add(networkPend);
- lookupKeyMap.put(ResourceKey.NETWORK_ID, networkPend.getNetworkId());
-
- List<VolumeGroup> volumeGroupsPend = serviceInstancePend.getVnfs().get(0).getVolumeGroups();
- VolumeGroup volumeGroupPend = new VolumeGroup();
- volumeGroupPend.setVolumeGroupId("abc");
- volumeGroupsPend.add(volumeGroupPend);
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroupPend.getVolumeGroupId());
-
- List<AllottedResource> allotedResourcesPend = serviceInstancePend.getAllottedResources();
- AllottedResource allotedResourcePend = new AllottedResource();
- allotedResourcePend.setId("abc");
- allotedResourcesPend.add(allotedResourcePend);
- lookupKeyMap.put(ResourceKey.ALLOTTED_RESOURCE_ID, allotedResourcePend.getId());
-
- Configuration configurationPend = new Configuration();
- configurationPend.setConfigurationId("abc");
- serviceInstancePend.getConfigurations().add(configurationPend);
- lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, configurationPend.getConfigurationId());
-
- List<InstanceGroup> instanceGroupsPend = serviceInstancePend.getInstanceGroups();
- InstanceGroup instanceGroupPend = new InstanceGroup();
- instanceGroupPend.setId("test-instance-group-1");
- instanceGroupsPend.add(instanceGroupPend);
- lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupPend.getId());
-
- customer.getServiceSubscription().getServiceInstances().add(serviceInstancePend);
- gBBInput.setCustomer(customer);
-
- ServiceInstance extractServPend = extractPojos.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- assertEquals(extractServPend.getServiceInstanceId(), serviceInstancePend.getServiceInstanceId());
- GenericVnf extractVnfPend = extractPojos.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- assertEquals(extractVnfPend.getVnfId(), vnfPend.getVnfId());
- L3Network extractNetworkPend = extractPojos.extractByKey(execution, ResourceKey.NETWORK_ID);
- assertEquals(extractNetworkPend.getNetworkId(), networkPend.getNetworkId());
- VolumeGroup extractVolumeGroupPend = extractPojos.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
- assertEquals(extractVolumeGroupPend.getVolumeGroupId(), volumeGroupPend.getVolumeGroupId());
- AllottedResource extractallotedResourcePend = extractPojos.extractByKey(execution,
- ResourceKey.ALLOTTED_RESOURCE_ID);
- assertEquals(extractallotedResourcePend.getId(), allotedResourcePend.getId());
- Configuration extractConfigurationPend = extractPojos.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
- assertEquals(extractConfigurationPend.getConfigurationId(), configurationPend.getConfigurationId());
- VpnBinding extractVpnBinding = extractPojos.extractByKey(execution, ResourceKey.VPN_ID);
- assertEquals(extractVpnBinding.getVpnId(), vpnBinding.getVpnId());
-
- VfModule extractVfModulePend = extractPojos.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- assertEquals(extractVfModulePend.getVfModuleId(), vfModulePend.getVfModuleId());
-
- VpnBondingLink extractVpnBondingLinkPend = extractPojos.extractByKey(execution, ResourceKey.VPN_BONDING_LINK_ID);
- assertEquals(extractVpnBondingLinkPend.getVpnBondingLinkId(), vpnBondingLinkPend.getVpnBondingLinkId());
-
- InstanceGroup extractInstanceGroupPend = extractPojos.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
- assertEquals(instanceGroupPend.getId(), extractInstanceGroupPend.getId());
- }
-
- @Test
- public void siError() throws BBObjectNotFoundException {
- expectedException.expect(BBObjectNotFoundException.class);
-
- Customer customer = new Customer();
- customer.setServiceSubscription(new ServiceSubscription());
- ServiceInstance serviceInstance = new ServiceInstance();
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- gBBInput.setCustomer(customer);
-
- extractPojos.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
- }
-
- @Test
- public void vnfError() throws BBObjectNotFoundException {
- expectedException.expect(BBObjectNotFoundException.class);
-
- Customer customer = new Customer();
- customer.setServiceSubscription(new ServiceSubscription());
- ServiceInstance serviceInstance = new ServiceInstance();
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- gBBInput.setCustomer(customer);
- extractPojos.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
- }
-
- @Test
- public void vfModuleError() throws BBObjectNotFoundException {
- expectedException.expect(BBObjectNotFoundException.class);
-
- Customer customer = new Customer();
- customer.setServiceSubscription(new ServiceSubscription());
- ServiceInstance serviceInstance = new ServiceInstance();
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- gBBInput.setCustomer(customer);
- extractPojos.extractByKey(execution, ResourceKey.VF_MODULE_ID);
- }
-
- @Test
- public void configurationError() throws BBObjectNotFoundException {
- expectedException.expect(BBObjectNotFoundException.class);
-
- Customer customer = new Customer();
- customer.setServiceSubscription(new ServiceSubscription());
- ServiceInstance serviceInstance = new ServiceInstance();
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- gBBInput.setCustomer(customer);
- extractPojos.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
- }
- @Test
- public void allotedError() throws BBObjectNotFoundException {
- expectedException.expect(BBObjectNotFoundException.class);
-
- Customer customer = new Customer();
- customer.setServiceSubscription(new ServiceSubscription());
- ServiceInstance serviceInstance = new ServiceInstance();
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- gBBInput.setCustomer(customer);
- extractPojos.extractByKey(execution, ResourceKey.ALLOTTED_RESOURCE_ID);
- }
- @Test
- public void vpnBindingError() throws BBObjectNotFoundException {
- expectedException.expect(BBObjectNotFoundException.class);
- Customer customer = new Customer();
- customer.setServiceSubscription(new ServiceSubscription());
- ServiceInstance serviceInstance = new ServiceInstance();
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- gBBInput.setCustomer(customer);
- extractPojos.extractByKey(execution, ResourceKey.VPN_ID);
- }
-
- @Test
- public void vpnBondingLinkError() throws BBObjectNotFoundException {
- expectedException.expect(BBObjectNotFoundException.class);
- Customer customer = new Customer();
- customer.setServiceSubscription(new ServiceSubscription());
- ServiceInstance serviceInstance = new ServiceInstance();
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- gBBInput.setCustomer(customer);
- extractPojos.extractByKey(execution, ResourceKey.VPN_BONDING_LINK_ID);
- }
+public class ExtractPojosForBBTest extends BaseTest {
+ ExtractPojosForBB extractPojos = new ExtractPojosForBB();
+ private BuildingBlockExecution execution;
+ private GeneralBuildingBlock gBBInput;
+ private HashMap<ResourceKey, String> lookupKeyMap;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Before
+ public void before() {
+ execution = new DelegateExecutionImpl(new ExecutionImpl());
+ execution.setVariable("testProcessKey", "AAICreateTasksTests");
+ gBBInput = new GeneralBuildingBlock();
+ execution.setVariable("gBBInput", gBBInput);
+ lookupKeyMap = new HashMap<>();
+ execution.setVariable("lookupKeyMap", lookupKeyMap);
+ }
+
+ @Test
+ public void get() throws BBObjectNotFoundException {
+ ServiceInstance serviceInstancePend = new ServiceInstance();
+ serviceInstancePend.setServiceInstanceId("abc");
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstancePend.getServiceInstanceId());
+
+ VpnBondingLink vpnBondingLinkPend = new VpnBondingLink();
+ vpnBondingLinkPend.setVpnBondingLinkId("testVpnBondingLink");
+ serviceInstancePend.getVpnBondingLinks().add(vpnBondingLinkPend);
+ lookupKeyMap.put(ResourceKey.VPN_BONDING_LINK_ID, vpnBondingLinkPend.getVpnBondingLinkId());
+
+ Customer customer = new Customer();
+ customer.setServiceSubscription(new ServiceSubscription());
+ VpnBinding vpnBinding = new VpnBinding();
+ vpnBinding.setVpnId("abc");
+ customer.getVpnBindings().add(vpnBinding);
+ lookupKeyMap.put(ResourceKey.VPN_ID, vpnBinding.getVpnId());
+
+ List<GenericVnf> vnfsPend = serviceInstancePend.getVnfs();
+ GenericVnf vnfPend = new GenericVnf();
+ vnfPend.setVnfId("abc");
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfPend.getVnfId());
+
+ List<VfModule> vfModulesPend = vnfPend.getVfModules();
+ VfModule vfModulePend = new VfModule();
+ vfModulePend.setVfModuleId("abc");
+ vfModulesPend.add(vfModulePend);
+ vnfsPend.add(vnfPend);
+ lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModulePend.getVfModuleId());
+
+ List<L3Network> networksPend = serviceInstancePend.getNetworks();
+ L3Network networkPend = new L3Network();
+ networkPend.setNetworkId("abc");
+ networksPend.add(networkPend);
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, networkPend.getNetworkId());
+
+ List<VolumeGroup> volumeGroupsPend = serviceInstancePend.getVnfs().get(0).getVolumeGroups();
+ VolumeGroup volumeGroupPend = new VolumeGroup();
+ volumeGroupPend.setVolumeGroupId("abc");
+ volumeGroupsPend.add(volumeGroupPend);
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroupPend.getVolumeGroupId());
+
+ List<AllottedResource> allotedResourcesPend = serviceInstancePend.getAllottedResources();
+ AllottedResource allotedResourcePend = new AllottedResource();
+ allotedResourcePend.setId("abc");
+ allotedResourcesPend.add(allotedResourcePend);
+ lookupKeyMap.put(ResourceKey.ALLOTTED_RESOURCE_ID, allotedResourcePend.getId());
+
+ Configuration configurationPend = new Configuration();
+ configurationPend.setConfigurationId("abc");
+ serviceInstancePend.getConfigurations().add(configurationPend);
+ lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, configurationPend.getConfigurationId());
+
+ List<InstanceGroup> instanceGroupsPend = serviceInstancePend.getInstanceGroups();
+ InstanceGroup instanceGroupPend = new InstanceGroup();
+ instanceGroupPend.setId("test-instance-group-1");
+ instanceGroupsPend.add(instanceGroupPend);
+ lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupPend.getId());
+
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstancePend);
+ gBBInput.setCustomer(customer);
+
+ ServiceInstance extractServPend = extractPojos.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ assertEquals(extractServPend.getServiceInstanceId(), serviceInstancePend.getServiceInstanceId());
+ GenericVnf extractVnfPend = extractPojos.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ assertEquals(extractVnfPend.getVnfId(), vnfPend.getVnfId());
+ L3Network extractNetworkPend = extractPojos.extractByKey(execution, ResourceKey.NETWORK_ID);
+ assertEquals(extractNetworkPend.getNetworkId(), networkPend.getNetworkId());
+ VolumeGroup extractVolumeGroupPend = extractPojos.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
+ assertEquals(extractVolumeGroupPend.getVolumeGroupId(), volumeGroupPend.getVolumeGroupId());
+ AllottedResource extractallotedResourcePend =
+ extractPojos.extractByKey(execution, ResourceKey.ALLOTTED_RESOURCE_ID);
+ assertEquals(extractallotedResourcePend.getId(), allotedResourcePend.getId());
+ Configuration extractConfigurationPend = extractPojos.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
+ assertEquals(extractConfigurationPend.getConfigurationId(), configurationPend.getConfigurationId());
+ VpnBinding extractVpnBinding = extractPojos.extractByKey(execution, ResourceKey.VPN_ID);
+ assertEquals(extractVpnBinding.getVpnId(), vpnBinding.getVpnId());
+
+ VfModule extractVfModulePend = extractPojos.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ assertEquals(extractVfModulePend.getVfModuleId(), vfModulePend.getVfModuleId());
+
+ VpnBondingLink extractVpnBondingLinkPend =
+ extractPojos.extractByKey(execution, ResourceKey.VPN_BONDING_LINK_ID);
+ assertEquals(extractVpnBondingLinkPend.getVpnBondingLinkId(), vpnBondingLinkPend.getVpnBondingLinkId());
+
+ InstanceGroup extractInstanceGroupPend = extractPojos.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
+ assertEquals(instanceGroupPend.getId(), extractInstanceGroupPend.getId());
+ }
+
+ @Test
+ public void siError() throws BBObjectNotFoundException {
+ expectedException.expect(BBObjectNotFoundException.class);
+
+ Customer customer = new Customer();
+ customer.setServiceSubscription(new ServiceSubscription());
+ ServiceInstance serviceInstance = new ServiceInstance();
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ gBBInput.setCustomer(customer);
+
+ extractPojos.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
+ }
+
+ @Test
+ public void vnfError() throws BBObjectNotFoundException {
+ expectedException.expect(BBObjectNotFoundException.class);
+
+ Customer customer = new Customer();
+ customer.setServiceSubscription(new ServiceSubscription());
+ ServiceInstance serviceInstance = new ServiceInstance();
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ gBBInput.setCustomer(customer);
+ extractPojos.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ }
+
+ @Test
+ public void vfModuleError() throws BBObjectNotFoundException {
+ expectedException.expect(BBObjectNotFoundException.class);
+
+ Customer customer = new Customer();
+ customer.setServiceSubscription(new ServiceSubscription());
+ ServiceInstance serviceInstance = new ServiceInstance();
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ gBBInput.setCustomer(customer);
+ extractPojos.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ }
+
+ @Test
+ public void configurationError() throws BBObjectNotFoundException {
+ expectedException.expect(BBObjectNotFoundException.class);
+
+ Customer customer = new Customer();
+ customer.setServiceSubscription(new ServiceSubscription());
+ ServiceInstance serviceInstance = new ServiceInstance();
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ gBBInput.setCustomer(customer);
+ extractPojos.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
+ }
+
+ @Test
+ public void allotedError() throws BBObjectNotFoundException {
+ expectedException.expect(BBObjectNotFoundException.class);
+
+ Customer customer = new Customer();
+ customer.setServiceSubscription(new ServiceSubscription());
+ ServiceInstance serviceInstance = new ServiceInstance();
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ gBBInput.setCustomer(customer);
+ extractPojos.extractByKey(execution, ResourceKey.ALLOTTED_RESOURCE_ID);
+ }
+
+ @Test
+ public void vpnBindingError() throws BBObjectNotFoundException {
+ expectedException.expect(BBObjectNotFoundException.class);
+ Customer customer = new Customer();
+ customer.setServiceSubscription(new ServiceSubscription());
+ ServiceInstance serviceInstance = new ServiceInstance();
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ gBBInput.setCustomer(customer);
+ extractPojos.extractByKey(execution, ResourceKey.VPN_ID);
+ }
+
+ @Test
+ public void vpnBondingLinkError() throws BBObjectNotFoundException {
+ expectedException.expect(BBObjectNotFoundException.class);
+ Customer customer = new Customer();
+ customer.setServiceSubscription(new ServiceSubscription());
+ ServiceInstance serviceInstance = new ServiceInstance();
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ gBBInput.setCustomer(customer);
+ extractPojos.extractByKey(execution, ResourceKey.VPN_BONDING_LINK_ID);
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/SerializationTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/SerializationTest.java
index cfafe1622b..b970b95b97 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/SerializationTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/SerializationTest.java
@@ -21,7 +21,6 @@
package org.onap.so.bpmn.servicedecomposition;
import static org.junit.Assert.assertEquals;
-
import java.io.ByteArrayOutputStream;
import java.io.Externalizable;
import java.io.File;
@@ -31,7 +30,6 @@ import java.io.OutputStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl;
import org.junit.Test;
@@ -41,50 +39,44 @@ import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.common.DelegateExecutionImpl;
import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
-
import com.fasterxml.jackson.databind.ObjectMapper;
public class SerializationTest {
-
- private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
- private static final String FLOW_VAR_NAME = "flowToBeCalled";
- private static final String LOOKUP_KEY_MAP_VAR_NAME = "lookupKeyMap";
- private static final String GBB_INPUT_VAR_NAME = "gBBInput";
- protected ObjectMapper mapper = new ObjectMapper();
-
- @Test
- public void testSerializationOfAllPojos() throws IOException {
- GeneralBuildingBlock gbb = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- DelegateExecution execution = new ExecutionImpl();
- execution.setVariable(FLOW_VAR_NAME, "AssignServiceInstanceBB");
- execution.setVariable(GBB_INPUT_VAR_NAME, gbb);
- execution.setVariable(LOOKUP_KEY_MAP_VAR_NAME, lookupKeyMap);
- System.out.println(execution.getVariables());
- BuildingBlockExecution gBuildingBlockExecution = new DelegateExecutionImpl(execution);
- boolean isSerializable = SerializationTest.isSerializable(gBuildingBlockExecution);
- assertEquals(true, isSerializable);
- }
-
- public static boolean isSerializable(final Object o)
- {
+
+ private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
+ private static final String FLOW_VAR_NAME = "flowToBeCalled";
+ private static final String LOOKUP_KEY_MAP_VAR_NAME = "lookupKeyMap";
+ private static final String GBB_INPUT_VAR_NAME = "gBBInput";
+ protected ObjectMapper mapper = new ObjectMapper();
+
+ @Test
+ public void testSerializationOfAllPojos() throws IOException {
+ GeneralBuildingBlock gbb = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ DelegateExecution execution = new ExecutionImpl();
+ execution.setVariable(FLOW_VAR_NAME, "AssignServiceInstanceBB");
+ execution.setVariable(GBB_INPUT_VAR_NAME, gbb);
+ execution.setVariable(LOOKUP_KEY_MAP_VAR_NAME, lookupKeyMap);
+ System.out.println(execution.getVariables());
+ BuildingBlockExecution gBuildingBlockExecution = new DelegateExecutionImpl(execution);
+ boolean isSerializable = SerializationTest.isSerializable(gBuildingBlockExecution);
+ assertEquals(true, isSerializable);
+ }
+
+ public static boolean isSerializable(final Object o) {
final boolean retVal;
- if(implementsInterface(o))
- {
+ if (implementsInterface(o)) {
retVal = attemptToSerialize(o);
- }
- else
- {
+ } else {
retVal = false;
}
return (retVal);
}
- private static boolean implementsInterface(final Object o)
- {
+ private static boolean implementsInterface(final Object o) {
final boolean retVal;
retVal = ((o instanceof Serializable) || (o instanceof Externalizable));
@@ -92,34 +84,24 @@ public class SerializationTest {
return (retVal);
}
- private static boolean attemptToSerialize(final Object o)
- {
+ private static boolean attemptToSerialize(final Object o) {
final OutputStream sink;
ObjectOutputStream stream;
stream = null;
- try
- {
- sink = new ByteArrayOutputStream();
+ try {
+ sink = new ByteArrayOutputStream();
stream = new ObjectOutputStream(sink);
stream.writeObject(o);
// could also re-serilalize at this point too
- }
- catch(final IOException ex)
- {
+ } catch (final IOException ex) {
return (false);
- }
- finally
- {
- if(stream != null)
- {
- try
- {
+ } finally {
+ if (stream != null) {
+ try {
stream.close();
- }
- catch(final IOException ex)
- {
+ } catch (final IOException ex) {
// should not be able to happen
}
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/entities/exceptions/InvalidBuildingBlockInputExceptionTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/entities/exceptions/InvalidBuildingBlockInputExceptionTest.java
index 9d34a95e79..958eb069b8 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/entities/exceptions/InvalidBuildingBlockInputExceptionTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/entities/exceptions/InvalidBuildingBlockInputExceptionTest.java
@@ -21,47 +21,48 @@
package org.onap.so.bpmn.servicedecomposition.entities.exceptions;
import static org.junit.Assert.assertEquals;
-
import org.junit.Test;
public class InvalidBuildingBlockInputExceptionTest {
- private static final String MESSAGE = "message";
- private static final Throwable CAUSE = new Throwable();
- private InvalidBuildingBlockInputException invalidBuildingBlockInputException;
-
- @Test
- public void defaultConstructorTest() {
- invalidBuildingBlockInputException = new InvalidBuildingBlockInputException();
- assertEquals(null, invalidBuildingBlockInputException.getMessage());
- assertEquals(null, invalidBuildingBlockInputException.getCause());
- }
-
- @Test
- public void messageConstructorTest() {
- invalidBuildingBlockInputException = new InvalidBuildingBlockInputException(MESSAGE);
- assertEquals(MESSAGE, invalidBuildingBlockInputException.getMessage());
- assertEquals(null, invalidBuildingBlockInputException.getCause());
- }
-
- @Test
- public void causeConstructorTest() {
- invalidBuildingBlockInputException = new InvalidBuildingBlockInputException(CAUSE);
- assertEquals(CAUSE.toString(), invalidBuildingBlockInputException.getMessage()); // CAUSE.toString because of the implementation of Exception(Throwable cause)
- assertEquals(CAUSE, invalidBuildingBlockInputException.getCause());
- }
-
- @Test
- public void messageAndCauseConstructorTest() {
- invalidBuildingBlockInputException = new InvalidBuildingBlockInputException(MESSAGE, CAUSE);
- assertEquals(MESSAGE, invalidBuildingBlockInputException.getMessage());
- assertEquals(CAUSE, invalidBuildingBlockInputException.getCause());
- }
-
- @Test
- public void messageAndCauseAndFlagsConstructorTest() {
- invalidBuildingBlockInputException = new InvalidBuildingBlockInputException(MESSAGE, CAUSE, true, true);
- assertEquals(MESSAGE, invalidBuildingBlockInputException.getMessage());
- assertEquals(CAUSE, invalidBuildingBlockInputException.getCause());
- }
+ private static final String MESSAGE = "message";
+ private static final Throwable CAUSE = new Throwable();
+ private InvalidBuildingBlockInputException invalidBuildingBlockInputException;
+
+ @Test
+ public void defaultConstructorTest() {
+ invalidBuildingBlockInputException = new InvalidBuildingBlockInputException();
+ assertEquals(null, invalidBuildingBlockInputException.getMessage());
+ assertEquals(null, invalidBuildingBlockInputException.getCause());
+ }
+
+ @Test
+ public void messageConstructorTest() {
+ invalidBuildingBlockInputException = new InvalidBuildingBlockInputException(MESSAGE);
+ assertEquals(MESSAGE, invalidBuildingBlockInputException.getMessage());
+ assertEquals(null, invalidBuildingBlockInputException.getCause());
+ }
+
+ @Test
+ public void causeConstructorTest() {
+ invalidBuildingBlockInputException = new InvalidBuildingBlockInputException(CAUSE);
+ assertEquals(CAUSE.toString(), invalidBuildingBlockInputException.getMessage()); // CAUSE.toString because of
+ // the implementation of
+ // Exception(Throwable cause)
+ assertEquals(CAUSE, invalidBuildingBlockInputException.getCause());
+ }
+
+ @Test
+ public void messageAndCauseConstructorTest() {
+ invalidBuildingBlockInputException = new InvalidBuildingBlockInputException(MESSAGE, CAUSE);
+ assertEquals(MESSAGE, invalidBuildingBlockInputException.getMessage());
+ assertEquals(CAUSE, invalidBuildingBlockInputException.getCause());
+ }
+
+ @Test
+ public void messageAndCauseAndFlagsConstructorTest() {
+ invalidBuildingBlockInputException = new InvalidBuildingBlockInputException(MESSAGE, CAUSE, true, true);
+ assertEquals(MESSAGE, invalidBuildingBlockInputException.getMessage());
+ assertEquals(CAUSE, invalidBuildingBlockInputException.getCause());
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java
index 9ac148f5bd..e7afa9ec8b 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java
@@ -26,7 +26,6 @@ import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -34,7 +33,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.junit.Test;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
@@ -81,647 +79,665 @@ import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
import org.onap.so.db.catalog.beans.VnfcCustomization;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
import org.onap.so.serviceinstancebeans.RequestDetails;
-
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
public class BBInputSetupMapperLayerTest {
-
- BBInputSetupMapperLayer bbInputSetupMapperLayer = new BBInputSetupMapperLayer();
-
- ObjectMapper mapper = new ObjectMapper();
-
- private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
-
- @Test
- public void testMapOrchestrationStatusFromAAI() {
- OrchestrationStatus expected = OrchestrationStatus.INVENTORIED;
- String orchStatusInput = "Inventoried";
- OrchestrationStatus actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
- assertThat(actual, sameBeanAs(expected));
-
- expected = OrchestrationStatus.ASSIGNED;
- orchStatusInput = "Assigned";
- actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
- assertThat(actual, sameBeanAs(expected));
-
- expected = OrchestrationStatus.ACTIVE;
- orchStatusInput = "Active";
- actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
- assertThat(actual, sameBeanAs(expected));
-
- expected = OrchestrationStatus.CREATED;
- orchStatusInput = "Created";
- actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
- assertThat(actual, sameBeanAs(expected));
-
- expected = OrchestrationStatus.PRECREATED;
- orchStatusInput = "PreCreated";
- actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
- assertThat(actual, sameBeanAs(expected));
-
- expected = OrchestrationStatus.PENDING_CREATE;
- orchStatusInput = "PendingCreate";
- actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
- assertThat(actual, sameBeanAs(expected));
-
- expected = OrchestrationStatus.PENDING_DELETE;
- orchStatusInput = "PendingDelete";
- actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
- assertThat(actual, sameBeanAs(expected));
-
- expected = OrchestrationStatus.PENDING;
- orchStatusInput = "Pending";
- actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
- assertThat(actual, sameBeanAs(expected));
-
- expected = OrchestrationStatus.PENDING_ACTIVATION;
- orchStatusInput = "PendingActivation";
- actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapOrchestrationFuzzyCases() {
- List<String> values = Arrays.asList("pending-create", "pending_Create", "pendinggcreate", "PendingCreate");
- values.forEach(value -> {
- assertThat(bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(value), equalTo(OrchestrationStatus.PENDING_CREATE));
- });
- }
-
- @Test
- public void testMapAAICustomer() throws IOException {
- Customer expected = mapper.readValue(
- new File(RESOURCE_PATH+"Customer.json"),
- Customer.class);
-
- org.onap.aai.domain.yang.Customer customerAAI = mapper.readValue(
- new File(RESOURCE_PATH+"Customer_AAI.json"), org.onap.aai.domain.yang.Customer.class);
-
- Customer actual = bbInputSetupMapperLayer.mapAAICustomer(customerAAI);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapAAIServiceSubscription() throws IOException {
- ServiceSubscription expected = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceSubscriptionExpected.json"), ServiceSubscription.class);
-
- org.onap.aai.domain.yang.ServiceSubscription svcSubscriptionAAI = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceSubscription_AAI.json"), org.onap.aai.domain.yang.ServiceSubscription.class);
-
- ServiceSubscription actual = bbInputSetupMapperLayer.mapAAIServiceSubscription(svcSubscriptionAAI);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapAAIProject() throws IOException {
- Project expected = mapper.readValue(new File(RESOURCE_PATH+"Project.json"),Project.class);
-
- org.onap.aai.domain.yang.Project projectAAI = new org.onap.aai.domain.yang.Project();
- projectAAI.setProjectName("projectName");
-
- Project actual = bbInputSetupMapperLayer.mapAAIProject(projectAAI);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapRequestProject() throws IOException {
- Project expected = mapper.readValue(new File(RESOURCE_PATH+"Project.json"),Project.class);
-
- org.onap.so.serviceinstancebeans.Project requestProject = new org.onap.so.serviceinstancebeans.Project();
- requestProject.setProjectName("projectName");
-
- Project actual = bbInputSetupMapperLayer.mapRequestProject(requestProject);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapAAIOwningEntity() throws IOException {
- OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH+"OwningEntity.json"),OwningEntity.class);
-
- org.onap.aai.domain.yang.OwningEntity entityAAI = new org.onap.aai.domain.yang.OwningEntity();
- entityAAI.setOwningEntityId("owningEntityId");
- entityAAI.setOwningEntityName("owningEntityName");
-
- OwningEntity actual = bbInputSetupMapperLayer.mapAAIOwningEntity(entityAAI);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapRequestOwningEntity() throws IOException {
- OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH+"OwningEntity.json"),OwningEntity.class);
-
- org.onap.so.serviceinstancebeans.OwningEntity requestOwningEntity = new org.onap.so.serviceinstancebeans.OwningEntity();
- requestOwningEntity.setOwningEntityId("owningEntityId");
- requestOwningEntity.setOwningEntityName("owningEntityName");
-
- OwningEntity actual = bbInputSetupMapperLayer.mapRequestOwningEntity(requestOwningEntity);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapAAIPlatform() throws IOException {
- Platform expected = mapper.readValue(new File(RESOURCE_PATH+"Platform.json"),Platform.class);
-
- org.onap.aai.domain.yang.Platform platformAAI = new org.onap.aai.domain.yang.Platform();
- platformAAI.setPlatformName("platformName");
-
- Platform actual = bbInputSetupMapperLayer.mapAAIPlatform(platformAAI);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapAAILineOfBusiness() throws IOException {
- LineOfBusiness expected = mapper.readValue(new File(RESOURCE_PATH+"LineOfBusiness.json"),LineOfBusiness.class);
-
- org.onap.aai.domain.yang.LineOfBusiness lobAAI = new org.onap.aai.domain.yang.LineOfBusiness();
- lobAAI.setLineOfBusinessName("lineOfBusinessName");
-
- LineOfBusiness actual = bbInputSetupMapperLayer.mapAAILineOfBusiness(lobAAI);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapAAINetworkPolicy() throws JsonParseException, JsonMappingException, IOException {
- NetworkPolicy expectedNetworkPolicy = mapper.readValue(new File(RESOURCE_PATH + "NetworkPolicy.json"), NetworkPolicy.class);
-
- org.onap.aai.domain.yang.NetworkPolicy aaiNetworkPolicy = new org.onap.aai.domain.yang.NetworkPolicy();
- aaiNetworkPolicy.setNetworkPolicyId("networkPolicyId");
- aaiNetworkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
- aaiNetworkPolicy.setHeatStackId("heatStackId");
- aaiNetworkPolicy.setResourceVersion("resourceVersion");
-
- NetworkPolicy actualNetworkPolicy = bbInputSetupMapperLayer.mapAAINetworkPolicy(aaiNetworkPolicy);
-
- assertThat(actualNetworkPolicy, sameBeanAs(expectedNetworkPolicy));
- }
-
- @Test
- public void testMapAAIVolumeGroup() throws JsonParseException, JsonMappingException, IOException {
- VolumeGroup expectedVolumeGroup = mapper.readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
-
- org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = mapper.readValue(
- new File(RESOURCE_PATH + "VolumeGroup_AAI.json"), org.onap.aai.domain.yang.VolumeGroup.class);
-
- VolumeGroup actualVolumeGroup = bbInputSetupMapperLayer.mapAAIVolumeGroup(aaiVolumeGroup);
-
- assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
- }
-
- @Test
- public void testMapCatalogServiceIntoServiceInstance() throws IOException {
- ModelInfoServiceInstance expected = mapper.readValue(
- new File(RESOURCE_PATH + "ModelInfoServiceInstance.json"),
- ModelInfoServiceInstance.class);
-
- Service catalogService = mapper.readValue(
- new File(RESOURCE_PATH + "CatalogServiceInput.json"), Service.class);
-
- ModelInfoServiceInstance actual = bbInputSetupMapperLayer.mapCatalogServiceIntoServiceInstance(catalogService);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapCatalogInstanceGroupToInstanceGroup() throws IOException {
- ModelInfoInstanceGroup expected = mapper.readValue(
- new File(RESOURCE_PATH + "ModelInfoInstanceGroup.json"),
- ModelInfoInstanceGroup.class);
-
- InstanceGroup instanceGroup = mapper.readValue(
- new File(RESOURCE_PATH + "InstanceGroup.json"), InstanceGroup.class);
- instanceGroup.setCollectionInstanceGroupCustomizations(new ArrayList<>());
- CollectionResourceInstanceGroupCustomization collectionInstanceGroupCust = new CollectionResourceInstanceGroupCustomization();
- collectionInstanceGroupCust.setModelCustomizationUUID("modelCustomizationUUID");
- collectionInstanceGroupCust.setFunction("function");
- collectionInstanceGroupCust.setDescription("description");
- instanceGroup.getCollectionInstanceGroupCustomizations().add(collectionInstanceGroupCust);
- CollectionResourceCustomization collectionResourceCust = new CollectionResourceCustomization();
- collectionResourceCust.setModelCustomizationUUID("modelCustomizationUUID");
- ModelInfoInstanceGroup actual = bbInputSetupMapperLayer.mapCatalogInstanceGroupToInstanceGroup(collectionResourceCust, instanceGroup);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapCollectionNetworkResourceCustToNetworkResourceCust() {
- String modelCustomizationUUID = "modelCustomizationUUID";
- String modelInstanceName = "modelInstanceName";
- String networkRole = "networkRole";
- String networkScope = "networkScope";
- String networkTechnology = "networkTechnology";
- String networkType = "networkType";
-
- NetworkResourceCustomization expected = new NetworkResourceCustomization();
- expected.setModelCustomizationUUID(modelCustomizationUUID);
- expected.setModelInstanceName(modelInstanceName);
- expected.setNetworkRole(networkRole);
- expected.setNetworkScope(networkScope);
- expected.setNetworkTechnology(networkTechnology);
- expected.setNetworkType(networkType);
- CollectionNetworkResourceCustomization collectionNetworkResourceCust = new CollectionNetworkResourceCustomization();
- collectionNetworkResourceCust.setModelCustomizationUUID(modelCustomizationUUID);
- collectionNetworkResourceCust.setModelInstanceName(modelInstanceName);
- collectionNetworkResourceCust.setNetworkRole(networkRole);
- collectionNetworkResourceCust.setNetworkScope(networkScope);
- collectionNetworkResourceCust.setNetworkTechnology(networkTechnology);
- collectionNetworkResourceCust.setNetworkType(networkType);
- NetworkResourceCustomization actual = bbInputSetupMapperLayer.mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapCatalogCollectionToCollection() throws IOException {
- ModelInfoCollection expected = mapper.readValue(
- new File(RESOURCE_PATH + "ModelInfoCollection.json"),
- ModelInfoCollection.class);
-
- CollectionResourceCustomization collectionCust = mapper.readValue(
- new File(RESOURCE_PATH + "CollectionResourceCustomization.json"),
- CollectionResourceCustomization.class);
-
- CollectionResource collectionResource = mapper.readValue(
- new File(RESOURCE_PATH + "CollectionResource.json"),
- CollectionResource.class);
-
- ModelInfoCollection actual = bbInputSetupMapperLayer.mapCatalogCollectionToCollection(collectionCust, collectionResource);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapAAIServiceInstanceIntoServiceInstance() throws IOException {
- ServiceInstance expected = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceInstance_aaiServiceInstanceToSI.json"),
- ServiceInstance.class);
-
- org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceInstanceAAIInput.json"),
- org.onap.aai.domain.yang.ServiceInstance.class);
-
- ServiceInstance actual = bbInputSetupMapperLayer.mapAAIServiceInstanceIntoServiceInstance(serviceInstanceAAI);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testSetPlatformAndLOB() throws IOException {
- ServiceInstance expected = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceInstance_aaiPlatformAndLOBToSI.json"),
- ServiceInstance.class);
-
- Map<ResourceKey, String> resourcesToBeOrchestrated = new HashMap<>();
- resourcesToBeOrchestrated.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- Platform platformMSO = new Platform();
- platformMSO.setPlatformName("platformName");
- LineOfBusiness lineOfBusinessMSO = new LineOfBusiness();
- lineOfBusinessMSO.setLineOfBusinessName("lineOfBusinessName");
-
- ServiceInstance actual = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceInstanceAAIPlatformAndLOBInput.json"),
- ServiceInstance.class);
-
- bbInputSetupMapperLayer.setPlatformAndLOBIntoServiceInstance(platformMSO, lineOfBusinessMSO, actual,
- resourcesToBeOrchestrated);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapAAIL3NetworkIntoL3Network() throws IOException {
- L3Network expected = mapper.readValue(
- new File(RESOURCE_PATH + "l3NetworkExpected.json"), L3Network.class);
-
- org.onap.aai.domain.yang.L3Network aaiL3Network = mapper.readValue(
- new File(RESOURCE_PATH + "aaiL3NetworkInput.json"),
- org.onap.aai.domain.yang.L3Network.class);
-
- L3Network actual = bbInputSetupMapperLayer.mapAAIL3Network(aaiL3Network);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapAAIGenericVnfIntoGenericVnf() throws IOException {
- GenericVnf expected = mapper.readValue(new File(RESOURCE_PATH + "GenericVnfExpected.json"), GenericVnf.class);
- org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = mapper.readValue(
- new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), org.onap.aai.domain.yang.GenericVnf.class);
-
- GenericVnf actual = bbInputSetupMapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapAAICollectionIntoCollection() throws JsonParseException, JsonMappingException, IOException {
- org.onap.aai.domain.yang.Collection aaiCollection = mapper.readValue(
- new File(RESOURCE_PATH + "CollectionInput.json"), org.onap.aai.domain.yang.Collection.class);
-
- Collection expectedCollection = mapper.readValue(new File(RESOURCE_PATH + "CollectionExpected.json"), Collection.class);
-
- Collection actualCollection = bbInputSetupMapperLayer.mapAAICollectionIntoCollection(aaiCollection);
-
- assertThat(actualCollection, sameBeanAs(expectedCollection));
- }
-
- @Test
- public void testMapAAIInstanceGroupIntoInstanceGroup() throws JsonParseException, JsonMappingException, IOException {
- org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = mapper.readValue(
- new File(RESOURCE_PATH + "InstanceGroupInput.json"), org.onap.aai.domain.yang.InstanceGroup.class);
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup expectedInstanceGroup = mapper.readValue(
- new File(RESOURCE_PATH + "InstanceGroupExpected.json"), org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class);
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup actualInstanceGroup =
- bbInputSetupMapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup);
-
- assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
- }
-
- @Test
- public void testMapAAIRouteTableReferenceIntoRouteTableReference() throws JsonParseException, JsonMappingException, IOException {
- org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference = mapper.readValue(
- new File(RESOURCE_PATH + "RouteTableReferenceInput.json"), org.onap.aai.domain.yang.RouteTableReference.class);
-
- RouteTableReference expectedRouteTableReference = mapper.readValue(
- new File(RESOURCE_PATH + "RouteTableReferenceExpected.json"), RouteTableReference.class);
-
- RouteTableReference actualRouteTableReference = bbInputSetupMapperLayer.mapAAIRouteTableReferenceIntoRouteTableReference(aaiRouteTableReference);
-
- assertThat(actualRouteTableReference, sameBeanAs(expectedRouteTableReference));
- }
-
- @Test
- public void testMapCatalogNetworkToNetwork() throws JsonParseException, JsonMappingException, IOException {
- NetworkResourceCustomization networkResourceCustomization = mapper.readValue(
- new File(RESOURCE_PATH + "NetworkResourceCustomizationInput.json"), NetworkResourceCustomization.class);
-
- ModelInfoNetwork expectedModelInfoNetwork = mapper.readValue(
- new File(RESOURCE_PATH + "ModelInfoNetworkExpected.json"), ModelInfoNetwork.class);
-
- ModelInfoNetwork actualModelInfoNetwork = bbInputSetupMapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization);
-
- assertThat(actualModelInfoNetwork, sameBeanAs(expectedModelInfoNetwork));
- }
-
- @Test
- public void testMapCatalogVnfToVnf() throws IOException {
- VnfResourceCustomization vnfResourceCustomization = mapper.readValue(
- new File(RESOURCE_PATH + "VnfResourceCustomizationInput.json"), VnfResourceCustomization.class);
-
- ModelInfoGenericVnf expectedModelInfoGenericVnf = mapper.readValue(
- new File(RESOURCE_PATH + "ModelInfoGenericVnfExpected.json"), ModelInfoGenericVnf.class);
-
- ModelInfoGenericVnf actualModelInfoGenericVnf = bbInputSetupMapperLayer.mapCatalogVnfToVnf(vnfResourceCustomization);
-
- assertThat(actualModelInfoGenericVnf, sameBeanAs(expectedModelInfoGenericVnf));
- }
-
- @Test
- public void testMapCatalogVfModuleToVfModule() throws JsonParseException, JsonMappingException, IOException {
- VfModuleCustomization vfResourceCustomization = mapper.readValue(
- new File(RESOURCE_PATH + "VfModuleCustomizationInput.json"), VfModuleCustomization.class);
-
- ModelInfoVfModule expectedModelInfoVfModule = mapper.readValue(new File(RESOURCE_PATH + "ModelInfoVfModuleExpected.json"), ModelInfoVfModule.class);
-
- ModelInfoVfModule actualModelInfoVfModule = bbInputSetupMapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization);
-
- assertThat(actualModelInfoVfModule, sameBeanAs(expectedModelInfoVfModule));
- }
-
- @Test
- public void testMapRequestPlatform() throws JsonParseException, JsonMappingException, IOException {
- org.onap.so.serviceinstancebeans.Platform platform = mapper.readValue(
- new File(RESOURCE_PATH + "RequestPlatformInput.json"), org.onap.so.serviceinstancebeans.Platform.class);
-
- Platform expectedPlatform = mapper.readValue(new File(RESOURCE_PATH + "PlatformExpected.json"), Platform.class);
-
- Platform actualPlatform = bbInputSetupMapperLayer.mapRequestPlatform(platform);
-
- assertThat(actualPlatform, sameBeanAs(expectedPlatform));
- }
-
- @Test
- public void testMapRequestLineOfBusiness() throws JsonParseException, JsonMappingException, IOException {
- org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = mapper.readValue(
- new File(RESOURCE_PATH + "RequestLineOfBusinessInput.json"), org.onap.so.serviceinstancebeans.LineOfBusiness.class);
-
- LineOfBusiness expectedLineOfBusiness = mapper.readValue(new File(RESOURCE_PATH + "LineOfBusinessExpected.json"), LineOfBusiness.class);
-
- LineOfBusiness actualLineOfBusiness = bbInputSetupMapperLayer.mapRequestLineOfBusiness(lineOfBusiness);
-
- assertThat(actualLineOfBusiness, sameBeanAs(expectedLineOfBusiness));
- }
-
- @Test
- public void testMapAAIConfiguration() throws JsonParseException, JsonMappingException, IOException {
- org.onap.aai.domain.yang.Configuration configurationAAI = mapper.readValue(
- new File(RESOURCE_PATH + "ConfigurationInput.json"), org.onap.aai.domain.yang.Configuration.class);
-
- Configuration expectedConfiguration = mapper.readValue(
- new File(RESOURCE_PATH + "ConfigurationExpected.json"), Configuration.class);
-
- Configuration actualConfiguration = bbInputSetupMapperLayer.mapAAIConfiguration(configurationAAI);
-
- assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
- }
-
- @Test
- public void testMapRequestContext() throws IOException {
- RequestContext expected = mapper.readValue(
- new File(RESOURCE_PATH + "RequestContextExpected.json"),
- RequestContext.class);
-
- RequestDetails requestDetails = mapper.readValue(
- new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"),
- RequestDetails.class);
- RequestContext actual = bbInputSetupMapperLayer.mapRequestContext(requestDetails);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapOrchestrationContext() throws IOException {
- OrchestrationContext expected = new OrchestrationContext();
- expected.setIsRollbackEnabled(true);
-
- RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
-
- OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapLocationContext() {
- CloudRegion expected = new CloudRegion();
- expected.setCloudOwner("test-owner-name");
- expected.setLcpCloudRegionId("cloudRegionId");
- expected.setComplex("complexName");
- expected.setTenantId("tenantId");
- CloudConfiguration cloudConfig = new CloudConfiguration();
- cloudConfig.setTenantId("tenantId");
- cloudConfig.setLcpCloudRegionId("cloudRegionId");
- cloudConfig.setAicNodeClli("aicNodeClli");
- org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
- cloudRegion.setCloudOwner("test-owner-name");
- cloudRegion.setCloudRegionId("cloudRegionId");
- cloudRegion.setComplexName("complexName");
-
- CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapCloudRegion() {
- CloudRegion expected = new CloudRegion();
- expected.setCloudOwner("test-owner-name");
- expected.setLcpCloudRegionId("cloudRegionId");
- expected.setTenantId("tenantId");
- expected.setCloudRegionVersion("cloudRegionVersion");
-
- CloudConfiguration cloudConfig = new CloudConfiguration();
- cloudConfig.setTenantId("tenantId");
- cloudConfig.setLcpCloudRegionId("cloudRegionId");
- cloudConfig.setAicNodeClli("aicNodeClli");
-
- org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
- cloudRegion.setCloudOwner("test-owner-name");
- cloudRegion.setCloudRegionId("cloudRegionId");
- cloudRegion.setCloudRegionVersion("cloudRegionVersion");
-
- CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapTenant() {
- Tenant expected = new Tenant();
- expected.setTenantId("tenantId");
- expected.setTenantName("tenantName");
- expected.setTenantContext("tenantContext");
-
- org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant();
- aaiTenant.setTenantId("tenantId");
- aaiTenant.setTenantName("tenantName");
- aaiTenant.setTenantContext("tenantContext");
-
- Tenant actual = bbInputSetupMapperLayer.mapTenant(aaiTenant);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapCloudRegionWithNullCheck() {
- CloudRegion expected = new CloudRegion();
-
- CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testmapCatalogConfigurationToConfiguration() {
- String modelCustUUID = "modelCustomizationUUID";
- String modelInvariantUUID = "modelInvariantUUID";
- String modelVersionUUID = "modelUUID";
- String policyName = "policyName";
- ModelInfoConfiguration expected = new ModelInfoConfiguration();
- expected.setModelCustomizationId(modelCustUUID);
- expected.setModelInvariantId(modelInvariantUUID);
- expected.setModelVersionId(modelVersionUUID);
- expected.setPolicyName(policyName);
- ConfigurationResourceCustomization configurationResourceCustomization = new ConfigurationResourceCustomization();
- configurationResourceCustomization.setModelCustomizationUUID(modelCustUUID);
- configurationResourceCustomization.setConfigurationResource(new ConfigurationResource());
- configurationResourceCustomization.getConfigurationResource().setModelInvariantUUID(modelInvariantUUID);
- configurationResourceCustomization.getConfigurationResource().setModelUUID(modelVersionUUID);
- CvnfcConfigurationCustomization policyNameTable = new CvnfcConfigurationCustomization();
- policyNameTable.setCvnfcCustomization(new CvnfcCustomization());
- policyNameTable.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
- policyNameTable.setPolicyName(policyName);
-
- ModelInfoConfiguration actual = bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(configurationResourceCustomization, policyNameTable);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testmapCatalogConfigurationToFabricConfiguration() {
- String modelCustUUID = "modelCustomizationUUID";
- String modelInvariantUUID = "modelInvariantUUID";
- String modelVersionUUID = "modelUUID";
- String policyName = "policyName";
- ModelInfoConfiguration expected = new ModelInfoConfiguration();
- expected.setModelCustomizationId(modelCustUUID);
- expected.setModelInvariantId(modelInvariantUUID);
- expected.setModelVersionId(modelVersionUUID);
- expected.setPolicyName(policyName);
-
- CvnfcConfigurationCustomization fabricCustomization = new CvnfcConfigurationCustomization();
- fabricCustomization.setCvnfcCustomization(new CvnfcCustomization());
- fabricCustomization.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
- fabricCustomization.setPolicyName(policyName);
- fabricCustomization.setModelCustomizationUUID(modelCustUUID);
-
- ConfigurationResource configurationResource = new ConfigurationResource();
- configurationResource.setModelUUID(modelVersionUUID);
- configurationResource.setModelInvariantUUID(modelInvariantUUID);
- fabricCustomization.setConfigurationResource(configurationResource);
-
- ModelInfoConfiguration actual = bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(fabricCustomization);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapNameValueUserParams() throws IOException {
- RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
- Map<String,Object> actual = bbInputSetupMapperLayer.mapNameValueUserParams(requestDetails.getRequestParameters());
-
- assertTrue(actual.containsKey("mns_vfw_protected_route_prefixes"));
- assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("interface_route_table_routes_route"));
- assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("1.1.1.1/32"));
- assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("0::1/128"));
- assertTrue(actual.containsKey("name1"));
- assertTrue(actual.containsValue("value1"));
- assertTrue(actual.get("name1").equals("value1"));
-
- assertFalse(actual.containsKey("ignore"));
- assertFalse(actual.containsValue("ignore"));
- }
-
- @Test
- public void testMapRequestParameters() throws IOException {
- RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
- RequestParameters actual = bbInputSetupMapperLayer.mapRequestParameters(requestDetails.getRequestParameters());
-
- assertEquals(actual.getUsePreload(), requestDetails.getRequestParameters().getUsePreload());
- assertEquals(actual.getSubscriptionServiceType(), requestDetails.getRequestParameters().getSubscriptionServiceType());
- assertEquals(actual.getPayload(), requestDetails.getRequestParameters().getPayload());
- }
-
- protected RequestParameters mapRequestParameters(org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
- RequestParameters requestParams = new RequestParameters();
- requestParams.setaLaCarte(requestParameters.getALaCarte());
- requestParams.setUsePreload(requestParameters.getUsePreload());
- requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
- requestParams.setUserParams(requestParameters.getUserParams());
- requestParams.setPayload(requestParameters.getPayload());
- return requestParams;
- }
-
+
+ BBInputSetupMapperLayer bbInputSetupMapperLayer = new BBInputSetupMapperLayer();
+
+ ObjectMapper mapper = new ObjectMapper();
+
+ private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
+
+ @Test
+ public void testMapOrchestrationStatusFromAAI() {
+ OrchestrationStatus expected = OrchestrationStatus.INVENTORIED;
+ String orchStatusInput = "Inventoried";
+ OrchestrationStatus actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
+ assertThat(actual, sameBeanAs(expected));
+
+ expected = OrchestrationStatus.ASSIGNED;
+ orchStatusInput = "Assigned";
+ actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
+ assertThat(actual, sameBeanAs(expected));
+
+ expected = OrchestrationStatus.ACTIVE;
+ orchStatusInput = "Active";
+ actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
+ assertThat(actual, sameBeanAs(expected));
+
+ expected = OrchestrationStatus.CREATED;
+ orchStatusInput = "Created";
+ actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
+ assertThat(actual, sameBeanAs(expected));
+
+ expected = OrchestrationStatus.PRECREATED;
+ orchStatusInput = "PreCreated";
+ actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
+ assertThat(actual, sameBeanAs(expected));
+
+ expected = OrchestrationStatus.PENDING_CREATE;
+ orchStatusInput = "PendingCreate";
+ actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
+ assertThat(actual, sameBeanAs(expected));
+
+ expected = OrchestrationStatus.PENDING_DELETE;
+ orchStatusInput = "PendingDelete";
+ actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
+ assertThat(actual, sameBeanAs(expected));
+
+ expected = OrchestrationStatus.PENDING;
+ orchStatusInput = "Pending";
+ actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
+ assertThat(actual, sameBeanAs(expected));
+
+ expected = OrchestrationStatus.PENDING_ACTIVATION;
+ orchStatusInput = "PendingActivation";
+ actual = bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(orchStatusInput);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapOrchestrationFuzzyCases() {
+ List<String> values = Arrays.asList("pending-create", "pending_Create", "pendinggcreate", "PendingCreate");
+ values.forEach(value -> {
+ assertThat(bbInputSetupMapperLayer.mapOrchestrationStatusFromAAI(value),
+ equalTo(OrchestrationStatus.PENDING_CREATE));
+ });
+ }
+
+ @Test
+ public void testMapAAICustomer() throws IOException {
+ Customer expected = mapper.readValue(new File(RESOURCE_PATH + "Customer.json"), Customer.class);
+
+ org.onap.aai.domain.yang.Customer customerAAI = mapper.readValue(new File(RESOURCE_PATH + "Customer_AAI.json"),
+ org.onap.aai.domain.yang.Customer.class);
+
+ Customer actual = bbInputSetupMapperLayer.mapAAICustomer(customerAAI);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapAAIServiceSubscription() throws IOException {
+ ServiceSubscription expected = mapper.readValue(new File(RESOURCE_PATH + "ServiceSubscriptionExpected.json"),
+ ServiceSubscription.class);
+
+ org.onap.aai.domain.yang.ServiceSubscription svcSubscriptionAAI =
+ mapper.readValue(new File(RESOURCE_PATH + "ServiceSubscription_AAI.json"),
+ org.onap.aai.domain.yang.ServiceSubscription.class);
+
+ ServiceSubscription actual = bbInputSetupMapperLayer.mapAAIServiceSubscription(svcSubscriptionAAI);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapAAIProject() throws IOException {
+ Project expected = mapper.readValue(new File(RESOURCE_PATH + "Project.json"), Project.class);
+
+ org.onap.aai.domain.yang.Project projectAAI = new org.onap.aai.domain.yang.Project();
+ projectAAI.setProjectName("projectName");
+
+ Project actual = bbInputSetupMapperLayer.mapAAIProject(projectAAI);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapRequestProject() throws IOException {
+ Project expected = mapper.readValue(new File(RESOURCE_PATH + "Project.json"), Project.class);
+
+ org.onap.so.serviceinstancebeans.Project requestProject = new org.onap.so.serviceinstancebeans.Project();
+ requestProject.setProjectName("projectName");
+
+ Project actual = bbInputSetupMapperLayer.mapRequestProject(requestProject);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapAAIOwningEntity() throws IOException {
+ OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH + "OwningEntity.json"), OwningEntity.class);
+
+ org.onap.aai.domain.yang.OwningEntity entityAAI = new org.onap.aai.domain.yang.OwningEntity();
+ entityAAI.setOwningEntityId("owningEntityId");
+ entityAAI.setOwningEntityName("owningEntityName");
+
+ OwningEntity actual = bbInputSetupMapperLayer.mapAAIOwningEntity(entityAAI);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapRequestOwningEntity() throws IOException {
+ OwningEntity expected = mapper.readValue(new File(RESOURCE_PATH + "OwningEntity.json"), OwningEntity.class);
+
+ org.onap.so.serviceinstancebeans.OwningEntity requestOwningEntity =
+ new org.onap.so.serviceinstancebeans.OwningEntity();
+ requestOwningEntity.setOwningEntityId("owningEntityId");
+ requestOwningEntity.setOwningEntityName("owningEntityName");
+
+ OwningEntity actual = bbInputSetupMapperLayer.mapRequestOwningEntity(requestOwningEntity);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapAAIPlatform() throws IOException {
+ Platform expected = mapper.readValue(new File(RESOURCE_PATH + "Platform.json"), Platform.class);
+
+ org.onap.aai.domain.yang.Platform platformAAI = new org.onap.aai.domain.yang.Platform();
+ platformAAI.setPlatformName("platformName");
+
+ Platform actual = bbInputSetupMapperLayer.mapAAIPlatform(platformAAI);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapAAILineOfBusiness() throws IOException {
+ LineOfBusiness expected =
+ mapper.readValue(new File(RESOURCE_PATH + "LineOfBusiness.json"), LineOfBusiness.class);
+
+ org.onap.aai.domain.yang.LineOfBusiness lobAAI = new org.onap.aai.domain.yang.LineOfBusiness();
+ lobAAI.setLineOfBusinessName("lineOfBusinessName");
+
+ LineOfBusiness actual = bbInputSetupMapperLayer.mapAAILineOfBusiness(lobAAI);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapAAINetworkPolicy() throws JsonParseException, JsonMappingException, IOException {
+ NetworkPolicy expectedNetworkPolicy =
+ mapper.readValue(new File(RESOURCE_PATH + "NetworkPolicy.json"), NetworkPolicy.class);
+
+ org.onap.aai.domain.yang.NetworkPolicy aaiNetworkPolicy = new org.onap.aai.domain.yang.NetworkPolicy();
+ aaiNetworkPolicy.setNetworkPolicyId("networkPolicyId");
+ aaiNetworkPolicy.setNetworkPolicyFqdn("networkPolicyFqdn");
+ aaiNetworkPolicy.setHeatStackId("heatStackId");
+ aaiNetworkPolicy.setResourceVersion("resourceVersion");
+
+ NetworkPolicy actualNetworkPolicy = bbInputSetupMapperLayer.mapAAINetworkPolicy(aaiNetworkPolicy);
+
+ assertThat(actualNetworkPolicy, sameBeanAs(expectedNetworkPolicy));
+ }
+
+ @Test
+ public void testMapAAIVolumeGroup() throws JsonParseException, JsonMappingException, IOException {
+ VolumeGroup expectedVolumeGroup =
+ mapper.readValue(new File(RESOURCE_PATH + "VolumeGroup.json"), VolumeGroup.class);
+
+ org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = mapper.readValue(
+ new File(RESOURCE_PATH + "VolumeGroup_AAI.json"), org.onap.aai.domain.yang.VolumeGroup.class);
+
+ VolumeGroup actualVolumeGroup = bbInputSetupMapperLayer.mapAAIVolumeGroup(aaiVolumeGroup);
+
+ assertThat(actualVolumeGroup, sameBeanAs(expectedVolumeGroup));
+ }
+
+ @Test
+ public void testMapCatalogServiceIntoServiceInstance() throws IOException {
+ ModelInfoServiceInstance expected = mapper.readValue(new File(RESOURCE_PATH + "ModelInfoServiceInstance.json"),
+ ModelInfoServiceInstance.class);
+
+ Service catalogService = mapper.readValue(new File(RESOURCE_PATH + "CatalogServiceInput.json"), Service.class);
+
+ ModelInfoServiceInstance actual = bbInputSetupMapperLayer.mapCatalogServiceIntoServiceInstance(catalogService);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapCatalogInstanceGroupToInstanceGroup() throws IOException {
+ ModelInfoInstanceGroup expected =
+ mapper.readValue(new File(RESOURCE_PATH + "ModelInfoInstanceGroup.json"), ModelInfoInstanceGroup.class);
+
+ InstanceGroup instanceGroup =
+ mapper.readValue(new File(RESOURCE_PATH + "InstanceGroup.json"), InstanceGroup.class);
+ instanceGroup.setCollectionInstanceGroupCustomizations(new ArrayList<>());
+ CollectionResourceInstanceGroupCustomization collectionInstanceGroupCust =
+ new CollectionResourceInstanceGroupCustomization();
+ collectionInstanceGroupCust.setModelCustomizationUUID("modelCustomizationUUID");
+ collectionInstanceGroupCust.setFunction("function");
+ collectionInstanceGroupCust.setDescription("description");
+ instanceGroup.getCollectionInstanceGroupCustomizations().add(collectionInstanceGroupCust);
+ CollectionResourceCustomization collectionResourceCust = new CollectionResourceCustomization();
+ collectionResourceCust.setModelCustomizationUUID("modelCustomizationUUID");
+ ModelInfoInstanceGroup actual =
+ bbInputSetupMapperLayer.mapCatalogInstanceGroupToInstanceGroup(collectionResourceCust, instanceGroup);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapCollectionNetworkResourceCustToNetworkResourceCust() {
+ String modelCustomizationUUID = "modelCustomizationUUID";
+ String modelInstanceName = "modelInstanceName";
+ String networkRole = "networkRole";
+ String networkScope = "networkScope";
+ String networkTechnology = "networkTechnology";
+ String networkType = "networkType";
+
+ NetworkResourceCustomization expected = new NetworkResourceCustomization();
+ expected.setModelCustomizationUUID(modelCustomizationUUID);
+ expected.setModelInstanceName(modelInstanceName);
+ expected.setNetworkRole(networkRole);
+ expected.setNetworkScope(networkScope);
+ expected.setNetworkTechnology(networkTechnology);
+ expected.setNetworkType(networkType);
+ CollectionNetworkResourceCustomization collectionNetworkResourceCust =
+ new CollectionNetworkResourceCustomization();
+ collectionNetworkResourceCust.setModelCustomizationUUID(modelCustomizationUUID);
+ collectionNetworkResourceCust.setModelInstanceName(modelInstanceName);
+ collectionNetworkResourceCust.setNetworkRole(networkRole);
+ collectionNetworkResourceCust.setNetworkScope(networkScope);
+ collectionNetworkResourceCust.setNetworkTechnology(networkTechnology);
+ collectionNetworkResourceCust.setNetworkType(networkType);
+ NetworkResourceCustomization actual = bbInputSetupMapperLayer
+ .mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapCatalogCollectionToCollection() throws IOException {
+ ModelInfoCollection expected =
+ mapper.readValue(new File(RESOURCE_PATH + "ModelInfoCollection.json"), ModelInfoCollection.class);
+
+ CollectionResourceCustomization collectionCust =
+ mapper.readValue(new File(RESOURCE_PATH + "CollectionResourceCustomization.json"),
+ CollectionResourceCustomization.class);
+
+ CollectionResource collectionResource =
+ mapper.readValue(new File(RESOURCE_PATH + "CollectionResource.json"), CollectionResource.class);
+
+ ModelInfoCollection actual =
+ bbInputSetupMapperLayer.mapCatalogCollectionToCollection(collectionCust, collectionResource);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapAAIServiceInstanceIntoServiceInstance() throws IOException {
+ ServiceInstance expected = mapper.readValue(
+ new File(RESOURCE_PATH + "ServiceInstance_aaiServiceInstanceToSI.json"), ServiceInstance.class);
+
+ org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI =
+ mapper.readValue(new File(RESOURCE_PATH + "ServiceInstanceAAIInput.json"),
+ org.onap.aai.domain.yang.ServiceInstance.class);
+
+ ServiceInstance actual = bbInputSetupMapperLayer.mapAAIServiceInstanceIntoServiceInstance(serviceInstanceAAI);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testSetPlatformAndLOB() throws IOException {
+ ServiceInstance expected = mapper.readValue(
+ new File(RESOURCE_PATH + "ServiceInstance_aaiPlatformAndLOBToSI.json"), ServiceInstance.class);
+
+ Map<ResourceKey, String> resourcesToBeOrchestrated = new HashMap<>();
+ resourcesToBeOrchestrated.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
+ Platform platformMSO = new Platform();
+ platformMSO.setPlatformName("platformName");
+ LineOfBusiness lineOfBusinessMSO = new LineOfBusiness();
+ lineOfBusinessMSO.setLineOfBusinessName("lineOfBusinessName");
+
+ ServiceInstance actual = mapper.readValue(
+ new File(RESOURCE_PATH + "ServiceInstanceAAIPlatformAndLOBInput.json"), ServiceInstance.class);
+
+ bbInputSetupMapperLayer.setPlatformAndLOBIntoServiceInstance(platformMSO, lineOfBusinessMSO, actual,
+ resourcesToBeOrchestrated);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapAAIL3NetworkIntoL3Network() throws IOException {
+ L3Network expected = mapper.readValue(new File(RESOURCE_PATH + "l3NetworkExpected.json"), L3Network.class);
+
+ org.onap.aai.domain.yang.L3Network aaiL3Network = mapper.readValue(
+ new File(RESOURCE_PATH + "aaiL3NetworkInput.json"), org.onap.aai.domain.yang.L3Network.class);
+
+ L3Network actual = bbInputSetupMapperLayer.mapAAIL3Network(aaiL3Network);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapAAIGenericVnfIntoGenericVnf() throws IOException {
+ GenericVnf expected = mapper.readValue(new File(RESOURCE_PATH + "GenericVnfExpected.json"), GenericVnf.class);
+ org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = mapper.readValue(
+ new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), org.onap.aai.domain.yang.GenericVnf.class);
+
+ GenericVnf actual = bbInputSetupMapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapAAICollectionIntoCollection() throws JsonParseException, JsonMappingException, IOException {
+ org.onap.aai.domain.yang.Collection aaiCollection = mapper
+ .readValue(new File(RESOURCE_PATH + "CollectionInput.json"), org.onap.aai.domain.yang.Collection.class);
+
+ Collection expectedCollection =
+ mapper.readValue(new File(RESOURCE_PATH + "CollectionExpected.json"), Collection.class);
+
+ Collection actualCollection = bbInputSetupMapperLayer.mapAAICollectionIntoCollection(aaiCollection);
+
+ assertThat(actualCollection, sameBeanAs(expectedCollection));
+ }
+
+ @Test
+ public void testMapAAIInstanceGroupIntoInstanceGroup()
+ throws JsonParseException, JsonMappingException, IOException {
+ org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = mapper.readValue(
+ new File(RESOURCE_PATH + "InstanceGroupInput.json"), org.onap.aai.domain.yang.InstanceGroup.class);
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup expectedInstanceGroup =
+ mapper.readValue(new File(RESOURCE_PATH + "InstanceGroupExpected.json"),
+ org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup.class);
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup actualInstanceGroup =
+ bbInputSetupMapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstanceGroup);
+
+ assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
+ }
+
+ @Test
+ public void testMapAAIRouteTableReferenceIntoRouteTableReference()
+ throws JsonParseException, JsonMappingException, IOException {
+ org.onap.aai.domain.yang.RouteTableReference aaiRouteTableReference =
+ mapper.readValue(new File(RESOURCE_PATH + "RouteTableReferenceInput.json"),
+ org.onap.aai.domain.yang.RouteTableReference.class);
+
+ RouteTableReference expectedRouteTableReference = mapper
+ .readValue(new File(RESOURCE_PATH + "RouteTableReferenceExpected.json"), RouteTableReference.class);
+
+ RouteTableReference actualRouteTableReference =
+ bbInputSetupMapperLayer.mapAAIRouteTableReferenceIntoRouteTableReference(aaiRouteTableReference);
+
+ assertThat(actualRouteTableReference, sameBeanAs(expectedRouteTableReference));
+ }
+
+ @Test
+ public void testMapCatalogNetworkToNetwork() throws JsonParseException, JsonMappingException, IOException {
+ NetworkResourceCustomization networkResourceCustomization = mapper.readValue(
+ new File(RESOURCE_PATH + "NetworkResourceCustomizationInput.json"), NetworkResourceCustomization.class);
+
+ ModelInfoNetwork expectedModelInfoNetwork =
+ mapper.readValue(new File(RESOURCE_PATH + "ModelInfoNetworkExpected.json"), ModelInfoNetwork.class);
+
+ ModelInfoNetwork actualModelInfoNetwork =
+ bbInputSetupMapperLayer.mapCatalogNetworkToNetwork(networkResourceCustomization);
+
+ assertThat(actualModelInfoNetwork, sameBeanAs(expectedModelInfoNetwork));
+ }
+
+ @Test
+ public void testMapCatalogVnfToVnf() throws IOException {
+ VnfResourceCustomization vnfResourceCustomization = mapper.readValue(
+ new File(RESOURCE_PATH + "VnfResourceCustomizationInput.json"), VnfResourceCustomization.class);
+
+ ModelInfoGenericVnf expectedModelInfoGenericVnf = mapper
+ .readValue(new File(RESOURCE_PATH + "ModelInfoGenericVnfExpected.json"), ModelInfoGenericVnf.class);
+
+ ModelInfoGenericVnf actualModelInfoGenericVnf =
+ bbInputSetupMapperLayer.mapCatalogVnfToVnf(vnfResourceCustomization);
+
+ assertThat(actualModelInfoGenericVnf, sameBeanAs(expectedModelInfoGenericVnf));
+ }
+
+ @Test
+ public void testMapCatalogVfModuleToVfModule() throws JsonParseException, JsonMappingException, IOException {
+ VfModuleCustomization vfResourceCustomization = mapper
+ .readValue(new File(RESOURCE_PATH + "VfModuleCustomizationInput.json"), VfModuleCustomization.class);
+
+ ModelInfoVfModule expectedModelInfoVfModule =
+ mapper.readValue(new File(RESOURCE_PATH + "ModelInfoVfModuleExpected.json"), ModelInfoVfModule.class);
+
+ ModelInfoVfModule actualModelInfoVfModule =
+ bbInputSetupMapperLayer.mapCatalogVfModuleToVfModule(vfResourceCustomization);
+
+ assertThat(actualModelInfoVfModule, sameBeanAs(expectedModelInfoVfModule));
+ }
+
+ @Test
+ public void testMapRequestPlatform() throws JsonParseException, JsonMappingException, IOException {
+ org.onap.so.serviceinstancebeans.Platform platform = mapper.readValue(
+ new File(RESOURCE_PATH + "RequestPlatformInput.json"), org.onap.so.serviceinstancebeans.Platform.class);
+
+ Platform expectedPlatform = mapper.readValue(new File(RESOURCE_PATH + "PlatformExpected.json"), Platform.class);
+
+ Platform actualPlatform = bbInputSetupMapperLayer.mapRequestPlatform(platform);
+
+ assertThat(actualPlatform, sameBeanAs(expectedPlatform));
+ }
+
+ @Test
+ public void testMapRequestLineOfBusiness() throws JsonParseException, JsonMappingException, IOException {
+ org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness =
+ mapper.readValue(new File(RESOURCE_PATH + "RequestLineOfBusinessInput.json"),
+ org.onap.so.serviceinstancebeans.LineOfBusiness.class);
+
+ LineOfBusiness expectedLineOfBusiness =
+ mapper.readValue(new File(RESOURCE_PATH + "LineOfBusinessExpected.json"), LineOfBusiness.class);
+
+ LineOfBusiness actualLineOfBusiness = bbInputSetupMapperLayer.mapRequestLineOfBusiness(lineOfBusiness);
+
+ assertThat(actualLineOfBusiness, sameBeanAs(expectedLineOfBusiness));
+ }
+
+ @Test
+ public void testMapAAIConfiguration() throws JsonParseException, JsonMappingException, IOException {
+ org.onap.aai.domain.yang.Configuration configurationAAI = mapper.readValue(
+ new File(RESOURCE_PATH + "ConfigurationInput.json"), org.onap.aai.domain.yang.Configuration.class);
+
+ Configuration expectedConfiguration =
+ mapper.readValue(new File(RESOURCE_PATH + "ConfigurationExpected.json"), Configuration.class);
+
+ Configuration actualConfiguration = bbInputSetupMapperLayer.mapAAIConfiguration(configurationAAI);
+
+ assertThat(actualConfiguration, sameBeanAs(expectedConfiguration));
+ }
+
+ @Test
+ public void testMapRequestContext() throws IOException {
+ RequestContext expected =
+ mapper.readValue(new File(RESOURCE_PATH + "RequestContextExpected.json"), RequestContext.class);
+
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
+ RequestContext actual = bbInputSetupMapperLayer.mapRequestContext(requestDetails);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapOrchestrationContext() throws IOException {
+ OrchestrationContext expected = new OrchestrationContext();
+ expected.setIsRollbackEnabled(true);
+
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
+
+ OrchestrationContext actual = bbInputSetupMapperLayer.mapOrchestrationContext(requestDetails);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapLocationContext() {
+ CloudRegion expected = new CloudRegion();
+ expected.setCloudOwner("test-owner-name");
+ expected.setLcpCloudRegionId("cloudRegionId");
+ expected.setComplex("complexName");
+ expected.setTenantId("tenantId");
+ CloudConfiguration cloudConfig = new CloudConfiguration();
+ cloudConfig.setTenantId("tenantId");
+ cloudConfig.setLcpCloudRegionId("cloudRegionId");
+ cloudConfig.setAicNodeClli("aicNodeClli");
+ org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
+ cloudRegion.setCloudOwner("test-owner-name");
+ cloudRegion.setCloudRegionId("cloudRegionId");
+ cloudRegion.setComplexName("complexName");
+
+ CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapCloudRegion() {
+ CloudRegion expected = new CloudRegion();
+ expected.setCloudOwner("test-owner-name");
+ expected.setLcpCloudRegionId("cloudRegionId");
+ expected.setTenantId("tenantId");
+ expected.setCloudRegionVersion("cloudRegionVersion");
+
+ CloudConfiguration cloudConfig = new CloudConfiguration();
+ cloudConfig.setTenantId("tenantId");
+ cloudConfig.setLcpCloudRegionId("cloudRegionId");
+ cloudConfig.setAicNodeClli("aicNodeClli");
+
+ org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
+ cloudRegion.setCloudOwner("test-owner-name");
+ cloudRegion.setCloudRegionId("cloudRegionId");
+ cloudRegion.setCloudRegionVersion("cloudRegionVersion");
+
+ CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(cloudConfig, cloudRegion);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapTenant() {
+ Tenant expected = new Tenant();
+ expected.setTenantId("tenantId");
+ expected.setTenantName("tenantName");
+ expected.setTenantContext("tenantContext");
+
+ org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant();
+ aaiTenant.setTenantId("tenantId");
+ aaiTenant.setTenantName("tenantName");
+ aaiTenant.setTenantContext("tenantContext");
+
+ Tenant actual = bbInputSetupMapperLayer.mapTenant(aaiTenant);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapCloudRegionWithNullCheck() {
+ CloudRegion expected = new CloudRegion();
+
+ CloudRegion actual = bbInputSetupMapperLayer.mapCloudRegion(null, null);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testmapCatalogConfigurationToConfiguration() {
+ String modelCustUUID = "modelCustomizationUUID";
+ String modelInvariantUUID = "modelInvariantUUID";
+ String modelVersionUUID = "modelUUID";
+ String policyName = "policyName";
+ ModelInfoConfiguration expected = new ModelInfoConfiguration();
+ expected.setModelCustomizationId(modelCustUUID);
+ expected.setModelInvariantId(modelInvariantUUID);
+ expected.setModelVersionId(modelVersionUUID);
+ expected.setPolicyName(policyName);
+ ConfigurationResourceCustomization configurationResourceCustomization =
+ new ConfigurationResourceCustomization();
+ configurationResourceCustomization.setModelCustomizationUUID(modelCustUUID);
+ configurationResourceCustomization.setConfigurationResource(new ConfigurationResource());
+ configurationResourceCustomization.getConfigurationResource().setModelInvariantUUID(modelInvariantUUID);
+ configurationResourceCustomization.getConfigurationResource().setModelUUID(modelVersionUUID);
+ CvnfcConfigurationCustomization policyNameTable = new CvnfcConfigurationCustomization();
+ policyNameTable.setCvnfcCustomization(new CvnfcCustomization());
+ policyNameTable.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
+ policyNameTable.setPolicyName(policyName);
+
+ ModelInfoConfiguration actual = bbInputSetupMapperLayer
+ .mapCatalogConfigurationToConfiguration(configurationResourceCustomization, policyNameTable);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testmapCatalogConfigurationToFabricConfiguration() {
+ String modelCustUUID = "modelCustomizationUUID";
+ String modelInvariantUUID = "modelInvariantUUID";
+ String modelVersionUUID = "modelUUID";
+ String policyName = "policyName";
+ ModelInfoConfiguration expected = new ModelInfoConfiguration();
+ expected.setModelCustomizationId(modelCustUUID);
+ expected.setModelInvariantId(modelInvariantUUID);
+ expected.setModelVersionId(modelVersionUUID);
+ expected.setPolicyName(policyName);
+
+ CvnfcConfigurationCustomization fabricCustomization = new CvnfcConfigurationCustomization();
+ fabricCustomization.setCvnfcCustomization(new CvnfcCustomization());
+ fabricCustomization.getCvnfcCustomization().setVnfcCustomization(new VnfcCustomization());
+ fabricCustomization.setPolicyName(policyName);
+ fabricCustomization.setModelCustomizationUUID(modelCustUUID);
+
+ ConfigurationResource configurationResource = new ConfigurationResource();
+ configurationResource.setModelUUID(modelVersionUUID);
+ configurationResource.setModelInvariantUUID(modelInvariantUUID);
+ fabricCustomization.setConfigurationResource(configurationResource);
+
+ ModelInfoConfiguration actual =
+ bbInputSetupMapperLayer.mapCatalogConfigurationToConfiguration(fabricCustomization);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapNameValueUserParams() throws IOException {
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
+ Map<String, Object> actual =
+ bbInputSetupMapperLayer.mapNameValueUserParams(requestDetails.getRequestParameters());
+
+ assertTrue(actual.containsKey("mns_vfw_protected_route_prefixes"));
+ assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString()
+ .contains("interface_route_table_routes_route"));
+ assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("1.1.1.1/32"));
+ assertTrue(actual.get("mns_vfw_protected_route_prefixes").toString().contains("0::1/128"));
+ assertTrue(actual.containsKey("name1"));
+ assertTrue(actual.containsValue("value1"));
+ assertTrue(actual.get("name1").equals("value1"));
+
+ assertFalse(actual.containsKey("ignore"));
+ assertFalse(actual.containsValue("ignore"));
+ }
+
+ @Test
+ public void testMapRequestParameters() throws IOException {
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_mapReqContext.json"), RequestDetails.class);
+ RequestParameters actual = bbInputSetupMapperLayer.mapRequestParameters(requestDetails.getRequestParameters());
+
+ assertEquals(actual.getUsePreload(), requestDetails.getRequestParameters().getUsePreload());
+ assertEquals(actual.getSubscriptionServiceType(),
+ requestDetails.getRequestParameters().getSubscriptionServiceType());
+ assertEquals(actual.getPayload(), requestDetails.getRequestParameters().getPayload());
+ }
+
+ protected RequestParameters mapRequestParameters(
+ org.onap.so.serviceinstancebeans.RequestParameters requestParameters) {
+ RequestParameters requestParams = new RequestParameters();
+ requestParams.setaLaCarte(requestParameters.getALaCarte());
+ requestParams.setUsePreload(requestParameters.getUsePreload());
+ requestParams.setSubscriptionServiceType(requestParameters.getSubscriptionServiceType());
+ requestParams.setUserParams(requestParameters.getUserParams());
+ requestParams.setPayload(requestParameters.getPayload());
+ return requestParams;
+ }
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
index 8d0b2f60e1..ad1918e6da 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java
@@ -34,7 +34,6 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -43,7 +42,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.junit.Assert;
import org.junit.Before;
@@ -116,2624 +114,2684 @@ import org.onap.so.serviceinstancebeans.RequestInfo;
import org.onap.so.serviceinstancebeans.RequestParameters;
import org.onap.so.serviceinstancebeans.Resources;
import org.onap.so.serviceinstancebeans.SubscriberInfo;
-
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+
@RunWith(MockitoJUnitRunner.class)
public class BBInputSetupTest {
- private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
-
- protected ObjectMapper mapper = new ObjectMapper();
- private static final String CLOUD_OWNER = "CloudOwner";
-
- @Spy
- private BBInputSetup SPY_bbInputSetup = new BBInputSetup();
-
- @Mock
- private BBInputSetupUtils SPY_bbInputSetupUtils;
-
- @Mock
- private CloudInfoFromAAI SPY_cloudInfoFromAAI;
-
- @Spy
- private BBInputSetupMapperLayer bbInputSetupMapperLayer;
-
- @Before
- public void setup(){
- SPY_bbInputSetup.setBbInputSetupUtils(SPY_bbInputSetupUtils);
- SPY_bbInputSetup.setMapperLayer(bbInputSetupMapperLayer);
- SPY_bbInputSetup.setCloudInfoFromAAI(SPY_cloudInfoFromAAI);
- }
-
- @Test
- public void testGetVolumeGroupIdRelatedToVfModule() {
- String expected = "volumeGroupId";
- String modelCustomizationId = "modelCustomizationId";
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelCustomizationId(modelCustomizationId);
- String cloudOwner = "cloudOwner";
- String cloudRegionId = "cloudRegionId";
- String volumeGroupId = "volumeGroupId";
- GenericVnf vnf = new GenericVnf();
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId(expected);
- vnf.getVolumeGroups().add(volumeGroup);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, null);
- org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = new org.onap.aai.domain.yang.VolumeGroup();
- aaiVolumeGroup.setModelCustomizationId(modelCustomizationId);
- doReturn(aaiVolumeGroup).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(cloudOwner, cloudRegionId, volumeGroupId);
-
- Optional<String> actual = SPY_bbInputSetup.getVolumeGroupIdRelatedToVfModule(vnf, modelInfo, cloudOwner, cloudRegionId, lookupKeyMap);
-
- assertEquals(expected, actual.get());
- }
-
- @Test
- public void testGetAlaCarteServiceInstance() throws Exception {
- ServiceInstance expected = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
- ServiceInstance.class);
- RequestDetails requestDetails = new RequestDetails();
- RequestInfo requestInfo = new RequestInfo();
- requestInfo.setInstanceName("SharansInstanceName");
- requestDetails.setRequestInfo(requestInfo);
- Customer customer = new Customer();
- String serviceInstanceId = "SharansInstanceId";
- boolean aLaCarte = true;
- Service service = new Service();
- service.setModelUUID("modelUUID");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelUuid("modelUUID");
- expected.setModelInfoServiceInstance(modelInfoServiceInstance);
- org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
- serviceInstanceAAI.setModelVersionId("modelUUIDDifferent");
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- String bbName = AssignFlows.SERVICE_INSTANCE.toString();
- Service differentService = new Service();
- differentService.setModelUUID("modelUUIDDifferent");
-
- doReturn(expected).when(SPY_bbInputSetup).getServiceInstanceHelper(requestDetails, customer, null, null,
- lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
- doReturn(serviceInstanceAAI).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(serviceInstanceId);
- doReturn(differentService).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(serviceInstanceAAI.getModelVersionId());
- doReturn(expected.getModelInfoServiceInstance()).when(bbInputSetupMapperLayer)
- .mapCatalogServiceIntoServiceInstance(differentService);
-
- ServiceInstance actual = SPY_bbInputSetup.getALaCarteServiceInstance(service, requestDetails, customer, null,
- null, lookupKeyMap, serviceInstanceId, aLaCarte, bbName);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test(expected = Exception.class)
- public void testGetAlaCarteServiceInstanceException() throws Exception {
- ServiceInstance expected = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
- ServiceInstance.class);
- RequestDetails requestDetails = new RequestDetails();
- RequestInfo requestInfo = new RequestInfo();
- requestInfo.setInstanceName("SharansInstanceName");
- requestDetails.setRequestInfo(requestInfo);
- Customer customer = new Customer();
- String serviceInstanceId = "SharansInstanceId";
- boolean aLaCarte = true;
- Service service = new Service();
- service.setModelUUID("modelUUID");
- ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
- modelInfoServiceInstance.setModelUuid("modelUUID");
- expected.setModelInfoServiceInstance(modelInfoServiceInstance);
- org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
- serviceInstanceAAI.setModelVersionId("modelUUIDDifferent");
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- String bbName = AssignFlows.SERVICE_INSTANCE.toString();
- Service differentService = new Service();
- differentService.setModelUUID("modelUUIDDifferent");
-
- doReturn(expected).when(SPY_bbInputSetup).getServiceInstanceHelper(requestDetails, customer, null, null,
- lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
- doReturn(serviceInstanceAAI).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(serviceInstanceId);
- doReturn(null).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(serviceInstanceAAI.getModelVersionId());
-
- ServiceInstance actual = SPY_bbInputSetup.getALaCarteServiceInstance(service, requestDetails, customer, null,
- null, lookupKeyMap, serviceInstanceId, aLaCarte, bbName);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetCustomerAndServiceSubscription() throws JsonParseException, JsonMappingException, IOException {
- RequestDetails requestDetails = mapper.readValue(
- new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
- SubscriberInfo subscriberInfo = new SubscriberInfo();
- subscriberInfo.setGlobalSubscriberId("globalSubscriberId");
- RequestParameters requestParams = new RequestParameters();
- requestParams.setSubscriptionServiceType("subscriptionServiceType");
- requestDetails.setRequestParameters(requestParams);
- requestDetails.setSubscriberInfo(subscriberInfo);
- String resourceId = "resourceId";
- Customer expected = new Customer();
- expected.setGlobalCustomerId("globalCustomerId");
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- serviceSubscription.setServiceType("subscriptionServiceType");
-
- doReturn(expected).when(this.SPY_bbInputSetup).getCustomerFromRequest(requestDetails);
- doReturn(serviceSubscription).when(this.SPY_bbInputSetup).getServiceSubscription(requestDetails, expected);
-
- Customer actual = this.SPY_bbInputSetup.getCustomerAndServiceSubscription(requestDetails, resourceId);
-
- assertThat(actual, sameBeanAs(expected));
-
- requestDetails.setSubscriberInfo(null);
-
-
- assertThat(actual, sameBeanAs(expected));
-
- }
-
- @Test
- public void testSetHomingFlag() throws JsonParseException, JsonMappingException, IOException {
- GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- GenericVnf genericVnfExpected = new GenericVnf();
- genericVnfExpected.setVnfId("vnfId");
- genericVnfExpected.setCallHoming(true);
- expected.getCustomer().getServiceSubscription().getServiceInstances().get(0).getVnfs().add(genericVnfExpected);
- boolean homing = true;
- GenericVnf genericVnfActual = new GenericVnf();
- genericVnfActual.setVnfId("vnfId");
- genericVnfActual.setCallHoming(false);
- GeneralBuildingBlock actual = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- actual.getCustomer().getServiceSubscription().getServiceInstances().get(0).getVnfs().add(genericVnfActual);
-
- SPY_bbInputSetup.setHomingFlag(actual, homing, lookupKeyMap);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetExecuteBBFromExecution() throws IOException {
- ExecuteBuildingBlock expected = new ExecuteBuildingBlock();
- BuildingBlock bb = new BuildingBlock();
- bb.setBpmnFlowName("AssignServiceInstanceBB");
- expected.setBuildingBlock(bb);
- expected.setRequestId("00032ab7-3fb3-42e5-965d-8ea592502017");
- DelegateExecution execution = Mockito.mock(DelegateExecution.class);
- doReturn(expected).when(execution).getVariable(any(String.class));
- ExecuteBuildingBlock actual = SPY_bbInputSetup.getExecuteBBFromExecution(execution);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetGBB() throws Exception {
- GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
-
- ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock();
- executeBB.setRequestId("requestId");
- RequestDetails requestDetails = new RequestDetails();
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelType(ModelType.service);
- requestDetails.setModelInfo(modelInfo);
- RequestParameters requestParams = new RequestParameters();
- requestParams.setaLaCarte(true);
- requestDetails.setRequestParameters(requestParams);
- doReturn(requestDetails).when(SPY_bbInputSetupUtils).getRequestDetails(executeBB.getRequestId());
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- String resourceId = "123";
- String requestAction = "createInstance";
- doReturn(expected).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId);
- doNothing().when(SPY_bbInputSetup).populateLookupKeyMapWithIds(executeBB.getWorkflowResourceIds(),lookupKeyMap);
- boolean aLaCarte = true;
- GeneralBuildingBlock actual = SPY_bbInputSetup.getGBB(executeBB, lookupKeyMap, requestAction, aLaCarte,
- resourceId, null);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetGBBCM() throws Exception {
- GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockCMExpected.json"),
- GeneralBuildingBlock.class);
-
- ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock();
- executeBB.setRequestId("requestId");
- RequestDetails requestDetails = new RequestDetails();
- requestDetails.setModelInfo(null);
- RequestParameters requestParams = new RequestParameters();
- requestParams.setaLaCarte(true);
- requestDetails.setRequestParameters(requestParams);
- RequestInfo requestInfo = new RequestInfo();
- requestInfo.setSuppressRollback(true);
- requestInfo.setSource("VID");
- requestDetails.setRequestInfo(requestInfo);
- CloudConfiguration cloudConfiguration = new CloudConfiguration();
- cloudConfiguration.setLcpCloudRegionId("myRegionId");
- requestDetails.setCloudConfiguration(cloudConfiguration);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- String resourceId = "123";
- String requestAction = "createInstance";
-
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnf-001");
-
- doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(SPY_bbInputSetupUtils).getAAIGenericVnf(ArgumentMatchers.isA(String.class));
- doReturn(null).when(bbInputSetupMapperLayer).mapAAIGenericVnfIntoGenericVnf(ArgumentMatchers.isA(org.onap.aai.domain.yang.GenericVnf.class));
- GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBCM(executeBB, requestDetails, lookupKeyMap, requestAction,
- resourceId);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetGBBCMAddMembersAction() throws Exception {
- GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockInstanceGroupExpected.json"),
- GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper.readValue(
- new File(RESOURCE_PATH + "RequestDetailsInput_instanceGroupAddMembers.json"), RequestDetails.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- String requestAction = "addMembers";
- String instanceGroupId = "instance-group-001";
-
- WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
- workflowResourceIds.setInstanceGroupId(instanceGroupId);
- executeBB.setWorkflowResourceIds(workflowResourceIds);
-
- lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupId);
-
- org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = new org.onap.aai.domain.yang.InstanceGroup();
- aaiInstanceGroup.setId(instanceGroupId);
- aaiInstanceGroup.setInstanceGroupName("test instance group 1");
-
- org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
- aaiServiceInstance.setServiceInstanceId("service-instance-001");
- aaiServiceInstance.setServiceInstanceName("test service instance 1");
- Optional<org.onap.aai.domain.yang.ServiceInstance> optSI = Optional.of(aaiServiceInstance);
-
- org.onap.aai.domain.yang.GenericVnf vnf1 = new org.onap.aai.domain.yang.GenericVnf();
- vnf1.setVnfId("vnf-001");
- vnf1.setVnfName("test vnf 1");
-
- org.onap.aai.domain.yang.GenericVnf vnf2 = new org.onap.aai.domain.yang.GenericVnf();
- vnf2.setVnfId("vnf-002");
- vnf2.setVnfName("test vnf 2");
-
- doReturn(aaiInstanceGroup).when(SPY_bbInputSetupUtils).getAAIInstanceGroup(instanceGroupId);
- doReturn(optSI).when(SPY_bbInputSetupUtils).getRelatedServiceInstanceFromInstanceGroup(instanceGroupId);
- doReturn(vnf1).when(SPY_bbInputSetupUtils).getAAIGenericVnf("vnf-001");
- doReturn(vnf2).when(SPY_bbInputSetupUtils).getAAIGenericVnf("vnf-002");
-
- GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBCM(executeBB, requestDetails, lookupKeyMap,
- requestAction, instanceGroupId);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetGBBALaCarteNonService() throws Exception {
- GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper.readValue(
- new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- String requestAction = "createInstance";
- Service service = Mockito.mock(Service.class);
- ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
- String resourceId = "123";
- String vnfType = "vnfType";
- org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
- aaiServiceInstance.setModelVersionId("modelVersionId");
- org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "instanceId");
- doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
- doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId");
-
- doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(requestDetails, service, "bbName",
- serviceInstance, lookupKeyMap, resourceId, vnfType, null, null);
- doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
- doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
- executeBB, requestAction, null);
-
- GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId, vnfType);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test(expected = Exception.class)
- public void testGetGBBALaCarteNonServiceWithoutServiceModelInfo() throws Exception {
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper.readValue(
- new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- String requestAction = "createInstance";
- org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
- aaiServiceInstance.setModelVersionId("modelVersionId");
- String resourceId = "123";
- String vnfType = "vnfType";
-
- SPY_bbInputSetup.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId,
- vnfType);
- }
-
- @Test
- public void testGetGBBALaCarteNonServiceWithoutRelatedInstances() throws Exception {
- GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper.readValue(
- new File(RESOURCE_PATH + "RequestDetailsInput_withoutRelatedInstanceList.json"), RequestDetails.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- String requestAction = "createInstance";
- Service service = Mockito.mock(Service.class);
- String resourceId = "123";
- ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
- org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
- aaiServiceInstance.setModelVersionId("modelVersionId");
- org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
- String vnfType = "vnfType";
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "instanceId");
- doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
- doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId");
-
- doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(requestDetails, service, "bbName",
- serviceInstance, lookupKeyMap, resourceId, vnfType, null, null);
-
- doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
- doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
- executeBB, requestAction,null);
-
- GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId, vnfType);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetGBBALaCarteService() throws Exception {
- GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper.readValue(
- new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
-
- org.onap.so.serviceinstancebeans.Project requestProject = new org.onap.so.serviceinstancebeans.Project();
- org.onap.so.serviceinstancebeans.OwningEntity requestOwningEntity = new org.onap.so.serviceinstancebeans.OwningEntity();
- requestDetails.setProject(requestProject);
- requestDetails.setOwningEntity(requestOwningEntity);
-
- Service service = Mockito.mock(Service.class);
- Customer customer = Mockito.mock(Customer.class);
- ServiceSubscription serviceSubscription = Mockito.mock(ServiceSubscription.class);
- Project project = Mockito.mock(Project.class);
- OwningEntity owningEntity = Mockito.mock(OwningEntity.class);
- ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
- String resourceId = "123";
- String requestAction = "createInstance";
- executeBB.setaLaCarte(true);
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.SERVICE_INSTANCE.toString());
- org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
-
- doReturn(service).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId());
- doReturn(project).when(bbInputSetupMapperLayer).mapRequestProject(requestDetails.getProject());
- doReturn(owningEntity).when(bbInputSetupMapperLayer)
- .mapRequestOwningEntity(requestDetails.getOwningEntity());
-
- doReturn(customer).when(SPY_bbInputSetup).getCustomerAndServiceSubscription(requestDetails, resourceId);
- doReturn(serviceInstance).when(SPY_bbInputSetup).getALaCarteServiceInstance(service, requestDetails, customer,
- project, owningEntity, lookupKeyMap, resourceId, Boolean.TRUE.equals(executeBB.isaLaCarte()),
- executeBB.getBuildingBlock().getBpmnFlowName());
- doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
- executeBB, requestAction, customer);
-
- GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetGBBALaCarteServiceFindServiceByModelVersionId() throws Exception {
- GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper.readValue(
- new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
-
- org.onap.so.serviceinstancebeans.Project requestProject = new org.onap.so.serviceinstancebeans.Project();
- org.onap.so.serviceinstancebeans.OwningEntity requestOwningEntity = new org.onap.so.serviceinstancebeans.OwningEntity();
- requestDetails.setProject(requestProject);
- requestDetails.setOwningEntity(requestOwningEntity);
-
- Service service = Mockito.mock(Service.class);
- Customer customer = Mockito.mock(Customer.class);
- ServiceSubscription serviceSubscription = Mockito.mock(ServiceSubscription.class);
- Project project = Mockito.mock(Project.class);
- OwningEntity owningEntity = Mockito.mock(OwningEntity.class);
- ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
- String resourceId = "123";
- String requestAction = "createInstance";
- executeBB.setaLaCarte(true);
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.SERVICE_INSTANCE.toString());
- org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
-
- doReturn(null).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId());
- doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelVersionAndModelInvariantUUID(
- requestDetails.getModelInfo().getModelVersion(), requestDetails.getModelInfo().getModelInvariantId());
- doReturn(project).when(bbInputSetupMapperLayer).mapRequestProject(requestDetails.getProject());
- doReturn(owningEntity).when(bbInputSetupMapperLayer)
- .mapRequestOwningEntity(requestDetails.getOwningEntity());
-
- doReturn(customer).when(SPY_bbInputSetup).getCustomerAndServiceSubscription(requestDetails, resourceId);
- doReturn(serviceInstance).when(SPY_bbInputSetup).getALaCarteServiceInstance(service, requestDetails, customer,
- project, owningEntity, lookupKeyMap, resourceId, Boolean.TRUE.equals(executeBB.isaLaCarte()),
- executeBB.getBuildingBlock().getBpmnFlowName());
- doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
- executeBB, requestAction,customer);
-
- GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetGBBALaCarteServiceNoProjectNoOE() throws Exception {
- GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper.readValue(
- new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
-
- Service service = Mockito.mock(Service.class);
- Customer customer = Mockito.mock(Customer.class);
- ServiceSubscription serviceSubscription = Mockito.mock(ServiceSubscription.class);
- ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
- String resourceId = "123";
- String requestAction = "createInstance";
- executeBB.setaLaCarte(true);
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.SERVICE_INSTANCE.toString());
- org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
-
- Map<String, String> uriKeys = new HashMap<>();
- uriKeys.put("global-customer-id", "globalCustomerId");
- uriKeys.put("service-type", "serviceType");
-
- doReturn(service).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId());
-
- doReturn(customer).when(SPY_bbInputSetup).getCustomerAndServiceSubscription(requestDetails, resourceId);
-
- doReturn(serviceInstance).when(SPY_bbInputSetup).getALaCarteServiceInstance(service, requestDetails, customer,
- null, null, lookupKeyMap, resourceId, Boolean.TRUE.equals(executeBB.isaLaCarte()),
- executeBB.getBuildingBlock().getBpmnFlowName());
- doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
- executeBB, requestAction,customer);
-
- GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetServiceInstanceHelperCreateScenario() throws Exception {
- RequestDetails requestDetails = new RequestDetails();
- RequestInfo requestInfo = new RequestInfo();
- requestInfo.setInstanceName("SharansInstanceName");
- requestDetails.setRequestInfo(requestInfo);
- Customer customer = new Customer();
- String serviceInstanceId = "SharansInstanceId";
- boolean aLaCarte = true;
- ServiceInstance expected = new ServiceInstance();
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- Service service = new Service();
- service.setModelUUID("modelUUID");
- String bbName = AssignFlows.SERVICE_INSTANCE.toString();
-
- doReturn(null).when(SPY_bbInputSetupUtils).getAAIServiceInstanceByName(requestInfo.getInstanceName(), customer);
- doReturn(null).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(serviceInstanceId);
-
-
- doReturn(expected).when(SPY_bbInputSetup).createServiceInstance(requestDetails, null, null,
- lookupKeyMap, serviceInstanceId);
-
- ServiceInstance actual = SPY_bbInputSetup.getServiceInstanceHelper(requestDetails, customer, null, null,
- lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetServiceInstanceHelperCreateScenarioExisting() throws Exception {
- RequestDetails requestDetails = new RequestDetails();
- RequestInfo requestInfo = new RequestInfo();
- requestInfo.setInstanceName("SharansInstanceName");
- requestDetails.setRequestInfo(requestInfo);
- Customer customer = new Customer();
- String serviceInstanceId = "SharansInstanceId";
- boolean aLaCarte = true;
- Service service = new Service();
- service.setModelUUID("modelUUID");
- ServiceInstance expected = new ServiceInstance();
- org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
- serviceInstanceAAI.setModelVersionId("modelUUID");
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- String bbName = AssignFlows.SERVICE_INSTANCE.toString();
-
- doReturn(serviceInstanceAAI).when(SPY_bbInputSetupUtils)
- .getAAIServiceInstanceByName(requestInfo.getInstanceName(), customer);
- doReturn(expected).when(SPY_bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
-
- ServiceInstance actual = SPY_bbInputSetup.getServiceInstanceHelper(requestDetails, customer, null, null,
- lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetServiceInstanceHelperCreateScenarioExistingNoNameButWithId() throws Exception {
- RequestDetails requestDetails = new RequestDetails();
- RequestInfo requestInfo = new RequestInfo();
- requestInfo.setInstanceName("SharansInstanceName");
- requestDetails.setRequestInfo(requestInfo);
- Customer customer = new Customer();
- String serviceInstanceId = "SharansInstanceId";
- boolean aLaCarte = true;
- Service service = new Service();
- service.setModelUUID("modelUUID");
- ServiceInstance expected = new ServiceInstance();
- org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
- serviceInstanceAAI.setModelVersionId("modelUUID");
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- String bbName = "ActivateServiceInstanceBB";
-
- doReturn(serviceInstanceAAI).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(serviceInstanceId);
- doReturn(expected).when(SPY_bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
-
- ServiceInstance actual = SPY_bbInputSetup.getServiceInstanceHelper(requestDetails, customer, null, null,
- lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetServiceInstanceHelperCreateScenarioExistingNoNameButWithIdDifferentModel() throws Exception {
- RequestDetails requestDetails = new RequestDetails();
- RequestInfo requestInfo = new RequestInfo();
- requestDetails.setRequestInfo(requestInfo);
- Customer customer = new Customer();
- String serviceInstanceId = "SharansInstanceId";
- boolean aLaCarte = true;
- Service service = new Service();
- service.setModelUUID("modelUUID");
- ServiceInstance expected = new ServiceInstance();
- org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
- serviceInstanceAAI.setModelVersionId("modelUUIDDifferent");
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- String bbName = "ActivateServiceInstanceBB";
- Service differentService = new Service();
- differentService.setModelUUID("modelUUIDDifferent");
-
- doReturn(serviceInstanceAAI).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(serviceInstanceId);
-
-
- ServiceInstance actual = SPY_bbInputSetup.getServiceInstanceHelper(requestDetails, customer, null, null,
- lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test(expected = Exception.class)
- public void testGetServiceInstanceHelperCreateScenarioExistingNoNameButWithIdExceptionThrown() throws Exception {
- RequestDetails requestDetails = new RequestDetails();
- RequestInfo requestInfo = new RequestInfo();
- requestDetails.setRequestInfo(requestInfo);
- Customer customer = new Customer();
- String serviceInstanceId = "SharansInstanceId";
- boolean aLaCarte = true;
- Service service = new Service();
- service.setModelUUID("modelUUID");
- org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
- serviceInstanceAAI.setModelVersionId("modelUUIDDifferent");
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- String bbName = AssignFlows.SERVICE_INSTANCE.toString();
-
- ServiceInstance actual = SPY_bbInputSetup.getServiceInstanceHelper(requestDetails, customer, null, null,
- lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
- }
-
- @Test
- public void testPopulateObjectsOnAssignAndCreateFlows() throws Exception {
- String bbName = AssignFlows.SERVICE_INSTANCE.toString();
- String instanceName = "instanceName";
- String vnfType = "vnfType";
- String resourceId = "networkId";
- String productFamilyId = "productFamilyId";
- Service service = Mockito.mock(Service.class);
- ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
- RequestDetails requestDetails = Mockito.mock(RequestDetails.class);
- ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
- RequestInfo requestInfo = Mockito.mock(RequestInfo.class);
- RelatedInstanceList[] relatedInstanceList = new RelatedInstanceList[] {};
- CloudConfiguration cloudConfiguration = new CloudConfiguration();
- org.onap.so.serviceinstancebeans.Platform platform = Mockito
- .mock(org.onap.so.serviceinstancebeans.Platform.class);
- org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = Mockito
- .mock(org.onap.so.serviceinstancebeans.LineOfBusiness.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
-
- doNothing().when(SPY_bbInputSetup).populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance,
- lookupKeyMap, resourceId, null);
- doReturn(modelInfo).when(requestDetails).getModelInfo();
- doReturn(productFamilyId).when(requestInfo).getProductFamilyId();
- doReturn(requestInfo).when(requestDetails).getRequestInfo();
- doReturn(instanceName).when(requestInfo).getInstanceName();
- doReturn(platform).when(requestDetails).getPlatform();
- doReturn(lineOfBusiness).when(requestDetails).getLineOfBusiness();
- doReturn(relatedInstanceList).when(requestDetails).getRelatedInstanceList();
- doReturn(cloudConfiguration).when(requestDetails).getCloudConfiguration();
-
- doReturn(ModelType.network).when(modelInfo).getModelType();
- SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
- lookupKeyMap, resourceId, vnfType, null, null);
- verify(SPY_bbInputSetup, times(1)).populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance,
- lookupKeyMap, resourceId, null);
- assertEquals("NetworkId populated", true, lookupKeyMap.get(ResourceKey.NETWORK_ID).equalsIgnoreCase(resourceId));
-
- doReturn(ModelType.vnf).when(modelInfo).getModelType();
- resourceId = "vnfId";
- doNothing().when(SPY_bbInputSetup).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness,
- service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId);
- SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
- lookupKeyMap, resourceId, vnfType, null, null);
- verify(SPY_bbInputSetup, times(1)).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness,
- service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null, productFamilyId);
- assertEquals("VnfId populated", true, lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID).equalsIgnoreCase(resourceId));
-
- doReturn(ModelType.volumeGroup).when(modelInfo).getModelType();
- resourceId = "volumeGroupId";
- doNothing().when(SPY_bbInputSetup).populateVolumeGroup(modelInfo, service, bbName, serviceInstance,
- lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null);
- SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
- lookupKeyMap, resourceId, vnfType, null, null);
- verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(modelInfo, service, bbName, serviceInstance,
- lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null);
- assertEquals("VolumeGroupId populated", true, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID).equalsIgnoreCase(resourceId));
-
- doReturn(ModelType.vfModule).when(modelInfo).getModelType();
- resourceId = "vfModuleId";
- doNothing().when(SPY_bbInputSetup).populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap,
- resourceId, relatedInstanceList, instanceName, null, cloudConfiguration);
- SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
- lookupKeyMap, resourceId, vnfType, null, null);
- verify(SPY_bbInputSetup, times(1)).populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap,
- resourceId, relatedInstanceList, instanceName, null, cloudConfiguration);
- assertEquals("VfModuleId populated", true, lookupKeyMap.get(ResourceKey.VF_MODULE_ID).equalsIgnoreCase(resourceId));
- }
-
- @Test
- public void testPopulateGBBWithSIAndAdditionalInfo() throws Exception {
- GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpectedWUserParamsInfo.json"),
- GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper.readValue(
- new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
- RequestContext requestContext = mapper.readValue(new File(RESOURCE_PATH + "RequestContextExpected.json"),
- RequestContext.class);
- ServiceInstance serviceInstance = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
- ServiceInstance.class);
- CloudConfiguration cloudConfiguration = new CloudConfiguration();
- cloudConfiguration.setTenantId("tenantId");
- requestDetails.setCloudConfiguration(cloudConfiguration);
- OrchestrationContext orchestrationContext = new OrchestrationContext();
- orchestrationContext.setIsRollbackEnabled(false);
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setCloudOwner("test-owner-name");
- cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
- cloudRegion.setComplex("complexName");
- cloudRegion.setTenantId("tenantId");
-
- Map<String, String> uriKeys = new HashMap<>();
- uriKeys.put("global-customer-id","global-customer-id");
- uriKeys.put("service-type","service-type");
-
- Customer customer = new Customer();
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- serviceSubscription.setServiceType("subscriptionServiceType");
- customer.setGlobalCustomerId("globalCustomerId");
- customer.setSubscriberName("subscriberName");
- customer.setSubscriberType("subscriberType");
- customer.setServiceSubscription(serviceSubscription);
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant tenant = new org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant();
- tenant.setTenantContext("tenantContext");
- tenant.setTenantId("tenantId");
- tenant.setTenantName("tenantName");
-
- org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
- org.onap.aai.domain.yang.Tenants aaiTenants = Mockito.mock(org.onap.aai.domain.yang.Tenants.class);
- org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant();
- aaiTenant.setTenantId("tenantId");
- List<org.onap.aai.domain.yang.Tenant> tenants = new ArrayList<>();
- tenants.add(aaiTenant);
-
- String requestAction = "createInstance";
-
- doReturn(uriKeys).when(SPY_bbInputSetupUtils).getURIKeysFromServiceInstance(serviceInstance.getServiceInstanceId());
- doReturn(customer).when(SPY_bbInputSetup).mapCustomer(uriKeys.get("global-customer-id"),uriKeys.get("service-type"));
- doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration());
- doReturn(orchestrationContext).when(bbInputSetupMapperLayer).mapOrchestrationContext(requestDetails);
- doReturn(requestContext).when(bbInputSetupMapperLayer).mapRequestContext(requestDetails);
- doReturn(cloudRegion).when(bbInputSetupMapperLayer).mapCloudRegion(requestDetails.getCloudConfiguration(), aaiCloudRegion);
- doReturn(tenant).when(bbInputSetupMapperLayer).mapTenant(aaiTenant);
- doReturn(aaiTenants).when(aaiCloudRegion).getTenants();
- doReturn(tenants).when(aaiTenants).getTenant();
-
- GeneralBuildingBlock actual = SPY_bbInputSetup.populateGBBWithSIAndAdditionalInfo(requestDetails,
- serviceInstance, executeBB, requestAction, null);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetServiceInstanceNOAAI() throws Exception {
- ServiceInstance expected = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
- ServiceInstance.class);
- Service service = mapper.readValue(
- new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
- Customer customer = mapper.readValue(new File(RESOURCE_PATH + "Customer.json"), Customer.class);
- Project project = mapper.readValue(new File(RESOURCE_PATH + "Project.json"), Project.class);
- OwningEntity owningEntity = mapper.readValue(new File(RESOURCE_PATH + "OwningEntity.json"), OwningEntity.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
-
- ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock();
- executeBB.setaLaCarte(true);
- BuildingBlock buildingBlock = new BuildingBlock();
- buildingBlock.setBpmnFlowName(AssignFlows.SERVICE_INSTANCE.toString());
- executeBB.setBuildingBlock(buildingBlock);
- RequestDetails requestDetails = new RequestDetails();
- RequestInfo reqInfo = new RequestInfo();
- reqInfo.setInstanceName("serviceInstanceName");
- requestDetails.setRequestInfo(reqInfo);
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelType(ModelType.service);
- requestDetails.setModelInfo(modelInfo);
- doReturn(null).when(SPY_bbInputSetupUtils)
- .getAAIServiceInstanceByName(requestDetails.getRequestInfo().getInstanceName(), customer);
- doReturn(expected.getModelInfoServiceInstance()).when(bbInputSetupMapperLayer)
- .mapCatalogServiceIntoServiceInstance(service);
- doReturn(null).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(any(String.class));
- String serviceInstanceId = "3655a595-05d1-433c-93c0-3afd6b572545";
- boolean aLaCarte = true;
-
- ServiceInstance actual = SPY_bbInputSetup.getALaCarteServiceInstance(service, requestDetails, customer, project,
- owningEntity, lookupKeyMap, serviceInstanceId, aLaCarte,
- executeBB.getBuildingBlock().getBpmnFlowName());
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetServiceSubscription() throws IOException {
- ServiceSubscription expected = new ServiceSubscription();
- RequestDetails requestDetails = new RequestDetails();
- RequestParameters params = new RequestParameters();
- params.setSubscriptionServiceType("subscriptionServiceType");
- requestDetails.setRequestParameters(params);
- org.onap.aai.domain.yang.ServiceSubscription aaiServiceSubscription = new org.onap.aai.domain.yang.ServiceSubscription();
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- doReturn(aaiServiceSubscription).when(SPY_bbInputSetupUtils).getAAIServiceSubscription(
- customer.getGlobalCustomerId(), requestDetails.getRequestParameters().getSubscriptionServiceType());
- doReturn(expected).when(bbInputSetupMapperLayer).mapAAIServiceSubscription(aaiServiceSubscription);
-
- ServiceSubscription actual = SPY_bbInputSetup.getServiceSubscription(requestDetails, customer);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetCustomer() throws IOException {
- Customer expected = new Customer();
- RequestDetails requestDetails = new RequestDetails();
- SubscriberInfo subscriberInfo = new SubscriberInfo();
- subscriberInfo.setGlobalSubscriberId("globalSubscriberId");
- requestDetails.setSubscriberInfo(subscriberInfo);
- org.onap.aai.domain.yang.Customer aaiCustomer = new org.onap.aai.domain.yang.Customer();
- doReturn(aaiCustomer).when(SPY_bbInputSetupUtils)
- .getAAICustomer(requestDetails.getSubscriberInfo().getGlobalSubscriberId());
- doReturn(expected).when(bbInputSetupMapperLayer).mapAAICustomer(aaiCustomer);
-
- Customer actual = SPY_bbInputSetup.getCustomerFromRequest(requestDetails);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetExistingServiceInstance() throws Exception {
- org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
- ServiceInstance expected = new ServiceInstance();
-
- doReturn(expected).when(bbInputSetupMapperLayer)
- .mapAAIServiceInstanceIntoServiceInstance(serviceInstanceAAI);
-
-
- ServiceInstance actual = SPY_bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testPopulateNetworkCollectionAndInstanceGroupAssign() throws Exception {
- Service service = Mockito.mock(Service.class);
- String key = "collectionCustId";
- ServiceInstance serviceInstance = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
- ServiceInstance.class);
- String resourceId = "123";
- Collection collection = SPY_bbInputSetup.createCollection(resourceId);
- InstanceGroup instanceGroup = SPY_bbInputSetup.createInstanceGroup();
- assertNull(serviceInstance.getCollection());
- doReturn(true).when(SPY_bbInputSetup).isVlanTagging(service, key);
- doReturn(collection).when(SPY_bbInputSetup).createCollection(resourceId);
- doReturn(instanceGroup).when(SPY_bbInputSetup).createInstanceGroup();
- doNothing().when(SPY_bbInputSetup).mapCatalogCollection(service, collection, key);
-
- NetworkCollectionResourceCustomization networkCollection = new NetworkCollectionResourceCustomization();
- networkCollection.setModelCustomizationUUID(key);
- networkCollection.setCollectionResource(new CollectionResource());
- networkCollection.getCollectionResource().setInstanceGroup(new org.onap.so.db.catalog.beans.InstanceGroup());
- networkCollection.getCollectionResource().getInstanceGroup().setToscaNodeType("NetworkCollectionResource");
- networkCollection.getCollectionResource().getInstanceGroup().setType(InstanceGroupType.L3_NETWORK);
- networkCollection.getCollectionResource().getInstanceGroup().setCollectionInstanceGroupCustomizations(new ArrayList<>());
- List<CollectionResourceCustomization> customizations = new ArrayList<>();
- customizations.add(networkCollection);
- doReturn(customizations).when(service).getCollectionResourceCustomizations();
-
- SPY_bbInputSetup.populateNetworkCollectionAndInstanceGroupAssign(service,
- AssignFlows.NETWORK_COLLECTION.toString(), serviceInstance, resourceId, key);
-
- assertNotNull(serviceInstance.getCollection());
- assertNotNull(serviceInstance.getCollection().getInstanceGroup());
-
- verify(SPY_bbInputSetup, times(1)).mapCatalogCollection(service, serviceInstance.getCollection(), key);
- verify(SPY_bbInputSetup, times(1)).mapCatalogNetworkCollectionInstanceGroup(service,
- serviceInstance.getCollection().getInstanceGroup(), key);
- }
-
- @Test
- public void testPopulateInstanceGroup() throws Exception {
- ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
- Service service = Mockito.mock(Service.class);
- List<InstanceGroup> instanceGroups = Mockito.spy(new ArrayList<>());
- ServiceInstance serviceInstance = Mockito.spy(new ServiceInstance());
- serviceInstance.setServiceInstanceId("si-001");
- serviceInstance.setServiceInstanceName("test service instance");
- serviceInstance.setInstanceGroups(instanceGroups);
-
- SPY_bbInputSetup.populateInstanceGroup(modelInfo, service, serviceInstance, "instance-group-001", "test instance group");
- verify(SPY_bbInputSetup, times(1)).mapCatalogInstanceGroup(isA(InstanceGroup.class), isA(ModelInfo.class), isA(Service.class));
- verify(instanceGroups, times(1)).add(isA(InstanceGroup.class));
- }
-
- @Test
- public void testIsVlanTagging() throws Exception {
- boolean expected = true;
- Service service = Mockito.mock(Service.class);
- String key = "collectionCustId";
- NetworkCollectionResourceCustomization networkCollection = new NetworkCollectionResourceCustomization();
- networkCollection.setModelCustomizationUUID(key);
- networkCollection.setCollectionResource(new CollectionResource());
- networkCollection.getCollectionResource().setInstanceGroup(new org.onap.so.db.catalog.beans.InstanceGroup());
- networkCollection.getCollectionResource().getInstanceGroup().setToscaNodeType("org.openecomp.resource.cr.NetworkCollectionResource1806");
- List<CollectionResourceCustomization> customizations = new ArrayList<>();
- customizations.add(networkCollection);
- doReturn(customizations).when(service).getCollectionResourceCustomizations();
- boolean actual = SPY_bbInputSetup.isVlanTagging(service, key);
- assertEquals("Is Vlan Tagging check.", expected, actual);
- }
-
- @Test
- public void testPopulateVolumeGroup() throws Exception {
- RequestDetails requestDetails = new RequestDetails();
- RelatedInstanceList ril = new RelatedInstanceList();
- RelatedInstance ri = new RelatedInstance();
- ModelInfo mi = new ModelInfo();
- mi.setModelType(ModelType.vnf);
- mi.setModelCustomizationUuid("vnfModelCustomizationUUID");
- ri.setModelInfo(mi);
- ril.setRelatedInstance(ri);
- requestDetails.setRelatedInstanceList(new RelatedInstanceList[] { ril });
-
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelType(ModelType.volumeGroup);
-
- RequestInfo reqInfo = new RequestInfo();
- reqInfo.setInstanceName("volumeGroupName");
- requestDetails.setModelInfo(modelInfo);
- requestDetails.setRequestInfo(reqInfo);
-
- ServiceInstance serviceInstance = new ServiceInstance();
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("genericVnfId");
-
- VolumeGroup vg = new VolumeGroup();
- vg.setVolumeGroupName("volumeGroupName");
- vg.setVolumeGroupId("volumeGroupId");
- vnf.getVolumeGroups().add(vg);
- serviceInstance.getVnfs().add(vnf);
-
- Service service = mapper.readValue(
- new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId");
-
- String bbName = AssignFlows.VOLUME_GROUP.toString();
- String resourceId = "123";
- doNothing().when(SPY_bbInputSetup).mapCatalogVolumeGroup(isA(VolumeGroup.class), eq(modelInfo),
- eq(service), eq("vnfModelCustomizationUUID"));
- org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = new org.onap.aai.domain.yang.GenericVnf();
- aaiGenericVnf.setModelCustomizationId("vnfModelCustomizationUUID");
- doReturn(aaiGenericVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
-
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
- SPY_bbInputSetup.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
- requestDetails.getRelatedInstanceList(), reqInfo.getInstanceName(), null, null);
- verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(vg, modelInfo, service, "vnfModelCustomizationUUID");
- vnf.getVolumeGroups().clear();
- SPY_bbInputSetup.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
- requestDetails.getRelatedInstanceList(), reqInfo.getInstanceName(), null, null);
- verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(vnf.getVolumeGroups().get(0), modelInfo, service,
- "vnfModelCustomizationUUID");
- }
-
- @Test
- public void testMapCatalogVolumeGroup() {
- VolumeGroup volumeGroup = new VolumeGroup();
- RequestDetails requestDetails = new RequestDetails();
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelCustomizationUuid("modelCustomizationUUID");
- requestDetails.setModelInfo(modelInfo);
- Service service = new Service();
- VnfResourceCustomization resourceCust = new VnfResourceCustomization();
- resourceCust.setModelCustomizationUUID("vnfModelCustomizationUUID");
- service.getVnfCustomizations().add(resourceCust);
- VfModuleCustomization vfResourceCust = new VfModuleCustomization();
- vfResourceCust.setModelCustomizationUUID("modelCustomizationUUID");
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
- resourceCust.getVfModuleCustomizations().add(vfResourceCust);
-
- doReturn(modelInfoVfModule).when(bbInputSetupMapperLayer).mapCatalogVfModuleToVfModule(vfResourceCust);
-
- SPY_bbInputSetup.mapCatalogVolumeGroup(volumeGroup, modelInfo, service, "vnfModelCustomizationUUID");
-
- assertEquals(modelInfoVfModule, volumeGroup.getModelInfoVfModule());
- }
-
- @Test
- public void testPopulateL3Network() throws JsonParseException, JsonMappingException, IOException {
- String instanceName = "networkName";
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelType(ModelType.network);
-
- ServiceInstance serviceInstance = new ServiceInstance();
- L3Network network = new L3Network();
- network.setNetworkId("networkId");
- network.setNetworkName("networkName");
- serviceInstance.getNetworks().add(network);
- String resourceId = "123";
- // Mock service
- Service service = mapper.readValue(
- new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
- String bbName = AssignFlows.NETWORK_A_LA_CARTE.toString();
-
- doNothing().when(SPY_bbInputSetup).mapCatalogNetwork(network, modelInfo, service);
-
- SPY_bbInputSetup.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap,
- resourceId, null);
-
- lookupKeyMap.put(ResourceKey.NETWORK_ID, null);
-
- SPY_bbInputSetup.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap,
- resourceId, null);
- verify(SPY_bbInputSetup, times(1)).mapCatalogNetwork(network, modelInfo, service);
-
- instanceName = "networkName2";
- L3Network network2 = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, resourceId, null);
- SPY_bbInputSetup.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap,
- resourceId, null);
- verify(SPY_bbInputSetup, times(2)).mapCatalogNetwork(network2, modelInfo, service);
- }
-
- @Test
- public void testMapCatalogNetwork() {
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- L3Network network = new L3Network();
-
- RequestDetails requestDetails = new RequestDetails();
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelCustomizationUuid("modelCustomizationUUID");
- requestDetails.setModelInfo(modelInfo);
- Service service = new Service();
- NetworkResourceCustomization resourceCust = new NetworkResourceCustomization();
- resourceCust.setModelCustomizationUUID("modelCustomizationUUID");
- service.setNetworkCustomizations(Arrays.asList(new NetworkResourceCustomization[] { resourceCust }));
-
- doReturn(modelInfoNetwork).when(bbInputSetupMapperLayer).mapCatalogNetworkToNetwork(resourceCust);
-
- SPY_bbInputSetup.mapCatalogNetwork(network, modelInfo, service);
-
- assertEquals(modelInfoNetwork, network.getModelInfoNetwork());
- }
-
- @Test
- public void testPopulateConfiguration() throws JsonParseException, JsonMappingException, IOException {
- String instanceName = "configurationName";
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelCustomizationUuid("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
-
- ServiceInstance serviceInstance = new ServiceInstance();
- Configuration configuration = new Configuration();
- configuration.setConfigurationId("configurationId");
- configuration.setConfigurationName("configurationName");
- serviceInstance.getConfigurations().add(configuration);
- String resourceId = "configurationId";
- String vnfcName = "vnfcName";
- // Mock service
- Service service = mapper.readValue(
- new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
- ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization();
- configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
- service.getConfigurationCustomizations().add(configurationCust);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
- String bbName = AssignFlows.FABRIC_CONFIGURATION.toString();
- ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
- configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
- configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
- configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
- configResourceKeys.setVnfcName(vnfcName);
- Vnfc vnfc = new Vnfc();
- vnfc.setVnfcName(vnfcName);
-
- doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
- doReturn(vnfc).when(SPY_bbInputSetup).getVnfcToConfiguration(vnfcName);
- SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
- instanceName, configResourceKeys);
- verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
-
- lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, null);
-
- SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
- instanceName, configResourceKeys);
- verify(SPY_bbInputSetup, times(2)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
-
- instanceName = "configurationName2";
- resourceId = "resourceId2";
- lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId2");
- Configuration configuration2 = SPY_bbInputSetup.createConfiguration(lookupKeyMap, instanceName, resourceId);
- doReturn(configuration2).when(SPY_bbInputSetup).createConfiguration(lookupKeyMap, instanceName, resourceId);
- doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration2, modelInfo, service, configResourceKeys);
- SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
- instanceName, configResourceKeys);
- verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration2, modelInfo, service, configResourceKeys);
- }
-
- @Test
- public void testMapCatalogConfiguration() {
- ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
- L3Network network = new L3Network();
-
- RequestDetails requestDetails = new RequestDetails();
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelCustomizationUuid("modelCustomizationUUID");
- requestDetails.setModelInfo(modelInfo);
- Service service = new Service();
- NetworkResourceCustomization resourceCust = new NetworkResourceCustomization();
- resourceCust.setModelCustomizationUUID("modelCustomizationUUID");
- service.setNetworkCustomizations(Arrays.asList(new NetworkResourceCustomization[] { resourceCust }));
-
- doReturn(modelInfoNetwork).when(bbInputSetupMapperLayer).mapCatalogNetworkToNetwork(resourceCust);
-
- SPY_bbInputSetup.mapCatalogNetwork(network, modelInfo, service);
-
- assertEquals(modelInfoNetwork, network.getModelInfoNetwork());
- }
-
- @Test
- public void testPopulateFabricConfiguration() throws JsonParseException, JsonMappingException, IOException {
- String instanceName = "configurationName";
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelCustomizationUuid("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
-
- ServiceInstance serviceInstance = new ServiceInstance();
- Configuration configuration = new Configuration();
- configuration.setConfigurationId("configurationId");
- configuration.setConfigurationName("configurationName");
- serviceInstance.getConfigurations().add(configuration);
- String resourceId = "configurationId";
- String vnfcName = "vnfcName";
- // Mock service
- Service service = mapper.readValue(
- new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
- String bbName = AssignFlows.FABRIC_CONFIGURATION.toString();
- ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
- configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
- configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
- configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
- configResourceKeys.setVnfcName(vnfcName);
- Vnfc vnfc = new Vnfc();
- vnfc.setVnfcName(vnfcName);
-
- CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization = new CvnfcConfigurationCustomization();
- ConfigurationResource configurationResource = new ConfigurationResource();
- configurationResource.setModelUUID("modelUUID");
- configurationResource.setModelInvariantUUID("modelInvariantUUID");
- vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource);
-
- doReturn(null).when(SPY_bbInputSetup).findConfigurationResourceCustomization(modelInfo, service);
- doReturn(vnfc).when(SPY_bbInputSetup).getVnfcToConfiguration(vnfcName);
-
- SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
- instanceName, configResourceKeys);
- verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service, configResourceKeys);
- }
-
- @Test
- public void testPopulateGenericVnf() throws JsonParseException, JsonMappingException, IOException {
- org.onap.so.serviceinstancebeans.Platform platform = new org.onap.so.serviceinstancebeans.Platform();
- org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = new org.onap.so.serviceinstancebeans.LineOfBusiness();
- String instanceName = "vnfName";
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelType(ModelType.vnf);
-
- ServiceInstance serviceInstance = new ServiceInstance();
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("genericVnfId");
- vnf.setVnfName("vnfName");
- serviceInstance.getVnfs().add(vnf);
- String vnfType = "vnfType";
- RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetails_CreateVnf.json"),
- RequestDetails.class);
-
- Service service = mapper.readValue(
- new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId");
- String bbName = AssignFlows.VNF.toString();
-
- Platform expectedPlatform = new Platform();
- LineOfBusiness expectedLineOfBusiness = new LineOfBusiness();
- String resourceId = "123";
- doReturn(expectedPlatform).when(bbInputSetupMapperLayer).mapRequestPlatform(platform);
- doReturn(expectedLineOfBusiness).when(bbInputSetupMapperLayer).mapRequestLineOfBusiness(lineOfBusiness);
- org.onap.aai.domain.yang.GenericVnf vnfAAI = new org.onap.aai.domain.yang.GenericVnf();
- vnfAAI.setModelCustomizationId("modelCustId");
- doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
- doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf, modelInfo, service);
- org.onap.aai.domain.yang.InstanceGroup instanceGroupAAI = new org.onap.aai.domain.yang.InstanceGroup();
- doReturn(instanceGroupAAI).when(SPY_bbInputSetupUtils).getAAIInstanceGroup(any());
- org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
- doReturn(catalogInstanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup(any());
-
- SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
- serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
- requestDetails.getRequestInfo().getProductFamilyId());
-
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
-
- SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
- serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
- requestDetails.getRequestInfo().getProductFamilyId());
- verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service);
-
- instanceName = "vnfName2";
- GenericVnf vnf2 = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness,
- resourceId, vnfType, null, requestDetails.getRequestInfo().getProductFamilyId());
- doReturn(vnf2).when(SPY_bbInputSetup).createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness,
- resourceId, vnfType, null, requestDetails.getRequestInfo().getProductFamilyId());
- doNothing().when(SPY_bbInputSetup).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
- doNothing().when(SPY_bbInputSetup).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
-
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId2");
-
- SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
- serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
- requestDetails.getRequestInfo().getProductFamilyId());
- verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service);
- verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
- verify(SPY_bbInputSetup, times(2)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
- }
-
- @Test
- public void testMapVnfcCollectionInstanceGroup() {
- VnfResourceCustomization vnfResourceCust = Mockito.mock(VnfResourceCustomization.class);
- GenericVnf genericVnf = new GenericVnf();
- ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
- Service service = Mockito.mock(Service.class);
- org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
- instanceGroup.setModelUUID("modelUUID");
- List<VnfcInstanceGroupCustomization> vnfcInstanceGroups = new ArrayList<>();
- VnfcInstanceGroupCustomization vnfcInstanceGroupCust = new VnfcInstanceGroupCustomization();
- vnfcInstanceGroupCust.setInstanceGroup(instanceGroup);
- vnfcInstanceGroupCust.setFunction("function");
- vnfcInstanceGroupCust.setDescription("description");
- vnfcInstanceGroups.add(vnfcInstanceGroupCust);
-
- ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
- modelInfoInstanceGroup.setModelUUID("modelUUID");
- doReturn(vnfResourceCust).when(SPY_bbInputSetup).getVnfResourceCustomizationFromService(modelInfo, service);
- doReturn(vnfcInstanceGroups).when(vnfResourceCust).getVnfcInstanceGroupCustomizations();
- doReturn(instanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup("modelUUID");
- doReturn(modelInfoInstanceGroup).when(bbInputSetupMapperLayer).mapCatalogInstanceGroupToInstanceGroup(null, instanceGroup);
-
- SPY_bbInputSetup.mapVnfcCollectionInstanceGroup(genericVnf, modelInfo, service);
-
- assertEquals("Instance Group was created", true, genericVnf.getInstanceGroups().size() == 1);
- }
- @Test
- public void testPopulateGenericVnfWhereVnfTypeIsNull()
- throws JsonParseException, JsonMappingException, IOException {
- org.onap.so.serviceinstancebeans.Platform platform = new org.onap.so.serviceinstancebeans.Platform();
- org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness = new org.onap.so.serviceinstancebeans.LineOfBusiness();
- String instanceName = "vnfName";
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelType(ModelType.vnf);
-
- ServiceInstance serviceInstance = new ServiceInstance();
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("genericVnfId");
- vnf.setVnfName("vnfName");
- serviceInstance.getVnfs().add(vnf);
- String vnfType = null;
- RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetails_CreateVnf.json"),
- RequestDetails.class);
-
- Service service = mapper.readValue(
- new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId");
- String bbName = AssignFlows.VNF.toString();
-
- Platform expectedPlatform = new Platform();
- LineOfBusiness expectedLineOfBusiness = new LineOfBusiness();
- String resourceId = "123";
- doReturn(expectedPlatform).when(bbInputSetupMapperLayer).mapRequestPlatform(platform);
- doReturn(expectedLineOfBusiness).when(bbInputSetupMapperLayer).mapRequestLineOfBusiness(lineOfBusiness);
- org.onap.aai.domain.yang.GenericVnf vnfAAI = new org.onap.aai.domain.yang.GenericVnf();
- vnfAAI.setModelCustomizationId("modelCustId");
- doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
- doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf, modelInfo, service);
- org.onap.aai.domain.yang.InstanceGroup instanceGroupAAI = new org.onap.aai.domain.yang.InstanceGroup();
- doReturn(instanceGroupAAI).when(SPY_bbInputSetupUtils).getAAIInstanceGroup(any());
- org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
- doReturn(catalogInstanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup(any());
-
- SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
- serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
- requestDetails.getRequestInfo().getProductFamilyId());
-
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
-
- SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
- serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
- requestDetails.getRequestInfo().getProductFamilyId());
- verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service);
-
- instanceName = "vnfName2";
- GenericVnf vnf2 = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness,
- resourceId, vnfType, null, requestDetails.getRequestInfo().getProductFamilyId());
-
- org.onap.aai.domain.yang.GenericVnf vnf2AAI = new org.onap.aai.domain.yang.GenericVnf();
- vnfAAI.setModelCustomizationId("modelCustId2");
- doReturn(vnf2AAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf2.getVnfId());
- doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf2, modelInfo, service);
- doNothing().when(SPY_bbInputSetup).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
- SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
- serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
- requestDetails.getRequestInfo().getProductFamilyId());
- verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service);
- verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
- verify(SPY_bbInputSetup, times(1)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
- }
-
- @Test
- public void testMapCatalogVnf() {
- ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
- GenericVnf genericVnf = new GenericVnf();
- RequestDetails requestDetails = new RequestDetails();
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelCustomizationUuid("modelCustomizationUUID");
- requestDetails.setModelInfo(modelInfo);
- Service service = new Service();
- VnfResourceCustomization resourceCust = new VnfResourceCustomization();
- resourceCust.setModelCustomizationUUID("vnfModelCustomizationUUID");
- service.getVnfCustomizations().add(resourceCust);
- resourceCust.setModelCustomizationUUID("modelCustomizationUUID");
-
- doReturn(modelInfoGenericVnf).when(bbInputSetupMapperLayer).mapCatalogVnfToVnf(resourceCust);
-
- SPY_bbInputSetup.mapCatalogVnf(genericVnf, modelInfo, service);
-
- assertEquals(modelInfoGenericVnf, genericVnf.getModelInfoGenericVnf());
- }
-
- @Test
- public void testMapCatalogCollectionAndInstanceGroup() {
- ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
- modelInfoCollection.setCollectionFunction("collectionFunction");
- modelInfoCollection.setCollectionRole("collectionRole");
- modelInfoCollection.setCollectionType("collectionType");
- modelInfoCollection.setDescription("description");
- modelInfoCollection.setModelInvariantUUID("modelInvariantUUID");
- modelInfoCollection.setQuantity(0);
-
- ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
- modelInfoInstanceGroup.setFunction("function");
- modelInfoInstanceGroup.setInstanceGroupRole("instanceGroupRole");
- modelInfoInstanceGroup.setModelInvariantUUID("modelInvariantUUID");
- modelInfoInstanceGroup.setModelUUID("modelUUID");
- modelInfoInstanceGroup.setType("VNFC");
- modelInfoInstanceGroup.setDescription("description");
-
- InstanceGroup instanceGroup = new InstanceGroup();
- Collection collection = new Collection();
- collection.setInstanceGroup(instanceGroup);
-
- CollectionResource collectionResource = new CollectionResource();
- org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
- collectionResource.setToscaNodeType("NetworkCollection");
- collectionResource.setInstanceGroup(catalogInstanceGroup);
-
- CollectionResourceCustomization collectionCust = new NetworkCollectionResourceCustomization();
- collectionCust.setModelCustomizationUUID("modelCustomizationUUID");
- collectionCust.setCollectionResource(collectionResource);
-
- Service service = new Service();
- service.getCollectionResourceCustomizations().add(collectionCust);
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setCollection(collection);
-
- List<CollectionResourceInstanceGroupCustomization> instanceGroupCustList = new ArrayList<>();
- CollectionResourceInstanceGroupCustomization instanceGroupCust = new CollectionResourceInstanceGroupCustomization();
- instanceGroupCust.setFunction("function");
- instanceGroupCust.setDescription("description");
-
- doReturn(modelInfoCollection).when(bbInputSetupMapperLayer).mapCatalogCollectionToCollection(collectionCust,
- collectionResource);
-
- doReturn(modelInfoInstanceGroup).when(bbInputSetupMapperLayer).mapCatalogInstanceGroupToInstanceGroup(collectionCust,
- catalogInstanceGroup);
-
- SPY_bbInputSetup.mapCatalogCollection(service, serviceInstance.getCollection(), "modelCustomizationUUID");
- SPY_bbInputSetup.mapCatalogNetworkCollectionInstanceGroup(service,
- serviceInstance.getCollection().getInstanceGroup(), collectionCust.getModelCustomizationUUID());
-
- assertThat(collection.getModelInfoCollection(), sameBeanAs(modelInfoCollection));
- assertThat(instanceGroup.getModelInfoInstanceGroup(), sameBeanAs(modelInfoInstanceGroup));
- }
-
- @Test
- public void testAddRelationshipsToSI() throws Exception {
- ServiceInstance serviceInstance = new ServiceInstance();
- org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
- serviceInstanceAAI.setServiceInstanceId("serviceInstanceId");
-
- org.onap.aai.domain.yang.RelationshipList relationshipList = new org.onap.aai.domain.yang.RelationshipList();
- org.onap.aai.domain.yang.Relationship relationship = new org.onap.aai.domain.yang.Relationship();
- relationshipList.getRelationship().add(relationship);
- serviceInstanceAAI.setRelationshipList(relationshipList);
-
- Map<String, String> uriKeys = new HashMap<>();
- uriKeys.put("global-customer-id", "globalCustomerId");
- uriKeys.put("service-type", "serviceType");
-
-
- doNothing().when(SPY_bbInputSetup).mapProject(any(), eq(serviceInstance));
- doNothing().when(SPY_bbInputSetup).mapOwningEntity(any(), eq(serviceInstance));
- doNothing().when(SPY_bbInputSetup).mapL3Networks(any(), eq(serviceInstance.getNetworks()));
- doNothing().when(SPY_bbInputSetup).mapGenericVnfs(any(), eq(serviceInstance.getVnfs()));
- doNothing().when(SPY_bbInputSetup).mapCollection(any(), eq(serviceInstance));
-
- SPY_bbInputSetup.addRelationshipsToSI(serviceInstanceAAI, serviceInstance);
-
- verify(SPY_bbInputSetup, times(1)).mapProject(any(), eq(serviceInstance));
- verify(SPY_bbInputSetup, times(1)).mapOwningEntity(any(), eq(serviceInstance));
- verify(SPY_bbInputSetup, times(1)).mapL3Networks(any(), eq(serviceInstance.getNetworks()));
- verify(SPY_bbInputSetup, times(1)).mapGenericVnfs(any(), eq(serviceInstance.getVnfs()));
- verify(SPY_bbInputSetup, times(1)).mapCollection(any(), eq(serviceInstance));
- verify(SPY_bbInputSetup, times(1)).mapConfigurations(any(), eq(serviceInstance.getConfigurations()));
- }
-
- @Test
- public void testMapConfigurations() throws JsonProcessingException {
- org.onap.aai.domain.yang.Configuration expectedAAI = new org.onap.aai.domain.yang.Configuration();
- org.onap.aai.domain.yang.RelationshipList relationshipList = new org.onap.aai.domain.yang.RelationshipList();
- org.onap.aai.domain.yang.Relationship relationship = new org.onap.aai.domain.yang.Relationship();
- relationshipList.getRelationship().add(relationship);
- expectedAAI.setRelationshipList(relationshipList);
-
- Configuration expected = new Configuration();
- AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, "configurationId");
- AAIResultWrapper configurationWrapper = new AAIResultWrapper(
- new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
-
- doReturn(configurationWrapper).when(SPY_bbInputSetupUtils).getAAIResourceDepthOne(aaiResourceUri);
- doReturn(expected).when(bbInputSetupMapperLayer)
- .mapAAIConfiguration(isA(org.onap.aai.domain.yang.Configuration.class));
-
- List<Configuration> configurations = new ArrayList<>();
-
- SPY_bbInputSetup.mapConfigurations(Arrays.asList(new AAIResourceUri[] { aaiResourceUri }), configurations);
-
- assertEquals(expected, configurations.get(0));
- }
-
- @Test
- public void testMapGenericVnfs() throws JsonProcessingException {
- org.onap.aai.domain.yang.GenericVnf expectedAAI = new org.onap.aai.domain.yang.GenericVnf();
- org.onap.aai.domain.yang.RelationshipList relationshipList = new org.onap.aai.domain.yang.RelationshipList();
- org.onap.aai.domain.yang.Relationship relationship = new org.onap.aai.domain.yang.Relationship();
- relationshipList.getRelationship().add(relationship);
- expectedAAI.setRelationshipList(relationshipList);
-
- GenericVnf expected = new GenericVnf();
- AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId");
- AAIResultWrapper vnfWrapper = new AAIResultWrapper(
- new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
-
- doReturn(vnfWrapper).when(SPY_bbInputSetupUtils).getAAIResourceDepthOne(aaiResourceUri);
- doReturn(expected).when(bbInputSetupMapperLayer)
- .mapAAIGenericVnfIntoGenericVnf(isA(org.onap.aai.domain.yang.GenericVnf.class));
- doNothing().when(SPY_bbInputSetup).mapPlatform(any(), eq(expected));
- doNothing().when(SPY_bbInputSetup).mapLineOfBusiness(any(), eq(expected));
- doReturn(new ArrayList<>()).when(SPY_bbInputSetup).mapVolumeGroups(any());
-
- List<GenericVnf> genericVnfs = new ArrayList<>();
-
- SPY_bbInputSetup.mapGenericVnfs(Arrays.asList(new AAIResourceUri[] { aaiResourceUri }), genericVnfs);
-
- assertEquals(expected, genericVnfs.get(0));
- verify(SPY_bbInputSetup, times(1)).mapPlatform(any(), eq(expected));
- verify(SPY_bbInputSetup, times(1)).mapLineOfBusiness(any(), eq(expected));
- verify(SPY_bbInputSetup, times(1)).mapVolumeGroups(any());
- }
-
- @Test
- public void testMapVolumeGroups() throws JsonProcessingException {
- org.onap.aai.domain.yang.VolumeGroup expectedAAI = new org.onap.aai.domain.yang.VolumeGroup();
-
- VolumeGroup expected = new VolumeGroup();
- AAIResultWrapper vnfWrapper = new AAIResultWrapper(
- new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
-
- doReturn(expected).when(bbInputSetupMapperLayer)
- .mapAAIVolumeGroup(isA(org.onap.aai.domain.yang.VolumeGroup.class));
-
- List<VolumeGroup> volumeGroupsList =
- SPY_bbInputSetup.mapVolumeGroups(Arrays.asList(new AAIResultWrapper[] { vnfWrapper }));
-
- assertEquals(expected, volumeGroupsList.get(0));
- }
-
- @Test
- public void testMapLineOfBusiness() throws JsonProcessingException {
- org.onap.aai.domain.yang.LineOfBusiness expectedAAI = new org.onap.aai.domain.yang.LineOfBusiness();
-
- LineOfBusiness expected = new LineOfBusiness();
- AAIResultWrapper vnfWrapper = new AAIResultWrapper(
- new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
-
- doReturn(expected).when(bbInputSetupMapperLayer)
- .mapAAILineOfBusiness(isA(org.onap.aai.domain.yang.LineOfBusiness.class));
-
- GenericVnf vnf = new GenericVnf();
-
- SPY_bbInputSetup.mapLineOfBusiness(Arrays.asList(new AAIResultWrapper[] { vnfWrapper }), vnf);
-
- assertEquals(expected, vnf.getLineOfBusiness());
- }
-
- @Test
- public void testMapPlatform() throws JsonProcessingException {
- org.onap.aai.domain.yang.Platform expectedAAI = new org.onap.aai.domain.yang.Platform();
-
- Platform expected = new Platform();
- AAIResultWrapper vnfWrapper = new AAIResultWrapper(
- new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
-
- doReturn(expected).when(bbInputSetupMapperLayer)
- .mapAAIPlatform(isA(org.onap.aai.domain.yang.Platform.class));
-
- GenericVnf vnf = new GenericVnf();
-
- SPY_bbInputSetup.mapPlatform(Arrays.asList(new AAIResultWrapper[] { vnfWrapper }), vnf);
-
- assertEquals(expected, vnf.getPlatform());
- }
-
- @Test
- public void testMapCollection() throws JsonProcessingException {
- List<AAIResultWrapper> collections = new ArrayList<>();
- ServiceInstance serviceInstance = new ServiceInstance();
-
- org.onap.aai.domain.yang.Collection aaiCollection = new org.onap.aai.domain.yang.Collection();
- org.onap.aai.domain.yang.RelationshipList collectionRelationshipList = new org.onap.aai.domain.yang.RelationshipList();
- org.onap.aai.domain.yang.Relationship collectionInstanceGroupRelationship = new org.onap.aai.domain.yang.Relationship();
- collectionRelationshipList.getRelationship().add(collectionInstanceGroupRelationship);
- aaiCollection.setRelationshipList(collectionRelationshipList);
-
- collections.add(new AAIResultWrapper(
- new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiCollection)));
-
- Collection collection = new Collection();
- ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
- List<InstanceGroup> instanceGroupsList = new ArrayList<>();
- InstanceGroup instanceGroup = new InstanceGroup();
- instanceGroupsList.add(instanceGroup);
- NetworkCollectionResourceCustomization networkCollectionCust = Mockito.mock(NetworkCollectionResourceCustomization.class);
- CollectionResource collectionResource = new CollectionResource();
- doReturn(collection).when(bbInputSetupMapperLayer)
- .mapAAICollectionIntoCollection(isA(org.onap.aai.domain.yang.Collection.class));
- doReturn(instanceGroupsList).when(SPY_bbInputSetup).mapInstanceGroups(any());
- doReturn(networkCollectionCust).when(SPY_bbInputSetupUtils).getCatalogNetworkCollectionResourceCustByID(aaiCollection.getCollectionCustomizationId());
- doReturn(collectionResource).when(networkCollectionCust).getCollectionResource();
- doReturn(modelInfoCollection).when(bbInputSetupMapperLayer).mapCatalogCollectionToCollection(networkCollectionCust, collectionResource);
+ private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
+
+ protected ObjectMapper mapper = new ObjectMapper();
+ private static final String CLOUD_OWNER = "CloudOwner";
+
+ @Spy
+ private BBInputSetup SPY_bbInputSetup = new BBInputSetup();
+
+ @Mock
+ private BBInputSetupUtils SPY_bbInputSetupUtils;
+
+ @Mock
+ private CloudInfoFromAAI SPY_cloudInfoFromAAI;
+
+ @Spy
+ private BBInputSetupMapperLayer bbInputSetupMapperLayer;
+
+ @Before
+ public void setup() {
+ SPY_bbInputSetup.setBbInputSetupUtils(SPY_bbInputSetupUtils);
+ SPY_bbInputSetup.setMapperLayer(bbInputSetupMapperLayer);
+ SPY_bbInputSetup.setCloudInfoFromAAI(SPY_cloudInfoFromAAI);
+ }
+
+ @Test
+ public void testGetVolumeGroupIdRelatedToVfModule() {
+ String expected = "volumeGroupId";
+ String modelCustomizationId = "modelCustomizationId";
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationId(modelCustomizationId);
+ String cloudOwner = "cloudOwner";
+ String cloudRegionId = "cloudRegionId";
+ String volumeGroupId = "volumeGroupId";
+ GenericVnf vnf = new GenericVnf();
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId(expected);
+ vnf.getVolumeGroups().add(volumeGroup);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, null);
+ org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = new org.onap.aai.domain.yang.VolumeGroup();
+ aaiVolumeGroup.setModelCustomizationId(modelCustomizationId);
+ doReturn(aaiVolumeGroup).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(cloudOwner, cloudRegionId,
+ volumeGroupId);
+
+ Optional<String> actual = SPY_bbInputSetup.getVolumeGroupIdRelatedToVfModule(vnf, modelInfo, cloudOwner,
+ cloudRegionId, lookupKeyMap);
+
+ assertEquals(expected, actual.get());
+ }
+
+ @Test
+ public void testGetAlaCarteServiceInstance() throws Exception {
+ ServiceInstance expected =
+ mapper.readValue(new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
+ ServiceInstance.class);
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setInstanceName("SharansInstanceName");
+ requestDetails.setRequestInfo(requestInfo);
+ Customer customer = new Customer();
+ String serviceInstanceId = "SharansInstanceId";
+ boolean aLaCarte = true;
+ Service service = new Service();
+ service.setModelUUID("modelUUID");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelUuid("modelUUID");
+ expected.setModelInfoServiceInstance(modelInfoServiceInstance);
+ org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
+ serviceInstanceAAI.setModelVersionId("modelUUIDDifferent");
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ String bbName = AssignFlows.SERVICE_INSTANCE.toString();
+ Service differentService = new Service();
+ differentService.setModelUUID("modelUUIDDifferent");
+
+ doReturn(expected).when(SPY_bbInputSetup).getServiceInstanceHelper(requestDetails, customer, null, null,
+ lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
+ doReturn(serviceInstanceAAI).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(serviceInstanceId);
+ doReturn(differentService).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(serviceInstanceAAI.getModelVersionId());
+ doReturn(expected.getModelInfoServiceInstance()).when(bbInputSetupMapperLayer)
+ .mapCatalogServiceIntoServiceInstance(differentService);
+
+ ServiceInstance actual = SPY_bbInputSetup.getALaCarteServiceInstance(service, requestDetails, customer, null,
+ null, lookupKeyMap, serviceInstanceId, aLaCarte, bbName);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test(expected = Exception.class)
+ public void testGetAlaCarteServiceInstanceException() throws Exception {
+ ServiceInstance expected =
+ mapper.readValue(new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
+ ServiceInstance.class);
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setInstanceName("SharansInstanceName");
+ requestDetails.setRequestInfo(requestInfo);
+ Customer customer = new Customer();
+ String serviceInstanceId = "SharansInstanceId";
+ boolean aLaCarte = true;
+ Service service = new Service();
+ service.setModelUUID("modelUUID");
+ ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
+ modelInfoServiceInstance.setModelUuid("modelUUID");
+ expected.setModelInfoServiceInstance(modelInfoServiceInstance);
+ org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
+ serviceInstanceAAI.setModelVersionId("modelUUIDDifferent");
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ String bbName = AssignFlows.SERVICE_INSTANCE.toString();
+ Service differentService = new Service();
+ differentService.setModelUUID("modelUUIDDifferent");
+
+ doReturn(expected).when(SPY_bbInputSetup).getServiceInstanceHelper(requestDetails, customer, null, null,
+ lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
+ doReturn(serviceInstanceAAI).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(serviceInstanceId);
+ doReturn(null).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(serviceInstanceAAI.getModelVersionId());
+
+ ServiceInstance actual = SPY_bbInputSetup.getALaCarteServiceInstance(service, requestDetails, customer, null,
+ null, lookupKeyMap, serviceInstanceId, aLaCarte, bbName);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetCustomerAndServiceSubscription() throws JsonParseException, JsonMappingException, IOException {
+ RequestDetails requestDetails = mapper.readValue(
+ new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
+ SubscriberInfo subscriberInfo = new SubscriberInfo();
+ subscriberInfo.setGlobalSubscriberId("globalSubscriberId");
+ RequestParameters requestParams = new RequestParameters();
+ requestParams.setSubscriptionServiceType("subscriptionServiceType");
+ requestDetails.setRequestParameters(requestParams);
+ requestDetails.setSubscriberInfo(subscriberInfo);
+ String resourceId = "resourceId";
+ Customer expected = new Customer();
+ expected.setGlobalCustomerId("globalCustomerId");
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setServiceType("subscriptionServiceType");
+
+ doReturn(expected).when(this.SPY_bbInputSetup).getCustomerFromRequest(requestDetails);
+ doReturn(serviceSubscription).when(this.SPY_bbInputSetup).getServiceSubscription(requestDetails, expected);
+
+ Customer actual = this.SPY_bbInputSetup.getCustomerAndServiceSubscription(requestDetails, resourceId);
+
+ assertThat(actual, sameBeanAs(expected));
+
+ requestDetails.setSubscriberInfo(null);
+
+
+ assertThat(actual, sameBeanAs(expected));
+
+ }
+
+ @Test
+ public void testSetHomingFlag() throws JsonParseException, JsonMappingException, IOException {
+ GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
+ GenericVnf genericVnfExpected = new GenericVnf();
+ genericVnfExpected.setVnfId("vnfId");
+ genericVnfExpected.setCallHoming(true);
+ expected.getCustomer().getServiceSubscription().getServiceInstances().get(0).getVnfs().add(genericVnfExpected);
+ boolean homing = true;
+ GenericVnf genericVnfActual = new GenericVnf();
+ genericVnfActual.setVnfId("vnfId");
+ genericVnfActual.setCallHoming(false);
+ GeneralBuildingBlock actual = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ actual.getCustomer().getServiceSubscription().getServiceInstances().get(0).getVnfs().add(genericVnfActual);
+
+ SPY_bbInputSetup.setHomingFlag(actual, homing, lookupKeyMap);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetExecuteBBFromExecution() throws IOException {
+ ExecuteBuildingBlock expected = new ExecuteBuildingBlock();
+ BuildingBlock bb = new BuildingBlock();
+ bb.setBpmnFlowName("AssignServiceInstanceBB");
+ expected.setBuildingBlock(bb);
+ expected.setRequestId("00032ab7-3fb3-42e5-965d-8ea592502017");
+ DelegateExecution execution = Mockito.mock(DelegateExecution.class);
+ doReturn(expected).when(execution).getVariable(any(String.class));
+ ExecuteBuildingBlock actual = SPY_bbInputSetup.getExecuteBBFromExecution(execution);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetGBB() throws Exception {
+ GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+
+ ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock();
+ executeBB.setRequestId("requestId");
+ RequestDetails requestDetails = new RequestDetails();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelType(ModelType.service);
+ requestDetails.setModelInfo(modelInfo);
+ RequestParameters requestParams = new RequestParameters();
+ requestParams.setaLaCarte(true);
+ requestDetails.setRequestParameters(requestParams);
+ doReturn(requestDetails).when(SPY_bbInputSetupUtils).getRequestDetails(executeBB.getRequestId());
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ String resourceId = "123";
+ String requestAction = "createInstance";
+ doReturn(expected).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, resourceId);
+ doNothing().when(SPY_bbInputSetup).populateLookupKeyMapWithIds(executeBB.getWorkflowResourceIds(),
+ lookupKeyMap);
+ boolean aLaCarte = true;
+ GeneralBuildingBlock actual =
+ SPY_bbInputSetup.getGBB(executeBB, lookupKeyMap, requestAction, aLaCarte, resourceId, null);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetGBBCM() throws Exception {
+ GeneralBuildingBlock expected = mapper
+ .readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockCMExpected.json"), GeneralBuildingBlock.class);
+
+ ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock();
+ executeBB.setRequestId("requestId");
+ RequestDetails requestDetails = new RequestDetails();
+ requestDetails.setModelInfo(null);
+ RequestParameters requestParams = new RequestParameters();
+ requestParams.setaLaCarte(true);
+ requestDetails.setRequestParameters(requestParams);
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setSuppressRollback(true);
+ requestInfo.setSource("VID");
+ requestDetails.setRequestInfo(requestInfo);
+ CloudConfiguration cloudConfiguration = new CloudConfiguration();
+ cloudConfiguration.setLcpCloudRegionId("myRegionId");
+ requestDetails.setCloudConfiguration(cloudConfiguration);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ String resourceId = "123";
+ String requestAction = "createInstance";
+
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnf-001");
+
+ doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(SPY_bbInputSetupUtils)
+ .getAAIGenericVnf(ArgumentMatchers.isA(String.class));
+ doReturn(null).when(bbInputSetupMapperLayer)
+ .mapAAIGenericVnfIntoGenericVnf(ArgumentMatchers.isA(org.onap.aai.domain.yang.GenericVnf.class));
+ GeneralBuildingBlock actual =
+ SPY_bbInputSetup.getGBBCM(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetGBBCMAddMembersAction() throws Exception {
+ GeneralBuildingBlock expected = mapper.readValue(
+ new File(RESOURCE_PATH + "GeneralBuildingBlockInstanceGroupExpected.json"), GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper.readValue(
+ new File(RESOURCE_PATH + "RequestDetailsInput_instanceGroupAddMembers.json"), RequestDetails.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ String requestAction = "addMembers";
+ String instanceGroupId = "instance-group-001";
+
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ workflowResourceIds.setInstanceGroupId(instanceGroupId);
+ executeBB.setWorkflowResourceIds(workflowResourceIds);
+
+ lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupId);
+
+ org.onap.aai.domain.yang.InstanceGroup aaiInstanceGroup = new org.onap.aai.domain.yang.InstanceGroup();
+ aaiInstanceGroup.setId(instanceGroupId);
+ aaiInstanceGroup.setInstanceGroupName("test instance group 1");
+
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ aaiServiceInstance.setServiceInstanceId("service-instance-001");
+ aaiServiceInstance.setServiceInstanceName("test service instance 1");
+ Optional<org.onap.aai.domain.yang.ServiceInstance> optSI = Optional.of(aaiServiceInstance);
+
+ org.onap.aai.domain.yang.GenericVnf vnf1 = new org.onap.aai.domain.yang.GenericVnf();
+ vnf1.setVnfId("vnf-001");
+ vnf1.setVnfName("test vnf 1");
+
+ org.onap.aai.domain.yang.GenericVnf vnf2 = new org.onap.aai.domain.yang.GenericVnf();
+ vnf2.setVnfId("vnf-002");
+ vnf2.setVnfName("test vnf 2");
+
+ doReturn(aaiInstanceGroup).when(SPY_bbInputSetupUtils).getAAIInstanceGroup(instanceGroupId);
+ doReturn(optSI).when(SPY_bbInputSetupUtils).getRelatedServiceInstanceFromInstanceGroup(instanceGroupId);
+ doReturn(vnf1).when(SPY_bbInputSetupUtils).getAAIGenericVnf("vnf-001");
+ doReturn(vnf2).when(SPY_bbInputSetupUtils).getAAIGenericVnf("vnf-002");
+
+ GeneralBuildingBlock actual =
+ SPY_bbInputSetup.getGBBCM(executeBB, requestDetails, lookupKeyMap, requestAction, instanceGroupId);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetGBBALaCarteNonService() throws Exception {
+ GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper.readValue(
+ new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ String requestAction = "createInstance";
+ Service service = Mockito.mock(Service.class);
+ ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
+ String resourceId = "123";
+ String vnfType = "vnfType";
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ aaiServiceInstance.setModelVersionId("modelVersionId");
+ org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "instanceId");
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+ doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId");
+
+ doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(requestDetails, service, "bbName",
+ serviceInstance, lookupKeyMap, resourceId, vnfType, null, null);
+ doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
+ doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
+
+ GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, resourceId, vnfType);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test(expected = Exception.class)
+ public void testGetGBBALaCarteNonServiceWithoutServiceModelInfo() throws Exception {
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper.readValue(
+ new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ String requestAction = "createInstance";
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ aaiServiceInstance.setModelVersionId("modelVersionId");
+ String resourceId = "123";
+ String vnfType = "vnfType";
+
+ SPY_bbInputSetup.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId,
+ vnfType);
+ }
+
+ @Test
+ public void testGetGBBALaCarteNonServiceWithoutRelatedInstances() throws Exception {
+ GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper.readValue(
+ new File(RESOURCE_PATH + "RequestDetailsInput_withoutRelatedInstanceList.json"), RequestDetails.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ String requestAction = "createInstance";
+ Service service = Mockito.mock(Service.class);
+ String resourceId = "123";
+ ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ aaiServiceInstance.setModelVersionId("modelVersionId");
+ org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
+ String vnfType = "vnfType";
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "instanceId");
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+ doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById("instanceId");
+
+ doNothing().when(SPY_bbInputSetup).populateObjectsOnAssignAndCreateFlows(requestDetails, service, "bbName",
+ serviceInstance, lookupKeyMap, resourceId, vnfType, null, null);
+
+ doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
+ doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
+
+ GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBALaCarteNonService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, resourceId, vnfType);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetGBBALaCarteService() throws Exception {
+ GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper.readValue(
+ new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+
+ org.onap.so.serviceinstancebeans.Project requestProject = new org.onap.so.serviceinstancebeans.Project();
+ org.onap.so.serviceinstancebeans.OwningEntity requestOwningEntity =
+ new org.onap.so.serviceinstancebeans.OwningEntity();
+ requestDetails.setProject(requestProject);
+ requestDetails.setOwningEntity(requestOwningEntity);
+
+ Service service = Mockito.mock(Service.class);
+ Customer customer = Mockito.mock(Customer.class);
+ ServiceSubscription serviceSubscription = Mockito.mock(ServiceSubscription.class);
+ Project project = Mockito.mock(Project.class);
+ OwningEntity owningEntity = Mockito.mock(OwningEntity.class);
+ ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
+ String resourceId = "123";
+ String requestAction = "createInstance";
+ executeBB.setaLaCarte(true);
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.SERVICE_INSTANCE.toString());
+ org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
+
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId());
+ doReturn(project).when(bbInputSetupMapperLayer).mapRequestProject(requestDetails.getProject());
+ doReturn(owningEntity).when(bbInputSetupMapperLayer).mapRequestOwningEntity(requestDetails.getOwningEntity());
+
+ doReturn(customer).when(SPY_bbInputSetup).getCustomerAndServiceSubscription(requestDetails, resourceId);
+ doReturn(serviceInstance).when(SPY_bbInputSetup).getALaCarteServiceInstance(service, requestDetails, customer,
+ project, owningEntity, lookupKeyMap, resourceId, Boolean.TRUE.equals(executeBB.isaLaCarte()),
+ executeBB.getBuildingBlock().getBpmnFlowName());
+ doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, customer);
+
+ GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, resourceId);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetGBBALaCarteServiceFindServiceByModelVersionId() throws Exception {
+ GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper.readValue(
+ new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+
+ org.onap.so.serviceinstancebeans.Project requestProject = new org.onap.so.serviceinstancebeans.Project();
+ org.onap.so.serviceinstancebeans.OwningEntity requestOwningEntity =
+ new org.onap.so.serviceinstancebeans.OwningEntity();
+ requestDetails.setProject(requestProject);
+ requestDetails.setOwningEntity(requestOwningEntity);
+
+ Service service = Mockito.mock(Service.class);
+ Customer customer = Mockito.mock(Customer.class);
+ ServiceSubscription serviceSubscription = Mockito.mock(ServiceSubscription.class);
+ Project project = Mockito.mock(Project.class);
+ OwningEntity owningEntity = Mockito.mock(OwningEntity.class);
+ ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
+ String resourceId = "123";
+ String requestAction = "createInstance";
+ executeBB.setaLaCarte(true);
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.SERVICE_INSTANCE.toString());
+ org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
+
+ doReturn(null).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId());
+ doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelVersionAndModelInvariantUUID(
+ requestDetails.getModelInfo().getModelVersion(), requestDetails.getModelInfo().getModelInvariantId());
+ doReturn(project).when(bbInputSetupMapperLayer).mapRequestProject(requestDetails.getProject());
+ doReturn(owningEntity).when(bbInputSetupMapperLayer).mapRequestOwningEntity(requestDetails.getOwningEntity());
+
+ doReturn(customer).when(SPY_bbInputSetup).getCustomerAndServiceSubscription(requestDetails, resourceId);
+ doReturn(serviceInstance).when(SPY_bbInputSetup).getALaCarteServiceInstance(service, requestDetails, customer,
+ project, owningEntity, lookupKeyMap, resourceId, Boolean.TRUE.equals(executeBB.isaLaCarte()),
+ executeBB.getBuildingBlock().getBpmnFlowName());
+ doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, customer);
+
+ GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, resourceId);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetGBBALaCarteServiceNoProjectNoOE() throws Exception {
+ GeneralBuildingBlock expected = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper.readValue(
+ new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+
+ Service service = Mockito.mock(Service.class);
+ Customer customer = Mockito.mock(Customer.class);
+ ServiceSubscription serviceSubscription = Mockito.mock(ServiceSubscription.class);
+ ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
+ String resourceId = "123";
+ String requestAction = "createInstance";
+ executeBB.setaLaCarte(true);
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.SERVICE_INSTANCE.toString());
+ org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
+
+ Map<String, String> uriKeys = new HashMap<>();
+ uriKeys.put("global-customer-id", "globalCustomerId");
+ uriKeys.put("service-type", "serviceType");
+
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId());
+
+ doReturn(customer).when(SPY_bbInputSetup).getCustomerAndServiceSubscription(requestDetails, resourceId);
+
+ doReturn(serviceInstance).when(SPY_bbInputSetup).getALaCarteServiceInstance(service, requestDetails, customer,
+ null, null, lookupKeyMap, resourceId, Boolean.TRUE.equals(executeBB.isaLaCarte()),
+ executeBB.getBuildingBlock().getBpmnFlowName());
+ doReturn(expected).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, customer);
+
+ GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, resourceId);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetServiceInstanceHelperCreateScenario() throws Exception {
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setInstanceName("SharansInstanceName");
+ requestDetails.setRequestInfo(requestInfo);
+ Customer customer = new Customer();
+ String serviceInstanceId = "SharansInstanceId";
+ boolean aLaCarte = true;
+ ServiceInstance expected = new ServiceInstance();
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ Service service = new Service();
+ service.setModelUUID("modelUUID");
+ String bbName = AssignFlows.SERVICE_INSTANCE.toString();
+
+ doReturn(null).when(SPY_bbInputSetupUtils).getAAIServiceInstanceByName(requestInfo.getInstanceName(), customer);
+ doReturn(null).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(serviceInstanceId);
+
+
+ doReturn(expected).when(SPY_bbInputSetup).createServiceInstance(requestDetails, null, null, lookupKeyMap,
+ serviceInstanceId);
+
+ ServiceInstance actual = SPY_bbInputSetup.getServiceInstanceHelper(requestDetails, customer, null, null,
+ lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetServiceInstanceHelperCreateScenarioExisting() throws Exception {
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setInstanceName("SharansInstanceName");
+ requestDetails.setRequestInfo(requestInfo);
+ Customer customer = new Customer();
+ String serviceInstanceId = "SharansInstanceId";
+ boolean aLaCarte = true;
+ Service service = new Service();
+ service.setModelUUID("modelUUID");
+ ServiceInstance expected = new ServiceInstance();
+ org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
+ serviceInstanceAAI.setModelVersionId("modelUUID");
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ String bbName = AssignFlows.SERVICE_INSTANCE.toString();
+
+ doReturn(serviceInstanceAAI).when(SPY_bbInputSetupUtils)
+ .getAAIServiceInstanceByName(requestInfo.getInstanceName(), customer);
+ doReturn(expected).when(SPY_bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
+
+ ServiceInstance actual = SPY_bbInputSetup.getServiceInstanceHelper(requestDetails, customer, null, null,
+ lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetServiceInstanceHelperCreateScenarioExistingNoNameButWithId() throws Exception {
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setInstanceName("SharansInstanceName");
+ requestDetails.setRequestInfo(requestInfo);
+ Customer customer = new Customer();
+ String serviceInstanceId = "SharansInstanceId";
+ boolean aLaCarte = true;
+ Service service = new Service();
+ service.setModelUUID("modelUUID");
+ ServiceInstance expected = new ServiceInstance();
+ org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
+ serviceInstanceAAI.setModelVersionId("modelUUID");
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ String bbName = "ActivateServiceInstanceBB";
+
+ doReturn(serviceInstanceAAI).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(serviceInstanceId);
+ doReturn(expected).when(SPY_bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
+
+ ServiceInstance actual = SPY_bbInputSetup.getServiceInstanceHelper(requestDetails, customer, null, null,
+ lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetServiceInstanceHelperCreateScenarioExistingNoNameButWithIdDifferentModel() throws Exception {
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestDetails.setRequestInfo(requestInfo);
+ Customer customer = new Customer();
+ String serviceInstanceId = "SharansInstanceId";
+ boolean aLaCarte = true;
+ Service service = new Service();
+ service.setModelUUID("modelUUID");
+ ServiceInstance expected = new ServiceInstance();
+ org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
+ serviceInstanceAAI.setModelVersionId("modelUUIDDifferent");
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ String bbName = "ActivateServiceInstanceBB";
+ Service differentService = new Service();
+ differentService.setModelUUID("modelUUIDDifferent");
+
+ doReturn(serviceInstanceAAI).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(serviceInstanceId);
+
+
+ ServiceInstance actual = SPY_bbInputSetup.getServiceInstanceHelper(requestDetails, customer, null, null,
+ lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test(expected = Exception.class)
+ public void testGetServiceInstanceHelperCreateScenarioExistingNoNameButWithIdExceptionThrown() throws Exception {
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestDetails.setRequestInfo(requestInfo);
+ Customer customer = new Customer();
+ String serviceInstanceId = "SharansInstanceId";
+ boolean aLaCarte = true;
+ Service service = new Service();
+ service.setModelUUID("modelUUID");
+ org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
+ serviceInstanceAAI.setModelVersionId("modelUUIDDifferent");
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ String bbName = AssignFlows.SERVICE_INSTANCE.toString();
+
+ ServiceInstance actual = SPY_bbInputSetup.getServiceInstanceHelper(requestDetails, customer, null, null,
+ lookupKeyMap, serviceInstanceId, aLaCarte, service, bbName);
+ }
+
+ @Test
+ public void testPopulateObjectsOnAssignAndCreateFlows() throws Exception {
+ String bbName = AssignFlows.SERVICE_INSTANCE.toString();
+ String instanceName = "instanceName";
+ String vnfType = "vnfType";
+ String resourceId = "networkId";
+ String productFamilyId = "productFamilyId";
+ Service service = Mockito.mock(Service.class);
+ ServiceInstance serviceInstance = Mockito.mock(ServiceInstance.class);
+ RequestDetails requestDetails = Mockito.mock(RequestDetails.class);
+ ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
+ RequestInfo requestInfo = Mockito.mock(RequestInfo.class);
+ RelatedInstanceList[] relatedInstanceList = new RelatedInstanceList[] {};
+ CloudConfiguration cloudConfiguration = new CloudConfiguration();
+ org.onap.so.serviceinstancebeans.Platform platform =
+ Mockito.mock(org.onap.so.serviceinstancebeans.Platform.class);
+ org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness =
+ Mockito.mock(org.onap.so.serviceinstancebeans.LineOfBusiness.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+
+ doNothing().when(SPY_bbInputSetup).populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance,
+ lookupKeyMap, resourceId, null);
+ doReturn(modelInfo).when(requestDetails).getModelInfo();
+ doReturn(productFamilyId).when(requestInfo).getProductFamilyId();
+ doReturn(requestInfo).when(requestDetails).getRequestInfo();
+ doReturn(instanceName).when(requestInfo).getInstanceName();
+ doReturn(platform).when(requestDetails).getPlatform();
+ doReturn(lineOfBusiness).when(requestDetails).getLineOfBusiness();
+ doReturn(relatedInstanceList).when(requestDetails).getRelatedInstanceList();
+ doReturn(cloudConfiguration).when(requestDetails).getCloudConfiguration();
+
+ doReturn(ModelType.network).when(modelInfo).getModelType();
+ SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
+ lookupKeyMap, resourceId, vnfType, null, null);
+ verify(SPY_bbInputSetup, times(1)).populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance,
+ lookupKeyMap, resourceId, null);
+ assertEquals("NetworkId populated", true,
+ lookupKeyMap.get(ResourceKey.NETWORK_ID).equalsIgnoreCase(resourceId));
+
+ doReturn(ModelType.vnf).when(modelInfo).getModelType();
+ resourceId = "vnfId";
+ doNothing().when(SPY_bbInputSetup).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness,
+ service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null,
+ productFamilyId);
+ SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
+ lookupKeyMap, resourceId, vnfType, null, null);
+ verify(SPY_bbInputSetup, times(1)).populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness,
+ service, bbName, serviceInstance, lookupKeyMap, relatedInstanceList, resourceId, vnfType, null,
+ productFamilyId);
+ assertEquals("VnfId populated", true,
+ lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID).equalsIgnoreCase(resourceId));
+
+ doReturn(ModelType.volumeGroup).when(modelInfo).getModelType();
+ resourceId = "volumeGroupId";
+ doNothing().when(SPY_bbInputSetup).populateVolumeGroup(modelInfo, service, bbName, serviceInstance,
+ lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null);
+ SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
+ lookupKeyMap, resourceId, vnfType, null, null);
+ verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(modelInfo, service, bbName, serviceInstance,
+ lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null);
+ assertEquals("VolumeGroupId populated", true,
+ lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID).equalsIgnoreCase(resourceId));
+
+ doReturn(ModelType.vfModule).when(modelInfo).getModelType();
+ resourceId = "vfModuleId";
+ doNothing().when(SPY_bbInputSetup).populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap,
+ resourceId, relatedInstanceList, instanceName, null, cloudConfiguration);
+ SPY_bbInputSetup.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance,
+ lookupKeyMap, resourceId, vnfType, null, null);
+ verify(SPY_bbInputSetup, times(1)).populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap,
+ resourceId, relatedInstanceList, instanceName, null, cloudConfiguration);
+ assertEquals("VfModuleId populated", true,
+ lookupKeyMap.get(ResourceKey.VF_MODULE_ID).equalsIgnoreCase(resourceId));
+ }
+
+ @Test
+ public void testPopulateGBBWithSIAndAdditionalInfo() throws Exception {
+ GeneralBuildingBlock expected =
+ mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpectedWUserParamsInfo.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper.readValue(
+ new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
+ RequestContext requestContext =
+ mapper.readValue(new File(RESOURCE_PATH + "RequestContextExpected.json"), RequestContext.class);
+ ServiceInstance serviceInstance =
+ mapper.readValue(new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
+ ServiceInstance.class);
+ CloudConfiguration cloudConfiguration = new CloudConfiguration();
+ cloudConfiguration.setTenantId("tenantId");
+ requestDetails.setCloudConfiguration(cloudConfiguration);
+ OrchestrationContext orchestrationContext = new OrchestrationContext();
+ orchestrationContext.setIsRollbackEnabled(false);
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setCloudOwner("test-owner-name");
+ cloudRegion.setLcpCloudRegionId("lcpCloudRegionId");
+ cloudRegion.setComplex("complexName");
+ cloudRegion.setTenantId("tenantId");
+
+ Map<String, String> uriKeys = new HashMap<>();
+ uriKeys.put("global-customer-id", "global-customer-id");
+ uriKeys.put("service-type", "service-type");
+
+ Customer customer = new Customer();
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setServiceType("subscriptionServiceType");
+ customer.setGlobalCustomerId("globalCustomerId");
+ customer.setSubscriberName("subscriberName");
+ customer.setSubscriberType("subscriberType");
+ customer.setServiceSubscription(serviceSubscription);
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant tenant =
+ new org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant();
+ tenant.setTenantContext("tenantContext");
+ tenant.setTenantId("tenantId");
+ tenant.setTenantName("tenantName");
+
+ org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
+ org.onap.aai.domain.yang.Tenants aaiTenants = Mockito.mock(org.onap.aai.domain.yang.Tenants.class);
+ org.onap.aai.domain.yang.Tenant aaiTenant = new org.onap.aai.domain.yang.Tenant();
+ aaiTenant.setTenantId("tenantId");
+ List<org.onap.aai.domain.yang.Tenant> tenants = new ArrayList<>();
+ tenants.add(aaiTenant);
+
+ String requestAction = "createInstance";
+
+ doReturn(uriKeys).when(SPY_bbInputSetupUtils)
+ .getURIKeysFromServiceInstance(serviceInstance.getServiceInstanceId());
+ doReturn(customer).when(SPY_bbInputSetup).mapCustomer(uriKeys.get("global-customer-id"),
+ uriKeys.get("service-type"));
+ doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration());
+ doReturn(orchestrationContext).when(bbInputSetupMapperLayer).mapOrchestrationContext(requestDetails);
+ doReturn(requestContext).when(bbInputSetupMapperLayer).mapRequestContext(requestDetails);
+ doReturn(cloudRegion).when(bbInputSetupMapperLayer).mapCloudRegion(requestDetails.getCloudConfiguration(),
+ aaiCloudRegion);
+ doReturn(tenant).when(bbInputSetupMapperLayer).mapTenant(aaiTenant);
+ doReturn(aaiTenants).when(aaiCloudRegion).getTenants();
+ doReturn(tenants).when(aaiTenants).getTenant();
+
+ GeneralBuildingBlock actual = SPY_bbInputSetup.populateGBBWithSIAndAdditionalInfo(requestDetails,
+ serviceInstance, executeBB, requestAction, null);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetServiceInstanceNOAAI() throws Exception {
+ ServiceInstance expected =
+ mapper.readValue(new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
+ ServiceInstance.class);
+ Service service = mapper.readValue(
+ new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
+ Customer customer = mapper.readValue(new File(RESOURCE_PATH + "Customer.json"), Customer.class);
+ Project project = mapper.readValue(new File(RESOURCE_PATH + "Project.json"), Project.class);
+ OwningEntity owningEntity = mapper.readValue(new File(RESOURCE_PATH + "OwningEntity.json"), OwningEntity.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+
+ ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock();
+ executeBB.setaLaCarte(true);
+ BuildingBlock buildingBlock = new BuildingBlock();
+ buildingBlock.setBpmnFlowName(AssignFlows.SERVICE_INSTANCE.toString());
+ executeBB.setBuildingBlock(buildingBlock);
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo reqInfo = new RequestInfo();
+ reqInfo.setInstanceName("serviceInstanceName");
+ requestDetails.setRequestInfo(reqInfo);
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelType(ModelType.service);
+ requestDetails.setModelInfo(modelInfo);
+ doReturn(null).when(SPY_bbInputSetupUtils)
+ .getAAIServiceInstanceByName(requestDetails.getRequestInfo().getInstanceName(), customer);
+ doReturn(expected.getModelInfoServiceInstance()).when(bbInputSetupMapperLayer)
+ .mapCatalogServiceIntoServiceInstance(service);
+ doReturn(null).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(any(String.class));
+ String serviceInstanceId = "3655a595-05d1-433c-93c0-3afd6b572545";
+ boolean aLaCarte = true;
+
+ ServiceInstance actual =
+ SPY_bbInputSetup.getALaCarteServiceInstance(service, requestDetails, customer, project, owningEntity,
+ lookupKeyMap, serviceInstanceId, aLaCarte, executeBB.getBuildingBlock().getBpmnFlowName());
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetServiceSubscription() throws IOException {
+ ServiceSubscription expected = new ServiceSubscription();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestParameters params = new RequestParameters();
+ params.setSubscriptionServiceType("subscriptionServiceType");
+ requestDetails.setRequestParameters(params);
+ org.onap.aai.domain.yang.ServiceSubscription aaiServiceSubscription =
+ new org.onap.aai.domain.yang.ServiceSubscription();
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+ doReturn(aaiServiceSubscription).when(SPY_bbInputSetupUtils).getAAIServiceSubscription(
+ customer.getGlobalCustomerId(), requestDetails.getRequestParameters().getSubscriptionServiceType());
+ doReturn(expected).when(bbInputSetupMapperLayer).mapAAIServiceSubscription(aaiServiceSubscription);
+
+ ServiceSubscription actual = SPY_bbInputSetup.getServiceSubscription(requestDetails, customer);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetCustomer() throws IOException {
+ Customer expected = new Customer();
+ RequestDetails requestDetails = new RequestDetails();
+ SubscriberInfo subscriberInfo = new SubscriberInfo();
+ subscriberInfo.setGlobalSubscriberId("globalSubscriberId");
+ requestDetails.setSubscriberInfo(subscriberInfo);
+ org.onap.aai.domain.yang.Customer aaiCustomer = new org.onap.aai.domain.yang.Customer();
+ doReturn(aaiCustomer).when(SPY_bbInputSetupUtils)
+ .getAAICustomer(requestDetails.getSubscriberInfo().getGlobalSubscriberId());
+ doReturn(expected).when(bbInputSetupMapperLayer).mapAAICustomer(aaiCustomer);
+
+ Customer actual = SPY_bbInputSetup.getCustomerFromRequest(requestDetails);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetExistingServiceInstance() throws Exception {
+ org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
+ ServiceInstance expected = new ServiceInstance();
+
+ doReturn(expected).when(bbInputSetupMapperLayer).mapAAIServiceInstanceIntoServiceInstance(serviceInstanceAAI);
+
+
+ ServiceInstance actual = SPY_bbInputSetup.getExistingServiceInstance(serviceInstanceAAI);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testPopulateNetworkCollectionAndInstanceGroupAssign() throws Exception {
+ Service service = Mockito.mock(Service.class);
+ String key = "collectionCustId";
+ ServiceInstance serviceInstance =
+ mapper.readValue(new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
+ ServiceInstance.class);
+ String resourceId = "123";
+ Collection collection = SPY_bbInputSetup.createCollection(resourceId);
+ InstanceGroup instanceGroup = SPY_bbInputSetup.createInstanceGroup();
+ assertNull(serviceInstance.getCollection());
+ doReturn(true).when(SPY_bbInputSetup).isVlanTagging(service, key);
+ doReturn(collection).when(SPY_bbInputSetup).createCollection(resourceId);
+ doReturn(instanceGroup).when(SPY_bbInputSetup).createInstanceGroup();
+ doNothing().when(SPY_bbInputSetup).mapCatalogCollection(service, collection, key);
+
+ NetworkCollectionResourceCustomization networkCollection = new NetworkCollectionResourceCustomization();
+ networkCollection.setModelCustomizationUUID(key);
+ networkCollection.setCollectionResource(new CollectionResource());
+ networkCollection.getCollectionResource().setInstanceGroup(new org.onap.so.db.catalog.beans.InstanceGroup());
+ networkCollection.getCollectionResource().getInstanceGroup().setToscaNodeType("NetworkCollectionResource");
+ networkCollection.getCollectionResource().getInstanceGroup().setType(InstanceGroupType.L3_NETWORK);
+ networkCollection.getCollectionResource().getInstanceGroup()
+ .setCollectionInstanceGroupCustomizations(new ArrayList<>());
+ List<CollectionResourceCustomization> customizations = new ArrayList<>();
+ customizations.add(networkCollection);
+ doReturn(customizations).when(service).getCollectionResourceCustomizations();
+
+ SPY_bbInputSetup.populateNetworkCollectionAndInstanceGroupAssign(service,
+ AssignFlows.NETWORK_COLLECTION.toString(), serviceInstance, resourceId, key);
+
+ assertNotNull(serviceInstance.getCollection());
+ assertNotNull(serviceInstance.getCollection().getInstanceGroup());
+
+ verify(SPY_bbInputSetup, times(1)).mapCatalogCollection(service, serviceInstance.getCollection(), key);
+ verify(SPY_bbInputSetup, times(1)).mapCatalogNetworkCollectionInstanceGroup(service,
+ serviceInstance.getCollection().getInstanceGroup(), key);
+ }
+
+ @Test
+ public void testPopulateInstanceGroup() throws Exception {
+ ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
+ Service service = Mockito.mock(Service.class);
+ List<InstanceGroup> instanceGroups = Mockito.spy(new ArrayList<>());
+ ServiceInstance serviceInstance = Mockito.spy(new ServiceInstance());
+ serviceInstance.setServiceInstanceId("si-001");
+ serviceInstance.setServiceInstanceName("test service instance");
+ serviceInstance.setInstanceGroups(instanceGroups);
+
+ SPY_bbInputSetup.populateInstanceGroup(modelInfo, service, serviceInstance, "instance-group-001",
+ "test instance group");
+ verify(SPY_bbInputSetup, times(1)).mapCatalogInstanceGroup(isA(InstanceGroup.class), isA(ModelInfo.class),
+ isA(Service.class));
+ verify(instanceGroups, times(1)).add(isA(InstanceGroup.class));
+ }
+
+ @Test
+ public void testIsVlanTagging() throws Exception {
+ boolean expected = true;
+ Service service = Mockito.mock(Service.class);
+ String key = "collectionCustId";
+ NetworkCollectionResourceCustomization networkCollection = new NetworkCollectionResourceCustomization();
+ networkCollection.setModelCustomizationUUID(key);
+ networkCollection.setCollectionResource(new CollectionResource());
+ networkCollection.getCollectionResource().setInstanceGroup(new org.onap.so.db.catalog.beans.InstanceGroup());
+ networkCollection.getCollectionResource().getInstanceGroup()
+ .setToscaNodeType("org.openecomp.resource.cr.NetworkCollectionResource1806");
+ List<CollectionResourceCustomization> customizations = new ArrayList<>();
+ customizations.add(networkCollection);
+ doReturn(customizations).when(service).getCollectionResourceCustomizations();
+ boolean actual = SPY_bbInputSetup.isVlanTagging(service, key);
+ assertEquals("Is Vlan Tagging check.", expected, actual);
+ }
+
+ @Test
+ public void testPopulateVolumeGroup() throws Exception {
+ RequestDetails requestDetails = new RequestDetails();
+ RelatedInstanceList ril = new RelatedInstanceList();
+ RelatedInstance ri = new RelatedInstance();
+ ModelInfo mi = new ModelInfo();
+ mi.setModelType(ModelType.vnf);
+ mi.setModelCustomizationUuid("vnfModelCustomizationUUID");
+ ri.setModelInfo(mi);
+ ril.setRelatedInstance(ri);
+ requestDetails.setRelatedInstanceList(new RelatedInstanceList[] {ril});
+
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelType(ModelType.volumeGroup);
+
+ RequestInfo reqInfo = new RequestInfo();
+ reqInfo.setInstanceName("volumeGroupName");
+ requestDetails.setModelInfo(modelInfo);
+ requestDetails.setRequestInfo(reqInfo);
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("genericVnfId");
+
+ VolumeGroup vg = new VolumeGroup();
+ vg.setVolumeGroupName("volumeGroupName");
+ vg.setVolumeGroupId("volumeGroupId");
+ vnf.getVolumeGroups().add(vg);
+ serviceInstance.getVnfs().add(vnf);
+
+ Service service = mapper.readValue(
+ new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId");
+
+ String bbName = AssignFlows.VOLUME_GROUP.toString();
+ String resourceId = "123";
+ doNothing().when(SPY_bbInputSetup).mapCatalogVolumeGroup(isA(VolumeGroup.class), eq(modelInfo), eq(service),
+ eq("vnfModelCustomizationUUID"));
+ org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = new org.onap.aai.domain.yang.GenericVnf();
+ aaiGenericVnf.setModelCustomizationId("vnfModelCustomizationUUID");
+ doReturn(aaiGenericVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
+
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
+ SPY_bbInputSetup.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
+ requestDetails.getRelatedInstanceList(), reqInfo.getInstanceName(), null, null);
+ verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(vg, modelInfo, service, "vnfModelCustomizationUUID");
+ vnf.getVolumeGroups().clear();
+ SPY_bbInputSetup.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
+ requestDetails.getRelatedInstanceList(), reqInfo.getInstanceName(), null, null);
+ verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(vnf.getVolumeGroups().get(0), modelInfo, service,
+ "vnfModelCustomizationUUID");
+ }
+
+ @Test
+ public void testMapCatalogVolumeGroup() {
+ VolumeGroup volumeGroup = new VolumeGroup();
+ RequestDetails requestDetails = new RequestDetails();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationUuid("modelCustomizationUUID");
+ requestDetails.setModelInfo(modelInfo);
+ Service service = new Service();
+ VnfResourceCustomization resourceCust = new VnfResourceCustomization();
+ resourceCust.setModelCustomizationUUID("vnfModelCustomizationUUID");
+ service.getVnfCustomizations().add(resourceCust);
+ VfModuleCustomization vfResourceCust = new VfModuleCustomization();
+ vfResourceCust.setModelCustomizationUUID("modelCustomizationUUID");
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+ resourceCust.getVfModuleCustomizations().add(vfResourceCust);
+
+ doReturn(modelInfoVfModule).when(bbInputSetupMapperLayer).mapCatalogVfModuleToVfModule(vfResourceCust);
+
+ SPY_bbInputSetup.mapCatalogVolumeGroup(volumeGroup, modelInfo, service, "vnfModelCustomizationUUID");
+
+ assertEquals(modelInfoVfModule, volumeGroup.getModelInfoVfModule());
+ }
+
+ @Test
+ public void testPopulateL3Network() throws JsonParseException, JsonMappingException, IOException {
+ String instanceName = "networkName";
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelType(ModelType.network);
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ L3Network network = new L3Network();
+ network.setNetworkId("networkId");
+ network.setNetworkName("networkName");
+ serviceInstance.getNetworks().add(network);
+ String resourceId = "123";
+ // Mock service
+ Service service = mapper.readValue(
+ new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
+ String bbName = AssignFlows.NETWORK_A_LA_CARTE.toString();
+
+ doNothing().when(SPY_bbInputSetup).mapCatalogNetwork(network, modelInfo, service);
+
+ SPY_bbInputSetup.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap,
+ resourceId, null);
+
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, null);
+
+ SPY_bbInputSetup.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap,
+ resourceId, null);
+ verify(SPY_bbInputSetup, times(1)).mapCatalogNetwork(network, modelInfo, service);
+
+ instanceName = "networkName2";
+ L3Network network2 = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, resourceId, null);
+ SPY_bbInputSetup.populateL3Network(instanceName, modelInfo, service, bbName, serviceInstance, lookupKeyMap,
+ resourceId, null);
+ verify(SPY_bbInputSetup, times(2)).mapCatalogNetwork(network2, modelInfo, service);
+ }
+
+ @Test
+ public void testMapCatalogNetwork() {
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ L3Network network = new L3Network();
+
+ RequestDetails requestDetails = new RequestDetails();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationUuid("modelCustomizationUUID");
+ requestDetails.setModelInfo(modelInfo);
+ Service service = new Service();
+ NetworkResourceCustomization resourceCust = new NetworkResourceCustomization();
+ resourceCust.setModelCustomizationUUID("modelCustomizationUUID");
+ service.setNetworkCustomizations(Arrays.asList(new NetworkResourceCustomization[] {resourceCust}));
+
+ doReturn(modelInfoNetwork).when(bbInputSetupMapperLayer).mapCatalogNetworkToNetwork(resourceCust);
+
+ SPY_bbInputSetup.mapCatalogNetwork(network, modelInfo, service);
+
+ assertEquals(modelInfoNetwork, network.getModelInfoNetwork());
+ }
+
+ @Test
+ public void testPopulateConfiguration() throws JsonParseException, JsonMappingException, IOException {
+ String instanceName = "configurationName";
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationUuid("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationId("configurationId");
+ configuration.setConfigurationName("configurationName");
+ serviceInstance.getConfigurations().add(configuration);
+ String resourceId = "configurationId";
+ String vnfcName = "vnfcName";
+ // Mock service
+ Service service = mapper.readValue(
+ new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
+ ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization();
+ configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
+ service.getConfigurationCustomizations().add(configurationCust);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
+ String bbName = AssignFlows.FABRIC_CONFIGURATION.toString();
+ ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
+ configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
+ configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
+ configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
+ configResourceKeys.setVnfcName(vnfcName);
+ Vnfc vnfc = new Vnfc();
+ vnfc.setVnfcName(vnfcName);
+
+ doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration, modelInfo, service,
+ configResourceKeys);
+ doReturn(vnfc).when(SPY_bbInputSetup).getVnfcToConfiguration(vnfcName);
+ SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
+ instanceName, configResourceKeys);
+ verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service,
+ configResourceKeys);
+
+ lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, null);
+
+ SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
+ instanceName, configResourceKeys);
+ verify(SPY_bbInputSetup, times(2)).mapCatalogConfiguration(configuration, modelInfo, service,
+ configResourceKeys);
+
+ instanceName = "configurationName2";
+ resourceId = "resourceId2";
+ lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId2");
+ Configuration configuration2 = SPY_bbInputSetup.createConfiguration(lookupKeyMap, instanceName, resourceId);
+ doReturn(configuration2).when(SPY_bbInputSetup).createConfiguration(lookupKeyMap, instanceName, resourceId);
+ doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(configuration2, modelInfo, service,
+ configResourceKeys);
+ SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
+ instanceName, configResourceKeys);
+ verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration2, modelInfo, service,
+ configResourceKeys);
+ }
+
+ @Test
+ public void testMapCatalogConfiguration() {
+ ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
+ L3Network network = new L3Network();
+
+ RequestDetails requestDetails = new RequestDetails();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationUuid("modelCustomizationUUID");
+ requestDetails.setModelInfo(modelInfo);
+ Service service = new Service();
+ NetworkResourceCustomization resourceCust = new NetworkResourceCustomization();
+ resourceCust.setModelCustomizationUUID("modelCustomizationUUID");
+ service.setNetworkCustomizations(Arrays.asList(new NetworkResourceCustomization[] {resourceCust}));
+
+ doReturn(modelInfoNetwork).when(bbInputSetupMapperLayer).mapCatalogNetworkToNetwork(resourceCust);
+
+ SPY_bbInputSetup.mapCatalogNetwork(network, modelInfo, service);
+
+ assertEquals(modelInfoNetwork, network.getModelInfoNetwork());
+ }
+
+ @Test
+ public void testPopulateFabricConfiguration() throws JsonParseException, JsonMappingException, IOException {
+ String instanceName = "configurationName";
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationUuid("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationId("configurationId");
+ configuration.setConfigurationName("configurationName");
+ serviceInstance.getConfigurations().add(configuration);
+ String resourceId = "configurationId";
+ String vnfcName = "vnfcName";
+ // Mock service
+ Service service = mapper.readValue(
+ new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
+ String bbName = AssignFlows.FABRIC_CONFIGURATION.toString();
+ ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
+ configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
+ configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
+ configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
+ configResourceKeys.setVnfcName(vnfcName);
+ Vnfc vnfc = new Vnfc();
+ vnfc.setVnfcName(vnfcName);
+
+ CvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization =
+ new CvnfcConfigurationCustomization();
+ ConfigurationResource configurationResource = new ConfigurationResource();
+ configurationResource.setModelUUID("modelUUID");
+ configurationResource.setModelInvariantUUID("modelInvariantUUID");
+ vnfVfmoduleCvnfcConfigurationCustomization.setConfigurationResource(configurationResource);
+
+ doReturn(null).when(SPY_bbInputSetup).findConfigurationResourceCustomization(modelInfo, service);
+ doReturn(vnfc).when(SPY_bbInputSetup).getVnfcToConfiguration(vnfcName);
+
+ SPY_bbInputSetup.populateConfiguration(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
+ instanceName, configResourceKeys);
+ verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(configuration, modelInfo, service,
+ configResourceKeys);
+ }
+
+ @Test
+ public void testPopulateGenericVnf() throws JsonParseException, JsonMappingException, IOException {
+ org.onap.so.serviceinstancebeans.Platform platform = new org.onap.so.serviceinstancebeans.Platform();
+ org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness =
+ new org.onap.so.serviceinstancebeans.LineOfBusiness();
+ String instanceName = "vnfName";
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelType(ModelType.vnf);
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("genericVnfId");
+ vnf.setVnfName("vnfName");
+ serviceInstance.getVnfs().add(vnf);
+ String vnfType = "vnfType";
+ RequestDetails requestDetails =
+ mapper.readValue(new File(RESOURCE_PATH + "RequestDetails_CreateVnf.json"), RequestDetails.class);
+
+ Service service = mapper.readValue(
+ new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId");
+ String bbName = AssignFlows.VNF.toString();
+
+ Platform expectedPlatform = new Platform();
+ LineOfBusiness expectedLineOfBusiness = new LineOfBusiness();
+ String resourceId = "123";
+ doReturn(expectedPlatform).when(bbInputSetupMapperLayer).mapRequestPlatform(platform);
+ doReturn(expectedLineOfBusiness).when(bbInputSetupMapperLayer).mapRequestLineOfBusiness(lineOfBusiness);
+ org.onap.aai.domain.yang.GenericVnf vnfAAI = new org.onap.aai.domain.yang.GenericVnf();
+ vnfAAI.setModelCustomizationId("modelCustId");
+ doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
+ doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf, modelInfo, service);
+ org.onap.aai.domain.yang.InstanceGroup instanceGroupAAI = new org.onap.aai.domain.yang.InstanceGroup();
+ doReturn(instanceGroupAAI).when(SPY_bbInputSetupUtils).getAAIInstanceGroup(any());
+ org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup =
+ new org.onap.so.db.catalog.beans.InstanceGroup();
+ doReturn(catalogInstanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup(any());
+
+ SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
+ serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
+ requestDetails.getRequestInfo().getProductFamilyId());
+
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
+
+ SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
+ serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
+ requestDetails.getRequestInfo().getProductFamilyId());
+ verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service);
+
+ instanceName = "vnfName2";
+ GenericVnf vnf2 = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness,
+ resourceId, vnfType, null, requestDetails.getRequestInfo().getProductFamilyId());
+ doReturn(vnf2).when(SPY_bbInputSetup).createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness,
+ resourceId, vnfType, null, requestDetails.getRequestInfo().getProductFamilyId());
+ doNothing().when(SPY_bbInputSetup).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
+ doNothing().when(SPY_bbInputSetup).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
+
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId2");
+
+ SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
+ serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
+ requestDetails.getRequestInfo().getProductFamilyId());
+ verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service);
+ verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
+ verify(SPY_bbInputSetup, times(2)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
+ }
+
+ @Test
+ public void testMapVnfcCollectionInstanceGroup() {
+ VnfResourceCustomization vnfResourceCust = Mockito.mock(VnfResourceCustomization.class);
+ GenericVnf genericVnf = new GenericVnf();
+ ModelInfo modelInfo = Mockito.mock(ModelInfo.class);
+ Service service = Mockito.mock(Service.class);
+ org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = new org.onap.so.db.catalog.beans.InstanceGroup();
+ instanceGroup.setModelUUID("modelUUID");
+ List<VnfcInstanceGroupCustomization> vnfcInstanceGroups = new ArrayList<>();
+ VnfcInstanceGroupCustomization vnfcInstanceGroupCust = new VnfcInstanceGroupCustomization();
+ vnfcInstanceGroupCust.setInstanceGroup(instanceGroup);
+ vnfcInstanceGroupCust.setFunction("function");
+ vnfcInstanceGroupCust.setDescription("description");
+ vnfcInstanceGroups.add(vnfcInstanceGroupCust);
+
+ ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
+ modelInfoInstanceGroup.setModelUUID("modelUUID");
+ doReturn(vnfResourceCust).when(SPY_bbInputSetup).getVnfResourceCustomizationFromService(modelInfo, service);
+ doReturn(vnfcInstanceGroups).when(vnfResourceCust).getVnfcInstanceGroupCustomizations();
+ doReturn(instanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup("modelUUID");
+ doReturn(modelInfoInstanceGroup).when(bbInputSetupMapperLayer).mapCatalogInstanceGroupToInstanceGroup(null,
+ instanceGroup);
+
+ SPY_bbInputSetup.mapVnfcCollectionInstanceGroup(genericVnf, modelInfo, service);
+
+ assertEquals("Instance Group was created", true, genericVnf.getInstanceGroups().size() == 1);
+ }
+
+ @Test
+ public void testPopulateGenericVnfWhereVnfTypeIsNull()
+ throws JsonParseException, JsonMappingException, IOException {
+ org.onap.so.serviceinstancebeans.Platform platform = new org.onap.so.serviceinstancebeans.Platform();
+ org.onap.so.serviceinstancebeans.LineOfBusiness lineOfBusiness =
+ new org.onap.so.serviceinstancebeans.LineOfBusiness();
+ String instanceName = "vnfName";
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelType(ModelType.vnf);
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("genericVnfId");
+ vnf.setVnfName("vnfName");
+ serviceInstance.getVnfs().add(vnf);
+ String vnfType = null;
+ RequestDetails requestDetails =
+ mapper.readValue(new File(RESOURCE_PATH + "RequestDetails_CreateVnf.json"), RequestDetails.class);
+
+ Service service = mapper.readValue(
+ new File(RESOURCE_PATH + "CatalogDBService_getServiceInstanceNOAAIInput.json"), Service.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "genericVnfId");
+ String bbName = AssignFlows.VNF.toString();
+
+ Platform expectedPlatform = new Platform();
+ LineOfBusiness expectedLineOfBusiness = new LineOfBusiness();
+ String resourceId = "123";
+ doReturn(expectedPlatform).when(bbInputSetupMapperLayer).mapRequestPlatform(platform);
+ doReturn(expectedLineOfBusiness).when(bbInputSetupMapperLayer).mapRequestLineOfBusiness(lineOfBusiness);
+ org.onap.aai.domain.yang.GenericVnf vnfAAI = new org.onap.aai.domain.yang.GenericVnf();
+ vnfAAI.setModelCustomizationId("modelCustId");
+ doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
+ doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf, modelInfo, service);
+ org.onap.aai.domain.yang.InstanceGroup instanceGroupAAI = new org.onap.aai.domain.yang.InstanceGroup();
+ doReturn(instanceGroupAAI).when(SPY_bbInputSetupUtils).getAAIInstanceGroup(any());
+ org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup =
+ new org.onap.so.db.catalog.beans.InstanceGroup();
+ doReturn(catalogInstanceGroup).when(SPY_bbInputSetupUtils).getCatalogInstanceGroup(any());
+
+ SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
+ serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
+ requestDetails.getRequestInfo().getProductFamilyId());
+
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
+
+ SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
+ serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
+ requestDetails.getRequestInfo().getProductFamilyId());
+ verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(vnf, modelInfo, service);
+
+ instanceName = "vnfName2";
+ GenericVnf vnf2 = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, platform, lineOfBusiness,
+ resourceId, vnfType, null, requestDetails.getRequestInfo().getProductFamilyId());
+
+ org.onap.aai.domain.yang.GenericVnf vnf2AAI = new org.onap.aai.domain.yang.GenericVnf();
+ vnfAAI.setModelCustomizationId("modelCustId2");
+ doReturn(vnf2AAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf2.getVnfId());
+ doNothing().when(SPY_bbInputSetup).mapCatalogVnf(vnf2, modelInfo, service);
+ doNothing().when(SPY_bbInputSetup).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
+ SPY_bbInputSetup.populateGenericVnf(modelInfo, instanceName, platform, lineOfBusiness, service, bbName,
+ serviceInstance, lookupKeyMap, requestDetails.getRelatedInstanceList(), resourceId, vnfType, null,
+ requestDetails.getRequestInfo().getProductFamilyId());
+ verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(vnf2, modelInfo, service);
+ verify(SPY_bbInputSetup, times(2)).mapNetworkCollectionInstanceGroup(vnf2, "{instanceGroupId}");
+ verify(SPY_bbInputSetup, times(1)).mapVnfcCollectionInstanceGroup(vnf2, modelInfo, service);
+ }
+
+ @Test
+ public void testMapCatalogVnf() {
+ ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
+ GenericVnf genericVnf = new GenericVnf();
+ RequestDetails requestDetails = new RequestDetails();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationUuid("modelCustomizationUUID");
+ requestDetails.setModelInfo(modelInfo);
+ Service service = new Service();
+ VnfResourceCustomization resourceCust = new VnfResourceCustomization();
+ resourceCust.setModelCustomizationUUID("vnfModelCustomizationUUID");
+ service.getVnfCustomizations().add(resourceCust);
+ resourceCust.setModelCustomizationUUID("modelCustomizationUUID");
+
+ doReturn(modelInfoGenericVnf).when(bbInputSetupMapperLayer).mapCatalogVnfToVnf(resourceCust);
+
+ SPY_bbInputSetup.mapCatalogVnf(genericVnf, modelInfo, service);
+
+ assertEquals(modelInfoGenericVnf, genericVnf.getModelInfoGenericVnf());
+ }
+
+ @Test
+ public void testMapCatalogCollectionAndInstanceGroup() {
+ ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
+ modelInfoCollection.setCollectionFunction("collectionFunction");
+ modelInfoCollection.setCollectionRole("collectionRole");
+ modelInfoCollection.setCollectionType("collectionType");
+ modelInfoCollection.setDescription("description");
+ modelInfoCollection.setModelInvariantUUID("modelInvariantUUID");
+ modelInfoCollection.setQuantity(0);
+
+ ModelInfoInstanceGroup modelInfoInstanceGroup = new ModelInfoInstanceGroup();
+ modelInfoInstanceGroup.setFunction("function");
+ modelInfoInstanceGroup.setInstanceGroupRole("instanceGroupRole");
+ modelInfoInstanceGroup.setModelInvariantUUID("modelInvariantUUID");
+ modelInfoInstanceGroup.setModelUUID("modelUUID");
+ modelInfoInstanceGroup.setType("VNFC");
+ modelInfoInstanceGroup.setDescription("description");
+
+ InstanceGroup instanceGroup = new InstanceGroup();
+ Collection collection = new Collection();
+ collection.setInstanceGroup(instanceGroup);
+
+ CollectionResource collectionResource = new CollectionResource();
+ org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup =
+ new org.onap.so.db.catalog.beans.InstanceGroup();
+ collectionResource.setToscaNodeType("NetworkCollection");
+ collectionResource.setInstanceGroup(catalogInstanceGroup);
+
+ CollectionResourceCustomization collectionCust = new NetworkCollectionResourceCustomization();
+ collectionCust.setModelCustomizationUUID("modelCustomizationUUID");
+ collectionCust.setCollectionResource(collectionResource);
+
+ Service service = new Service();
+ service.getCollectionResourceCustomizations().add(collectionCust);
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setCollection(collection);
+
+ List<CollectionResourceInstanceGroupCustomization> instanceGroupCustList = new ArrayList<>();
+ CollectionResourceInstanceGroupCustomization instanceGroupCust =
+ new CollectionResourceInstanceGroupCustomization();
+ instanceGroupCust.setFunction("function");
+ instanceGroupCust.setDescription("description");
+
+ doReturn(modelInfoCollection).when(bbInputSetupMapperLayer).mapCatalogCollectionToCollection(collectionCust,
+ collectionResource);
+
+ doReturn(modelInfoInstanceGroup).when(bbInputSetupMapperLayer)
+ .mapCatalogInstanceGroupToInstanceGroup(collectionCust, catalogInstanceGroup);
+
+ SPY_bbInputSetup.mapCatalogCollection(service, serviceInstance.getCollection(), "modelCustomizationUUID");
+ SPY_bbInputSetup.mapCatalogNetworkCollectionInstanceGroup(service,
+ serviceInstance.getCollection().getInstanceGroup(), collectionCust.getModelCustomizationUUID());
+
+ assertThat(collection.getModelInfoCollection(), sameBeanAs(modelInfoCollection));
+ assertThat(instanceGroup.getModelInfoInstanceGroup(), sameBeanAs(modelInfoInstanceGroup));
+ }
+
+ @Test
+ public void testAddRelationshipsToSI() throws Exception {
+ ServiceInstance serviceInstance = new ServiceInstance();
+ org.onap.aai.domain.yang.ServiceInstance serviceInstanceAAI = new org.onap.aai.domain.yang.ServiceInstance();
+ serviceInstanceAAI.setServiceInstanceId("serviceInstanceId");
+
+ org.onap.aai.domain.yang.RelationshipList relationshipList = new org.onap.aai.domain.yang.RelationshipList();
+ org.onap.aai.domain.yang.Relationship relationship = new org.onap.aai.domain.yang.Relationship();
+ relationshipList.getRelationship().add(relationship);
+ serviceInstanceAAI.setRelationshipList(relationshipList);
+
+ Map<String, String> uriKeys = new HashMap<>();
+ uriKeys.put("global-customer-id", "globalCustomerId");
+ uriKeys.put("service-type", "serviceType");
+
+
+ doNothing().when(SPY_bbInputSetup).mapProject(any(), eq(serviceInstance));
+ doNothing().when(SPY_bbInputSetup).mapOwningEntity(any(), eq(serviceInstance));
+ doNothing().when(SPY_bbInputSetup).mapL3Networks(any(), eq(serviceInstance.getNetworks()));
+ doNothing().when(SPY_bbInputSetup).mapGenericVnfs(any(), eq(serviceInstance.getVnfs()));
+ doNothing().when(SPY_bbInputSetup).mapCollection(any(), eq(serviceInstance));
+
+ SPY_bbInputSetup.addRelationshipsToSI(serviceInstanceAAI, serviceInstance);
+
+ verify(SPY_bbInputSetup, times(1)).mapProject(any(), eq(serviceInstance));
+ verify(SPY_bbInputSetup, times(1)).mapOwningEntity(any(), eq(serviceInstance));
+ verify(SPY_bbInputSetup, times(1)).mapL3Networks(any(), eq(serviceInstance.getNetworks()));
+ verify(SPY_bbInputSetup, times(1)).mapGenericVnfs(any(), eq(serviceInstance.getVnfs()));
+ verify(SPY_bbInputSetup, times(1)).mapCollection(any(), eq(serviceInstance));
+ verify(SPY_bbInputSetup, times(1)).mapConfigurations(any(), eq(serviceInstance.getConfigurations()));
+ }
+
+ @Test
+ public void testMapConfigurations() throws JsonProcessingException {
+ org.onap.aai.domain.yang.Configuration expectedAAI = new org.onap.aai.domain.yang.Configuration();
+ org.onap.aai.domain.yang.RelationshipList relationshipList = new org.onap.aai.domain.yang.RelationshipList();
+ org.onap.aai.domain.yang.Relationship relationship = new org.onap.aai.domain.yang.Relationship();
+ relationshipList.getRelationship().add(relationship);
+ expectedAAI.setRelationshipList(relationshipList);
+
+ Configuration expected = new Configuration();
+ AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, "configurationId");
+ AAIResultWrapper configurationWrapper =
+ new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
+
+ doReturn(configurationWrapper).when(SPY_bbInputSetupUtils).getAAIResourceDepthOne(aaiResourceUri);
+ doReturn(expected).when(bbInputSetupMapperLayer)
+ .mapAAIConfiguration(isA(org.onap.aai.domain.yang.Configuration.class));
+
+ List<Configuration> configurations = new ArrayList<>();
+
+ SPY_bbInputSetup.mapConfigurations(Arrays.asList(new AAIResourceUri[] {aaiResourceUri}), configurations);
+
+ assertEquals(expected, configurations.get(0));
+ }
+
+ @Test
+ public void testMapGenericVnfs() throws JsonProcessingException {
+ org.onap.aai.domain.yang.GenericVnf expectedAAI = new org.onap.aai.domain.yang.GenericVnf();
+ org.onap.aai.domain.yang.RelationshipList relationshipList = new org.onap.aai.domain.yang.RelationshipList();
+ org.onap.aai.domain.yang.Relationship relationship = new org.onap.aai.domain.yang.Relationship();
+ relationshipList.getRelationship().add(relationship);
+ expectedAAI.setRelationshipList(relationshipList);
+
+ GenericVnf expected = new GenericVnf();
+ AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "vnfId");
+ AAIResultWrapper vnfWrapper =
+ new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
+
+ doReturn(vnfWrapper).when(SPY_bbInputSetupUtils).getAAIResourceDepthOne(aaiResourceUri);
+ doReturn(expected).when(bbInputSetupMapperLayer)
+ .mapAAIGenericVnfIntoGenericVnf(isA(org.onap.aai.domain.yang.GenericVnf.class));
+ doNothing().when(SPY_bbInputSetup).mapPlatform(any(), eq(expected));
+ doNothing().when(SPY_bbInputSetup).mapLineOfBusiness(any(), eq(expected));
+ doReturn(new ArrayList<>()).when(SPY_bbInputSetup).mapVolumeGroups(any());
+
+ List<GenericVnf> genericVnfs = new ArrayList<>();
+
+ SPY_bbInputSetup.mapGenericVnfs(Arrays.asList(new AAIResourceUri[] {aaiResourceUri}), genericVnfs);
+
+ assertEquals(expected, genericVnfs.get(0));
+ verify(SPY_bbInputSetup, times(1)).mapPlatform(any(), eq(expected));
+ verify(SPY_bbInputSetup, times(1)).mapLineOfBusiness(any(), eq(expected));
+ verify(SPY_bbInputSetup, times(1)).mapVolumeGroups(any());
+ }
+
+ @Test
+ public void testMapVolumeGroups() throws JsonProcessingException {
+ org.onap.aai.domain.yang.VolumeGroup expectedAAI = new org.onap.aai.domain.yang.VolumeGroup();
+
+ VolumeGroup expected = new VolumeGroup();
+ AAIResultWrapper vnfWrapper =
+ new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
+
+ doReturn(expected).when(bbInputSetupMapperLayer)
+ .mapAAIVolumeGroup(isA(org.onap.aai.domain.yang.VolumeGroup.class));
+
+ List<VolumeGroup> volumeGroupsList =
+ SPY_bbInputSetup.mapVolumeGroups(Arrays.asList(new AAIResultWrapper[] {vnfWrapper}));
+
+ assertEquals(expected, volumeGroupsList.get(0));
+ }
+
+ @Test
+ public void testMapLineOfBusiness() throws JsonProcessingException {
+ org.onap.aai.domain.yang.LineOfBusiness expectedAAI = new org.onap.aai.domain.yang.LineOfBusiness();
+
+ LineOfBusiness expected = new LineOfBusiness();
+ AAIResultWrapper vnfWrapper =
+ new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
+
+ doReturn(expected).when(bbInputSetupMapperLayer)
+ .mapAAILineOfBusiness(isA(org.onap.aai.domain.yang.LineOfBusiness.class));
+
+ GenericVnf vnf = new GenericVnf();
+
+ SPY_bbInputSetup.mapLineOfBusiness(Arrays.asList(new AAIResultWrapper[] {vnfWrapper}), vnf);
+
+ assertEquals(expected, vnf.getLineOfBusiness());
+ }
+
+ @Test
+ public void testMapPlatform() throws JsonProcessingException {
+ org.onap.aai.domain.yang.Platform expectedAAI = new org.onap.aai.domain.yang.Platform();
+
+ Platform expected = new Platform();
+ AAIResultWrapper vnfWrapper =
+ new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
+
+ doReturn(expected).when(bbInputSetupMapperLayer).mapAAIPlatform(isA(org.onap.aai.domain.yang.Platform.class));
+
+ GenericVnf vnf = new GenericVnf();
+
+ SPY_bbInputSetup.mapPlatform(Arrays.asList(new AAIResultWrapper[] {vnfWrapper}), vnf);
+
+ assertEquals(expected, vnf.getPlatform());
+ }
+
+ @Test
+ public void testMapCollection() throws JsonProcessingException {
+ List<AAIResultWrapper> collections = new ArrayList<>();
+ ServiceInstance serviceInstance = new ServiceInstance();
+
+ org.onap.aai.domain.yang.Collection aaiCollection = new org.onap.aai.domain.yang.Collection();
+ org.onap.aai.domain.yang.RelationshipList collectionRelationshipList =
+ new org.onap.aai.domain.yang.RelationshipList();
+ org.onap.aai.domain.yang.Relationship collectionInstanceGroupRelationship =
+ new org.onap.aai.domain.yang.Relationship();
+ collectionRelationshipList.getRelationship().add(collectionInstanceGroupRelationship);
+ aaiCollection.setRelationshipList(collectionRelationshipList);
+
+ collections.add(new AAIResultWrapper(
+ new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiCollection)));
+
+ Collection collection = new Collection();
+ ModelInfoCollection modelInfoCollection = new ModelInfoCollection();
+ List<InstanceGroup> instanceGroupsList = new ArrayList<>();
+ InstanceGroup instanceGroup = new InstanceGroup();
+ instanceGroupsList.add(instanceGroup);
+ NetworkCollectionResourceCustomization networkCollectionCust =
+ Mockito.mock(NetworkCollectionResourceCustomization.class);
+ CollectionResource collectionResource = new CollectionResource();
+ doReturn(collection).when(bbInputSetupMapperLayer)
+ .mapAAICollectionIntoCollection(isA(org.onap.aai.domain.yang.Collection.class));
+ doReturn(instanceGroupsList).when(SPY_bbInputSetup).mapInstanceGroups(any());
+ doReturn(networkCollectionCust).when(SPY_bbInputSetupUtils)
+ .getCatalogNetworkCollectionResourceCustByID(aaiCollection.getCollectionCustomizationId());
+ doReturn(collectionResource).when(networkCollectionCust).getCollectionResource();
+ doReturn(modelInfoCollection).when(bbInputSetupMapperLayer)
+ .mapCatalogCollectionToCollection(networkCollectionCust, collectionResource);
+
+ SPY_bbInputSetup.mapCollection(collections, serviceInstance);
+
+ assertEquals(collection, serviceInstance.getCollection());
+ assertEquals(instanceGroup, collection.getInstanceGroup());
+
+ instanceGroupsList.clear();
+ collection = new Collection();
+
+ SPY_bbInputSetup.mapCollection(collections, serviceInstance);
+ assertEquals(collection, serviceInstance.getCollection());
+ assertNull(collection.getInstanceGroup());
+ }
- SPY_bbInputSetup.mapCollection(collections, serviceInstance);
+ @Test
+ public void testMapL3Networks() throws JsonProcessingException {
+ org.onap.aai.domain.yang.L3Network expectedAAI = new org.onap.aai.domain.yang.L3Network();
+ org.onap.aai.domain.yang.RelationshipList relationshipList = new org.onap.aai.domain.yang.RelationshipList();
+ org.onap.aai.domain.yang.Relationship relationship = new org.onap.aai.domain.yang.Relationship();
+ relationshipList.getRelationship().add(relationship);
+ expectedAAI.setRelationshipList(relationshipList);
- assertEquals(collection, serviceInstance.getCollection());
- assertEquals(instanceGroup, collection.getInstanceGroup());
-
- instanceGroupsList.clear();
- collection = new Collection();
-
- SPY_bbInputSetup.mapCollection(collections, serviceInstance);
- assertEquals(collection, serviceInstance.getCollection());
- assertNull(collection.getInstanceGroup());
- }
+ L3Network expected = new L3Network();
+ List<L3Network> l3Networks = new ArrayList<>();
+ AAIResultWrapper l3NetworksWrapper =
+ new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
+ AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, "networkId");
- @Test
- public void testMapL3Networks() throws JsonProcessingException {
- org.onap.aai.domain.yang.L3Network expectedAAI = new org.onap.aai.domain.yang.L3Network();
- org.onap.aai.domain.yang.RelationshipList relationshipList = new org.onap.aai.domain.yang.RelationshipList();
- org.onap.aai.domain.yang.Relationship relationship = new org.onap.aai.domain.yang.Relationship();
- relationshipList.getRelationship().add(relationship);
- expectedAAI.setRelationshipList(relationshipList);
+ doReturn(l3NetworksWrapper).when(SPY_bbInputSetupUtils).getAAIResourceDepthTwo(aaiResourceUri);
+ doReturn(expected).when(bbInputSetupMapperLayer).mapAAIL3Network(isA(org.onap.aai.domain.yang.L3Network.class));
+ doNothing().when(SPY_bbInputSetup).mapNetworkPolicies(any(), eq(expected.getNetworkPolicies()));
+ doNothing().when(SPY_bbInputSetup).mapRouteTableReferences(any(),
+ eq(expected.getContrailNetworkRouteTableReferences()));
+
+ SPY_bbInputSetup.mapL3Networks(Arrays.asList(new AAIResourceUri[] {aaiResourceUri}), l3Networks);
+
+ assertEquals(expected, l3Networks.get(0));
+ verify(SPY_bbInputSetup, times(1)).mapNetworkPolicies(any(), eq(expected.getNetworkPolicies()));
+ verify(SPY_bbInputSetup, times(1)).mapRouteTableReferences(any(),
+ eq(expected.getContrailNetworkRouteTableReferences()));
+ }
+
+ @Test
+ public void testMapRouteTableReferences() throws JsonProcessingException {
+ org.onap.aai.domain.yang.RouteTableReference expectedAAI = new org.onap.aai.domain.yang.RouteTableReference();
+
+ RouteTableReference expected = new RouteTableReference();
+ List<RouteTableReference> contrailNetworkRouteTableReferences = new ArrayList<>();
+ AAIResultWrapper vnfWrapper =
+ new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
+
+ doReturn(expected).when(bbInputSetupMapperLayer).mapAAIRouteTableReferenceIntoRouteTableReference(
+ isA(org.onap.aai.domain.yang.RouteTableReference.class));
+
+ SPY_bbInputSetup.mapRouteTableReferences(Arrays.asList(new AAIResultWrapper[] {vnfWrapper}),
+ contrailNetworkRouteTableReferences);
+
+ assertEquals(expected, contrailNetworkRouteTableReferences.get(0));
+ }
+
+ @Test
+ public void testMapOwningEntity() throws JsonProcessingException {
+ org.onap.aai.domain.yang.OwningEntity expectedAAI = new org.onap.aai.domain.yang.OwningEntity();
+
+ OwningEntity expected = new OwningEntity();
+ AAIResultWrapper vnfWrapper =
+ new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
+
+ doReturn(expected).when(bbInputSetupMapperLayer)
+ .mapAAIOwningEntity(isA(org.onap.aai.domain.yang.OwningEntity.class));
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+
+ SPY_bbInputSetup.mapOwningEntity(Arrays.asList(new AAIResultWrapper[] {vnfWrapper}), serviceInstance);
+
+ assertEquals(expected, serviceInstance.getOwningEntity());
+ }
+
+ @Test
+ public void testMapProject() throws JsonProcessingException {
+ org.onap.aai.domain.yang.Project expectedAAI = new org.onap.aai.domain.yang.Project();
+
+ Project expected = new Project();
+ AAIResultWrapper vnfWrapper =
+ new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
+
+ doReturn(expected).when(bbInputSetupMapperLayer).mapAAIProject(isA(org.onap.aai.domain.yang.Project.class));
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+
+ SPY_bbInputSetup.mapProject(Arrays.asList(new AAIResultWrapper[] {vnfWrapper}), serviceInstance);
+
+ assertEquals(expected, serviceInstance.getProject());
+ }
+
+ @Test
+ public void testMapCustomer() throws Exception {
+ org.onap.aai.domain.yang.Customer customerAAI = new org.onap.aai.domain.yang.Customer();
+ org.onap.aai.domain.yang.ServiceSubscription serviceSubscriptionAAI =
+ new org.onap.aai.domain.yang.ServiceSubscription();
+
+ Customer expected = new Customer();
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+
+ String globalCustomerId = "globalCustomerId";
+ String subscriptionServiceType = "subscriptionServiceType";
+
+ doReturn(customerAAI).when(SPY_bbInputSetupUtils).getAAICustomer(globalCustomerId);
+ doReturn(serviceSubscriptionAAI).when(SPY_bbInputSetupUtils).getAAIServiceSubscription(globalCustomerId,
+ subscriptionServiceType);
+ doReturn(expected).when(bbInputSetupMapperLayer).mapAAICustomer(isA(org.onap.aai.domain.yang.Customer.class));
+ doReturn(serviceSubscription).when(bbInputSetupMapperLayer)
+ .mapAAIServiceSubscription(isA(org.onap.aai.domain.yang.ServiceSubscription.class));
+
+ Customer actual = SPY_bbInputSetup.mapCustomer(globalCustomerId, subscriptionServiceType);
+
+ assertEquals(expected, actual);
+ assertEquals(serviceSubscription, expected.getServiceSubscription());
+ }
+
+ @Test
+ public void testPopulateLookupKeyMapWithIds() {
+ Map<ResourceKey, String> expected = new HashMap<>();
+ Map<ResourceKey, String> actual = new HashMap<>();
+ String serviceInstanceId = "serviceInstanceId";
+ String networkId = "networkId";
+ String vnfId = "vnfId";
+ String vfModuleId = "vfModuleId";
+ String volumeGroupId = "volumeGroupId";
+ String configurationId = "configurationId";
+ String instanceGroupId = "instancegroupId";
+
+ expected.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstanceId);
+ expected.put(ResourceKey.NETWORK_ID, networkId);
+ expected.put(ResourceKey.GENERIC_VNF_ID, vnfId);
+ expected.put(ResourceKey.VF_MODULE_ID, vfModuleId);
+ expected.put(ResourceKey.VOLUME_GROUP_ID, volumeGroupId);
+ expected.put(ResourceKey.CONFIGURATION_ID, configurationId);
+ expected.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupId);
+
+ WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
+ workflowResourceIds.setServiceInstanceId(serviceInstanceId);
+ workflowResourceIds.setNetworkId(networkId);
+ workflowResourceIds.setVnfId(vnfId);
+ workflowResourceIds.setVfModuleId(vfModuleId);
+ workflowResourceIds.setVolumeGroupId(volumeGroupId);
+ workflowResourceIds.setConfigurationId(configurationId);
+ workflowResourceIds.setInstanceGroupId(instanceGroupId);
+
+ SPY_bbInputSetup.populateLookupKeyMapWithIds(workflowResourceIds, actual);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testgetGBBMacro() throws Exception {
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class);
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
+ aaiVnf.setModelCustomizationId("modelCustId");
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
+ lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
+ lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
+ String resourceId = "123";
+ String vnfType = "vnfType";
+ Service service = Mockito.mock(Service.class);
+ String requestAction = "createInstance";
+
+ ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
+ configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
+ configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
+ configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
+ executeBB.setConfigurationResourceKeys(configResourceKeys);
+
+ executeBB.setRequestDetails(requestDetails);
+ doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(request).when(SPY_bbInputSetupUtils).getInfraActiveRequest(executeBB.getRequestId());
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
+ doNothing().when(SPY_bbInputSetupUtils).updateInfraActiveRequestVnfId(request,
+ lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID));
+ doReturn("vnfId").when(SPY_bbInputSetup).getVnfId(executeBB, lookupKeyMap);
+ doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(any(String.class));
+
+
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
+ executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), isA(ModelInfo.class),
+ isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any());
+
+ executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VNF.toString());
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class),
+ isA(org.onap.so.serviceinstancebeans.Platform.class),
+ isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class),
+ isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(),
+ any(String.class));
+
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString());
+ executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(1)).populateVfModule(isA(ModelInfo.class), isA(Service.class), any(String.class),
+ isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), any(),
+ isA(CloudConfiguration.class));
+
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString());
+ executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class),
+ any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(),
+ ArgumentMatchers.isNull(), any(String.class), any());
+
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationId("configurationId");
+ gBB.getServiceInstance().getConfigurations().add(configuration);
+ List<ConfigurationResourceCustomization> configurationCustList = new ArrayList<>();
+ ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization();
+ configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
+ doReturn(configurationCustList).when(service).getConfigurationCustomizations();
+ configurationCustList.add(configurationCust);
+ doNothing().when(SPY_bbInputSetup).populateConfiguration(isA(ModelInfo.class), isA(Service.class),
+ any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(),
+ isA(ConfigurationResourceKeys.class));
+
+ executeBB.getBuildingBlock().setBpmnFlowName("AssignFabricConfigurationBB");
+ executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(1)).populateConfiguration(isA(ModelInfo.class), isA(Service.class),
+ any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(),
+ isA(ConfigurationResourceKeys.class));
+ }
+
+ @Test
+ public void testgetGBBMacroCloudConfiguration() throws Exception {
+ org.onap.so.serviceinstancebeans.Service serviceMacro = mapper.readValue(
+ new File(RESOURCE_PATH + "ServiceMacroVfModules.json"), org.onap.so.serviceinstancebeans.Service.class);
+ CloudConfiguration cloudConfig = null;
+ org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = new org.onap.aai.domain.yang.CloudRegion();
+ aaiCloudRegion.setCloudOwner("test-owner-name");
+ Resources resources = serviceMacro.getResources();
+ doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(any(CloudConfiguration.class));
+ CloudRegion expected = new CloudRegion();
+ expected.setLcpCloudRegionId("mdt1");
+ expected.setCloudOwner("test-owner-name");
+ expected.setTenantId("88a6ca3ee0394ade9403f075db23167e");
+
+ CloudRegion actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources);
+ assertThat(actual, sameBeanAs(expected));
+
+ serviceMacro = mapper.readValue(new File(RESOURCE_PATH + "ServiceMacroVnfs.json"),
+ org.onap.so.serviceinstancebeans.Service.class);
+ resources = serviceMacro.getResources();
+
+ actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources);
+ assertThat(actual, sameBeanAs(expected));
+
+ serviceMacro = mapper.readValue(new File(RESOURCE_PATH + "ServiceMacroNetworks.json"),
+ org.onap.so.serviceinstancebeans.Service.class);
+ resources = serviceMacro.getResources();
+
+ actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources);
+ assertThat(actual, sameBeanAs(expected));
+
+ serviceMacro = mapper.readValue(new File(RESOURCE_PATH + "ServiceMacroNoCloudConfig.json"),
+ org.onap.so.serviceinstancebeans.Service.class);
+ resources = serviceMacro.getResources();
+
+ actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources);
+ assertNull(actual);
+ }
+
+ @Test
+ public void testgetGBBMacroWithEmptyUserParams() throws Exception {
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ requestDetails.getRequestParameters().getUserParams().clear();
+ InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class);
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
+ aaiVnf.setModelCustomizationId("modelCustId");
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
+ lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
+ String resourceId = "123";
+ String vnfType = "vnfType";
+ Service service = Mockito.mock(Service.class);
+ String requestAction = "createInstance";
+
+ doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
+
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
+ executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ executeBB.getBuildingBlock().setIsVirtualLink(Boolean.FALSE);
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(1)).getGBBMacroNoUserParamsCreate(any(ExecuteBuildingBlock.class), any(),
+ any(String.class), any(String.class), any(GeneralBuildingBlock.class), any(Service.class));
+ }
+
+ @Test(expected = Exception.class)
+ public void testgetGBBMacroException() throws Exception {
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ String resourceId = "123";
+ String vnfType = "vnfType";
+ Service service = Mockito.mock(Service.class);
+ String requestAction = "createInstance";
+
+ executeBB.getBuildingBlock().setBpmnFlowName("Network");
+ executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ }
+
+ @Test
+ public void testgetGBBMacroWithVnfTypeNull() throws Exception {
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
+ lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
+ aaiVnf.setModelCustomizationId("modelCustId");
+ InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class);
+ String resourceId = "123";
+ String vnfType = null;
+ Service service = Mockito.mock(Service.class);
+ String requestAction = "createInstance";
+
+
+ executeBB.setRequestDetails(requestDetails);
+ doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(request).when(SPY_bbInputSetupUtils).getInfraActiveRequest(executeBB.getRequestId());
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
+ doNothing().when(SPY_bbInputSetupUtils).updateInfraActiveRequestVnfId(request,
+ lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID));
+ doReturn("vnfId").when(SPY_bbInputSetup).getVnfId(executeBB, lookupKeyMap);
+ doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(any(String.class));
+
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
+ executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), isA(ModelInfo.class),
+ isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any());
+
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VNF.toString());
+ executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class),
+ isA(org.onap.so.serviceinstancebeans.Platform.class),
+ isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class),
+ isA(ServiceInstance.class), any(), ArgumentMatchers.isNull(), any(String.class),
+ ArgumentMatchers.isNull(), any(), any(String.class));
+
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString());
+ executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(1)).populateVfModule(isA(ModelInfo.class), isA(Service.class), any(String.class),
+ isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), any(),
+ isA(CloudConfiguration.class));
+
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString());
+ executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class),
+ any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(),
+ ArgumentMatchers.isNull(), ArgumentMatchers.isNull(), any());
+ }
+
+ @Test
+ public void testgetGBBMacroGetServiceWithInvariantId() throws Exception {
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
+ lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
+ aaiVnf.setModelCustomizationId("modelCustId");
+ InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class);
+ String resourceId = "123";
+ String vnfType = "vnfType";
+ Service service = Mockito.mock(Service.class);
+ String requestAction = "createInstance";
+
+ executeBB.setRequestDetails(requestDetails);
+ doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(request).when(SPY_bbInputSetupUtils).getInfraActiveRequest(executeBB.getRequestId());
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
+ doNothing().when(SPY_bbInputSetupUtils).updateInfraActiveRequestVnfId(request,
+ lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID));
+ doReturn("vnfId").when(SPY_bbInputSetup).getVnfId(executeBB, lookupKeyMap);
+ doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(any(String.class));
+
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
+ executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), isA(ModelInfo.class),
+ isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any());
+
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VNF.toString());
+ executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class),
+ isA(org.onap.so.serviceinstancebeans.Platform.class),
+ isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class),
+ isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(),
+ any(String.class));
+
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString());
+ executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(1)).populateVfModule(isA(ModelInfo.class), isA(Service.class), any(String.class),
+ isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), any(),
+ isA(CloudConfiguration.class));
+
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString());
+ executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class),
+ any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(),
+ ArgumentMatchers.isNull(), any(String.class), any());
+ }
+
+ @Test
+ public void testgetGBBMacroNoUserParamsDeactivateInstnace() throws Exception {
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ requestDetails.getRequestParameters().setUserParams(null);
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
+ aaiVnf.setModelCustomizationId("modelCustId");
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
+ lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
+ String resourceId = "123";
+ String vnfType = "vnfType";
+ Service service = Mockito.mock(Service.class);
+ String requestAction = "deactivateInstance";
+ doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
+ String generatedId = "12131";
+
+ executeBB.getBuildingBlock().setBpmnFlowName("DeactivateServiceInstanceBB");
+ executeBB.getBuildingBlock().setKey("3c40d244-808e-42ca-b09a-256d83d19d0a");
+ GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap,
+ requestAction, resourceId, vnfType);
+ assertThat(actual, sameBeanAs(gBB));
+ }
+
+ @Test
+ public void testgetGBBMacroNoUserParamsCreateInstance() throws Exception {
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class);
+ requestDetails.getRequestParameters().setUserParams(null);
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
+ aaiVnf.setModelCustomizationId("modelCustId");
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
+ lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
+ lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
+
+ ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
+ configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
+ configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
+ configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
+ executeBB.setConfigurationResourceKeys(configResourceKeys);
+
+ String resourceId = "123";
+ String vnfType = "vnfType";
+ Service service = Mockito.mock(Service.class);
+ String requestAction = "createInstance";
+ doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+
+
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
+ List<NetworkResourceCustomization> networkCustList = new ArrayList<>();
+ NetworkResourceCustomization networkCust = Mockito.mock(NetworkResourceCustomization.class);
+ doReturn("ab153b6e-c364-44c0-bef6-1f2982117f04").when(networkCust).getModelCustomizationUUID();
+ networkCustList.add(networkCust);
+ doReturn(networkCustList).when(service).getNetworkCustomizations();
+ doNothing().when(SPY_bbInputSetup).populateL3Network(any(), isA(ModelInfo.class), isA(Service.class),
+ any(String.class), isA(ServiceInstance.class), any(), any(String.class), any());
+
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
+ executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ executeBB.getBuildingBlock().setIsVirtualLink(false);
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(1)).getGBBMacroNoUserParamsCreate(executeBB, lookupKeyMap,
+ executeBB.getBuildingBlock().getBpmnFlowName(), "ab153b6e-c364-44c0-bef6-1f2982117f04", gBB, service);
+
+ CollectionNetworkResourceCustomization collectionNetworkResourceCust =
+ Mockito.mock(CollectionNetworkResourceCustomization.class);
+ doReturn(collectionNetworkResourceCust).when(SPY_bbInputSetupUtils)
+ .getCatalogCollectionNetworkResourceCustByID(any(String.class));
+ NetworkResourceCustomization networkResourceCustomization = Mockito.mock(NetworkResourceCustomization.class);
+ doReturn(networkResourceCustomization).when(bbInputSetupMapperLayer)
+ .mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
+ ModelInfoNetwork modelInfoNetwork = Mockito.mock(ModelInfoNetwork.class);
+ doReturn(modelInfoNetwork).when(bbInputSetupMapperLayer)
+ .mapCatalogNetworkToNetwork(networkResourceCustomization);
+
+ executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
+ executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ executeBB.getBuildingBlock().setIsVirtualLink(true);
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(2)).getGBBMacroNoUserParamsCreate(executeBB, lookupKeyMap,
+ executeBB.getBuildingBlock().getBpmnFlowName(), "ab153b6e-c364-44c0-bef6-1f2982117f04", gBB, service);
+
+ executeBB.getBuildingBlock().setBpmnFlowName("CreateNetworkBB");
+ executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ executeBB.getBuildingBlock().setIsVirtualLink(true);
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(1)).getGBBMacroNoUserParamsCreate(executeBB, lookupKeyMap,
+ executeBB.getBuildingBlock().getBpmnFlowName(), "ab153b6e-c364-44c0-bef6-1f2982117f04", gBB, service);
+ }
+
+ @Test
+ public void testgetGBBMacroNoUserParamsOther() throws Exception {
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ requestDetails.getRequestParameters().setUserParams(null);
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
+ aaiVnf.setModelCustomizationId("modelCustId");
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
+ lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
+ String resourceId = "123";
+ String vnfType = "vnfType";
+ Service service = Mockito.mock(Service.class);
+ String requestAction = "deleteInstance";
+
+ executeBB.setRequestDetails(requestDetails);
+ ServiceInstance serviceInstance = gBB.getServiceInstance();
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ aaiServiceInstance.setModelVersionId("modelVersionId");
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+ doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils)
+ .getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
+ doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
+
+ CloudConfiguration cloudConfig = new CloudConfiguration();
+ cloudConfig.setLcpCloudRegionId("lcpCloudRegionId");
+ requestDetails.setCloudConfiguration(cloudConfig);
+ org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
+ doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration());
+ executeBB.getBuildingBlock().setBpmnFlowName("DeleteNetworkBB");
+ executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(1)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(),
+ any(String.class), isA(String.class), isA(CloudConfiguration.class));
+
+ requestAction = "activateInstance";
+ doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
+ executeBB.getBuildingBlock().setBpmnFlowName("ActivateNetworkBB");
+ executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(2)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(),
+ any(String.class), isA(String.class), isA(CloudConfiguration.class));
+
+ requestAction = "unassignInstance";
+ doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
+ executeBB.getBuildingBlock().setBpmnFlowName("UnassignNetworkBB");
+ executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(3)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(),
+ any(String.class), isA(String.class), isA(CloudConfiguration.class));
+
+ requestAction = "activateFabricConfiguration";
+ doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
+ executeBB.getBuildingBlock().setBpmnFlowName("ActivateFabricConfigurationBB");
+ executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-134534656234");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ verify(SPY_bbInputSetup, times(4)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(),
+ any(String.class), isA(String.class), isA(CloudConfiguration.class));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testgetGBBMacroNoUserParamsOtherException() throws Exception {
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ requestDetails.getRequestParameters().setUserParams(null);
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
+ aaiVnf.setModelCustomizationId("modelCustId");
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
+ lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
+ String resourceId = "123";
+ String vnfType = "vnfType";
+ Service service = Mockito.mock(Service.class);
+ String requestAction = "assignInstance";
+ doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
+ requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
+ String generatedId = "12131";
+
+ executeBB.getBuildingBlock().setKey("3c40d244-808e-42ca-b09a-256d83d19d0a");
+ SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
+ }
+
+ @Test
+ public void testgetGBBMacroNoUserParamsExistingService() throws Exception {
+ GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
+ GeneralBuildingBlock.class);
+ ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
+ ExecuteBuildingBlock.class);
+ RequestDetails requestDetails = mapper
+ .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
+ requestDetails.getRequestParameters().setUserParams(null);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
+ lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
+ lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
+ lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
+ lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
+ Service service = Mockito.mock(Service.class);
+ CloudConfiguration cloudConfiguration = new CloudConfiguration();
+ cloudConfiguration.setLcpCloudRegionId("cloudRegionId");
+ String requestAction = "unassignInstance";
+ executeBB.setRequestDetails(requestDetails);
+
+ ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
+ configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
+ configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
+ configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
+ executeBB.setConfigurationResourceKeys(configResourceKeys);
+
+ ServiceInstance serviceInstance = gBB.getServiceInstance();
+ org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
+ aaiServiceInstance.setModelVersionId("modelVersionId");
+ doReturn(service).when(SPY_bbInputSetupUtils)
+ .getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
+ doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils)
+ .getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
+ doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
+ doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
+ executeBB, requestAction, null);
+
+ L3Network network = new L3Network();
+ network.setNetworkId("networkId");
+ gBB.getServiceInstance().getNetworks().add(network);
+ org.onap.aai.domain.yang.L3Network aaiNetwork = new org.onap.aai.domain.yang.L3Network();
+ aaiNetwork.setModelCustomizationId("modelCustId");
+ doReturn(aaiNetwork).when(SPY_bbInputSetupUtils).getAAIL3Network(network.getNetworkId());
+ doNothing().when(SPY_bbInputSetup).mapCatalogNetwork(any(L3Network.class), any(ModelInfo.class),
+ any(Service.class));
+
+ executeBB.getBuildingBlock().setBpmnFlowName("DeleteNetworkBB");
+ executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
+ executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, null);
+ verify(SPY_bbInputSetup, times(1)).mapCatalogNetwork(any(L3Network.class), any(ModelInfo.class),
+ any(Service.class));
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("vnfId");
+ gBB.getServiceInstance().getVnfs().add(vnf);
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
+ aaiVnf.setModelCustomizationId("modelCustId");
+ doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
+ doNothing().when(SPY_bbInputSetup).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
+ any(Service.class));
+
+ executeBB.getBuildingBlock().setBpmnFlowName("ActivateVnfBB");
+ executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
+ SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
+ executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, cloudConfiguration);
+ verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
+ any(Service.class));
+
+ VfModule vfModule = new VfModule();
+ vfModule.setVfModuleId("vfModuleId");
+ gBB.getServiceInstance().getVnfs().get(0).getVfModules().add(vfModule);
+ org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule();
+ aaiVfModule.setModelCustomizationId("modelCustId");
+ doReturn(aaiVfModule).when(SPY_bbInputSetupUtils).getAAIVfModule(vnf.getVnfId(), vfModule.getVfModuleId());
+
+ executeBB.getBuildingBlock().setBpmnFlowName("UnassignVfModuleBB");
+ executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
+ SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
+ executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, cloudConfiguration);
+ verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
+ any(Service.class));
+ verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(any(VfModule.class), any(ModelInfo.class),
+ any(Service.class), any(String.class));
+
+ CloudRegion cloudRegion = new CloudRegion();
+ cloudRegion.setLcpCloudRegionId("cloudRegionId");
+ cloudRegion.setCloudOwner("CloudOwner");
+ doReturn(Optional.of(cloudRegion)).when(SPY_cloudInfoFromAAI).getCloudInfoFromAAI(gBB.getServiceInstance());
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("volumeGroupId");
+ gBB.getServiceInstance().getVnfs().get(0).getVolumeGroups().add(volumeGroup);
+ org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = new org.onap.aai.domain.yang.VolumeGroup();
+ aaiVolumeGroup.setModelCustomizationId("modelCustId");
+ doReturn(aaiVolumeGroup).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(cloudRegion.getCloudOwner(),
+ cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
+
+ executeBB.getBuildingBlock().setBpmnFlowName("UnassignVolumeGroupBB");
+ executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
+ SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
+ executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, null);
+ verify(SPY_bbInputSetup, times(3)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
+ any(Service.class));
+ verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(isA(VolumeGroup.class), isA(ModelInfo.class),
+ isA(Service.class), isA(String.class));
+
+ Configuration configuration = new Configuration();
+ configuration.setConfigurationId("configurationId");
+ gBB.getServiceInstance().getConfigurations().add(configuration);
+ org.onap.aai.domain.yang.Configuration aaiConfiguration = new org.onap.aai.domain.yang.Configuration();
+ aaiConfiguration.setModelCustomizationId("modelCustId");
+ doReturn(aaiConfiguration).when(SPY_bbInputSetupUtils).getAAIConfiguration(configuration.getConfigurationId());
+ doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(isA(Configuration.class), isA(ModelInfo.class),
+ isA(Service.class), isA(ConfigurationResourceKeys.class));
+
+ executeBB.getBuildingBlock().setBpmnFlowName("ActivateFabricConfigurationBB");
+ executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
+ SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
+ executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, cloudConfiguration);
+ verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(any(Configuration.class), any(ModelInfo.class),
+ any(Service.class), isA(ConfigurationResourceKeys.class));
+ }
+
+ @Test
+ public void testGetVnfId() {
+ String expected = "vnfId";
+ ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock();
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ executeBB.setRequestId("requestId");
+ InfraActiveRequests request = new InfraActiveRequests();
+ request.setVnfId(expected);
+ doReturn(request).when(SPY_bbInputSetupUtils).getInfraActiveRequest(executeBB.getRequestId());
+
+ String actual = SPY_bbInputSetup.getVnfId(executeBB, lookupKeyMap);
+
+ assertEquals("VnfId is set correctly", expected, actual);
+ }
+
+ @Test
+ public void testCreateVfModule() {
+ String vfModuleId = "vfModuleId";
+ String instanceName = "vfModuleName";
+ Map<String, String> cloudParams = new HashMap<>();
+ cloudParams.put("param1", "param1Value");
+ VfModule expected = new VfModule();
+ expected.setVfModuleId(vfModuleId);
+ expected.setVfModuleName(instanceName);
+ expected.setCloudParams(cloudParams);
+ expected.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ List<Map<String, String>> instanceParams = new ArrayList<>();
+ instanceParams.add(cloudParams);
+
+ VfModule actual = SPY_bbInputSetup.createVfModule(lookupKeyMap, vfModuleId, instanceName, instanceParams);
+
+ assertThat(actual, sameBeanAs(expected));
+ assertEquals("LookupKeyMap is populated", vfModuleId, lookupKeyMap.get(ResourceKey.VF_MODULE_ID));
+
+ expected.getCloudParams().clear();
+ actual = SPY_bbInputSetup.createVfModule(lookupKeyMap, vfModuleId, instanceName, null);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testCreateVolumeGroup() {
+ String volumeGroupId = "volumeGroupId";
+ String instanceName = "vfModuleName";
+ String vnfType = "vnfType";
+ Map<String, String> cloudParams = new HashMap<>();
+ cloudParams.put("param1", "param1Value");
+ VolumeGroup expected = new VolumeGroup();
+ expected.setVolumeGroupId(volumeGroupId);
+ expected.setVolumeGroupName(instanceName);
+ expected.setCloudParams(cloudParams);
+ expected.setVnfType(vnfType);
+ expected.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ List<Map<String, String>> instanceParams = new ArrayList<>();
+ instanceParams.add(cloudParams);
+
+ VolumeGroup actual =
+ SPY_bbInputSetup.createVolumeGroup(lookupKeyMap, volumeGroupId, instanceName, vnfType, instanceParams);
+
+ assertThat(actual, sameBeanAs(expected));
+ assertEquals("LookupKeyMap is populated", volumeGroupId, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID));
+
+ expected.getCloudParams().clear();
+ actual = SPY_bbInputSetup.createVolumeGroup(lookupKeyMap, volumeGroupId, instanceName, vnfType, null);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testCreateNetwork() {
+ String networkId = "networkId";
+ String instanceName = "networkName";
+ Map<String, String> cloudParams = new HashMap<>();
+ cloudParams.put("param1", "param1Value");
+ L3Network expected = new L3Network();
+ expected.setNetworkId(networkId);
+ expected.setNetworkName(instanceName);
+ expected.setCloudParams(cloudParams);
+ expected.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ List<Map<String, String>> instanceParams = new ArrayList<>();
+ instanceParams.add(cloudParams);
+ L3Network actual = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, networkId, instanceParams);
+
+ assertThat(actual, sameBeanAs(expected));
+ assertEquals("LookupKeyMap is populated", networkId, lookupKeyMap.get(ResourceKey.NETWORK_ID));
+
+ expected.getCloudParams().clear();
+ actual = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, networkId, null);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testCreateGenericVnf() {
+ String vnfId = "vnfId";
+ String instanceName = "vnfName";
+ String vnfType = "vnfType";
+ String platformName = "platformName";
+ String lineOfBusinessName = "lineOfBusinessName";
+ String productFamilyId = "productFamilyId";
+ Platform platform = new Platform();
+ platform.setPlatformName(platformName);
+ LineOfBusiness lineOfBusiness = new LineOfBusiness();
+ lineOfBusiness.setLineOfBusinessName(lineOfBusinessName);
+ Map<String, String> cloudParams = new HashMap<>();
+ cloudParams.put("param1", "param1Value");
+ GenericVnf expected = new GenericVnf();
+ expected.setVnfId(vnfId);
+ expected.setVnfName(instanceName);
+ expected.setVnfType(vnfType);
+ expected.setCloudParams(cloudParams);
+ expected.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
+ expected.setPlatform(platform);
+ expected.setLineOfBusiness(lineOfBusiness);
+ expected.setProvStatus("PREPROV");
+ expected.setServiceId(productFamilyId);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ List<Map<String, String>> instanceParams = new ArrayList<>();
+ instanceParams.add(cloudParams);
+ org.onap.so.serviceinstancebeans.Platform requestPlatform = new org.onap.so.serviceinstancebeans.Platform();
+ platform.setPlatformName(platformName);
+ org.onap.so.serviceinstancebeans.LineOfBusiness requestLineOfBusiness =
+ new org.onap.so.serviceinstancebeans.LineOfBusiness();
+ lineOfBusiness.setLineOfBusinessName(lineOfBusinessName);
+
+ doReturn(platform).when(bbInputSetupMapperLayer).mapRequestPlatform(requestPlatform);
+ doReturn(lineOfBusiness).when(bbInputSetupMapperLayer).mapRequestLineOfBusiness(requestLineOfBusiness);
+
+ GenericVnf actual = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, requestPlatform,
+ requestLineOfBusiness, vnfId, vnfType, instanceParams, productFamilyId);
+
+ assertThat(actual, sameBeanAs(expected));
+ assertEquals("LookupKeyMap is populated", vnfId, lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID));
+
+ expected.getCloudParams().clear();
+ actual = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, requestPlatform, requestLineOfBusiness,
+ vnfId, vnfType, null, productFamilyId);
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testMapCatalogVfModule() {
+ String vnfModelCustomizationUUID = "vnfResourceCustUUID";
+ String vfModuleCustomizationUUID = "vfModelCustomizationUUID";
+ VfModule vfModule = new VfModule();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationUuid(vfModuleCustomizationUUID);
+ Service service = new Service();
+ VnfResourceCustomization vnfResourceCust = new VnfResourceCustomization();
+ vnfResourceCust.setModelCustomizationUUID(vnfModelCustomizationUUID);
+ VfModuleCustomization vfModuleCust = new VfModuleCustomization();
+ vfModuleCust.setModelCustomizationUUID(vfModuleCustomizationUUID);
+ vnfResourceCust.getVfModuleCustomizations().add(vfModuleCust);
+ service.getVnfCustomizations().add(vnfResourceCust);
+ ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
+
+ doReturn(modelInfoVfModule).when(bbInputSetupMapperLayer).mapCatalogVfModuleToVfModule(vfModuleCust);
+
+ SPY_bbInputSetup.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID);
+
+ assertThat(vfModule.getModelInfoVfModule(), sameBeanAs(modelInfoVfModule));
+
+ modelInfo.setModelCustomizationUuid(null);
+ modelInfo.setModelCustomizationId(vfModuleCustomizationUUID);
+
+ SPY_bbInputSetup.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID);
+
+ assertThat(vfModule.getModelInfoVfModule(), sameBeanAs(modelInfoVfModule));
+ }
+
+ @Test
+ public void testPopulateVfModule() throws Exception {
+ String vnfId = "vnfId";
+ String vfModuleId = "vfModuleId";
+ String volumeGroupId = "volumeGroupId";
+ String vfModuleCustomizationId = "vfModuleCustomizationId";
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelCustomizationId(vfModuleCustomizationId);
+ Service service = new Service();
+ String bbName = AssignFlows.VF_MODULE.toString();
+ ServiceInstance serviceInstance = new ServiceInstance();
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId(vnfId);
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId(volumeGroupId);
+ vnf.getVolumeGroups().add(volumeGroup);
+ serviceInstance.getVnfs().add(vnf);
+ VfModule vfModule1 = new VfModule();
+ vfModule1.setVfModuleId("vfModuleId1");
+ VfModule vfModule2 = new VfModule();
+ vfModule2.setVfModuleId("vfModuleId2");
+ vnf.getVfModules().add(vfModule1);
+ vnf.getVfModules().add(vfModule2);
+ Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
+ lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfId);
+ String resourceId = vfModuleId;
+ RelatedInstanceList[] relatedInstanceList = null;
+ String instanceName = "vfModuleName";
+ List<Map<String, String>> instanceParams = null;
+ CloudConfiguration cloudConfiguration = new CloudConfiguration();
+
+ org.onap.aai.domain.yang.GenericVnf vnfAAI = new org.onap.aai.domain.yang.GenericVnf();
+ vnfAAI.setModelCustomizationId("vnfModelCustId");
+ org.onap.aai.domain.yang.VolumeGroup volumeGroupAAI = new org.onap.aai.domain.yang.VolumeGroup();
+ volumeGroupAAI.setModelCustomizationId(vfModuleCustomizationId);
+ org.onap.aai.domain.yang.VfModule vfModuleAAI = new org.onap.aai.domain.yang.VfModule();
+ vfModuleAAI.setModelCustomizationId(vfModuleCustomizationId);
+
+ doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
+ doReturn(volumeGroupAAI).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(CLOUD_OWNER,
+ cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
+ doReturn(vfModuleAAI).when(SPY_bbInputSetupUtils).getAAIVfModule(isA(String.class), isA(String.class));
+ doNothing().when(SPY_bbInputSetup).mapCatalogVnf(isA(GenericVnf.class), isA(ModelInfo.class),
+ isA(Service.class));
+ doNothing().when(SPY_bbInputSetup).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class),
+ isA(Service.class), isA(String.class));
+
+ SPY_bbInputSetup.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId,
+ relatedInstanceList, instanceName, instanceParams, cloudConfiguration);
+
+ verify(SPY_bbInputSetup, times(3)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class),
+ isA(Service.class), isA(String.class));
+ 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);
+ }
- L3Network expected = new L3Network();
- List<L3Network> l3Networks = new ArrayList<>();
- AAIResultWrapper l3NetworksWrapper = new AAIResultWrapper(
- new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
- AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, "networkId");
- doReturn(l3NetworksWrapper).when(SPY_bbInputSetupUtils).getAAIResourceDepthTwo(aaiResourceUri);
- doReturn(expected).when(bbInputSetupMapperLayer)
- .mapAAIL3Network(isA(org.onap.aai.domain.yang.L3Network.class));
- doNothing().when(SPY_bbInputSetup).mapNetworkPolicies(any(), eq(expected.getNetworkPolicies()));
- doNothing().when(SPY_bbInputSetup).mapRouteTableReferences(any(),
- eq(expected.getContrailNetworkRouteTableReferences()));
-
- SPY_bbInputSetup.mapL3Networks(Arrays.asList(new AAIResourceUri[] { aaiResourceUri }), l3Networks);
-
- assertEquals(expected, l3Networks.get(0));
- verify(SPY_bbInputSetup, times(1)).mapNetworkPolicies(any(), eq(expected.getNetworkPolicies()));
- verify(SPY_bbInputSetup, times(1)).mapRouteTableReferences(any(),
- eq(expected.getContrailNetworkRouteTableReferences()));
- }
-
- @Test
- public void testMapRouteTableReferences() throws JsonProcessingException {
- org.onap.aai.domain.yang.RouteTableReference expectedAAI = new org.onap.aai.domain.yang.RouteTableReference();
-
- RouteTableReference expected = new RouteTableReference();
- List<RouteTableReference> contrailNetworkRouteTableReferences = new ArrayList<>();
- AAIResultWrapper vnfWrapper = new AAIResultWrapper(
- new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
-
- doReturn(expected).when(bbInputSetupMapperLayer).mapAAIRouteTableReferenceIntoRouteTableReference(
- isA(org.onap.aai.domain.yang.RouteTableReference.class));
-
- SPY_bbInputSetup.mapRouteTableReferences(Arrays.asList(new AAIResultWrapper[] { vnfWrapper }),
- contrailNetworkRouteTableReferences);
-
- assertEquals(expected, contrailNetworkRouteTableReferences.get(0));
- }
-
- @Test
- public void testMapOwningEntity() throws JsonProcessingException {
- org.onap.aai.domain.yang.OwningEntity expectedAAI = new org.onap.aai.domain.yang.OwningEntity();
-
- OwningEntity expected = new OwningEntity();
- AAIResultWrapper vnfWrapper = new AAIResultWrapper(
- new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
-
- doReturn(expected).when(bbInputSetupMapperLayer)
- .mapAAIOwningEntity(isA(org.onap.aai.domain.yang.OwningEntity.class));
-
- ServiceInstance serviceInstance = new ServiceInstance();
-
- SPY_bbInputSetup.mapOwningEntity(Arrays.asList(new AAIResultWrapper[] { vnfWrapper }), serviceInstance);
-
- assertEquals(expected, serviceInstance.getOwningEntity());
- }
-
- @Test
- public void testMapProject() throws JsonProcessingException {
- org.onap.aai.domain.yang.Project expectedAAI = new org.onap.aai.domain.yang.Project();
-
- Project expected = new Project();
- AAIResultWrapper vnfWrapper = new AAIResultWrapper(
- new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI));
-
- doReturn(expected).when(bbInputSetupMapperLayer).mapAAIProject(isA(org.onap.aai.domain.yang.Project.class));
-
- ServiceInstance serviceInstance = new ServiceInstance();
-
- SPY_bbInputSetup.mapProject(Arrays.asList(new AAIResultWrapper[] { vnfWrapper }), serviceInstance);
-
- assertEquals(expected, serviceInstance.getProject());
- }
-
- @Test
- public void testMapCustomer() throws Exception {
- org.onap.aai.domain.yang.Customer customerAAI = new org.onap.aai.domain.yang.Customer();
- org.onap.aai.domain.yang.ServiceSubscription serviceSubscriptionAAI = new org.onap.aai.domain.yang.ServiceSubscription();
-
- Customer expected = new Customer();
- ServiceSubscription serviceSubscription = new ServiceSubscription();
-
- String globalCustomerId = "globalCustomerId";
- String subscriptionServiceType = "subscriptionServiceType";
-
- doReturn(customerAAI).when(SPY_bbInputSetupUtils).getAAICustomer(globalCustomerId);
- doReturn(serviceSubscriptionAAI).when(SPY_bbInputSetupUtils).getAAIServiceSubscription(globalCustomerId,
- subscriptionServiceType);
- doReturn(expected).when(bbInputSetupMapperLayer)
- .mapAAICustomer(isA(org.onap.aai.domain.yang.Customer.class));
- doReturn(serviceSubscription).when(bbInputSetupMapperLayer)
- .mapAAIServiceSubscription(isA(org.onap.aai.domain.yang.ServiceSubscription.class));
-
- Customer actual = SPY_bbInputSetup.mapCustomer(globalCustomerId, subscriptionServiceType);
-
- assertEquals(expected, actual);
- assertEquals(serviceSubscription, expected.getServiceSubscription());
- }
-
- @Test
- public void testPopulateLookupKeyMapWithIds() {
- Map<ResourceKey, String> expected = new HashMap<>();
- Map<ResourceKey, String> actual = new HashMap<>();
- String serviceInstanceId = "serviceInstanceId";
- String networkId = "networkId";
- String vnfId = "vnfId";
- String vfModuleId = "vfModuleId";
- String volumeGroupId = "volumeGroupId";
- String configurationId = "configurationId";
- String instanceGroupId = "instancegroupId";
-
- expected.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstanceId);
- expected.put(ResourceKey.NETWORK_ID, networkId);
- expected.put(ResourceKey.GENERIC_VNF_ID, vnfId);
- expected.put(ResourceKey.VF_MODULE_ID, vfModuleId);
- expected.put(ResourceKey.VOLUME_GROUP_ID, volumeGroupId);
- expected.put(ResourceKey.CONFIGURATION_ID, configurationId);
- expected.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroupId);
-
- WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
- workflowResourceIds.setServiceInstanceId(serviceInstanceId);
- workflowResourceIds.setNetworkId(networkId);
- workflowResourceIds.setVnfId(vnfId);
- workflowResourceIds.setVfModuleId(vfModuleId);
- workflowResourceIds.setVolumeGroupId(volumeGroupId);
- workflowResourceIds.setConfigurationId(configurationId);
- workflowResourceIds.setInstanceGroupId(instanceGroupId);
-
- SPY_bbInputSetup.populateLookupKeyMapWithIds(workflowResourceIds, actual);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testgetGBBMacro() throws Exception {
- GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper
- .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
- InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class);
- org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
- aaiVnf.setModelCustomizationId("modelCustId");
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
- String resourceId = "123";
- String vnfType = "vnfType";
- Service service = Mockito.mock(Service.class);
- String requestAction = "createInstance";
-
- ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
- configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
- configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
- configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
- executeBB.setConfigurationResourceKeys(configResourceKeys);
-
- executeBB.setRequestDetails(requestDetails);
- doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
- doReturn(request).when(SPY_bbInputSetupUtils).getInfraActiveRequest(executeBB.getRequestId());
- doReturn(service).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
- doNothing().when(SPY_bbInputSetupUtils).updateInfraActiveRequestVnfId(request,
- lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID));
- doReturn("vnfId").when(SPY_bbInputSetup).getVnfId(executeBB, lookupKeyMap);
- doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(any(String.class));
-
-
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), isA(ModelInfo.class),
- isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any());
-
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VNF.toString());
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class),
- isA(org.onap.so.serviceinstancebeans.Platform.class),
- isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class),
- isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(), any(String.class));
-
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString());
- executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateVfModule(isA(ModelInfo.class), isA(Service.class), any(String.class),
- isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), any(), isA(CloudConfiguration.class));
-
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString());
- executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class),
- any(String.class), isA(ServiceInstance.class), any(), any(String.class),ArgumentMatchers.isNull(),ArgumentMatchers.isNull(),
- any(String.class), any());
-
- Configuration configuration = new Configuration();
- configuration.setConfigurationId("configurationId");
- gBB.getServiceInstance().getConfigurations().add(configuration);
- List<ConfigurationResourceCustomization> configurationCustList = new ArrayList<>();
- ConfigurationResourceCustomization configurationCust = new ConfigurationResourceCustomization();
- configurationCust.setModelCustomizationUUID("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
- doReturn(configurationCustList).when(service).getConfigurationCustomizations();
- configurationCustList.add(configurationCust);
- doNothing().when(SPY_bbInputSetup).populateConfiguration(isA(ModelInfo.class), isA(Service.class),
- any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), isA(ConfigurationResourceKeys.class));
-
- executeBB.getBuildingBlock().setBpmnFlowName("AssignFabricConfigurationBB");
- executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateConfiguration(isA(ModelInfo.class), isA(Service.class),
- any(String.class), isA(ServiceInstance.class), any(), any(String.class),ArgumentMatchers.isNull(), isA(ConfigurationResourceKeys.class));
- }
-
- @Test
- public void testgetGBBMacroCloudConfiguration() throws Exception {
- org.onap.so.serviceinstancebeans.Service serviceMacro = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceMacroVfModules.json"), org.onap.so.serviceinstancebeans.Service.class);
- CloudConfiguration cloudConfig = null;
- org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = new org.onap.aai.domain.yang.CloudRegion();
- aaiCloudRegion.setCloudOwner("test-owner-name");
- Resources resources = serviceMacro.getResources();
- doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(any(CloudConfiguration.class));
- CloudRegion expected = new CloudRegion();
- expected.setLcpCloudRegionId("mdt1");
- expected.setCloudOwner("test-owner-name");
- expected.setTenantId("88a6ca3ee0394ade9403f075db23167e");
-
- CloudRegion actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources);
- assertThat(actual, sameBeanAs(expected));
-
- serviceMacro = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceMacroVnfs.json"), org.onap.so.serviceinstancebeans.Service.class);
- resources = serviceMacro.getResources();
-
- actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources);
- assertThat(actual, sameBeanAs(expected));
-
- serviceMacro = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceMacroNetworks.json"), org.onap.so.serviceinstancebeans.Service.class);
- resources = serviceMacro.getResources();
-
- actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources);
- assertThat(actual, sameBeanAs(expected));
-
- serviceMacro = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceMacroNoCloudConfig.json"), org.onap.so.serviceinstancebeans.Service.class);
- resources = serviceMacro.getResources();
-
- actual = SPY_bbInputSetup.getCloudRegionFromMacroRequest(cloudConfig, resources);
- assertNull(actual);
- }
-
- @Test
- public void testgetGBBMacroWithEmptyUserParams() throws Exception {
- GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper
- .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
- requestDetails.getRequestParameters().getUserParams().clear();
- InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class);
- org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
- aaiVnf.setModelCustomizationId("modelCustId");
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- String resourceId = "123";
- String vnfType = "vnfType";
- Service service = Mockito.mock(Service.class);
- String requestAction = "createInstance";
-
- doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
- doReturn(service).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
-
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- executeBB.getBuildingBlock().setIsVirtualLink(Boolean.FALSE);
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).getGBBMacroNoUserParamsCreate(any(ExecuteBuildingBlock.class), any(),
- any(String.class), any(String.class), any(GeneralBuildingBlock.class), any(Service.class));
- }
-
- @Test(expected = Exception.class)
- public void testgetGBBMacroException() throws Exception {
- GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper
- .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- String resourceId = "123";
- String vnfType = "vnfType";
- Service service = Mockito.mock(Service.class);
- String requestAction = "createInstance";
-
- executeBB.getBuildingBlock().setBpmnFlowName("Network");
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- }
-
- @Test
- public void testgetGBBMacroWithVnfTypeNull() throws Exception {
- GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper
- .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
- aaiVnf.setModelCustomizationId("modelCustId");
- InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class);
- String resourceId = "123";
- String vnfType = null;
- Service service = Mockito.mock(Service.class);
- String requestAction = "createInstance";
-
-
- executeBB.setRequestDetails(requestDetails);
- doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
- doReturn(request).when(SPY_bbInputSetupUtils).getInfraActiveRequest(executeBB.getRequestId());
- doReturn(service).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
- doNothing().when(SPY_bbInputSetupUtils).updateInfraActiveRequestVnfId(request,
- lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID));
- doReturn("vnfId").when(SPY_bbInputSetup).getVnfId(executeBB, lookupKeyMap);
- doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(any(String.class));
-
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), isA(ModelInfo.class),
- isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any());
-
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VNF.toString());
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class),
- isA(org.onap.so.serviceinstancebeans.Platform.class),
- isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class),
- isA(ServiceInstance.class), any(),ArgumentMatchers.isNull(), any(String.class), ArgumentMatchers.isNull(), any(), any(String.class));
-
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString());
- executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateVfModule(isA(ModelInfo.class), isA(Service.class), any(String.class),
- isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), any(), isA(CloudConfiguration.class));
-
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString());
- executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class),
- any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), ArgumentMatchers.isNull(),
- ArgumentMatchers.isNull(), any());
- }
-
- @Test
- public void testgetGBBMacroGetServiceWithInvariantId() throws Exception {
- GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper
- .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
- aaiVnf.setModelCustomizationId("modelCustId");
- InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class);
- String resourceId = "123";
- String vnfType = "vnfType";
- Service service = Mockito.mock(Service.class);
- String requestAction = "createInstance";
-
- executeBB.setRequestDetails(requestDetails);
- doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
- doReturn(request).when(SPY_bbInputSetupUtils).getInfraActiveRequest(executeBB.getRequestId());
- doReturn(service).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
- doNothing().when(SPY_bbInputSetupUtils).updateInfraActiveRequestVnfId(request,
- lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID));
- doReturn("vnfId").when(SPY_bbInputSetup).getVnfId(executeBB, lookupKeyMap);
- doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(any(String.class));
-
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateL3Network(any(String.class), isA(ModelInfo.class),
- isA(Service.class), any(String.class), isA(ServiceInstance.class), any(), any(String.class), any());
-
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VNF.toString());
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateGenericVnf(isA(ModelInfo.class), any(String.class),
- isA(org.onap.so.serviceinstancebeans.Platform.class),
- isA(org.onap.so.serviceinstancebeans.LineOfBusiness.class), isA(Service.class), any(String.class),
- isA(ServiceInstance.class), any(), any(), any(String.class), any(String.class), any(),
- any(String.class));
-
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VF_MODULE.toString());
- executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateVfModule(isA(ModelInfo.class), isA(Service.class), any(String.class),
- isA(ServiceInstance.class), any(), any(String.class), any(), any(String.class), any(), isA(CloudConfiguration.class));
-
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, null);
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.VOLUME_GROUP.toString());
- executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).populateVolumeGroup(isA(ModelInfo.class), isA(Service.class),
- any(String.class), isA(ServiceInstance.class), any(), any(String.class), ArgumentMatchers.isNull(), ArgumentMatchers.isNull(),
- any(String.class), any());
- }
-
- @Test
- public void testgetGBBMacroNoUserParamsDeactivateInstnace() throws Exception {
- GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper
- .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
- requestDetails.getRequestParameters().setUserParams(null);
- org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
- aaiVnf.setModelCustomizationId("modelCustId");
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- String resourceId = "123";
- String vnfType = "vnfType";
- Service service = Mockito.mock(Service.class);
- String requestAction = "deactivateInstance";
- doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
- doReturn(service).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
- String generatedId = "12131";
-
- executeBB.getBuildingBlock().setBpmnFlowName("DeactivateServiceInstanceBB");
- executeBB.getBuildingBlock().setKey("3c40d244-808e-42ca-b09a-256d83d19d0a");
- GeneralBuildingBlock actual = SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap,
- requestAction, resourceId, vnfType);
- assertThat(actual, sameBeanAs(gBB));
- }
-
- @Test
- public void testgetGBBMacroNoUserParamsCreateInstance() throws Exception {
- GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper
- .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
- InfraActiveRequests request = Mockito.mock(InfraActiveRequests.class);
- requestDetails.getRequestParameters().setUserParams(null);
- org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
- aaiVnf.setModelCustomizationId("modelCustId");
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
-
- ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
- configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
- configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
- configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
- executeBB.setConfigurationResourceKeys(configResourceKeys);
-
- String resourceId = "123";
- String vnfType = "vnfType";
- Service service = Mockito.mock(Service.class);
- String requestAction = "createInstance";
- doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
-
-
- doReturn(service).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
- List<NetworkResourceCustomization> networkCustList = new ArrayList<>();
- NetworkResourceCustomization networkCust = Mockito.mock(NetworkResourceCustomization.class);
- doReturn("ab153b6e-c364-44c0-bef6-1f2982117f04").when(networkCust).getModelCustomizationUUID();
- networkCustList.add(networkCust);
- doReturn(networkCustList).when(service).getNetworkCustomizations();
- doNothing().when(SPY_bbInputSetup).populateL3Network(any(), isA(ModelInfo.class), isA(Service.class),
- any(String.class), isA(ServiceInstance.class), any(), any(String.class), any());
-
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- executeBB.getBuildingBlock().setIsVirtualLink(false);
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).getGBBMacroNoUserParamsCreate(executeBB, lookupKeyMap,
- executeBB.getBuildingBlock().getBpmnFlowName(), "ab153b6e-c364-44c0-bef6-1f2982117f04", gBB, service);
-
- CollectionNetworkResourceCustomization collectionNetworkResourceCust = Mockito.mock(CollectionNetworkResourceCustomization.class);
- doReturn(collectionNetworkResourceCust).when(SPY_bbInputSetupUtils).getCatalogCollectionNetworkResourceCustByID(any(String.class));
- NetworkResourceCustomization networkResourceCustomization = Mockito.mock(NetworkResourceCustomization.class);
- doReturn(networkResourceCustomization).when(bbInputSetupMapperLayer).mapCollectionNetworkResourceCustToNetworkResourceCust(collectionNetworkResourceCust);
- ModelInfoNetwork modelInfoNetwork = Mockito.mock(ModelInfoNetwork.class);
- doReturn(modelInfoNetwork ).when(bbInputSetupMapperLayer).mapCatalogNetworkToNetwork(networkResourceCustomization);
-
- executeBB.getBuildingBlock().setBpmnFlowName(AssignFlows.NETWORK_MACRO.toString());
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- executeBB.getBuildingBlock().setIsVirtualLink(true);
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(2)).getGBBMacroNoUserParamsCreate(executeBB, lookupKeyMap,
- executeBB.getBuildingBlock().getBpmnFlowName(), "ab153b6e-c364-44c0-bef6-1f2982117f04", gBB, service);
-
- executeBB.getBuildingBlock().setBpmnFlowName("CreateNetworkBB");
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- executeBB.getBuildingBlock().setIsVirtualLink(true);
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).getGBBMacroNoUserParamsCreate(executeBB, lookupKeyMap,
- executeBB.getBuildingBlock().getBpmnFlowName(), "ab153b6e-c364-44c0-bef6-1f2982117f04", gBB, service);
- }
-
- @Test
- public void testgetGBBMacroNoUserParamsOther() throws Exception {
- GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper
- .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
- requestDetails.getRequestParameters().setUserParams(null);
- org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
- aaiVnf.setModelCustomizationId("modelCustId");
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- String resourceId = "123";
- String vnfType = "vnfType";
- Service service = Mockito.mock(Service.class);
- String requestAction = "deleteInstance";
-
- executeBB.setRequestDetails(requestDetails);
- ServiceInstance serviceInstance = gBB.getServiceInstance();
- org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
- aaiServiceInstance.setModelVersionId("modelVersionId");
- doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
- doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
- doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
- doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
- executeBB, requestAction, null);
-
- CloudConfiguration cloudConfig = new CloudConfiguration();
- cloudConfig.setLcpCloudRegionId("lcpCloudRegionId");
- requestDetails.setCloudConfiguration(cloudConfig);
- org.onap.aai.domain.yang.CloudRegion aaiCloudRegion = Mockito.mock(org.onap.aai.domain.yang.CloudRegion.class);
- doReturn(aaiCloudRegion).when(SPY_bbInputSetupUtils).getCloudRegion(requestDetails.getCloudConfiguration());
- executeBB.getBuildingBlock().setBpmnFlowName("DeleteNetworkBB");
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(1)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(),
- any(String.class), isA(String.class),
- isA(CloudConfiguration.class));
-
- requestAction = "activateInstance";
- doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
- executeBB, requestAction, null);
- executeBB.getBuildingBlock().setBpmnFlowName("ActivateNetworkBB");
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(2)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(),
- any(String.class), isA(String.class),
- isA(CloudConfiguration.class));
-
- requestAction = "unassignInstance";
- doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
- executeBB, requestAction, null);
- executeBB.getBuildingBlock().setBpmnFlowName("UnassignNetworkBB");
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(3)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(),
- any(String.class), isA(String.class),
- isA(CloudConfiguration.class));
-
- requestAction = "activateFabricConfiguration";
- doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
- executeBB, requestAction, null);
- executeBB.getBuildingBlock().setBpmnFlowName("ActivateFabricConfigurationBB");
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-134534656234");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- verify(SPY_bbInputSetup, times(4)).getGBBMacroExistingService(isA(ExecuteBuildingBlock.class), any(),
- any(String.class), isA(String.class),
- isA(CloudConfiguration.class));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testgetGBBMacroNoUserParamsOtherException() throws Exception {
- GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper
- .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
- requestDetails.getRequestParameters().setUserParams(null);
- org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
- aaiVnf.setModelCustomizationId("modelCustId");
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- String resourceId = "123";
- String vnfType = "vnfType";
- Service service = Mockito.mock(Service.class);
- String requestAction = "assignInstance";
- doReturn(gBB).when(SPY_bbInputSetup).getGBBALaCarteService(executeBB, requestDetails, lookupKeyMap,
- requestAction, lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
- doReturn(service).when(SPY_bbInputSetupUtils)
- .getCatalogServiceByModelUUID(gBB.getServiceInstance().getModelInfoServiceInstance().getModelUuid());
- String generatedId = "12131";
-
- executeBB.getBuildingBlock().setKey("3c40d244-808e-42ca-b09a-256d83d19d0a");
- SPY_bbInputSetup.getGBBMacro(executeBB, requestDetails, lookupKeyMap, requestAction, resourceId, vnfType);
- }
- @Test
- public void testgetGBBMacroNoUserParamsExistingService() throws Exception {
- GeneralBuildingBlock gBB = mapper.readValue(new File(RESOURCE_PATH + "GeneralBuildingBlockExpected.json"),
- GeneralBuildingBlock.class);
- ExecuteBuildingBlock executeBB = mapper.readValue(new File(RESOURCE_PATH + "ExecuteBuildingBlockSimple.json"),
- ExecuteBuildingBlock.class);
- RequestDetails requestDetails = mapper
- .readValue(new File(RESOURCE_PATH + "RequestDetailsInput_serviceMacro.json"), RequestDetails.class);
- requestDetails.getRequestParameters().setUserParams(null);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.NETWORK_ID, "networkId");
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "vnfId");
- lookupKeyMap.put(ResourceKey.VF_MODULE_ID, "vfModuleId");
- lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, "volumeGroupId");
- lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "serviceInstanceId");
- lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "configurationId");
- Service service = Mockito.mock(Service.class);
- CloudConfiguration cloudConfiguration = new CloudConfiguration();
- cloudConfiguration.setLcpCloudRegionId("cloudRegionId");
- String requestAction = "unassignInstance";
- executeBB.setRequestDetails(requestDetails);
-
- ConfigurationResourceKeys configResourceKeys = new ConfigurationResourceKeys();
- configResourceKeys.setCvnfcCustomizationUUID("cvnfcCustomizationUUID");
- configResourceKeys.setVfModuleCustomizationUUID("vfModuleCustomizationUUID");
- configResourceKeys.setVnfResourceCustomizationUUID("vnfResourceCustomizationUUID");
- executeBB.setConfigurationResourceKeys(configResourceKeys);
-
- ServiceInstance serviceInstance = gBB.getServiceInstance();
- org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance();
- aaiServiceInstance.setModelVersionId("modelVersionId");
- doReturn(service).when(SPY_bbInputSetupUtils).getCatalogServiceByModelUUID(aaiServiceInstance.getModelVersionId());
- doReturn(aaiServiceInstance).when(SPY_bbInputSetupUtils).getAAIServiceInstanceById(lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID));
- doReturn(serviceInstance).when(SPY_bbInputSetup).getExistingServiceInstance(aaiServiceInstance);
- doReturn(gBB).when(SPY_bbInputSetup).populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance,
- executeBB, requestAction, null);
-
- L3Network network = new L3Network();
- network.setNetworkId("networkId");
- gBB.getServiceInstance().getNetworks().add(network);
- org.onap.aai.domain.yang.L3Network aaiNetwork = new org.onap.aai.domain.yang.L3Network();
- aaiNetwork.setModelCustomizationId("modelCustId");
- doReturn(aaiNetwork).when(SPY_bbInputSetupUtils).getAAIL3Network(network.getNetworkId());
- doNothing().when(SPY_bbInputSetup).mapCatalogNetwork(any(L3Network.class), any(ModelInfo.class),
- any(Service.class));
-
- executeBB.getBuildingBlock().setBpmnFlowName("DeleteNetworkBB");
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
- executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, null);
- verify(SPY_bbInputSetup, times(1)).mapCatalogNetwork(any(L3Network.class), any(ModelInfo.class),
- any(Service.class));
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("vnfId");
- gBB.getServiceInstance().getVnfs().add(vnf);
- org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
- aaiVnf.setModelCustomizationId("modelCustId");
- doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
- doNothing().when(SPY_bbInputSetup).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
- any(Service.class));
-
- executeBB.getBuildingBlock().setBpmnFlowName("ActivateVnfBB");
- executeBB.getBuildingBlock().setKey("ab153b6e-c364-44c0-bef6-1f2982117f04");
- SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
- executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, cloudConfiguration);
- verify(SPY_bbInputSetup, times(1)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
- any(Service.class));
-
- VfModule vfModule = new VfModule();
- vfModule.setVfModuleId("vfModuleId");
- gBB.getServiceInstance().getVnfs().get(0).getVfModules().add(vfModule);
- org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule();
- aaiVfModule.setModelCustomizationId("modelCustId");
- doReturn(aaiVfModule).when(SPY_bbInputSetupUtils).getAAIVfModule(vnf.getVnfId(), vfModule.getVfModuleId());
-
- executeBB.getBuildingBlock().setBpmnFlowName("UnassignVfModuleBB");
- executeBB.getBuildingBlock().setKey("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
- SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
- executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, cloudConfiguration);
- verify(SPY_bbInputSetup, times(2)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
- any(Service.class));
- verify(SPY_bbInputSetup, times(1)).mapCatalogVfModule(any(VfModule.class), any(ModelInfo.class),
- any(Service.class), any(String.class));
-
- CloudRegion cloudRegion = new CloudRegion();
- cloudRegion.setLcpCloudRegionId("cloudRegionId");
- cloudRegion.setCloudOwner("CloudOwner");
- doReturn(Optional.of(cloudRegion)).when(SPY_cloudInfoFromAAI).getCloudInfoFromAAI(gBB.getServiceInstance());
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("volumeGroupId");
- gBB.getServiceInstance().getVnfs().get(0).getVolumeGroups().add(volumeGroup);
- org.onap.aai.domain.yang.VolumeGroup aaiVolumeGroup = new org.onap.aai.domain.yang.VolumeGroup();
- aaiVolumeGroup.setModelCustomizationId("modelCustId");
- doReturn(aaiVolumeGroup).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(cloudRegion.getCloudOwner(),
- cloudRegion.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
-
- executeBB.getBuildingBlock().setBpmnFlowName("UnassignVolumeGroupBB");
- executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa8");
- SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
- executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, null);
- verify(SPY_bbInputSetup, times(3)).mapCatalogVnf(any(GenericVnf.class), any(ModelInfo.class),
- any(Service.class));
- verify(SPY_bbInputSetup, times(1)).mapCatalogVolumeGroup(isA(VolumeGroup.class), isA(ModelInfo.class),
- isA(Service.class), isA(String.class));
-
- Configuration configuration = new Configuration();
- configuration.setConfigurationId("configurationId");
- gBB.getServiceInstance().getConfigurations().add(configuration);
- org.onap.aai.domain.yang.Configuration aaiConfiguration = new org.onap.aai.domain.yang.Configuration();
- aaiConfiguration.setModelCustomizationId("modelCustId");
- doReturn(aaiConfiguration).when(SPY_bbInputSetupUtils).getAAIConfiguration(configuration.getConfigurationId());
- doNothing().when(SPY_bbInputSetup).mapCatalogConfiguration(isA(Configuration.class), isA(ModelInfo.class), isA(Service.class), isA(ConfigurationResourceKeys.class));
-
- executeBB.getBuildingBlock().setBpmnFlowName("ActivateFabricConfigurationBB");
- executeBB.getBuildingBlock().setKey("72d9d1cd-f46d-447a-abdb-451d6fb05fa9");
- SPY_bbInputSetup.getGBBMacroExistingService(executeBB, lookupKeyMap,
- executeBB.getBuildingBlock().getBpmnFlowName(), requestAction, cloudConfiguration);
- verify(SPY_bbInputSetup, times(1)).mapCatalogConfiguration(any(Configuration.class), any(ModelInfo.class),
- any(Service.class), isA(ConfigurationResourceKeys.class));
- }
-
- @Test
- public void testGetVnfId() {
- String expected = "vnfId";
- ExecuteBuildingBlock executeBB = new ExecuteBuildingBlock();
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- executeBB.setRequestId("requestId");
- InfraActiveRequests request = new InfraActiveRequests();
- request.setVnfId(expected);
- doReturn(request).when(SPY_bbInputSetupUtils).getInfraActiveRequest(executeBB.getRequestId());
-
- String actual = SPY_bbInputSetup.getVnfId(executeBB, lookupKeyMap);
-
- assertEquals("VnfId is set correctly", expected, actual);
- }
-
- @Test
- public void testCreateVfModule() {
- String vfModuleId = "vfModuleId";
- String instanceName = "vfModuleName";
- Map<String, String> cloudParams = new HashMap<>();
- cloudParams.put("param1", "param1Value");
- VfModule expected = new VfModule();
- expected.setVfModuleId(vfModuleId);
- expected.setVfModuleName(instanceName);
- expected.setCloudParams(cloudParams);
- expected.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- List<Map<String, String>> instanceParams = new ArrayList<>();
- instanceParams.add(cloudParams);
-
- VfModule actual = SPY_bbInputSetup.createVfModule(lookupKeyMap, vfModuleId, instanceName, instanceParams);
-
- assertThat(actual, sameBeanAs(expected));
- assertEquals("LookupKeyMap is populated", vfModuleId, lookupKeyMap.get(ResourceKey.VF_MODULE_ID));
-
- expected.getCloudParams().clear();
- actual = SPY_bbInputSetup.createVfModule(lookupKeyMap, vfModuleId, instanceName, null);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testCreateVolumeGroup() {
- String volumeGroupId = "volumeGroupId";
- String instanceName = "vfModuleName";
- String vnfType = "vnfType";
- Map<String, String> cloudParams = new HashMap<>();
- cloudParams.put("param1", "param1Value");
- VolumeGroup expected = new VolumeGroup();
- expected.setVolumeGroupId(volumeGroupId);
- expected.setVolumeGroupName(instanceName);
- expected.setCloudParams(cloudParams);
- expected.setVnfType(vnfType);
- expected.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- List<Map<String, String>> instanceParams = new ArrayList<>();
- instanceParams.add(cloudParams);
-
- VolumeGroup actual = SPY_bbInputSetup.createVolumeGroup(lookupKeyMap, volumeGroupId, instanceName, vnfType, instanceParams);
-
- assertThat(actual, sameBeanAs(expected));
- assertEquals("LookupKeyMap is populated", volumeGroupId, lookupKeyMap.get(ResourceKey.VOLUME_GROUP_ID));
-
- expected.getCloudParams().clear();
- actual = SPY_bbInputSetup.createVolumeGroup(lookupKeyMap, volumeGroupId, instanceName, vnfType, null);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testCreateNetwork() {
- String networkId = "networkId";
- String instanceName = "networkName";
- Map<String, String> cloudParams = new HashMap<>();
- cloudParams.put("param1", "param1Value");
- L3Network expected = new L3Network();
- expected.setNetworkId(networkId);
- expected.setNetworkName(instanceName);
- expected.setCloudParams(cloudParams);
- expected.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- List<Map<String, String>> instanceParams = new ArrayList<>();
- instanceParams.add(cloudParams);
- L3Network actual = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, networkId, instanceParams);
-
- assertThat(actual, sameBeanAs(expected));
- assertEquals("LookupKeyMap is populated", networkId, lookupKeyMap.get(ResourceKey.NETWORK_ID));
-
- expected.getCloudParams().clear();
- actual = SPY_bbInputSetup.createNetwork(lookupKeyMap, instanceName, networkId, null);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testCreateGenericVnf() {
- String vnfId = "vnfId";
- String instanceName = "vnfName";
- String vnfType = "vnfType";
- String platformName = "platformName";
- String lineOfBusinessName = "lineOfBusinessName";
- String productFamilyId = "productFamilyId";
- Platform platform = new Platform();
- platform.setPlatformName(platformName);
- LineOfBusiness lineOfBusiness = new LineOfBusiness();
- lineOfBusiness.setLineOfBusinessName(lineOfBusinessName);
- Map<String, String> cloudParams = new HashMap<>();
- cloudParams.put("param1", "param1Value");
- GenericVnf expected = new GenericVnf();
- expected.setVnfId(vnfId);
- expected.setVnfName(instanceName);
- expected.setVnfType(vnfType);
- expected.setCloudParams(cloudParams);
- expected.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- expected.setPlatform(platform);
- expected.setLineOfBusiness(lineOfBusiness);
- expected.setProvStatus("PREPROV");
- expected.setServiceId(productFamilyId);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- List<Map<String, String>> instanceParams = new ArrayList<>();
- instanceParams.add(cloudParams);
- org.onap.so.serviceinstancebeans.Platform requestPlatform = new org.onap.so.serviceinstancebeans.Platform();
- platform.setPlatformName(platformName);
- org.onap.so.serviceinstancebeans.LineOfBusiness requestLineOfBusiness = new org.onap.so.serviceinstancebeans.LineOfBusiness();
- lineOfBusiness.setLineOfBusinessName(lineOfBusinessName);
-
- doReturn(platform).when(bbInputSetupMapperLayer).mapRequestPlatform(requestPlatform);
- doReturn(lineOfBusiness).when(bbInputSetupMapperLayer).mapRequestLineOfBusiness(requestLineOfBusiness);
-
- GenericVnf actual = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, requestPlatform, requestLineOfBusiness, vnfId, vnfType, instanceParams,
- productFamilyId);
-
- assertThat(actual, sameBeanAs(expected));
- assertEquals("LookupKeyMap is populated", vnfId, lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID));
-
- expected.getCloudParams().clear();
- actual = SPY_bbInputSetup.createGenericVnf(lookupKeyMap, instanceName, requestPlatform, requestLineOfBusiness, vnfId, vnfType, null, productFamilyId);
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testMapCatalogVfModule() {
- String vnfModelCustomizationUUID = "vnfResourceCustUUID";
- String vfModuleCustomizationUUID = "vfModelCustomizationUUID";
- VfModule vfModule = new VfModule();
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelCustomizationUuid(vfModuleCustomizationUUID);
- Service service = new Service();
- VnfResourceCustomization vnfResourceCust = new VnfResourceCustomization();
- vnfResourceCust.setModelCustomizationUUID(vnfModelCustomizationUUID);
- VfModuleCustomization vfModuleCust = new VfModuleCustomization();
- vfModuleCust.setModelCustomizationUUID(vfModuleCustomizationUUID);
- vnfResourceCust.getVfModuleCustomizations().add(vfModuleCust);
- service.getVnfCustomizations().add(vnfResourceCust);
- ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
-
- doReturn(modelInfoVfModule).when(bbInputSetupMapperLayer).mapCatalogVfModuleToVfModule(vfModuleCust);
-
- SPY_bbInputSetup.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID);
-
- assertThat(vfModule.getModelInfoVfModule(), sameBeanAs(modelInfoVfModule));
-
- modelInfo.setModelCustomizationUuid(null);
- modelInfo.setModelCustomizationId(vfModuleCustomizationUUID);
-
- SPY_bbInputSetup.mapCatalogVfModule(vfModule, modelInfo, service, vnfModelCustomizationUUID);
-
- assertThat(vfModule.getModelInfoVfModule(), sameBeanAs(modelInfoVfModule));
- }
-
- @Test
- public void testPopulateVfModule() throws Exception {
- String vnfId = "vnfId";
- String vfModuleId = "vfModuleId";
- String volumeGroupId = "volumeGroupId";
- String vfModuleCustomizationId = "vfModuleCustomizationId";
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelCustomizationId(vfModuleCustomizationId);
- Service service = new Service();
- String bbName = AssignFlows.VF_MODULE.toString();
- ServiceInstance serviceInstance = new ServiceInstance();
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId(vnfId);
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId(volumeGroupId);
- vnf.getVolumeGroups().add(volumeGroup);
- serviceInstance.getVnfs().add(vnf);
- VfModule vfModule1 = new VfModule();
- vfModule1.setVfModuleId("vfModuleId1");
- VfModule vfModule2 = new VfModule();
- vfModule2.setVfModuleId("vfModuleId2");
- vnf.getVfModules().add(vfModule1);
- vnf.getVfModules().add(vfModule2);
- Map<ResourceKey, String> lookupKeyMap = new HashMap<>();
- lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, vnfId);
- String resourceId = vfModuleId;
- RelatedInstanceList[] relatedInstanceList = null;
- String instanceName = "vfModuleName";
- List<Map<String, String>> instanceParams = null;
- CloudConfiguration cloudConfiguration = new CloudConfiguration();
-
- org.onap.aai.domain.yang.GenericVnf vnfAAI = new org.onap.aai.domain.yang.GenericVnf();
- vnfAAI.setModelCustomizationId("vnfModelCustId");
- org.onap.aai.domain.yang.VolumeGroup volumeGroupAAI = new org.onap.aai.domain.yang.VolumeGroup();
- volumeGroupAAI.setModelCustomizationId(vfModuleCustomizationId);
- org.onap.aai.domain.yang.VfModule vfModuleAAI = new org.onap.aai.domain.yang.VfModule();
- vfModuleAAI.setModelCustomizationId(vfModuleCustomizationId);
-
- doReturn(vnfAAI).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
- doReturn(volumeGroupAAI).when(SPY_bbInputSetupUtils).getAAIVolumeGroup(CLOUD_OWNER,
- cloudConfiguration.getLcpCloudRegionId(), volumeGroup.getVolumeGroupId());
- doReturn(vfModuleAAI).when(SPY_bbInputSetupUtils).getAAIVfModule(isA(String.class), isA(String.class));
- doNothing().when(SPY_bbInputSetup).mapCatalogVnf(isA(GenericVnf.class), isA(ModelInfo.class), isA(Service.class));
- doNothing().when(SPY_bbInputSetup).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), isA(Service.class), isA(String.class));
-
- SPY_bbInputSetup.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap,
- resourceId, relatedInstanceList, instanceName, instanceParams, cloudConfiguration);
-
- verify(SPY_bbInputSetup, times(3)).mapCatalogVfModule(isA(VfModule.class), isA(ModelInfo.class), isA(Service.class), isA(String.class));
- 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);
- }
-
-
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
index 54e513e7d9..25135a0254 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
@@ -30,13 +30,11 @@ import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -67,7 +65,6 @@ import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.graphinventory.entities.uri.Depth;
-
import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
@@ -77,733 +74,762 @@ import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
import org.onap.so.serviceinstancebeans.ModelInfo;
import org.onap.so.serviceinstancebeans.RequestDetails;
-
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@RunWith(MockitoJUnitRunner.class)
public class BBInputSetupUtilsTest {
- protected ObjectMapper mapper = new ObjectMapper();
- private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
-
- @InjectMocks
- BBInputSetupUtils bbInputSetupUtils = new BBInputSetupUtils();
-
- @Mock
- protected CatalogDbClient MOCK_catalogDbClient;
-
- @Mock
- protected RequestsDbClient MOCK_requestsDbClient;
-
- @Mock
- protected AAIResourcesClient MOCK_aaiResourcesClient;
-
- @Mock
- protected InjectionHelper MOCK_injectionHelper;
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void setup(){
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- }
-
- @Test
- public void testGetCatalogServiceByModelUUID() throws JsonParseException, JsonMappingException, IOException {
- Service expected = mapper.readValue(
- new File(RESOURCE_PATH + "CatalogServiceExpected.json"), Service.class);
-
- RequestDetails requestDetails = new RequestDetails();
- ModelInfo modelInfo = new ModelInfo();
- modelInfo.setModelVersionId("modelUUID");
- requestDetails.setModelInfo(modelInfo);
- doReturn(expected).when(MOCK_catalogDbClient).getServiceByID("modelUUID");
- Service actual = bbInputSetupUtils.getCatalogServiceByModelUUID(modelInfo.getModelVersionId());
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void testGetCatalogServiceByModelVersionAndModelInvariantUUID() throws JsonParseException, JsonMappingException, IOException {
- String modelVersion = "modelVersion";
- String modelInvariantUUID = "modelInvariantUUID";
- Service expectedService = mapper.readValue(
- new File(RESOURCE_PATH + "CatalogServiceExpected.json"), Service.class);
-
- doReturn(expectedService).when(MOCK_catalogDbClient).getServiceByModelVersionAndModelInvariantUUID(isA(String.class), isA(String.class));
-
- Service actualService = bbInputSetupUtils.getCatalogServiceByModelVersionAndModelInvariantUUID(modelVersion, modelInvariantUUID);
-
- assertThat(actualService, sameBeanAs(expectedService));
- }
-
- @Test
- public void testGetVnfcInstanceGroups() throws JsonParseException, JsonMappingException, IOException {
- VnfcInstanceGroupCustomization vnfc = mapper.readValue(
- new File(RESOURCE_PATH + "VnfcInstanceGroupCustomization.json"), VnfcInstanceGroupCustomization.class);
- String modelCustomizationUUID = "modelCustomizationUUID";
-
- doReturn(Arrays.asList(vnfc)).when(MOCK_catalogDbClient).getVnfcInstanceGroupsByVnfResourceCust(isA(String.class));
-
- List<VnfcInstanceGroupCustomization> actualVnfcList = bbInputSetupUtils.getVnfcInstanceGroups(modelCustomizationUUID);
-
- assertThat(actualVnfcList, sameBeanAs(Arrays.asList(vnfc)));
- }
-
- @Test
- public void testGetRequestDetails() throws JsonParseException, JsonMappingException, IOException {
- InfraActiveRequests infraActiveRequest = mapper.readValue(
- new File(RESOURCE_PATH + "InfraActiveRequestExpected.json"),
- InfraActiveRequests.class);
-
- RequestDetails expected = mapper.readValue(
- new File(RESOURCE_PATH + "RequestDetailsExpected.json"),
- RequestDetails.class);
- String requestId = "requestId";
- doReturn(infraActiveRequest).when(MOCK_requestsDbClient).getInfraActiveRequestbyRequestId(requestId);
- RequestDetails actual = bbInputSetupUtils.getRequestDetails(requestId);
-
- assertThat(actual, sameBeanAs(expected));
- }
-
- @Test
- public void getRequestDetailsNullTest() throws IOException {
- RequestDetails requestDetails = bbInputSetupUtils.getRequestDetails("");
-
- assertNull(requestDetails);
- }
-
- @Test
- public void testGetCloudRegion() {
- CloudConfiguration cloudConfig = new CloudConfiguration();
- cloudConfig.setLcpCloudRegionId("lcpCloudRegionId");
- Optional<org.onap.aai.domain.yang.CloudRegion> expected = Optional.of(new org.onap.aai.domain.yang.CloudRegion());
- expected.get().setCloudOwner("cloudOwner");
- expected.get().setCloudRegionId("lcpCloudRegionId");
- doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.CloudRegion.class,
- AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudConfig.getCloudOwner(),
- cloudConfig.getLcpCloudRegionId()).depth(Depth.TWO));
-
- AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudConfig.getCloudOwner(),
- cloudConfig.getLcpCloudRegionId()).depth(Depth.TWO);
- bbInputSetupUtils.getCloudRegion(cloudConfig);
-
- verify(MOCK_aaiResourcesClient, times(1)).get(CloudRegion.class, expectedUri);
- }
-
- @Test
- public void testGetCloudRegionExceptionTest() {
-
- CloudConfiguration cloudConfig = new CloudConfiguration();
- cloudConfig.setLcpCloudRegionId("lcpCloudRegionId");
-
- RequestDetails requestDetails = new RequestDetails();
- requestDetails.setCloudConfiguration(cloudConfig);
-
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
-
- CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfig);
-
- assertNull(cloudRegion);
- }
-
- @Test
- public void testGetCloudRegionEmptyId() {
- CloudConfiguration cloudConfig = new CloudConfiguration();
- cloudConfig.setLcpCloudRegionId("");
-
- RequestDetails requestDetails = new RequestDetails();
- requestDetails.setCloudConfiguration(cloudConfig);
-
- CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfig);
-
- assertNull(cloudRegion);
- }
-
- @Test
- public void testGetCloudRegionEmptyConfiguration() {
- RequestDetails requestDetails = new RequestDetails();
-
- CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(requestDetails.getCloudConfiguration());
-
- assertNull(cloudRegion);
- }
-
- @Test
- public void testGetAAIInstanceGroup() {
- Optional<org.onap.aai.domain.yang.InstanceGroup> expected = Optional.of(new org.onap.aai.domain.yang.InstanceGroup());
- String instanceGroupId = "instanceGroupId";
- expected.get().setId(instanceGroupId);
- doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.InstanceGroup.class,
- AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId));
- AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId);
-
- bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId);
- verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.InstanceGroup.class, expectedUri);
- }
-
- @Test
- public void testGetAAIInstanceGroupThrowNotFound() {
- String instanceGroupId = "instanceGroupId";
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.InstanceGroup.class,
- AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId));
-
- org.onap.aai.domain.yang.InstanceGroup actual = bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId);
-
- assertNull(actual);
- }
-
- @Test
- public void testGetAAICustomer() {
- Optional<org.onap.aai.domain.yang.Customer> expected = Optional.of(new org.onap.aai.domain.yang.Customer());
- String globalSubscriberId = "globalSubscriberId";
- expected.get().setGlobalCustomerId(globalSubscriberId);
- doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.Customer.class,
- AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalSubscriberId));
- AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalSubscriberId);
-
- bbInputSetupUtils.getAAICustomer(globalSubscriberId);
- verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.Customer.class, expectedUri);
- }
-
- @Test
- public void testGetAAICustomerThrowNotFound() {
- String globalSubscriberId = "globalSubscriberId";
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.Customer.class,
- AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalSubscriberId));
-
- org.onap.aai.domain.yang.Customer actual = bbInputSetupUtils.getAAICustomer(globalSubscriberId);
-
- assertNull(actual);
- }
-
- @Test
- public void testGetAAIServiceSubscription() {
- Optional<org.onap.aai.domain.yang.ServiceSubscription> expected = Optional.of(new org.onap.aai.domain.yang.ServiceSubscription());
- String globalSubscriberId = "globalSubscriberId";
- String subscriptionServiceType = "subscriptionServiceType";
- expected.get().setServiceType(subscriptionServiceType);
- doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.ServiceSubscription.class,
- AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION, globalSubscriberId,
- subscriptionServiceType));
- AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION, globalSubscriberId,
- subscriptionServiceType);
-
- bbInputSetupUtils.getAAIServiceSubscription(globalSubscriberId, subscriptionServiceType);
- verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.ServiceSubscription.class, expectedUri);
- }
-
- @Test
- public void testGetAAIServiceSubscriptionErrors() {
- String globalSubId = null;
- String subServiceType = null;
- org.onap.aai.domain.yang.ServiceSubscription actual = bbInputSetupUtils.getAAIServiceSubscription(globalSubId, subServiceType);
- assertNull(actual);
-
- String globalSubId2 = "";
- String subServiceType2 = "";
- org.onap.aai.domain.yang.ServiceSubscription actual2 = bbInputSetupUtils.getAAIServiceSubscription(globalSubId2, subServiceType2);
- assertNull(actual2);
-
- String globalSubId3 = "";
- String subServiceType3 = null;
- org.onap.aai.domain.yang.ServiceSubscription actual3 = bbInputSetupUtils.getAAIServiceSubscription(globalSubId3, subServiceType3);
- assertNull(actual3);
-
- String globalSubId4 = null;
- String subServiceType4 = "";
- org.onap.aai.domain.yang.ServiceSubscription actual4 = bbInputSetupUtils.getAAIServiceSubscription(globalSubId4, subServiceType4);
- assertNull(actual4);
- }
-
- @Test
- public void testGetAAIServiceSubscriptionThrowNotFound() {
- String globalSubscriberId = "globalSubscriberId";
- String subscriptionServiceType = "subscriptionServiceType";
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient)
- .get(org.onap.aai.domain.yang.ServiceSubscription.class, AAIUriFactory.createResourceUri(
- AAIObjectType.SERVICE_SUBSCRIPTION, globalSubscriberId, subscriptionServiceType));
- org.onap.aai.domain.yang.ServiceSubscription actual = bbInputSetupUtils
- .getAAIServiceSubscription(globalSubscriberId, subscriptionServiceType);
- assertNull(actual);
- }
-
- @Test
- public void testGetAAIServiceInstanceById() {
- String serviceInstanceId = "serviceInstanceId";
-
- ServiceInstance expectedServiceInstance = new ServiceInstance();
-
- doReturn(Optional.of(expectedServiceInstance)).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
-
- ServiceInstance actualServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
-
- assertThat(actualServiceInstance, sameBeanAs(expectedServiceInstance));
- }
-
- @Test
- public void testGetAAIServiceInstanceByIdThrowNotFound() {
- String serviceInstanceId = "serviceInstanceId";
-
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
-
- ServiceInstance actualServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
-
- assertNull(actualServiceInstance);
- }
-
- @Test
- public void testGetAAIServiceInstanceByIdAndCustomer() {
- String globalCustomerId = "globalCustomerId";
- String serviceType = "serviceType";
- String serviceInstanceId = "serviceInstanceId";
- ServiceInstance expected = new ServiceInstance();
- expected.setServiceInstanceId(serviceInstanceId);
- doReturn(Optional.of(expected)).when(MOCK_aaiResourcesClient).get(isA(Class.class),
- isA(AAIResourceUri.class));
- AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(
- AAIObjectType.SERVICE_INSTANCE, globalCustomerId, serviceType, serviceInstanceId).depth(Depth.TWO);
- this.bbInputSetupUtils.getAAIServiceInstanceByIdAndCustomer(globalCustomerId, serviceType, serviceInstanceId);
-
- verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.ServiceInstance.class, expectedUri);
-
- }
-
- @Test
- public void testGetAAIServiceInstanceByIdAndCustomerThrowNotFound() {
- String globalCustomerId = "globalCustomerId";
- String serviceType = "serviceType";
- String serviceInstanceId = "serviceInstanceId";
-
- doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class),
- isA(AAIResourceUri.class));
- ServiceInstance actual = this.bbInputSetupUtils
- .getAAIServiceInstanceByIdAndCustomer(globalCustomerId, serviceType, serviceInstanceId);
-
- assertNull(actual);
- }
-
- @Test
- public void testGetAAIServiceInstanceByName() throws Exception {
- String serviceInstanceName = "serviceInstanceName";
-
- ServiceInstance expectedServiceInstance = new ServiceInstance();
- expectedServiceInstance.setServiceInstanceId("serviceInstanceId");
-
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- serviceSubscription.setServiceType("serviceType");
-
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- customer.setServiceSubscription(serviceSubscription);
-
- ServiceInstances serviceInstances = new ServiceInstances();
- serviceInstances.getServiceInstance().add(expectedServiceInstance);
-
- doReturn(Optional.of(serviceInstances)).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
- AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, customer.getGlobalCustomerId(),
- customer.getServiceSubscription().getServiceType())
- .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO);
- bbInputSetupUtils.getAAIServiceInstanceByName(serviceInstanceName, customer);
-
- verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.ServiceInstances.class, expectedUri);
- }
-
- @Test
- public void testGetAAIServiceInstanceByNameException() throws Exception {
- expectedException.expect(Exception.class);
-
- String serviceInstanceName = "serviceInstanceName";
-
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
-
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- serviceSubscription.setServiceType("serviceType");
-
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- customer.setServiceSubscription(serviceSubscription);
-
- ServiceInstances serviceInstances = new ServiceInstances();
- serviceInstances.getServiceInstance().add(serviceInstance);
- serviceInstances.getServiceInstance().add(serviceInstance);
-
- doReturn(Optional.of(serviceInstances)).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
-
- bbInputSetupUtils.getAAIServiceInstanceByName(serviceInstanceName, customer);
- }
-
- @Test
- public void testGetAAIServiceInstanceByNameNull() throws Exception {
- String serviceInstanceName = "serviceInstanceName";
-
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
-
- ServiceSubscription serviceSubscription = new ServiceSubscription();
- serviceSubscription.setServiceType("serviceType");
-
- Customer customer = new Customer();
- customer.setGlobalCustomerId("globalCustomerId");
- customer.setServiceSubscription(serviceSubscription);
-
- ServiceInstances serviceInstances = new ServiceInstances();
- serviceInstances.getServiceInstance().add(serviceInstance);
- serviceInstances.getServiceInstance().add(serviceInstance);
-
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
-
- ServiceInstance actualServiceInstance = bbInputSetupUtils.getAAIServiceInstanceByName(serviceInstanceName, customer);
-
- assertNull(actualServiceInstance);
- }
-
- @Test
- public void testGetOptionalAAIServiceInstanceByNameException() throws Exception {
- expectedException.expect(Exception.class);
-
- String globalCustomerId = "globalCustomerId";
- String serviceType = "serviceType";
- String serviceInstanceId = "serviceInstanceId";
-
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- serviceInstance.setServiceType(serviceType);
- serviceInstance.setServiceInstanceName("serviceInstanceName");
-
- ServiceInstances serviceInstances = new ServiceInstances();
- serviceInstances.getServiceInstance().add(serviceInstance);
- serviceInstances.getServiceInstance().add(serviceInstance);
-
- doReturn(Optional.of(serviceInstances)).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
-
- bbInputSetupUtils.getAAIServiceInstanceByName(globalCustomerId, serviceType, serviceInstanceId);
- }
-
- @Test
- public void testGetOptionalAAIServiceInstanceByNameNull() throws Exception {
- String globalCustomerId = "globalCustomerId";
- String serviceType = "serviceType";
- String serviceInstanceId = "serviceInstanceId";
-
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
- Optional<ServiceInstance> actual = this.bbInputSetupUtils
- .getAAIServiceInstanceByName(globalCustomerId, serviceType, serviceInstanceId);
-
- assertThat(actual, sameBeanAs(Optional.empty()));
- }
-
- @Test
- public void testGetCatalogInstanceGroup() throws JsonParseException, JsonMappingException, IOException {
- String modelUUID = "modelUUID";
-
- org.onap.so.db.catalog.beans.InstanceGroup expectedInstanceGroup = mapper.readValue(
- new File(RESOURCE_PATH + "InstanceGroup.json"), org.onap.so.db.catalog.beans.InstanceGroup.class);
-
- doReturn(expectedInstanceGroup).when(MOCK_catalogDbClient).getInstanceGroupByModelUUID(isA(String.class));
-
- org.onap.so.db.catalog.beans.InstanceGroup actualInstanceGroup = bbInputSetupUtils.getCatalogInstanceGroup(modelUUID);
-
- assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
- }
-
- @Test
- public void testGetCollectionResourceInstanceGroupCustomization() {
- String modelCustomizationUUID = "modelCustomizationUUID";
-
- CollectionResourceInstanceGroupCustomization expectedCollection = new CollectionResourceInstanceGroupCustomization();
-
- doReturn(Arrays.asList(expectedCollection)).when(MOCK_catalogDbClient)
- .getCollectionResourceInstanceGroupCustomizationByModelCustUUID(modelCustomizationUUID);
-
- List<CollectionResourceInstanceGroupCustomization> actualCollection = bbInputSetupUtils
- .getCollectionResourceInstanceGroupCustomization(modelCustomizationUUID);
-
- assertThat(actualCollection, sameBeanAs(Arrays.asList(expectedCollection)));
- }
-
- @Test
- public void testGetAAIGenericVnf() throws JsonParseException, JsonMappingException, IOException {
- String vnfId = "vnfId";
-
- GenericVnf expectedAaiVnf = mapper.readValue(
- new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), GenericVnf.class);
-
- doReturn(Optional.of(expectedAaiVnf)).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
- AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE);
- GenericVnf actualAaiVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId);
-
- assertThat(actualAaiVnf, sameBeanAs(expectedAaiVnf));
-
- verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.GenericVnf.class, expectedUri);
- }
-
- @Test
- public void testGetAAIConfiguration() throws JsonParseException, JsonMappingException, IOException {
- String configurationId = "configurationId";
-
- Configuration expectedAaiConfiguration = mapper.readValue(
- new File(RESOURCE_PATH + "ConfigurationInput.json"), Configuration.class);
-
- doReturn(Optional.of(expectedAaiConfiguration)).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
- AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId).depth(Depth.ONE);
- bbInputSetupUtils.getAAIConfiguration(configurationId);
-
- verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.Configuration.class, expectedUri);
- }
-
- @Test
- public void testGetAAIGenericVnfThrowNotFound() throws JsonParseException, JsonMappingException, IOException {
- String vnfId = "vnfId";
-
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
-
- GenericVnf actualAaiVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId);
-
- assertNull(actualAaiVnf);
- }
-
- @Test
- public void testGetAAIResourceDepthOne() {
- String vnfId = "vnfId";
- AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId);
- AAIResourceUri expectedUri = aaiResourceUri.clone().depth(Depth.ONE);
- AAIResourceUri aaiResourceUriClone = aaiResourceUri.clone();
- bbInputSetupUtils.getAAIResourceDepthOne(aaiResourceUri);
-
- verify(MOCK_aaiResourcesClient, times(1)).get(expectedUri);
- assertEquals("Uri should not have changed", aaiResourceUriClone.build(), aaiResourceUri.build());
- }
-
- @Test
- public void testGetAAIResourceDepthTwo() {
- String vnfId = "vnfId";
- AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId);
- AAIResourceUri expectedUri = aaiResourceUri.clone().depth(Depth.TWO);
- AAIResourceUri aaiResourceUriClone = aaiResourceUri.clone();
- bbInputSetupUtils.getAAIResourceDepthTwo(aaiResourceUri);
-
- verify(MOCK_aaiResourcesClient, times(1)).get(expectedUri);
- assertEquals("Uri should not have changed", aaiResourceUriClone.build(), aaiResourceUri.build());
- }
-
- @Test
- public void getRelatedNetworkByNameFromServiceInstanceTest() throws Exception {
- Optional<L3Networks> expected = Optional.of(new L3Networks());
- L3Network network = new L3Network();
- network.setNetworkId("id123");
- network.setNetworkName("name123");
- expected.get().getL3Network().add(network);
- doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(L3Networks.class), any(AAIResourceUri.class));
- Optional<L3Network> actual = this.bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance("id123", "name123");
- assertEquals(actual.get().getNetworkId(), expected.get().getL3Network().get(0).getNetworkId());
- }
-
- @Test
- public void getRelatedNetworkByNameFromServiceInstanceMultipleNetworksExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
-
- String serviceInstanceId = "serviceInstanceId";
- String networkName = "networkName";
-
- L3Network network = new L3Network();
- network.setNetworkId("id123");
- network.setNetworkName("name123");
-
- L3Networks expected = new L3Networks();
- expected.getL3Network().add(network);
- expected.getL3Network().add(network);
-
- doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(L3Networks.class), any(AAIResourceUri.class));
-
- bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance(serviceInstanceId, networkName);
- }
-
- @Test
- public void getRelatedNetworkByNameFromServiceInstanceNotFoundTest() throws Exception {
- String serviceInstanceId = "serviceInstanceId";
- String networkName = "networkName";
-
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(L3Networks.class), any(AAIResourceUri.class));
-
- Optional<L3Network> actualNetwork = bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance(serviceInstanceId, networkName);
-
- assertEquals(Optional.empty(), actualNetwork);
- }
-
- @Test
- public void getRelatedServiceInstanceFromInstanceGroupTest() throws Exception {
- Optional<ServiceInstances> expected = Optional.of(new ServiceInstances());
- ServiceInstance serviceInstance = new ServiceInstance();
- serviceInstance.setServiceInstanceId("serviceInstanceId");
- serviceInstance.setServiceInstanceName("serviceInstanceName");
- expected.get().getServiceInstance().add(serviceInstance);
-
- doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class), any(AAIResourceUri.class));
- Optional<ServiceInstance> actual = this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001");
- assertEquals(actual.get().getServiceInstanceId(), expected.get().getServiceInstance().get(0).getServiceInstanceId());
- }
-
- @Test
- public void getRelatedServiceInstanceFromInstanceGroupMultipleTest() throws Exception {
- expectedException.expect(MultipleObjectsFoundException.class);
- Optional<ServiceInstances> serviceInstances = Optional.of(new ServiceInstances());
- ServiceInstance si1 = Mockito.mock(ServiceInstance.class);
- ServiceInstance si2 = Mockito.mock(ServiceInstance.class);
- serviceInstances.get().getServiceInstance().add(si1);
- serviceInstances.get().getServiceInstance().add(si2);
-
- doReturn(serviceInstances).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class), any(AAIResourceUri.class));
- this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001");
- }
-
- @Test
- public void getRelatedServiceInstanceFromInstanceGroupNotFoundTest() throws Exception {
- expectedException.expect(NoServiceInstanceFoundException.class);
- Optional<ServiceInstances> serviceInstances = Optional.of(new ServiceInstances());
-
- doReturn(serviceInstances).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class), any(AAIResourceUri.class));
- this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001");
- }
-
- @Test
- public void getRelatedVnfByNameFromServiceInstanceTest() throws Exception {
- Optional<GenericVnfs> expected = Optional.of(new GenericVnfs());
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("id123");
- vnf.setVnfName("name123");
- expected.get().getGenericVnf().add(vnf);
- doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(GenericVnfs.class), any(AAIResourceUri.class));
- Optional<GenericVnf> actual = this.bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance("id123", "name123");
- assertEquals(actual.get().getVnfId(), expected.get().getGenericVnf().get(0).getVnfId());
- }
-
- @Test
- public void getRelatedVnfByNameFromServiceInstanceMultipleVnfsExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
-
- String serviceInstanceId = "serviceInstanceId";
- String vnfName = "vnfName";
-
- GenericVnf vnf = new GenericVnf();
- vnf.setVnfId("id123");
- vnf.setVnfName("name123");
-
- GenericVnfs expectedVnf = new GenericVnfs();
- expectedVnf.getGenericVnf().add(vnf);
- expectedVnf.getGenericVnf().add(vnf);
-
- doReturn(expectedVnf).when(MOCK_aaiResourcesClient).get(eq(GenericVnfs.class), any(AAIResourceUri.class));
-
- bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(serviceInstanceId, vnfName);
- }
-
- @Test
- public void getRelatedVnfByNameFromServiceInstanceNotFoundTest() throws Exception {
- String serviceInstanceId = "serviceInstanceId";
- String vnfName = "vnfName";
-
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(GenericVnfs.class), any(AAIResourceUri.class));
-
- Optional<GenericVnf> actualVnf = this.bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(serviceInstanceId, vnfName);
-
- assertEquals(actualVnf, Optional.empty());
- }
-
- @Test
- public void getRelatedVolumeGroupByNameFromVnfTest() throws Exception {
- Optional<VolumeGroups> expected = Optional.of(new VolumeGroups());
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("id123");
- volumeGroup.setVolumeGroupName("name123");
- expected.get().getVolumeGroup().add(volumeGroup);
- doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
- Optional<VolumeGroup> actual = this.bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "name123");
- assertEquals(actual.get().getVolumeGroupId(), expected.get().getVolumeGroup().get(0).getVolumeGroupId());
- }
-
- @Test
- public void getRelatedVolumeGroupByNameFromVnfMultipleVolumeGroupsExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
-
- String vnfId = "vnfId";
- String volumeGroupName = "volumeGroupName";
-
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("id123");
- volumeGroup.setVolumeGroupName("name123");
-
- VolumeGroups expectedVolumeGroup = new VolumeGroups();
- expectedVolumeGroup.getVolumeGroup().add(volumeGroup);
- expectedVolumeGroup.getVolumeGroup().add(volumeGroup);
-
- doReturn(expectedVolumeGroup).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
-
- bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(vnfId, volumeGroupName);
- }
-
- @Test
- public void getRelatedVolumeGroupByNameFromVnfNotFoundTest() throws Exception {
- String vnfId = "vnfId";
- String volumeGroupName = "volumeGroupName";
-
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
-
- Optional<VolumeGroup> actualVolumeGroup = bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(vnfId, volumeGroupName);
-
- assertEquals(actualVolumeGroup, Optional.empty());
- }
-
- @Test
- public void getRelatedVolumeGroupByNameFromVfModuleTest() throws Exception {
- Optional<VolumeGroups> expected = Optional.of(new VolumeGroups());
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("id123");
- volumeGroup.setVolumeGroupName("name123");
- expected.get().getVolumeGroup().add(volumeGroup);
- doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
- Optional<VolumeGroup> actual = this.bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule("id123", "id123", "name123");
- assertEquals(actual.get().getVolumeGroupId(), expected.get().getVolumeGroup().get(0).getVolumeGroupId());
- }
-
- @Test
- public void getRelatedVolumeGroupByNameFromVfModuleMultipleVolumeGroupsExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
-
- String vnfId = "vnfId";
- String volumeGroupId = "volumeGroupId";
- String volumeGroupName = "volumeGroupName";
-
- VolumeGroup volumeGroup = new VolumeGroup();
- volumeGroup.setVolumeGroupId("id123");
- volumeGroup.setVolumeGroupName("name123");
-
- VolumeGroups expectedVolumeGroup = new VolumeGroups();
- expectedVolumeGroup.getVolumeGroup().add(volumeGroup);
- expectedVolumeGroup.getVolumeGroup().add(volumeGroup);
-
- doReturn(expectedVolumeGroup).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
-
- bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule(vnfId, volumeGroupId, volumeGroupName);
- }
-
- @Test
- public void getRelatedVolumeGroupByNameFromVfModuleNotFoundTest() throws Exception {
- String vnfId = "vnfId";
- String volumeGroupId = "volumeGroupId";
- String volumeGroupName = "volumeGroupName";
-
- doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
-
- Optional<VolumeGroup> actualVolumeGroup = bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule(vnfId, volumeGroupId, volumeGroupName);
-
- assertEquals(actualVolumeGroup, Optional.empty());
- }
-} \ No newline at end of file
+ protected ObjectMapper mapper = new ObjectMapper();
+ private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
+
+ @InjectMocks
+ BBInputSetupUtils bbInputSetupUtils = new BBInputSetupUtils();
+
+ @Mock
+ protected CatalogDbClient MOCK_catalogDbClient;
+
+ @Mock
+ protected RequestsDbClient MOCK_requestsDbClient;
+
+ @Mock
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
+
+ @Mock
+ protected InjectionHelper MOCK_injectionHelper;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Before
+ public void setup() {
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ }
+
+ @Test
+ public void testGetCatalogServiceByModelUUID() throws JsonParseException, JsonMappingException, IOException {
+ Service expected = mapper.readValue(new File(RESOURCE_PATH + "CatalogServiceExpected.json"), Service.class);
+
+ RequestDetails requestDetails = new RequestDetails();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelVersionId("modelUUID");
+ requestDetails.setModelInfo(modelInfo);
+ doReturn(expected).when(MOCK_catalogDbClient).getServiceByID("modelUUID");
+ Service actual = bbInputSetupUtils.getCatalogServiceByModelUUID(modelInfo.getModelVersionId());
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testGetCatalogServiceByModelVersionAndModelInvariantUUID()
+ throws JsonParseException, JsonMappingException, IOException {
+ String modelVersion = "modelVersion";
+ String modelInvariantUUID = "modelInvariantUUID";
+ Service expectedService =
+ mapper.readValue(new File(RESOURCE_PATH + "CatalogServiceExpected.json"), Service.class);
+
+ doReturn(expectedService).when(MOCK_catalogDbClient)
+ .getServiceByModelVersionAndModelInvariantUUID(isA(String.class), isA(String.class));
+
+ Service actualService = bbInputSetupUtils.getCatalogServiceByModelVersionAndModelInvariantUUID(modelVersion,
+ modelInvariantUUID);
+
+ assertThat(actualService, sameBeanAs(expectedService));
+ }
+
+ @Test
+ public void testGetVnfcInstanceGroups() throws JsonParseException, JsonMappingException, IOException {
+ VnfcInstanceGroupCustomization vnfc = mapper.readValue(
+ new File(RESOURCE_PATH + "VnfcInstanceGroupCustomization.json"), VnfcInstanceGroupCustomization.class);
+ String modelCustomizationUUID = "modelCustomizationUUID";
+
+ doReturn(Arrays.asList(vnfc)).when(MOCK_catalogDbClient)
+ .getVnfcInstanceGroupsByVnfResourceCust(isA(String.class));
+
+ List<VnfcInstanceGroupCustomization> actualVnfcList =
+ bbInputSetupUtils.getVnfcInstanceGroups(modelCustomizationUUID);
+
+ assertThat(actualVnfcList, sameBeanAs(Arrays.asList(vnfc)));
+ }
+
+ @Test
+ public void testGetRequestDetails() throws JsonParseException, JsonMappingException, IOException {
+ InfraActiveRequests infraActiveRequest = mapper
+ .readValue(new File(RESOURCE_PATH + "InfraActiveRequestExpected.json"), InfraActiveRequests.class);
+
+ RequestDetails expected =
+ mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsExpected.json"), RequestDetails.class);
+ String requestId = "requestId";
+ doReturn(infraActiveRequest).when(MOCK_requestsDbClient).getInfraActiveRequestbyRequestId(requestId);
+ RequestDetails actual = bbInputSetupUtils.getRequestDetails(requestId);
+
+ assertThat(actual, sameBeanAs(expected));
+ }
+
+ @Test
+ public void getRequestDetailsNullTest() throws IOException {
+ RequestDetails requestDetails = bbInputSetupUtils.getRequestDetails("");
+
+ assertNull(requestDetails);
+ }
+
+ @Test
+ public void testGetCloudRegion() {
+ CloudConfiguration cloudConfig = new CloudConfiguration();
+ cloudConfig.setLcpCloudRegionId("lcpCloudRegionId");
+ Optional<org.onap.aai.domain.yang.CloudRegion> expected =
+ Optional.of(new org.onap.aai.domain.yang.CloudRegion());
+ expected.get().setCloudOwner("cloudOwner");
+ expected.get().setCloudRegionId("lcpCloudRegionId");
+ doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.CloudRegion.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudConfig.getCloudOwner(),
+ cloudConfig.getLcpCloudRegionId()).depth(Depth.TWO));
+
+ AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION,
+ cloudConfig.getCloudOwner(), cloudConfig.getLcpCloudRegionId()).depth(Depth.TWO);
+ bbInputSetupUtils.getCloudRegion(cloudConfig);
+
+ verify(MOCK_aaiResourcesClient, times(1)).get(CloudRegion.class, expectedUri);
+ }
+
+ @Test
+ public void testGetCloudRegionExceptionTest() {
+
+ CloudConfiguration cloudConfig = new CloudConfiguration();
+ cloudConfig.setLcpCloudRegionId("lcpCloudRegionId");
+
+ RequestDetails requestDetails = new RequestDetails();
+ requestDetails.setCloudConfiguration(cloudConfig);
+
+ doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
+
+ CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfig);
+
+ assertNull(cloudRegion);
+ }
+
+ @Test
+ public void testGetCloudRegionEmptyId() {
+ CloudConfiguration cloudConfig = new CloudConfiguration();
+ cloudConfig.setLcpCloudRegionId("");
+
+ RequestDetails requestDetails = new RequestDetails();
+ requestDetails.setCloudConfiguration(cloudConfig);
+
+ CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(cloudConfig);
+
+ assertNull(cloudRegion);
+ }
+
+ @Test
+ public void testGetCloudRegionEmptyConfiguration() {
+ RequestDetails requestDetails = new RequestDetails();
+
+ CloudRegion cloudRegion = bbInputSetupUtils.getCloudRegion(requestDetails.getCloudConfiguration());
+
+ assertNull(cloudRegion);
+ }
+
+ @Test
+ public void testGetAAIInstanceGroup() {
+ Optional<org.onap.aai.domain.yang.InstanceGroup> expected =
+ Optional.of(new org.onap.aai.domain.yang.InstanceGroup());
+ String instanceGroupId = "instanceGroupId";
+ expected.get().setId(instanceGroupId);
+ doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.InstanceGroup.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId));
+ AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId);
+
+ bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId);
+ verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.InstanceGroup.class, expectedUri);
+ }
+
+ @Test
+ public void testGetAAIInstanceGroupThrowNotFound() {
+ String instanceGroupId = "instanceGroupId";
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.InstanceGroup.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId));
+
+ org.onap.aai.domain.yang.InstanceGroup actual = bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId);
+
+ assertNull(actual);
+ }
+
+ @Test
+ public void testGetAAICustomer() {
+ Optional<org.onap.aai.domain.yang.Customer> expected = Optional.of(new org.onap.aai.domain.yang.Customer());
+ String globalSubscriberId = "globalSubscriberId";
+ expected.get().setGlobalCustomerId(globalSubscriberId);
+ doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.Customer.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalSubscriberId));
+ AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalSubscriberId);
+
+ bbInputSetupUtils.getAAICustomer(globalSubscriberId);
+ verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.Customer.class, expectedUri);
+ }
+
+ @Test
+ public void testGetAAICustomerThrowNotFound() {
+ String globalSubscriberId = "globalSubscriberId";
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.Customer.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalSubscriberId));
+
+ org.onap.aai.domain.yang.Customer actual = bbInputSetupUtils.getAAICustomer(globalSubscriberId);
+
+ assertNull(actual);
+ }
+
+ @Test
+ public void testGetAAIServiceSubscription() {
+ Optional<org.onap.aai.domain.yang.ServiceSubscription> expected =
+ Optional.of(new org.onap.aai.domain.yang.ServiceSubscription());
+ String globalSubscriberId = "globalSubscriberId";
+ String subscriptionServiceType = "subscriptionServiceType";
+ expected.get().setServiceType(subscriptionServiceType);
+ doReturn(expected).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.ServiceSubscription.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION, globalSubscriberId,
+ subscriptionServiceType));
+ AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION,
+ globalSubscriberId, subscriptionServiceType);
+
+ bbInputSetupUtils.getAAIServiceSubscription(globalSubscriberId, subscriptionServiceType);
+ verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.ServiceSubscription.class, expectedUri);
+ }
+
+ @Test
+ public void testGetAAIServiceSubscriptionErrors() {
+ String globalSubId = null;
+ String subServiceType = null;
+ org.onap.aai.domain.yang.ServiceSubscription actual =
+ bbInputSetupUtils.getAAIServiceSubscription(globalSubId, subServiceType);
+ assertNull(actual);
+
+ String globalSubId2 = "";
+ String subServiceType2 = "";
+ org.onap.aai.domain.yang.ServiceSubscription actual2 =
+ bbInputSetupUtils.getAAIServiceSubscription(globalSubId2, subServiceType2);
+ assertNull(actual2);
+
+ String globalSubId3 = "";
+ String subServiceType3 = null;
+ org.onap.aai.domain.yang.ServiceSubscription actual3 =
+ bbInputSetupUtils.getAAIServiceSubscription(globalSubId3, subServiceType3);
+ assertNull(actual3);
+
+ String globalSubId4 = null;
+ String subServiceType4 = "";
+ org.onap.aai.domain.yang.ServiceSubscription actual4 =
+ bbInputSetupUtils.getAAIServiceSubscription(globalSubId4, subServiceType4);
+ assertNull(actual4);
+ }
+
+ @Test
+ public void testGetAAIServiceSubscriptionThrowNotFound() {
+ String globalSubscriberId = "globalSubscriberId";
+ String subscriptionServiceType = "subscriptionServiceType";
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(org.onap.aai.domain.yang.ServiceSubscription.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION, globalSubscriberId,
+ subscriptionServiceType));
+ org.onap.aai.domain.yang.ServiceSubscription actual =
+ bbInputSetupUtils.getAAIServiceSubscription(globalSubscriberId, subscriptionServiceType);
+ assertNull(actual);
+ }
+
+ @Test
+ public void testGetAAIServiceInstanceById() {
+ String serviceInstanceId = "serviceInstanceId";
+
+ ServiceInstance expectedServiceInstance = new ServiceInstance();
+
+ doReturn(Optional.of(expectedServiceInstance)).when(MOCK_aaiResourcesClient).get(isA(Class.class),
+ isA(AAIResourceUri.class));
+
+ ServiceInstance actualServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
+
+ assertThat(actualServiceInstance, sameBeanAs(expectedServiceInstance));
+ }
+
+ @Test
+ public void testGetAAIServiceInstanceByIdThrowNotFound() {
+ String serviceInstanceId = "serviceInstanceId";
+
+ doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
+
+ ServiceInstance actualServiceInstance = bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId);
+
+ assertNull(actualServiceInstance);
+ }
+
+ @Test
+ public void testGetAAIServiceInstanceByIdAndCustomer() {
+ String globalCustomerId = "globalCustomerId";
+ String serviceType = "serviceType";
+ String serviceInstanceId = "serviceInstanceId";
+ ServiceInstance expected = new ServiceInstance();
+ expected.setServiceInstanceId(serviceInstanceId);
+ doReturn(Optional.of(expected)).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
+ AAIResourceUri expectedUri = AAIUriFactory
+ .createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustomerId, serviceType, serviceInstanceId)
+ .depth(Depth.TWO);
+ this.bbInputSetupUtils.getAAIServiceInstanceByIdAndCustomer(globalCustomerId, serviceType, serviceInstanceId);
+
+ verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.ServiceInstance.class, expectedUri);
+
+ }
+
+ @Test
+ public void testGetAAIServiceInstanceByIdAndCustomerThrowNotFound() {
+ String globalCustomerId = "globalCustomerId";
+ String serviceType = "serviceType";
+ String serviceInstanceId = "serviceInstanceId";
+
+ doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
+ doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
+ ServiceInstance actual = this.bbInputSetupUtils.getAAIServiceInstanceByIdAndCustomer(globalCustomerId,
+ serviceType, serviceInstanceId);
+
+ assertNull(actual);
+ }
+
+ @Test
+ public void testGetAAIServiceInstanceByName() throws Exception {
+ String serviceInstanceName = "serviceInstanceName";
+
+ ServiceInstance expectedServiceInstance = new ServiceInstance();
+ expectedServiceInstance.setServiceInstanceId("serviceInstanceId");
+
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setServiceType("serviceType");
+
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+ customer.setServiceSubscription(serviceSubscription);
+
+ ServiceInstances serviceInstances = new ServiceInstances();
+ serviceInstances.getServiceInstance().add(expectedServiceInstance);
+
+ doReturn(Optional.of(serviceInstances)).when(MOCK_aaiResourcesClient).get(isA(Class.class),
+ isA(AAIResourceUri.class));
+ AAIResourceUri expectedUri = AAIUriFactory
+ .createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, customer.getGlobalCustomerId(),
+ customer.getServiceSubscription().getServiceType())
+ .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO);
+ bbInputSetupUtils.getAAIServiceInstanceByName(serviceInstanceName, customer);
+
+ verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.ServiceInstances.class, expectedUri);
+ }
+
+ @Test
+ public void testGetAAIServiceInstanceByNameException() throws Exception {
+ expectedException.expect(Exception.class);
+
+ String serviceInstanceName = "serviceInstanceName";
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setServiceType("serviceType");
+
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+ customer.setServiceSubscription(serviceSubscription);
+
+ ServiceInstances serviceInstances = new ServiceInstances();
+ serviceInstances.getServiceInstance().add(serviceInstance);
+ serviceInstances.getServiceInstance().add(serviceInstance);
+
+ doReturn(Optional.of(serviceInstances)).when(MOCK_aaiResourcesClient).get(isA(Class.class),
+ isA(AAIResourceUri.class));
+
+ bbInputSetupUtils.getAAIServiceInstanceByName(serviceInstanceName, customer);
+ }
+
+ @Test
+ public void testGetAAIServiceInstanceByNameNull() throws Exception {
+ String serviceInstanceName = "serviceInstanceName";
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+
+ ServiceSubscription serviceSubscription = new ServiceSubscription();
+ serviceSubscription.setServiceType("serviceType");
+
+ Customer customer = new Customer();
+ customer.setGlobalCustomerId("globalCustomerId");
+ customer.setServiceSubscription(serviceSubscription);
+
+ ServiceInstances serviceInstances = new ServiceInstances();
+ serviceInstances.getServiceInstance().add(serviceInstance);
+ serviceInstances.getServiceInstance().add(serviceInstance);
+
+ doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
+
+ ServiceInstance actualServiceInstance =
+ bbInputSetupUtils.getAAIServiceInstanceByName(serviceInstanceName, customer);
+
+ assertNull(actualServiceInstance);
+ }
+
+ @Test
+ public void testGetOptionalAAIServiceInstanceByNameException() throws Exception {
+ expectedException.expect(Exception.class);
+
+ String globalCustomerId = "globalCustomerId";
+ String serviceType = "serviceType";
+ String serviceInstanceId = "serviceInstanceId";
+
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ serviceInstance.setServiceType(serviceType);
+ serviceInstance.setServiceInstanceName("serviceInstanceName");
+
+ ServiceInstances serviceInstances = new ServiceInstances();
+ serviceInstances.getServiceInstance().add(serviceInstance);
+ serviceInstances.getServiceInstance().add(serviceInstance);
+
+ doReturn(Optional.of(serviceInstances)).when(MOCK_aaiResourcesClient).get(isA(Class.class),
+ isA(AAIResourceUri.class));
+
+ bbInputSetupUtils.getAAIServiceInstanceByName(globalCustomerId, serviceType, serviceInstanceId);
+ }
+
+ @Test
+ public void testGetOptionalAAIServiceInstanceByNameNull() throws Exception {
+ String globalCustomerId = "globalCustomerId";
+ String serviceType = "serviceType";
+ String serviceInstanceId = "serviceInstanceId";
+
+ doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
+ Optional<ServiceInstance> actual =
+ this.bbInputSetupUtils.getAAIServiceInstanceByName(globalCustomerId, serviceType, serviceInstanceId);
+
+ assertThat(actual, sameBeanAs(Optional.empty()));
+ }
+
+ @Test
+ public void testGetCatalogInstanceGroup() throws JsonParseException, JsonMappingException, IOException {
+ String modelUUID = "modelUUID";
+
+ org.onap.so.db.catalog.beans.InstanceGroup expectedInstanceGroup = mapper.readValue(
+ new File(RESOURCE_PATH + "InstanceGroup.json"), org.onap.so.db.catalog.beans.InstanceGroup.class);
+
+ doReturn(expectedInstanceGroup).when(MOCK_catalogDbClient).getInstanceGroupByModelUUID(isA(String.class));
+
+ org.onap.so.db.catalog.beans.InstanceGroup actualInstanceGroup =
+ bbInputSetupUtils.getCatalogInstanceGroup(modelUUID);
+
+ assertThat(actualInstanceGroup, sameBeanAs(expectedInstanceGroup));
+ }
+
+ @Test
+ public void testGetCollectionResourceInstanceGroupCustomization() {
+ String modelCustomizationUUID = "modelCustomizationUUID";
+
+ CollectionResourceInstanceGroupCustomization expectedCollection =
+ new CollectionResourceInstanceGroupCustomization();
+
+ doReturn(Arrays.asList(expectedCollection)).when(MOCK_catalogDbClient)
+ .getCollectionResourceInstanceGroupCustomizationByModelCustUUID(modelCustomizationUUID);
+
+ List<CollectionResourceInstanceGroupCustomization> actualCollection =
+ bbInputSetupUtils.getCollectionResourceInstanceGroupCustomization(modelCustomizationUUID);
+
+ assertThat(actualCollection, sameBeanAs(Arrays.asList(expectedCollection)));
+ }
+
+ @Test
+ public void testGetAAIGenericVnf() throws JsonParseException, JsonMappingException, IOException {
+ String vnfId = "vnfId";
+
+ GenericVnf expectedAaiVnf =
+ mapper.readValue(new File(RESOURCE_PATH + "aaiGenericVnfInput.json"), GenericVnf.class);
+
+ doReturn(Optional.of(expectedAaiVnf)).when(MOCK_aaiResourcesClient).get(isA(Class.class),
+ isA(AAIResourceUri.class));
+ AAIResourceUri expectedUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE);
+ GenericVnf actualAaiVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId);
+
+ assertThat(actualAaiVnf, sameBeanAs(expectedAaiVnf));
+
+ verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.GenericVnf.class, expectedUri);
+ }
+
+ @Test
+ public void testGetAAIConfiguration() throws JsonParseException, JsonMappingException, IOException {
+ String configurationId = "configurationId";
+
+ Configuration expectedAaiConfiguration =
+ mapper.readValue(new File(RESOURCE_PATH + "ConfigurationInput.json"), Configuration.class);
+
+ doReturn(Optional.of(expectedAaiConfiguration)).when(MOCK_aaiResourcesClient).get(isA(Class.class),
+ isA(AAIResourceUri.class));
+ AAIResourceUri expectedUri =
+ AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId).depth(Depth.ONE);
+ bbInputSetupUtils.getAAIConfiguration(configurationId);
+
+ verify(MOCK_aaiResourcesClient, times(1)).get(org.onap.aai.domain.yang.Configuration.class, expectedUri);
+ }
+
+ @Test
+ public void testGetAAIGenericVnfThrowNotFound() throws JsonParseException, JsonMappingException, IOException {
+ String vnfId = "vnfId";
+
+ doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class));
+
+ GenericVnf actualAaiVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId);
+
+ assertNull(actualAaiVnf);
+ }
+
+ @Test
+ public void testGetAAIResourceDepthOne() {
+ String vnfId = "vnfId";
+ AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId);
+ AAIResourceUri expectedUri = aaiResourceUri.clone().depth(Depth.ONE);
+ AAIResourceUri aaiResourceUriClone = aaiResourceUri.clone();
+ bbInputSetupUtils.getAAIResourceDepthOne(aaiResourceUri);
+
+ verify(MOCK_aaiResourcesClient, times(1)).get(expectedUri);
+ assertEquals("Uri should not have changed", aaiResourceUriClone.build(), aaiResourceUri.build());
+ }
+
+ @Test
+ public void testGetAAIResourceDepthTwo() {
+ String vnfId = "vnfId";
+ AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId);
+ AAIResourceUri expectedUri = aaiResourceUri.clone().depth(Depth.TWO);
+ AAIResourceUri aaiResourceUriClone = aaiResourceUri.clone();
+ bbInputSetupUtils.getAAIResourceDepthTwo(aaiResourceUri);
+
+ verify(MOCK_aaiResourcesClient, times(1)).get(expectedUri);
+ assertEquals("Uri should not have changed", aaiResourceUriClone.build(), aaiResourceUri.build());
+ }
+
+ @Test
+ public void getRelatedNetworkByNameFromServiceInstanceTest() throws Exception {
+ Optional<L3Networks> expected = Optional.of(new L3Networks());
+ L3Network network = new L3Network();
+ network.setNetworkId("id123");
+ network.setNetworkName("name123");
+ expected.get().getL3Network().add(network);
+ doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(L3Networks.class), any(AAIResourceUri.class));
+ Optional<L3Network> actual =
+ this.bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance("id123", "name123");
+ assertEquals(actual.get().getNetworkId(), expected.get().getL3Network().get(0).getNetworkId());
+ }
+
+ @Test
+ public void getRelatedNetworkByNameFromServiceInstanceMultipleNetworksExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+
+ String serviceInstanceId = "serviceInstanceId";
+ String networkName = "networkName";
+
+ L3Network network = new L3Network();
+ network.setNetworkId("id123");
+ network.setNetworkName("name123");
+
+ L3Networks expected = new L3Networks();
+ expected.getL3Network().add(network);
+ expected.getL3Network().add(network);
+
+ doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(L3Networks.class), any(AAIResourceUri.class));
+
+ bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance(serviceInstanceId, networkName);
+ }
+
+ @Test
+ public void getRelatedNetworkByNameFromServiceInstanceNotFoundTest() throws Exception {
+ String serviceInstanceId = "serviceInstanceId";
+ String networkName = "networkName";
+
+ doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(L3Networks.class), any(AAIResourceUri.class));
+
+ Optional<L3Network> actualNetwork =
+ bbInputSetupUtils.getRelatedNetworkByNameFromServiceInstance(serviceInstanceId, networkName);
+
+ assertEquals(Optional.empty(), actualNetwork);
+ }
+
+ @Test
+ public void getRelatedServiceInstanceFromInstanceGroupTest() throws Exception {
+ Optional<ServiceInstances> expected = Optional.of(new ServiceInstances());
+ ServiceInstance serviceInstance = new ServiceInstance();
+ serviceInstance.setServiceInstanceId("serviceInstanceId");
+ serviceInstance.setServiceInstanceName("serviceInstanceName");
+ expected.get().getServiceInstance().add(serviceInstance);
+
+ doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class), any(AAIResourceUri.class));
+ Optional<ServiceInstance> actual = this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001");
+ assertEquals(actual.get().getServiceInstanceId(),
+ expected.get().getServiceInstance().get(0).getServiceInstanceId());
+ }
+
+ @Test
+ public void getRelatedServiceInstanceFromInstanceGroupMultipleTest() throws Exception {
+ expectedException.expect(MultipleObjectsFoundException.class);
+ Optional<ServiceInstances> serviceInstances = Optional.of(new ServiceInstances());
+ ServiceInstance si1 = Mockito.mock(ServiceInstance.class);
+ ServiceInstance si2 = Mockito.mock(ServiceInstance.class);
+ serviceInstances.get().getServiceInstance().add(si1);
+ serviceInstances.get().getServiceInstance().add(si2);
+
+ doReturn(serviceInstances).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class),
+ any(AAIResourceUri.class));
+ this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001");
+ }
+
+ @Test
+ public void getRelatedServiceInstanceFromInstanceGroupNotFoundTest() throws Exception {
+ expectedException.expect(NoServiceInstanceFoundException.class);
+ Optional<ServiceInstances> serviceInstances = Optional.of(new ServiceInstances());
+
+ doReturn(serviceInstances).when(MOCK_aaiResourcesClient).get(eq(ServiceInstances.class),
+ any(AAIResourceUri.class));
+ this.bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup("ig-001");
+ }
+
+ @Test
+ public void getRelatedVnfByNameFromServiceInstanceTest() throws Exception {
+ Optional<GenericVnfs> expected = Optional.of(new GenericVnfs());
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("id123");
+ vnf.setVnfName("name123");
+ expected.get().getGenericVnf().add(vnf);
+ doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(GenericVnfs.class), any(AAIResourceUri.class));
+ Optional<GenericVnf> actual = this.bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance("id123", "name123");
+ assertEquals(actual.get().getVnfId(), expected.get().getGenericVnf().get(0).getVnfId());
+ }
+
+ @Test
+ public void getRelatedVnfByNameFromServiceInstanceMultipleVnfsExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+
+ String serviceInstanceId = "serviceInstanceId";
+ String vnfName = "vnfName";
+
+ GenericVnf vnf = new GenericVnf();
+ vnf.setVnfId("id123");
+ vnf.setVnfName("name123");
+
+ GenericVnfs expectedVnf = new GenericVnfs();
+ expectedVnf.getGenericVnf().add(vnf);
+ expectedVnf.getGenericVnf().add(vnf);
+
+ doReturn(expectedVnf).when(MOCK_aaiResourcesClient).get(eq(GenericVnfs.class), any(AAIResourceUri.class));
+
+ bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(serviceInstanceId, vnfName);
+ }
+
+ @Test
+ public void getRelatedVnfByNameFromServiceInstanceNotFoundTest() throws Exception {
+ String serviceInstanceId = "serviceInstanceId";
+ String vnfName = "vnfName";
+
+ doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(GenericVnfs.class), any(AAIResourceUri.class));
+
+ Optional<GenericVnf> actualVnf =
+ this.bbInputSetupUtils.getRelatedVnfByNameFromServiceInstance(serviceInstanceId, vnfName);
+
+ assertEquals(actualVnf, Optional.empty());
+ }
+
+ @Test
+ public void getRelatedVolumeGroupByNameFromVnfTest() throws Exception {
+ Optional<VolumeGroups> expected = Optional.of(new VolumeGroups());
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("id123");
+ volumeGroup.setVolumeGroupName("name123");
+ expected.get().getVolumeGroup().add(volumeGroup);
+ doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
+ Optional<VolumeGroup> actual = this.bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf("id123", "name123");
+ assertEquals(actual.get().getVolumeGroupId(), expected.get().getVolumeGroup().get(0).getVolumeGroupId());
+ }
+
+ @Test
+ public void getRelatedVolumeGroupByNameFromVnfMultipleVolumeGroupsExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+
+ String vnfId = "vnfId";
+ String volumeGroupName = "volumeGroupName";
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("id123");
+ volumeGroup.setVolumeGroupName("name123");
+
+ VolumeGroups expectedVolumeGroup = new VolumeGroups();
+ expectedVolumeGroup.getVolumeGroup().add(volumeGroup);
+ expectedVolumeGroup.getVolumeGroup().add(volumeGroup);
+
+ doReturn(expectedVolumeGroup).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class),
+ any(AAIResourceUri.class));
+
+ bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(vnfId, volumeGroupName);
+ }
+
+ @Test
+ public void getRelatedVolumeGroupByNameFromVnfNotFoundTest() throws Exception {
+ String vnfId = "vnfId";
+ String volumeGroupName = "volumeGroupName";
+
+ doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
+
+ Optional<VolumeGroup> actualVolumeGroup =
+ bbInputSetupUtils.getRelatedVolumeGroupByNameFromVnf(vnfId, volumeGroupName);
+
+ assertEquals(actualVolumeGroup, Optional.empty());
+ }
+
+ @Test
+ public void getRelatedVolumeGroupByNameFromVfModuleTest() throws Exception {
+ Optional<VolumeGroups> expected = Optional.of(new VolumeGroups());
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("id123");
+ volumeGroup.setVolumeGroupName("name123");
+ expected.get().getVolumeGroup().add(volumeGroup);
+ doReturn(expected).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
+ Optional<VolumeGroup> actual =
+ this.bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule("id123", "id123", "name123");
+ assertEquals(actual.get().getVolumeGroupId(), expected.get().getVolumeGroup().get(0).getVolumeGroupId());
+ }
+
+ @Test
+ public void getRelatedVolumeGroupByNameFromVfModuleMultipleVolumeGroupsExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+
+ String vnfId = "vnfId";
+ String volumeGroupId = "volumeGroupId";
+ String volumeGroupName = "volumeGroupName";
+
+ VolumeGroup volumeGroup = new VolumeGroup();
+ volumeGroup.setVolumeGroupId("id123");
+ volumeGroup.setVolumeGroupName("name123");
+
+ VolumeGroups expectedVolumeGroup = new VolumeGroups();
+ expectedVolumeGroup.getVolumeGroup().add(volumeGroup);
+ expectedVolumeGroup.getVolumeGroup().add(volumeGroup);
+
+ doReturn(expectedVolumeGroup).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class),
+ any(AAIResourceUri.class));
+
+ bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule(vnfId, volumeGroupId, volumeGroupName);
+ }
+
+ @Test
+ public void getRelatedVolumeGroupByNameFromVfModuleNotFoundTest() throws Exception {
+ String vnfId = "vnfId";
+ String volumeGroupId = "volumeGroupId";
+ String volumeGroupName = "volumeGroupName";
+
+ doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(eq(VolumeGroups.class), any(AAIResourceUri.class));
+
+ Optional<VolumeGroup> actualVolumeGroup =
+ bbInputSetupUtils.getRelatedVolumeGroupByNameFromVfModule(vnfId, volumeGroupId, volumeGroupName);
+
+ assertEquals(actualVolumeGroup, Optional.empty());
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java
index af7dc582e0..1f4c8d3f1d 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/CloudInfoFromAAITest.java
@@ -26,13 +26,11 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
-
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -48,7 +46,6 @@ import org.onap.so.client.aai.AAICommonObjectMapperProvider;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.Relationships;
-
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
@@ -57,106 +54,106 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@RunWith(MockitoJUnitRunner.class)
public class CloudInfoFromAAITest {
- private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
-
- @Spy
- private CloudInfoFromAAI SPY_CloudInfoFromAAI = new CloudInfoFromAAI();
-
- protected ObjectMapper mapper = new ObjectMapper();
-
- @Mock
- private BBInputSetupUtils SPY_bbInputSetupUtils;
-
- @Before
- public void setup(){
- SPY_CloudInfoFromAAI.setBbInputSetupUtils(SPY_bbInputSetupUtils);
- }
-
- @Test
- public void testGetCloudInfoFromAAI() throws JsonParseException, JsonMappingException, IOException {
- //Test vnfs
- ServiceInstance serviceInstance = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
- ServiceInstance.class);
- CloudRegion expected = new CloudRegion();
- GenericVnf vnf = new GenericVnf();
- String vnfId = "vnfId";
- vnf.setVnfId(vnfId);
- serviceInstance.getVnfs().add(vnf);
- org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
- aaiVnf.setVnfId(vnfId);
- Relationships relationships = Mockito.mock(Relationships.class);
- Optional<Relationships> relationshipsOp= Optional.of(relationships);
- doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
- doReturn(relationshipsOp).when(SPY_CloudInfoFromAAI).getRelationshipsFromWrapper(isA(AAIResultWrapper.class));
- doReturn(Optional.of(expected)).when(SPY_CloudInfoFromAAI).getRelatedCloudRegionAndTenant(relationships);
- Optional<CloudRegion> actual = SPY_CloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
- assertThat(actual.get(), sameBeanAs(expected));
-
- //Test networks
- serviceInstance = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
- ServiceInstance.class);
- L3Network l3Network = new L3Network();
- String networkId = "networkId";
- l3Network.setNetworkId(networkId);
- serviceInstance.getNetworks().add(l3Network);
- org.onap.aai.domain.yang.L3Network aaiL3Network = new org.onap.aai.domain.yang.L3Network();
- aaiL3Network.setNetworkId(networkId);
- doReturn(aaiL3Network).when(SPY_bbInputSetupUtils).getAAIL3Network(l3Network.getNetworkId());
- actual = SPY_CloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
- assertThat(actual.get(), sameBeanAs(expected));
-
- //Test no relationships
-
- doReturn(Optional.empty()).when(SPY_CloudInfoFromAAI).getRelationshipsFromWrapper(isA(AAIResultWrapper.class));
- actual = SPY_CloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
- assertEquals(actual, Optional.empty());
-
- //Test null
- serviceInstance = mapper.readValue(
- new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
- ServiceInstance.class);
- actual = SPY_CloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
- assertEquals(actual, Optional.empty());
- }
-
- @Test
- public void testGetRelatedCloudRegionAndTenant() throws JsonProcessingException {
- String cloudOwner = "cloudOwner";
- String cloudRegionId = "cloudRegionId";
- String cloudRegionVersion = "cloudRegionVersion";
- String cloudRegionComplexName = "cloudRegionComplexName";
- String tenantId = "tenantId";
- CloudRegion expected = new CloudRegion();
- expected.setCloudOwner(cloudOwner);
- expected.setCloudRegionVersion(cloudRegionVersion);
- expected.setComplex(cloudRegionComplexName);
- expected.setLcpCloudRegionId(cloudRegionId);
- expected.setTenantId(tenantId);
-
- Relationships relationships = Mockito.mock(Relationships.class);
- List<AAIResultWrapper> cloudRegions = new ArrayList<>();
- org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
- cloudRegion.setCloudOwner(cloudOwner);
- cloudRegion.setCloudRegionId(cloudRegionId);
- cloudRegion.setCloudRegionVersion(cloudRegionVersion);
- cloudRegion.setComplexName(cloudRegionComplexName);
- AAIResultWrapper cloudRegionWrapper = new AAIResultWrapper(
- new AAICommonObjectMapperProvider().getMapper().writeValueAsString(cloudRegion));
- cloudRegions.add(cloudRegionWrapper);
-
- doReturn(cloudRegions).when(relationships).getByType(AAIObjectType.CLOUD_REGION);
- List<AAIResultWrapper> tenants = new ArrayList<>();
- org.onap.aai.domain.yang.Tenant tenant = new org.onap.aai.domain.yang.Tenant();
- tenant.setTenantId(tenantId);
- AAIResultWrapper tenantWrapper = new AAIResultWrapper(
- new AAICommonObjectMapperProvider().getMapper().writeValueAsString(tenant));
- tenants.add(tenantWrapper);
- doReturn(tenants).when(relationships).getByType(AAIObjectType.TENANT);
-
- Optional<CloudRegion> actual = SPY_CloudInfoFromAAI.getRelatedCloudRegionAndTenant(relationships);
-
- assertThat(actual.get(), sameBeanAs(expected));
- }
+ private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/";
+
+ @Spy
+ private CloudInfoFromAAI SPY_CloudInfoFromAAI = new CloudInfoFromAAI();
+
+ protected ObjectMapper mapper = new ObjectMapper();
+
+ @Mock
+ private BBInputSetupUtils SPY_bbInputSetupUtils;
+
+ @Before
+ public void setup() {
+ SPY_CloudInfoFromAAI.setBbInputSetupUtils(SPY_bbInputSetupUtils);
+ }
+
+ @Test
+ public void testGetCloudInfoFromAAI() throws JsonParseException, JsonMappingException, IOException {
+ // Test vnfs
+ ServiceInstance serviceInstance =
+ mapper.readValue(new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
+ ServiceInstance.class);
+ CloudRegion expected = new CloudRegion();
+ GenericVnf vnf = new GenericVnf();
+ String vnfId = "vnfId";
+ vnf.setVnfId(vnfId);
+ serviceInstance.getVnfs().add(vnf);
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = new org.onap.aai.domain.yang.GenericVnf();
+ aaiVnf.setVnfId(vnfId);
+ Relationships relationships = Mockito.mock(Relationships.class);
+ Optional<Relationships> relationshipsOp = Optional.of(relationships);
+ doReturn(aaiVnf).when(SPY_bbInputSetupUtils).getAAIGenericVnf(vnf.getVnfId());
+ doReturn(relationshipsOp).when(SPY_CloudInfoFromAAI).getRelationshipsFromWrapper(isA(AAIResultWrapper.class));
+ doReturn(Optional.of(expected)).when(SPY_CloudInfoFromAAI).getRelatedCloudRegionAndTenant(relationships);
+ Optional<CloudRegion> actual = SPY_CloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
+ assertThat(actual.get(), sameBeanAs(expected));
+
+ // Test networks
+ serviceInstance =
+ mapper.readValue(new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
+ ServiceInstance.class);
+ L3Network l3Network = new L3Network();
+ String networkId = "networkId";
+ l3Network.setNetworkId(networkId);
+ serviceInstance.getNetworks().add(l3Network);
+ org.onap.aai.domain.yang.L3Network aaiL3Network = new org.onap.aai.domain.yang.L3Network();
+ aaiL3Network.setNetworkId(networkId);
+ doReturn(aaiL3Network).when(SPY_bbInputSetupUtils).getAAIL3Network(l3Network.getNetworkId());
+ actual = SPY_CloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
+ assertThat(actual.get(), sameBeanAs(expected));
+
+ // Test no relationships
+
+ doReturn(Optional.empty()).when(SPY_CloudInfoFromAAI).getRelationshipsFromWrapper(isA(AAIResultWrapper.class));
+ actual = SPY_CloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
+ assertEquals(actual, Optional.empty());
+
+ // Test null
+ serviceInstance =
+ mapper.readValue(new File(RESOURCE_PATH + "ServiceInstance_getServiceInstanceNOAAIExpected.json"),
+ ServiceInstance.class);
+ actual = SPY_CloudInfoFromAAI.getCloudInfoFromAAI(serviceInstance);
+ assertEquals(actual, Optional.empty());
+ }
+
+ @Test
+ public void testGetRelatedCloudRegionAndTenant() throws JsonProcessingException {
+ String cloudOwner = "cloudOwner";
+ String cloudRegionId = "cloudRegionId";
+ String cloudRegionVersion = "cloudRegionVersion";
+ String cloudRegionComplexName = "cloudRegionComplexName";
+ String tenantId = "tenantId";
+ CloudRegion expected = new CloudRegion();
+ expected.setCloudOwner(cloudOwner);
+ expected.setCloudRegionVersion(cloudRegionVersion);
+ expected.setComplex(cloudRegionComplexName);
+ expected.setLcpCloudRegionId(cloudRegionId);
+ expected.setTenantId(tenantId);
+
+ Relationships relationships = Mockito.mock(Relationships.class);
+ List<AAIResultWrapper> cloudRegions = new ArrayList<>();
+ org.onap.aai.domain.yang.CloudRegion cloudRegion = new org.onap.aai.domain.yang.CloudRegion();
+ cloudRegion.setCloudOwner(cloudOwner);
+ cloudRegion.setCloudRegionId(cloudRegionId);
+ cloudRegion.setCloudRegionVersion(cloudRegionVersion);
+ cloudRegion.setComplexName(cloudRegionComplexName);
+ AAIResultWrapper cloudRegionWrapper =
+ new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(cloudRegion));
+ cloudRegions.add(cloudRegionWrapper);
+
+ doReturn(cloudRegions).when(relationships).getByType(AAIObjectType.CLOUD_REGION);
+ List<AAIResultWrapper> tenants = new ArrayList<>();
+ org.onap.aai.domain.yang.Tenant tenant = new org.onap.aai.domain.yang.Tenant();
+ tenant.setTenantId(tenantId);
+ AAIResultWrapper tenantWrapper =
+ new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(tenant));
+ tenants.add(tenantWrapper);
+ doReturn(tenants).when(relationships).getByType(AAIObjectType.TENANT);
+
+ Optional<CloudRegion> actual = SPY_CloudInfoFromAAI.getRelatedCloudRegionAndTenant(relationships);
+
+ assertThat(actual.get(), sameBeanAs(expected));
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java
index 6344a3f1a6..e8d597a823 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.junit.Before;
@@ -43,199 +42,215 @@ import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus;
import org.springframework.beans.factory.annotation.Autowired;
public class ExecuteBuildlingBlockRainyDayTest extends BaseTest {
- @Autowired
- private ExecuteBuildingBlockRainyDay executeBuildingBlockRainyDay;
-
- private ServiceInstance serviceInstance;
- private Customer customer; //will build service sub
- private GenericVnf vnf;
- private BuildingBlock buildingBlock;
- private ExecuteBuildingBlock executeBuildingBlock;
- private static final String ASTERISK = "*";
-
- @Before
- public void before() {
- serviceInstance = setServiceInstance();
- customer = setCustomer();
- vnf = setGenericVnf();
-
- buildingBlock = new BuildingBlock();
- buildingBlock.setBpmnFlowName("AssignServiceInstanceBB");
-
- executeBuildingBlock = new ExecuteBuildingBlock();
- executeBuildingBlock.setBuildingBlock(buildingBlock);
-
- delegateExecution.setVariable("gBBInput", gBBInput);
- delegateExecution.setVariable("WorkflowException", new WorkflowException("", 7000, ""));
- delegateExecution.setVariable("buildingBlock", executeBuildingBlock);
- delegateExecution.setVariable("lookupKeyMap", lookupKeyMap);
- }
-
- @Test
- public void setRetryTimerTest() throws Exception{
- delegateExecution.setVariable("retryCount", 2);
- executeBuildingBlockRainyDay.setRetryTimer(delegateExecution);
- assertEquals("PT40S",delegateExecution.getVariable("RetryDuration"));
- }
-
- @Test
- public void setRetryTimerExceptionTest() {
- expectedException.expect(BpmnError.class);
- DelegateExecution execution = mock(DelegateExecution.class);
- when(execution.getVariable(eq("retryCount"))).thenThrow(BpmnError.class);
- executeBuildingBlockRainyDay.setRetryTimer(execution);
- }
-
- @Test
- public void queryRainyDayTableExists() throws Exception{
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
- vnf.setVnfType("vnft1");
- delegateExecution.setVariable("aLaCarte", true);
- delegateExecution.setVariable("suppressRollback", false);
- delegateExecution.setVariable("WorkflowExceptionCode", "7000");
- RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
- rainyDayHandlerStatus.setErrorCode("7000");
- rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
- rainyDayHandlerStatus.setServiceType("st1");
- rainyDayHandlerStatus.setVnfType("vnft1");
- rainyDayHandlerStatus.setPolicy("Rollback");
- rainyDayHandlerStatus.setWorkStep(ASTERISK);
-
- doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "st1", "vnft1", "7000", "*");
-
- executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true);
-
- assertEquals("Rollback", delegateExecution.getVariable("handlingCode"));
- }
-
- @Test
- public void queryRainyDayTableDefault() throws Exception{
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
- vnf.setVnfType("vnft1");
- delegateExecution.setVariable("aLaCarte", true);
- delegateExecution.setVariable("suppressRollback", false);
- delegateExecution.setVariable("WorkflowExceptionCode", ASTERISK);
- RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
- rainyDayHandlerStatus.setErrorCode(ASTERISK);
- rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
- rainyDayHandlerStatus.setServiceType(ASTERISK);
- rainyDayHandlerStatus.setVnfType(ASTERISK);
- rainyDayHandlerStatus.setPolicy("Rollback");
- rainyDayHandlerStatus.setWorkStep(ASTERISK);
-
- doReturn(null).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "st1", "vnft1", "7000", ASTERISK);
- doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", ASTERISK, ASTERISK, ASTERISK, ASTERISK);
-
- executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true);
-
- assertEquals("Rollback", delegateExecution.getVariable("handlingCode"));
- assertEquals(5,delegateExecution.getVariable("maxRetries"));
- }
-
- @Test
- public void queryRainyDayTableDoesNotExist() throws Exception{
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
- vnf.setVnfType("vnft1");
- delegateExecution.setVariable("aLaCarte", true);
- doReturn(null).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class));
- delegateExecution.setVariable("suppressRollback", false);
-
- executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true);
-
- assertEquals("Abort", delegateExecution.getVariable("handlingCode"));
- }
-
- @Test
- public void queryRainyDayTableExceptionTest() {
- doThrow(RuntimeException.class).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class));
- delegateExecution.setVariable("aLaCarte", true);
- executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true);
- delegateExecution.setVariable("suppressRollback", false);
-
- assertEquals("Abort", delegateExecution.getVariable("handlingCode"));
- }
-
- @Test
- public void queryRainyDayTableSecondaryPolicyExists() throws Exception{
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
- vnf.setVnfType("vnft1");
- delegateExecution.setVariable("aLaCarte", true);
- delegateExecution.setVariable("suppressRollback", false);
- delegateExecution.setVariable("WorkflowExceptionCode", "7000");
- RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
- rainyDayHandlerStatus.setErrorCode("7000");
- rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
- rainyDayHandlerStatus.setServiceType("st1");
- rainyDayHandlerStatus.setVnfType("vnft1");
- rainyDayHandlerStatus.setPolicy("Retry");
- rainyDayHandlerStatus.setWorkStep(ASTERISK);
- rainyDayHandlerStatus.setSecondaryPolicy("Abort");
-
- doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "st1", "vnft1", "7000", "*");
-
- executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,false);
-
- assertEquals("Abort", delegateExecution.getVariable("handlingCode"));
- }
-
- @Test
- public void queryRainyDayTableRollbackToAssignedMacro() throws Exception{
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
- vnf.setVnfType("vnft1");
- delegateExecution.setVariable("aLaCarte", false);
- delegateExecution.setVariable("suppressRollback", false);
- delegateExecution.setVariable("WorkflowExceptionCode", "7000");
- RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
- rainyDayHandlerStatus.setErrorCode("7000");
- rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
- rainyDayHandlerStatus.setServiceType("st1");
- rainyDayHandlerStatus.setVnfType("vnft1");
- rainyDayHandlerStatus.setPolicy("RollbackToAssigned");
- rainyDayHandlerStatus.setWorkStep(ASTERISK);
- rainyDayHandlerStatus.setSecondaryPolicy("Abort");
-
- doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "st1", "vnft1", "7000", "*");
-
- executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true);
-
- assertEquals("Rollback", delegateExecution.getVariable("handlingCode"));
- }
-
- @Test
- public void queryRainyDayTableRollbackToAssignedALaCarte() throws Exception{
- customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
- serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
- vnf.setVnfType("vnft1");
- delegateExecution.setVariable("aLaCarte", true);
- delegateExecution.setVariable("suppressRollback", false);
- delegateExecution.setVariable("WorkflowExceptionCode", "7000");
- RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
- rainyDayHandlerStatus.setErrorCode("7000");
- rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
- rainyDayHandlerStatus.setServiceType("st1");
- rainyDayHandlerStatus.setVnfType("vnft1");
- rainyDayHandlerStatus.setPolicy("RollbackToAssigned");
- rainyDayHandlerStatus.setWorkStep(ASTERISK);
- rainyDayHandlerStatus.setSecondaryPolicy("Abort");
-
- doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep("AssignServiceInstanceBB", "st1", "vnft1", "7000", "*");
-
- executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true);
-
- assertEquals("RollbackToAssigned", delegateExecution.getVariable("handlingCode"));
- }
-
- @Test
- public void suppressRollbackTest() throws Exception {
- delegateExecution.setVariable("suppressRollback", true);
- delegateExecution.setVariable("aLaCarte", true);
- executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution,true);
- assertEquals("Abort", delegateExecution.getVariable("handlingCode"));
- }
-
+ @Autowired
+ private ExecuteBuildingBlockRainyDay executeBuildingBlockRainyDay;
+
+ private ServiceInstance serviceInstance;
+ private Customer customer; // will build service sub
+ private GenericVnf vnf;
+ private BuildingBlock buildingBlock;
+ private ExecuteBuildingBlock executeBuildingBlock;
+ private static final String ASTERISK = "*";
+
+ @Before
+ public void before() {
+ serviceInstance = setServiceInstance();
+ customer = setCustomer();
+ vnf = setGenericVnf();
+
+ buildingBlock = new BuildingBlock();
+ buildingBlock.setBpmnFlowName("AssignServiceInstanceBB");
+
+ executeBuildingBlock = new ExecuteBuildingBlock();
+ executeBuildingBlock.setBuildingBlock(buildingBlock);
+
+ delegateExecution.setVariable("gBBInput", gBBInput);
+ delegateExecution.setVariable("WorkflowException", new WorkflowException("", 7000, ""));
+ delegateExecution.setVariable("buildingBlock", executeBuildingBlock);
+ delegateExecution.setVariable("lookupKeyMap", lookupKeyMap);
+ }
+
+ @Test
+ public void setRetryTimerTest() throws Exception {
+ delegateExecution.setVariable("retryCount", 2);
+ executeBuildingBlockRainyDay.setRetryTimer(delegateExecution);
+ assertEquals("PT40S", delegateExecution.getVariable("RetryDuration"));
+ }
+
+ @Test
+ public void setRetryTimerExceptionTest() {
+ expectedException.expect(BpmnError.class);
+ DelegateExecution execution = mock(DelegateExecution.class);
+ when(execution.getVariable(eq("retryCount"))).thenThrow(BpmnError.class);
+ executeBuildingBlockRainyDay.setRetryTimer(execution);
+ }
+
+ @Test
+ public void queryRainyDayTableExists() throws Exception {
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
+ vnf.setVnfType("vnft1");
+ delegateExecution.setVariable("aLaCarte", true);
+ delegateExecution.setVariable("suppressRollback", false);
+ delegateExecution.setVariable("WorkflowExceptionCode", "7000");
+ RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
+ rainyDayHandlerStatus.setErrorCode("7000");
+ rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
+ rainyDayHandlerStatus.setServiceType("st1");
+ rainyDayHandlerStatus.setVnfType("vnft1");
+ rainyDayHandlerStatus.setPolicy("Rollback");
+ rainyDayHandlerStatus.setWorkStep(ASTERISK);
+
+ doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient)
+ .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(
+ "AssignServiceInstanceBB", "st1", "vnft1", "7000", "*");
+
+ executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true);
+
+ assertEquals("Rollback", delegateExecution.getVariable("handlingCode"));
+ }
+
+ @Test
+ public void queryRainyDayTableDefault() throws Exception {
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
+ vnf.setVnfType("vnft1");
+ delegateExecution.setVariable("aLaCarte", true);
+ delegateExecution.setVariable("suppressRollback", false);
+ delegateExecution.setVariable("WorkflowExceptionCode", ASTERISK);
+ RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
+ rainyDayHandlerStatus.setErrorCode(ASTERISK);
+ rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
+ rainyDayHandlerStatus.setServiceType(ASTERISK);
+ rainyDayHandlerStatus.setVnfType(ASTERISK);
+ rainyDayHandlerStatus.setPolicy("Rollback");
+ rainyDayHandlerStatus.setWorkStep(ASTERISK);
+
+ doReturn(null).when(MOCK_catalogDbClient)
+ .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(
+ "AssignServiceInstanceBB", "st1", "vnft1", "7000", ASTERISK);
+ doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient)
+ .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(
+ "AssignServiceInstanceBB", ASTERISK, ASTERISK, ASTERISK, ASTERISK);
+
+ executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true);
+
+ assertEquals("Rollback", delegateExecution.getVariable("handlingCode"));
+ assertEquals(5, delegateExecution.getVariable("maxRetries"));
+ }
+
+ @Test
+ public void queryRainyDayTableDoesNotExist() throws Exception {
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
+ vnf.setVnfType("vnft1");
+ delegateExecution.setVariable("aLaCarte", true);
+ doReturn(null).when(MOCK_catalogDbClient)
+ .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(isA(String.class),
+ isA(String.class), isA(String.class), isA(String.class), isA(String.class));
+ delegateExecution.setVariable("suppressRollback", false);
+
+ executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true);
+
+ assertEquals("Abort", delegateExecution.getVariable("handlingCode"));
+ }
+
+ @Test
+ public void queryRainyDayTableExceptionTest() {
+ doThrow(RuntimeException.class).when(MOCK_catalogDbClient)
+ .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(isA(String.class),
+ isA(String.class), isA(String.class), isA(String.class), isA(String.class));
+ delegateExecution.setVariable("aLaCarte", true);
+ executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true);
+ delegateExecution.setVariable("suppressRollback", false);
+
+ assertEquals("Abort", delegateExecution.getVariable("handlingCode"));
+ }
+
+ @Test
+ public void queryRainyDayTableSecondaryPolicyExists() throws Exception {
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
+ vnf.setVnfType("vnft1");
+ delegateExecution.setVariable("aLaCarte", true);
+ delegateExecution.setVariable("suppressRollback", false);
+ delegateExecution.setVariable("WorkflowExceptionCode", "7000");
+ RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
+ rainyDayHandlerStatus.setErrorCode("7000");
+ rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
+ rainyDayHandlerStatus.setServiceType("st1");
+ rainyDayHandlerStatus.setVnfType("vnft1");
+ rainyDayHandlerStatus.setPolicy("Retry");
+ rainyDayHandlerStatus.setWorkStep(ASTERISK);
+ rainyDayHandlerStatus.setSecondaryPolicy("Abort");
+
+ doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient)
+ .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(
+ "AssignServiceInstanceBB", "st1", "vnft1", "7000", "*");
+
+ executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, false);
+
+ assertEquals("Abort", delegateExecution.getVariable("handlingCode"));
+ }
+
+ @Test
+ public void queryRainyDayTableRollbackToAssignedMacro() throws Exception {
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
+ vnf.setVnfType("vnft1");
+ delegateExecution.setVariable("aLaCarte", false);
+ delegateExecution.setVariable("suppressRollback", false);
+ delegateExecution.setVariable("WorkflowExceptionCode", "7000");
+ RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
+ rainyDayHandlerStatus.setErrorCode("7000");
+ rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
+ rainyDayHandlerStatus.setServiceType("st1");
+ rainyDayHandlerStatus.setVnfType("vnft1");
+ rainyDayHandlerStatus.setPolicy("RollbackToAssigned");
+ rainyDayHandlerStatus.setWorkStep(ASTERISK);
+ rainyDayHandlerStatus.setSecondaryPolicy("Abort");
+
+ doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient)
+ .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(
+ "AssignServiceInstanceBB", "st1", "vnft1", "7000", "*");
+
+ executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true);
+
+ assertEquals("Rollback", delegateExecution.getVariable("handlingCode"));
+ }
+
+ @Test
+ public void queryRainyDayTableRollbackToAssignedALaCarte() throws Exception {
+ customer.getServiceSubscription().getServiceInstances().add(serviceInstance);
+ serviceInstance.getModelInfoServiceInstance().setServiceType("st1");
+ vnf.setVnfType("vnft1");
+ delegateExecution.setVariable("aLaCarte", true);
+ delegateExecution.setVariable("suppressRollback", false);
+ delegateExecution.setVariable("WorkflowExceptionCode", "7000");
+ RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus();
+ rainyDayHandlerStatus.setErrorCode("7000");
+ rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB");
+ rainyDayHandlerStatus.setServiceType("st1");
+ rainyDayHandlerStatus.setVnfType("vnft1");
+ rainyDayHandlerStatus.setPolicy("RollbackToAssigned");
+ rainyDayHandlerStatus.setWorkStep(ASTERISK);
+ rainyDayHandlerStatus.setSecondaryPolicy("Abort");
+
+ doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient)
+ .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(
+ "AssignServiceInstanceBB", "st1", "vnft1", "7000", "*");
+
+ executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true);
+
+ assertEquals("RollbackToAssigned", delegateExecution.getVariable("handlingCode"));
+ }
+
+ @Test
+ public void suppressRollbackTest() throws Exception {
+ delegateExecution.setVariable("suppressRollback", true);
+ delegateExecution.setVariable("aLaCarte", true);
+ executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true);
+ assertEquals("Abort", delegateExecution.getVariable("handlingCode"));
+ }
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundExceptionTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundExceptionTest.java
index 1cf70d050a..75df1a08d9 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundExceptionTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundExceptionTest.java
@@ -21,47 +21,46 @@
package org.onap.so.bpmn.servicedecomposition.tasks.exceptions;
import static org.junit.Assert.assertEquals;
-
import org.junit.Test;
import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException;
public class MultipleObjectsFoundExceptionTest {
- private static final String MESSAGE = "message";
- private static final Throwable CAUSE = new Throwable();
- private MultipleObjectsFoundException MultipleObjectsFoundException;
-
- @Test
- public void defaultConstructorTest() {
- MultipleObjectsFoundException = new MultipleObjectsFoundException();
- assertEquals(null, MultipleObjectsFoundException.getMessage());
- assertEquals(null, MultipleObjectsFoundException.getCause());
- }
-
- @Test
- public void messageConstructorTest() {
- MultipleObjectsFoundException = new MultipleObjectsFoundException(MESSAGE);
- assertEquals(MESSAGE, MultipleObjectsFoundException.getMessage());
- assertEquals(null, MultipleObjectsFoundException.getCause());
- }
-
- @Test
- public void causeConstructorTest() {
- MultipleObjectsFoundException = new MultipleObjectsFoundException(CAUSE);
- assertEquals(CAUSE.toString(), MultipleObjectsFoundException.getMessage());
- assertEquals(CAUSE, MultipleObjectsFoundException.getCause());
- }
-
- @Test
- public void messageAndCauseConstructorTest() {
- MultipleObjectsFoundException = new MultipleObjectsFoundException(MESSAGE, CAUSE);
- assertEquals(MESSAGE, MultipleObjectsFoundException.getMessage());
- assertEquals(CAUSE, MultipleObjectsFoundException.getCause());
- }
-
- @Test
- public void messageAndCauseAndFlagsConstructorTest() {
- MultipleObjectsFoundException = new MultipleObjectsFoundException(MESSAGE, CAUSE, true, true);
- assertEquals(MESSAGE, MultipleObjectsFoundException.getMessage());
- assertEquals(CAUSE, MultipleObjectsFoundException.getCause());
- }
+ private static final String MESSAGE = "message";
+ private static final Throwable CAUSE = new Throwable();
+ private MultipleObjectsFoundException MultipleObjectsFoundException;
+
+ @Test
+ public void defaultConstructorTest() {
+ MultipleObjectsFoundException = new MultipleObjectsFoundException();
+ assertEquals(null, MultipleObjectsFoundException.getMessage());
+ assertEquals(null, MultipleObjectsFoundException.getCause());
+ }
+
+ @Test
+ public void messageConstructorTest() {
+ MultipleObjectsFoundException = new MultipleObjectsFoundException(MESSAGE);
+ assertEquals(MESSAGE, MultipleObjectsFoundException.getMessage());
+ assertEquals(null, MultipleObjectsFoundException.getCause());
+ }
+
+ @Test
+ public void causeConstructorTest() {
+ MultipleObjectsFoundException = new MultipleObjectsFoundException(CAUSE);
+ assertEquals(CAUSE.toString(), MultipleObjectsFoundException.getMessage());
+ assertEquals(CAUSE, MultipleObjectsFoundException.getCause());
+ }
+
+ @Test
+ public void messageAndCauseConstructorTest() {
+ MultipleObjectsFoundException = new MultipleObjectsFoundException(MESSAGE, CAUSE);
+ assertEquals(MESSAGE, MultipleObjectsFoundException.getMessage());
+ assertEquals(CAUSE, MultipleObjectsFoundException.getCause());
+ }
+
+ @Test
+ public void messageAndCauseAndFlagsConstructorTest() {
+ MultipleObjectsFoundException = new MultipleObjectsFoundException(MESSAGE, CAUSE, true, true);
+ assertEquals(MESSAGE, MultipleObjectsFoundException.getMessage());
+ assertEquals(CAUSE, MultipleObjectsFoundException.getCause());
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundExceptionTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundExceptionTest.java
index 344481dbed..c5970f64ee 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundExceptionTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundExceptionTest.java
@@ -21,46 +21,45 @@
package org.onap.so.bpmn.servicedecomposition.tasks.exceptions;
import static org.junit.Assert.assertEquals;
-
import org.junit.Test;
public class NoServiceInstanceFoundExceptionTest {
- private static final String MESSAGE = "message";
- private static final Throwable CAUSE = new Throwable();
- private NoServiceInstanceFoundException NoObjectFoundException;
-
- @Test
- public void defaultConstructorTest() {
- NoObjectFoundException = new NoServiceInstanceFoundException();
- assertEquals(null, NoObjectFoundException.getMessage());
- assertEquals(null, NoObjectFoundException.getCause());
- }
-
- @Test
- public void messageConstructorTest() {
- NoObjectFoundException = new NoServiceInstanceFoundException(MESSAGE);
- assertEquals(MESSAGE, NoObjectFoundException.getMessage());
- assertEquals(null, NoObjectFoundException.getCause());
- }
-
- @Test
- public void causeConstructorTest() {
- NoObjectFoundException = new NoServiceInstanceFoundException(CAUSE);
- assertEquals(CAUSE.toString(), NoObjectFoundException.getMessage());
- assertEquals(CAUSE, NoObjectFoundException.getCause());
- }
-
- @Test
- public void messageAndCauseConstructorTest() {
- NoObjectFoundException = new NoServiceInstanceFoundException(MESSAGE, CAUSE);
- assertEquals(MESSAGE, NoObjectFoundException.getMessage());
- assertEquals(CAUSE, NoObjectFoundException.getCause());
- }
-
- @Test
- public void messageAndCauseAndFlagsConstructorTest() {
- NoObjectFoundException = new NoServiceInstanceFoundException(MESSAGE, CAUSE, true, true);
- assertEquals(MESSAGE, NoObjectFoundException.getMessage());
- assertEquals(CAUSE, NoObjectFoundException.getCause());
- }
+ private static final String MESSAGE = "message";
+ private static final Throwable CAUSE = new Throwable();
+ private NoServiceInstanceFoundException NoObjectFoundException;
+
+ @Test
+ public void defaultConstructorTest() {
+ NoObjectFoundException = new NoServiceInstanceFoundException();
+ assertEquals(null, NoObjectFoundException.getMessage());
+ assertEquals(null, NoObjectFoundException.getCause());
+ }
+
+ @Test
+ public void messageConstructorTest() {
+ NoObjectFoundException = new NoServiceInstanceFoundException(MESSAGE);
+ assertEquals(MESSAGE, NoObjectFoundException.getMessage());
+ assertEquals(null, NoObjectFoundException.getCause());
+ }
+
+ @Test
+ public void causeConstructorTest() {
+ NoObjectFoundException = new NoServiceInstanceFoundException(CAUSE);
+ assertEquals(CAUSE.toString(), NoObjectFoundException.getMessage());
+ assertEquals(CAUSE, NoObjectFoundException.getCause());
+ }
+
+ @Test
+ public void messageAndCauseConstructorTest() {
+ NoObjectFoundException = new NoServiceInstanceFoundException(MESSAGE, CAUSE);
+ assertEquals(MESSAGE, NoObjectFoundException.getMessage());
+ assertEquals(CAUSE, NoObjectFoundException.getCause());
+ }
+
+ @Test
+ public void messageAndCauseAndFlagsConstructorTest() {
+ NoObjectFoundException = new NoServiceInstanceFoundException(MESSAGE, CAUSE, true, true);
+ assertEquals(MESSAGE, NoObjectFoundException.getMessage());
+ assertEquals(CAUSE, NoObjectFoundException.getCause());
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/ResponseExceptionMapperImplTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/ResponseExceptionMapperImplTest.java
index 14a30391f9..cb98b1b603 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/ResponseExceptionMapperImplTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/ResponseExceptionMapperImplTest.java
@@ -22,11 +22,9 @@ package org.onap.so.client;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-
import java.io.ByteArrayInputStream;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
-
import javax.ws.rs.BadRequestException;
import javax.ws.rs.ForbiddenException;
import javax.ws.rs.InternalServerErrorException;
@@ -38,85 +36,79 @@ import javax.ws.rs.NotSupportedException;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
-
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
-
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
@RunWith(JUnitParamsRunner.class)
-public class ResponseExceptionMapperImplTest{
+public class ResponseExceptionMapperImplTest {
- private static final ResponseExceptionMapperImpl mapper = new ResponseExceptionMapperImpl();
+ private static final ResponseExceptionMapperImpl mapper = new ResponseExceptionMapperImpl();
- public static Object[][] statusesAndCorrespondingExceptions() {
- return new Object[][]{
- {Status.BAD_REQUEST, BadRequestException.class},
- {Status.UNAUTHORIZED, NotAuthorizedException.class},
- {Status.FORBIDDEN, ForbiddenException.class},
- {Status.NOT_FOUND, NotFoundException.class},
- {Status.METHOD_NOT_ALLOWED, NotAllowedException.class},
- {Status.NOT_ACCEPTABLE, NotAcceptableException.class},
- {Status.PRECONDITION_FAILED, PreconditionFailedException.class},
- {Status.UNSUPPORTED_MEDIA_TYPE, NotSupportedException.class},
- {Status.INTERNAL_SERVER_ERROR, InternalServerErrorException.class},
- {Status.SERVICE_UNAVAILABLE, WebApplicationException.class},
- {Status.BAD_GATEWAY, WebApplicationException.class},
- };
- }
+ public static Object[][] statusesAndCorrespondingExceptions() {
+ return new Object[][] {{Status.BAD_REQUEST, BadRequestException.class},
+ {Status.UNAUTHORIZED, NotAuthorizedException.class}, {Status.FORBIDDEN, ForbiddenException.class},
+ {Status.NOT_FOUND, NotFoundException.class}, {Status.METHOD_NOT_ALLOWED, NotAllowedException.class},
+ {Status.NOT_ACCEPTABLE, NotAcceptableException.class},
+ {Status.PRECONDITION_FAILED, PreconditionFailedException.class},
+ {Status.UNSUPPORTED_MEDIA_TYPE, NotSupportedException.class},
+ {Status.INTERNAL_SERVER_ERROR, InternalServerErrorException.class},
+ {Status.SERVICE_UNAVAILABLE, WebApplicationException.class},
+ {Status.BAD_GATEWAY, WebApplicationException.class},};
+ }
- @Rule
- public ExpectedException expectedExceptionTest = ExpectedException.none();
+ @Rule
+ public ExpectedException expectedExceptionTest = ExpectedException.none();
- @Test
- @Parameters(method = "statusesAndCorrespondingExceptions")
- public void shouldThrowExceptionWhenStatusIsNotOk(Status status, Class<Exception> expectedException) {
- // given
- Response response = createMockResponse(status);
- // when, then
- expectedExceptionTest.expect(expectedException);
- mapper.map(response);
- }
+ @Test
+ @Parameters(method = "statusesAndCorrespondingExceptions")
+ public void shouldThrowExceptionWhenStatusIsNotOk(Status status, Class<Exception> expectedException) {
+ // given
+ Response response = createMockResponse(status);
+ // when, then
+ expectedExceptionTest.expect(expectedException);
+ mapper.map(response);
+ }
+
+ @Test
+ public void shouldNotThrowExceptionWhenStatusIsOk() {
+ // given
+ Response response = createMockResponse(Status.OK);
+ // when, then
+ expectedExceptionTest.none();
+ mapper.map(response);
+ }
- @Test
- public void shouldNotThrowExceptionWhenStatusIsOk() {
- // given
- Response response = createMockResponse(Status.OK);
- // when, then
- expectedExceptionTest.none();
- mapper.map(response);
- }
-
@Test
public void shouldThrowExceptionWithCustomMessageWhenResponseHasEntity() throws UnsupportedEncodingException {
// given
- Response response = createMockResponse(Status.BAD_REQUEST);
+ Response response = createMockResponse(Status.BAD_REQUEST);
when(response.hasEntity()).thenReturn(true);
when(response.readEntity(String.class)).thenReturn("test message");
-
+
expectedExceptionTest.expect(BadRequestException.class);
expectedExceptionTest.expectMessage("test message");
- mapper.map(response);
+ mapper.map(response);
}
@Test
public void shouldThrowExceptionWithDefaultMessageWhenResponseHasNoEntity() {
// given
- Response response = createMockResponse(Status.BAD_REQUEST);
+ Response response = createMockResponse(Status.BAD_REQUEST);
when(response.hasEntity()).thenReturn(false);
// when, then
expectedExceptionTest.expect(BadRequestException.class);
expectedExceptionTest.expectMessage("");
- mapper.map(response);
+ mapper.map(response);
+ }
+
+ private static Response createMockResponse(Status status) {
+ Response responseContext = mock(Response.class);
+ when(responseContext.getStatusInfo()).thenReturn(status);
+ when(responseContext.getStatus()).thenReturn(status.getStatusCode());
+ return responseContext;
}
-
- private static Response createMockResponse(Status status) {
- Response responseContext = mock(Response.class);
- when(responseContext.getStatusInfo()).thenReturn(status);
- when(responseContext.getStatus()).thenReturn(status.getStatusCode());
- return responseContext;
- }
-} \ No newline at end of file
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerActionTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerActionTest.java
index 2f65f9ce66..32db3a7bf6 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerActionTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerActionTest.java
@@ -26,11 +26,9 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Optional;
-
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
@@ -43,420 +41,444 @@ import org.onap.so.BaseTest;
import com.fasterxml.jackson.core.JsonProcessingException;
-public class ApplicationControllerActionTest extends BaseTest{
-
- private ApplicationControllerAction appCAction;
-
- @Mock
- private ApplicationControllerOrchestrator client;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
-
- appCAction = new ApplicationControllerAction();
- appCAction.client = client;
- }
-
- @Test
- public void runAppCCommand_ResumeTraffic_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
- //Prepare method
- Action action = Action.ResumeTraffic;
- String msoRequestId = "testMsoRequestId";
- String vnfId = "testVnfId";
- Optional<String> payload = Optional.empty();
- Optional<String> vserverId = Optional.empty();
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName");
- String controllerType = "testControllerType";
-
- //Prepare mocks
- Status status = new Status();
- Optional<String> otherPayload = PayloadClient.resumeTrafficFormat(payloadInfo.get("vnfName"));
- doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
-
- //Run method
- appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
-
- //Verify call
- verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
- }
-
- @Test
- public void runAppCCommand_Start_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
- runAppCCommand_StartStop_Test(Action.Start);
- }
-
- @Test
- public void runAppCCommand_Stop_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
- runAppCCommand_StartStop_Test(Action.Stop);
- }
-
- private void runAppCCommand_StartStop_Test(Action action) throws ApplicationControllerOrchestratorException, JsonProcessingException {
- //Prepare method
- String msoRequestId = "testMsoRequestId";
- String vnfId = "testVnfId";
- Optional<String> payload = Optional.empty();
- Optional<String> vserverId = Optional.empty();
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName");
- String controllerType = "testControllerType";
-
- //Prepare mocks
- Status status = new Status();
- Optional<String> otherPayload = PayloadClient.startStopFormat(payloadInfo.get("vnfName"));
- doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
-
- //Run method
- appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
-
- //Verify call
- verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
- }
-
- @Test
- public void runAppCCommand_Unlock_Test() throws ApplicationControllerOrchestratorException {
- runAppCCommand_LockUnlock_Test(Action.Unlock);
- }
-
- @Test
- public void runAppCCommand_Lock_Test() throws ApplicationControllerOrchestratorException {
- runAppCCommand_LockUnlock_Test(Action.Lock);
- }
-
- private void runAppCCommand_LockUnlock_Test(Action action) throws ApplicationControllerOrchestratorException {
- //Prepare method
- String msoRequestId = "testMsoRequestId";
- String vnfId = "testVnfId";
- Optional<String> payload = Optional.empty();
- Optional<String> vserverId = Optional.empty();
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- String controllerType = "testControllerType";
-
- //Prepare mocks
- Status status = new Status();
- Optional<String> otherPayload = Optional.empty();
- doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
-
- //Run method
- appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
-
- //Verify call
- verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
- }
-
- @Test
- public void runAppCCommand_QuiesceTraffic_PayloadPresent_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
- //Prepare method
- Action action = Action.QuiesceTraffic;
- String msoRequestId = "testMsoRequestId";
- String vnfId = "testVnfId";
- Optional<String> payload = Optional.of("testPayload");
- Optional<String> vserverId = Optional.empty();
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName");
- String controllerType = "testControllerType";
-
- //Prepare mocks
- Status status = new Status();
- Optional<String> modifiedPayload = PayloadClient.quiesceTrafficFormat(payload, payloadInfo.get("vnfName"));
- doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, modifiedPayload, controllerType);
-
- //Run method
- appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
-
- //Verify call
- verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, modifiedPayload, controllerType);
- }
-
- @Test
- public void runAppCCommand_QuiesceTraffic_NoPayload_Test() throws ApplicationControllerOrchestratorException {
- //Prepare method
- Action action = Action.QuiesceTraffic;
- String msoRequestId = "testMsoRequestId";
- String vnfId = "testVnfId";
- Optional<String> payload = Optional.empty();
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- String controllerType = "testControllerType";
-
- //Run method
- appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
-
- //Verify non call
- verify(client, times(0)).vnfCommand(any(), any(), any(), any(), any(), any());
- assertEquals("Payload is not present for " + action.toString(), appCAction.getErrorMessage());
- }
-
- @Test
- public void runAppCCommand_HealthCheck_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
- //Prepare method
- Action action = Action.HealthCheck;
- String msoRequestId = "testMsoRequestId";
- String vnfId = "testVnfId";
- Optional<String> payload = Optional.empty();
- Optional<String> vserverId = Optional.empty();
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName");
- payloadInfo.put("vnfHostIpAddress", "testVnfHostIpAddress");
- String controllerType = "testControllerType";
-
- //Prepare mocks
- Status status = new Status();
- Optional<String> otherPayload = PayloadClient.healthCheckFormat(payloadInfo.get("vnfName"), payloadInfo.get("vnfHostIpAddress"));
- doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
-
- //Run method
- appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
-
- //Verify call
- verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
- }
-
- @Test
- public void runAppCCommand_Snapshot_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
- //Prepare method
- Action action = Action.Snapshot;
- String msoRequestId = "testMsoRequestId";
- String vnfId = "testVnfId";
- Optional<String> payload = Optional.empty();
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("identityUrl", "testIdentityUrl");
- ArrayList<String> vmIdList = new ArrayList<String>();
- String vmId1 = "testlink:testVmId1";
- vmIdList.add(vmId1);
- String vmId2 = "testlink:testVmId2";
- vmIdList.add(vmId2);
- JSONObject vmIdListJson = new JSONObject();
- vmIdListJson.put("vmIds", vmIdList);
- payloadInfo.put("vmIdList", vmIdListJson.toString());
- ArrayList<String> vserverIdList = new ArrayList<String>();
- String vserverId1 = "testVserverId1";
- Optional<String> vserverIdString1 = Optional.of(vserverId1);
- vserverIdList.add(vserverId1);
- String vserverId2 = "testVserverId2";
- Optional<String> vserverIdString2 = Optional.of(vserverId2);
- vserverIdList.add(vserverId2);
-
- JSONObject vserverIdListJson = new JSONObject();
- vserverIdListJson.put("vserverIds", vserverIdList);
- payloadInfo.put("vserverIdList", vserverIdListJson.toString());
- String controllerType = "testControllerType";
-
- //Prepare mocks
- Status status = new Status();
- Optional<String> otherPayloadVm1 = PayloadClient.snapshotFormat(vmId1, payloadInfo.get("identityUrl"));
- Optional<String> otherPayloadVm2 = PayloadClient.snapshotFormat(vmId2, payloadInfo.get("identityUrl"));
- doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverIdString1, otherPayloadVm1, controllerType);
- doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverIdString2, otherPayloadVm2, controllerType);
-
- //Run method
- appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
-
- //Verify call
- verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverIdString1, otherPayloadVm1, controllerType);
- verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverIdString2, otherPayloadVm2, controllerType);
- }
-
- @Test
- public void runAppCCommand_ConfigModify__PayloadPresent_Test() throws ApplicationControllerOrchestratorException {
- //Prepare method
- Action action = Action.ConfigModify;
- String msoRequestId = "testMsoRequestId";
- String vnfId = "testVnfId";
- Optional<String> payload = Optional.of("testPayload");
- Optional<String> vserverId = Optional.empty();
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- String controllerType = "testControllerType";
-
- //Prepare mocks
- Status status = new Status();
- doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, payload, controllerType);
-
- //Run method
- appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
-
- //Verify call
- verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, payload, controllerType);
- }
-
- @Test
- public void runAppCCommand_ConfigModify__NoPayload_Test() throws ApplicationControllerOrchestratorException {
- //Prepare method
- Action action = Action.ConfigModify;
- String msoRequestId = "testMsoRequestId";
- String vnfId = "testVnfId";
- Optional<String> payload = Optional.empty();
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- String controllerType = "testControllerType";
-
- //Run method
- appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
-
- //Verify non call
- verify(client, times(0)).vnfCommand(any(), any(), any(), any(), any(), any());
- assertEquals("Payload is not present for " + action.toString(), appCAction.getErrorMessage());
- }
-
- @Test
- public void runAppCCommand_UpgradePreCheck_PayloadPresent_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
- runAppCCommand_Upgrade_PayloadPresent_Test(Action.UpgradePreCheck);
- }
-
- @Test
- public void runAppCCommand_UpgradePostCheck_PayloadPresent_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
- runAppCCommand_Upgrade_PayloadPresent_Test(Action.UpgradePostCheck);
- }
-
- @Test
- public void runAppCCommand_UpgradeSoftware_PayloadPresent_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
- runAppCCommand_Upgrade_PayloadPresent_Test(Action.UpgradeSoftware);
- }
-
- @Test
- public void runAppCCommand_UpgradeBackup_PayloadPresent_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
- runAppCCommand_Upgrade_PayloadPresent_Test(Action.UpgradeBackup);
- }
-
- private void runAppCCommand_Upgrade_PayloadPresent_Test(Action action) throws ApplicationControllerOrchestratorException, JsonProcessingException {
- //Prepare method
- String msoRequestId = "testMsoRequestId";
- String vnfId = "testVnfId";
- Optional<String> payload = Optional.of("testPayload");
- Optional<String> vserverId = Optional.empty();
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName");
- String controllerType = "testControllerType";
-
- //Prepare mocks
- Status status = new Status();
- Optional<String> modifiedPayload = PayloadClient.upgradeFormat(payload, payloadInfo.get("vnfName"));
- doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, modifiedPayload, controllerType);
-
- //Run method
- appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
-
- //Verify call
- verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, modifiedPayload, controllerType);
- }
-
- @Test
- public void runAppCCommand_UpgradePreCheck_NoPayload_Test() throws ApplicationControllerOrchestratorException {
- runAppCCommand_Upgrade_NoPayload_Test(Action.UpgradePreCheck);
- }
-
- @Test
- public void runAppCCommand_UpgradePostCheck_NoPayload_Test() throws ApplicationControllerOrchestratorException {
- runAppCCommand_Upgrade_NoPayload_Test(Action.UpgradePostCheck);
- }
-
- @Test
- public void runAppCCommand_UpgradeSoftware_NoPayload_Test() throws ApplicationControllerOrchestratorException {
- runAppCCommand_Upgrade_NoPayload_Test(Action.UpgradeSoftware);
- }
-
- @Test
- public void runAppCCommand_UpgradeBackup_NoPayload_Test() throws ApplicationControllerOrchestratorException {
- runAppCCommand_Upgrade_NoPayload_Test(Action.UpgradeBackup);
- }
-
- private void runAppCCommand_Upgrade_NoPayload_Test(Action action) throws ApplicationControllerOrchestratorException {
- //Prepare method
- String msoRequestId = "testMsoRequestId";
- String vnfId = "testVnfId";
- Optional<String> payload = Optional.empty();
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- String controllerType = "testControllerType";
-
- //Run method
- appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
-
- //Verify non call
- verify(client, times(0)).vnfCommand(any(), any(), any(), any(), any(), any());
- assertEquals("Payload is not present for " + action.toString(), appCAction.getErrorMessage());
- }
-
- @Test
- public void runAppCCommand_InvalidAppCAction_Test() throws ApplicationControllerOrchestratorException {
- //Prepare method
- Action action = Action.ActionStatus;
- String msoRequestId = "testMsoRequestId";
- String vnfId = "testVnfId";
- Optional<String> payload = Optional.empty();
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- String controllerType = "testControllerType";
-
- //Run method
- appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
-
- //Verify non call
- verify(client, times(0)).vnfCommand(any(), any(), any(), any(), any(), any());
- //TODO For original author/architect: it appears that whoever coded this wanted the error message to be "Unable to idenify Action request for AppCClient" and this is not the case because of the ApplicationControllerSupport.getCategoryOf(appCStatus) call with a null appCStatus, so this may be something worth looking into
- }
-
- @Test
- public void runAppCCommand_NormalAppCStatusGetErrorCode_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
- //Prepare method
- Action action = Action.Start;
- String msoRequestId = "testMsoRequestId";
- String vnfId = "testVnfId";
- Optional<String> payload = Optional.empty();
- Optional<String> vserverId = Optional.empty();
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName");
- String controllerType = "testControllerType";
-
- //Prepare mocks
- Status status = new Status();
- status.setCode(100);
- Optional<String> otherPayload = PayloadClient.startStopFormat(payloadInfo.get("vnfName"));
- doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
-
- //Run method
- appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
-
- //Verify call
- String expectedErrorCode = "0";
- assertEquals(expectedErrorCode, appCAction.getErrorCode());
- }
-
- @Test
- public void getErrorCode_Test() {
- String defaultErrorCode = "1002";
- //Verify default error code
- assertEquals(defaultErrorCode, appCAction.getErrorCode());
- }
-
- @Test
- public void getErrorMessage_Test() {
- String defaultErrorMessage = "Unable to reach App C Servers";
- //Verify default error message
- assertEquals(defaultErrorMessage, appCAction.getErrorMessage());
- }
-
- @Test
- public void applicationControllerOrchestratorExceptionCaught_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
- //Prepare method
- Action action = Action.Start;
- String msoRequestId = "testMsoRequestId";
- String vnfId = "testVnfId";
- Optional<String> payload = Optional.empty();
- Optional<String> vserverId = Optional.empty();
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
- payloadInfo.put("vnfName", "testVnfName");
- String controllerType = "testControllerType";
-
- //Prepare mocks
- Optional<String> otherPayload = PayloadClient.startStopFormat(payloadInfo.get("vnfName"));
- String expectedErrorMessage = "Test appc orchestrator error message";
- doThrow(new ApplicationControllerOrchestratorException(expectedErrorMessage, 0)).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
-
- //Run method
- appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
-
- //Verify error
- assertEquals(expectedErrorMessage, appCAction.getErrorMessage());
- String expectedErrorCode = "1002";
- assertEquals(expectedErrorCode, appCAction.getErrorCode());
- }
-
+public class ApplicationControllerActionTest extends BaseTest {
+
+ private ApplicationControllerAction appCAction;
+
+ @Mock
+ private ApplicationControllerOrchestrator client;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+
+ appCAction = new ApplicationControllerAction();
+ appCAction.client = client;
+ }
+
+ @Test
+ public void runAppCCommand_ResumeTraffic_Test()
+ throws ApplicationControllerOrchestratorException, JsonProcessingException {
+ // Prepare method
+ Action action = Action.ResumeTraffic;
+ String msoRequestId = "testMsoRequestId";
+ String vnfId = "testVnfId";
+ Optional<String> payload = Optional.empty();
+ Optional<String> vserverId = Optional.empty();
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName");
+ String controllerType = "testControllerType";
+
+ // Prepare mocks
+ Status status = new Status();
+ Optional<String> otherPayload = PayloadClient.resumeTrafficFormat(payloadInfo.get("vnfName"));
+ doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
+
+ // Run method
+ appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
+
+ // Verify call
+ verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
+ }
+
+ @Test
+ public void runAppCCommand_Start_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
+ runAppCCommand_StartStop_Test(Action.Start);
+ }
+
+ @Test
+ public void runAppCCommand_Stop_Test() throws ApplicationControllerOrchestratorException, JsonProcessingException {
+ runAppCCommand_StartStop_Test(Action.Stop);
+ }
+
+ private void runAppCCommand_StartStop_Test(Action action)
+ throws ApplicationControllerOrchestratorException, JsonProcessingException {
+ // Prepare method
+ String msoRequestId = "testMsoRequestId";
+ String vnfId = "testVnfId";
+ Optional<String> payload = Optional.empty();
+ Optional<String> vserverId = Optional.empty();
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName");
+ String controllerType = "testControllerType";
+
+ // Prepare mocks
+ Status status = new Status();
+ Optional<String> otherPayload = PayloadClient.startStopFormat(payloadInfo.get("vnfName"));
+ doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
+
+ // Run method
+ appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
+
+ // Verify call
+ verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
+ }
+
+ @Test
+ public void runAppCCommand_Unlock_Test() throws ApplicationControllerOrchestratorException {
+ runAppCCommand_LockUnlock_Test(Action.Unlock);
+ }
+
+ @Test
+ public void runAppCCommand_Lock_Test() throws ApplicationControllerOrchestratorException {
+ runAppCCommand_LockUnlock_Test(Action.Lock);
+ }
+
+ private void runAppCCommand_LockUnlock_Test(Action action) throws ApplicationControllerOrchestratorException {
+ // Prepare method
+ String msoRequestId = "testMsoRequestId";
+ String vnfId = "testVnfId";
+ Optional<String> payload = Optional.empty();
+ Optional<String> vserverId = Optional.empty();
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ String controllerType = "testControllerType";
+
+ // Prepare mocks
+ Status status = new Status();
+ Optional<String> otherPayload = Optional.empty();
+ doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
+
+ // Run method
+ appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
+
+ // Verify call
+ verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
+ }
+
+ @Test
+ public void runAppCCommand_QuiesceTraffic_PayloadPresent_Test()
+ throws ApplicationControllerOrchestratorException, JsonProcessingException {
+ // Prepare method
+ Action action = Action.QuiesceTraffic;
+ String msoRequestId = "testMsoRequestId";
+ String vnfId = "testVnfId";
+ Optional<String> payload = Optional.of("testPayload");
+ Optional<String> vserverId = Optional.empty();
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName");
+ String controllerType = "testControllerType";
+
+ // Prepare mocks
+ Status status = new Status();
+ Optional<String> modifiedPayload = PayloadClient.quiesceTrafficFormat(payload, payloadInfo.get("vnfName"));
+ doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, modifiedPayload,
+ controllerType);
+
+ // Run method
+ appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
+
+ // Verify call
+ verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, modifiedPayload, controllerType);
+ }
+
+ @Test
+ public void runAppCCommand_QuiesceTraffic_NoPayload_Test() throws ApplicationControllerOrchestratorException {
+ // Prepare method
+ Action action = Action.QuiesceTraffic;
+ String msoRequestId = "testMsoRequestId";
+ String vnfId = "testVnfId";
+ Optional<String> payload = Optional.empty();
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ String controllerType = "testControllerType";
+
+ // Run method
+ appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
+
+ // Verify non call
+ verify(client, times(0)).vnfCommand(any(), any(), any(), any(), any(), any());
+ assertEquals("Payload is not present for " + action.toString(), appCAction.getErrorMessage());
+ }
+
+ @Test
+ public void runAppCCommand_HealthCheck_Test()
+ throws ApplicationControllerOrchestratorException, JsonProcessingException {
+ // Prepare method
+ Action action = Action.HealthCheck;
+ String msoRequestId = "testMsoRequestId";
+ String vnfId = "testVnfId";
+ Optional<String> payload = Optional.empty();
+ Optional<String> vserverId = Optional.empty();
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName");
+ payloadInfo.put("vnfHostIpAddress", "testVnfHostIpAddress");
+ String controllerType = "testControllerType";
+
+ // Prepare mocks
+ Status status = new Status();
+ Optional<String> otherPayload =
+ PayloadClient.healthCheckFormat(payloadInfo.get("vnfName"), payloadInfo.get("vnfHostIpAddress"));
+ doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
+
+ // Run method
+ appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
+
+ // Verify call
+ verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
+ }
+
+ @Test
+ public void runAppCCommand_Snapshot_Test()
+ throws ApplicationControllerOrchestratorException, JsonProcessingException {
+ // Prepare method
+ Action action = Action.Snapshot;
+ String msoRequestId = "testMsoRequestId";
+ String vnfId = "testVnfId";
+ Optional<String> payload = Optional.empty();
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("identityUrl", "testIdentityUrl");
+ ArrayList<String> vmIdList = new ArrayList<String>();
+ String vmId1 = "testlink:testVmId1";
+ vmIdList.add(vmId1);
+ String vmId2 = "testlink:testVmId2";
+ vmIdList.add(vmId2);
+ JSONObject vmIdListJson = new JSONObject();
+ vmIdListJson.put("vmIds", vmIdList);
+ payloadInfo.put("vmIdList", vmIdListJson.toString());
+ ArrayList<String> vserverIdList = new ArrayList<String>();
+ String vserverId1 = "testVserverId1";
+ Optional<String> vserverIdString1 = Optional.of(vserverId1);
+ vserverIdList.add(vserverId1);
+ String vserverId2 = "testVserverId2";
+ Optional<String> vserverIdString2 = Optional.of(vserverId2);
+ vserverIdList.add(vserverId2);
+
+ JSONObject vserverIdListJson = new JSONObject();
+ vserverIdListJson.put("vserverIds", vserverIdList);
+ payloadInfo.put("vserverIdList", vserverIdListJson.toString());
+ String controllerType = "testControllerType";
+
+ // Prepare mocks
+ Status status = new Status();
+ Optional<String> otherPayloadVm1 = PayloadClient.snapshotFormat(vmId1, payloadInfo.get("identityUrl"));
+ Optional<String> otherPayloadVm2 = PayloadClient.snapshotFormat(vmId2, payloadInfo.get("identityUrl"));
+ doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverIdString1, otherPayloadVm1,
+ controllerType);
+ doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverIdString2, otherPayloadVm2,
+ controllerType);
+
+ // Run method
+ appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
+
+ // Verify call
+ verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverIdString1, otherPayloadVm1,
+ controllerType);
+ verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverIdString2, otherPayloadVm2,
+ controllerType);
+ }
+
+ @Test
+ public void runAppCCommand_ConfigModify__PayloadPresent_Test() throws ApplicationControllerOrchestratorException {
+ // Prepare method
+ Action action = Action.ConfigModify;
+ String msoRequestId = "testMsoRequestId";
+ String vnfId = "testVnfId";
+ Optional<String> payload = Optional.of("testPayload");
+ Optional<String> vserverId = Optional.empty();
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ String controllerType = "testControllerType";
+
+ // Prepare mocks
+ Status status = new Status();
+ doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, payload, controllerType);
+
+ // Run method
+ appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
+
+ // Verify call
+ verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, payload, controllerType);
+ }
+
+ @Test
+ public void runAppCCommand_ConfigModify__NoPayload_Test() throws ApplicationControllerOrchestratorException {
+ // Prepare method
+ Action action = Action.ConfigModify;
+ String msoRequestId = "testMsoRequestId";
+ String vnfId = "testVnfId";
+ Optional<String> payload = Optional.empty();
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ String controllerType = "testControllerType";
+
+ // Run method
+ appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
+
+ // Verify non call
+ verify(client, times(0)).vnfCommand(any(), any(), any(), any(), any(), any());
+ assertEquals("Payload is not present for " + action.toString(), appCAction.getErrorMessage());
+ }
+
+ @Test
+ public void runAppCCommand_UpgradePreCheck_PayloadPresent_Test()
+ throws ApplicationControllerOrchestratorException, JsonProcessingException {
+ runAppCCommand_Upgrade_PayloadPresent_Test(Action.UpgradePreCheck);
+ }
+
+ @Test
+ public void runAppCCommand_UpgradePostCheck_PayloadPresent_Test()
+ throws ApplicationControllerOrchestratorException, JsonProcessingException {
+ runAppCCommand_Upgrade_PayloadPresent_Test(Action.UpgradePostCheck);
+ }
+
+ @Test
+ public void runAppCCommand_UpgradeSoftware_PayloadPresent_Test()
+ throws ApplicationControllerOrchestratorException, JsonProcessingException {
+ runAppCCommand_Upgrade_PayloadPresent_Test(Action.UpgradeSoftware);
+ }
+
+ @Test
+ public void runAppCCommand_UpgradeBackup_PayloadPresent_Test()
+ throws ApplicationControllerOrchestratorException, JsonProcessingException {
+ runAppCCommand_Upgrade_PayloadPresent_Test(Action.UpgradeBackup);
+ }
+
+ private void runAppCCommand_Upgrade_PayloadPresent_Test(Action action)
+ throws ApplicationControllerOrchestratorException, JsonProcessingException {
+ // Prepare method
+ String msoRequestId = "testMsoRequestId";
+ String vnfId = "testVnfId";
+ Optional<String> payload = Optional.of("testPayload");
+ Optional<String> vserverId = Optional.empty();
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName");
+ String controllerType = "testControllerType";
+
+ // Prepare mocks
+ Status status = new Status();
+ Optional<String> modifiedPayload = PayloadClient.upgradeFormat(payload, payloadInfo.get("vnfName"));
+ doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, modifiedPayload,
+ controllerType);
+
+ // Run method
+ appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
+
+ // Verify call
+ verify(client, times(1)).vnfCommand(action, msoRequestId, vnfId, vserverId, modifiedPayload, controllerType);
+ }
+
+ @Test
+ public void runAppCCommand_UpgradePreCheck_NoPayload_Test() throws ApplicationControllerOrchestratorException {
+ runAppCCommand_Upgrade_NoPayload_Test(Action.UpgradePreCheck);
+ }
+
+ @Test
+ public void runAppCCommand_UpgradePostCheck_NoPayload_Test() throws ApplicationControllerOrchestratorException {
+ runAppCCommand_Upgrade_NoPayload_Test(Action.UpgradePostCheck);
+ }
+
+ @Test
+ public void runAppCCommand_UpgradeSoftware_NoPayload_Test() throws ApplicationControllerOrchestratorException {
+ runAppCCommand_Upgrade_NoPayload_Test(Action.UpgradeSoftware);
+ }
+
+ @Test
+ public void runAppCCommand_UpgradeBackup_NoPayload_Test() throws ApplicationControllerOrchestratorException {
+ runAppCCommand_Upgrade_NoPayload_Test(Action.UpgradeBackup);
+ }
+
+ private void runAppCCommand_Upgrade_NoPayload_Test(Action action)
+ throws ApplicationControllerOrchestratorException {
+ // Prepare method
+ String msoRequestId = "testMsoRequestId";
+ String vnfId = "testVnfId";
+ Optional<String> payload = Optional.empty();
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ String controllerType = "testControllerType";
+
+ // Run method
+ appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
+
+ // Verify non call
+ verify(client, times(0)).vnfCommand(any(), any(), any(), any(), any(), any());
+ assertEquals("Payload is not present for " + action.toString(), appCAction.getErrorMessage());
+ }
+
+ @Test
+ public void runAppCCommand_InvalidAppCAction_Test() throws ApplicationControllerOrchestratorException {
+ // Prepare method
+ Action action = Action.ActionStatus;
+ String msoRequestId = "testMsoRequestId";
+ String vnfId = "testVnfId";
+ Optional<String> payload = Optional.empty();
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ String controllerType = "testControllerType";
+
+ // Run method
+ appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
+
+ // Verify non call
+ verify(client, times(0)).vnfCommand(any(), any(), any(), any(), any(), any());
+ // TODO For original author/architect: it appears that whoever coded this wanted the error message to be "Unable
+ // to idenify Action request for AppCClient" and this is not the case because of the
+ // ApplicationControllerSupport.getCategoryOf(appCStatus) call with a null appCStatus, so this may be something
+ // worth looking into
+ }
+
+ @Test
+ public void runAppCCommand_NormalAppCStatusGetErrorCode_Test()
+ throws ApplicationControllerOrchestratorException, JsonProcessingException {
+ // Prepare method
+ Action action = Action.Start;
+ String msoRequestId = "testMsoRequestId";
+ String vnfId = "testVnfId";
+ Optional<String> payload = Optional.empty();
+ Optional<String> vserverId = Optional.empty();
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName");
+ String controllerType = "testControllerType";
+
+ // Prepare mocks
+ Status status = new Status();
+ status.setCode(100);
+ Optional<String> otherPayload = PayloadClient.startStopFormat(payloadInfo.get("vnfName"));
+ doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, vserverId, otherPayload, controllerType);
+
+ // Run method
+ appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
+
+ // Verify call
+ String expectedErrorCode = "0";
+ assertEquals(expectedErrorCode, appCAction.getErrorCode());
+ }
+
+ @Test
+ public void getErrorCode_Test() {
+ String defaultErrorCode = "1002";
+ // Verify default error code
+ assertEquals(defaultErrorCode, appCAction.getErrorCode());
+ }
+
+ @Test
+ public void getErrorMessage_Test() {
+ String defaultErrorMessage = "Unable to reach App C Servers";
+ // Verify default error message
+ assertEquals(defaultErrorMessage, appCAction.getErrorMessage());
+ }
+
+ @Test
+ public void applicationControllerOrchestratorExceptionCaught_Test()
+ throws ApplicationControllerOrchestratorException, JsonProcessingException {
+ // Prepare method
+ Action action = Action.Start;
+ String msoRequestId = "testMsoRequestId";
+ String vnfId = "testVnfId";
+ Optional<String> payload = Optional.empty();
+ Optional<String> vserverId = Optional.empty();
+ HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ payloadInfo.put("vnfName", "testVnfName");
+ String controllerType = "testControllerType";
+
+ // Prepare mocks
+ Optional<String> otherPayload = PayloadClient.startStopFormat(payloadInfo.get("vnfName"));
+ String expectedErrorMessage = "Test appc orchestrator error message";
+ doThrow(new ApplicationControllerOrchestratorException(expectedErrorMessage, 0)).when(client).vnfCommand(action,
+ msoRequestId, vnfId, vserverId, otherPayload, controllerType);
+
+ // Run method
+ appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType);
+
+ // Verify error
+ assertEquals(expectedErrorMessage, appCAction.getErrorMessage());
+ String expectedErrorCode = "1002";
+ assertEquals(expectedErrorCode, appCAction.getErrorCode());
+ }
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java
index 77daee6050..c242017838 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerClientV2Test.java
@@ -35,96 +35,98 @@ import org.onap.appc.client.lcm.model.Status;
import org.onap.so.BaseTest;
import java.util.Properties;
import java.util.UUID;
-
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class ApplicationControllerClientV2Test {
- @Mock
- ApplicationControllerSupport applicationControllerSupport;
+ @Mock
+ ApplicationControllerSupport applicationControllerSupport;
+
+ @Mock
+ ApplicationControllerConfiguration applicationControllerConfiguration;
+
+ @InjectMocks
+ ApplicationControllerClientV2 client;
+
- @Mock
- ApplicationControllerConfiguration applicationControllerConfiguration;
+ @Before
+ public void setup() {
+ when(applicationControllerConfiguration.getReadTopic()).thenReturn("APPC-TEST-AMDOCS2");
+ when(applicationControllerConfiguration.getReadTimeout()).thenReturn("120000");
+ when(applicationControllerConfiguration.getResponseTimeout()).thenReturn("120000");
+ when(applicationControllerConfiguration.getWrite()).thenReturn("APPC-TEST-AMDOCS1-DEV3");
+ when(applicationControllerConfiguration.getService()).thenReturn("ueb");
+ when(applicationControllerConfiguration.getPoolMembers())
+ .thenReturn("localhost:3904,localhost:3904,localhost:3904");
+ when(applicationControllerConfiguration.getClientKey()).thenReturn("iaEMAfjsVsZnraBP");
+ when(applicationControllerConfiguration.getClientSecret()).thenReturn("wcivUjsjXzmGFBfxMmyJu9dz");
+ // client.buildClient();
+ }
- @InjectMocks
- ApplicationControllerClientV2 client;
+ @BeforeClass
+ public static void beforeClass() {
+ System.setProperty("mso.config.path", "src/test/resources");
+ }
+ @Ignore
+ @Test
+ public void createRequest_CheckLock_RequestBuilt() {
+ ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
+ actionIdentifiers.setVnfId("vnfId");
+ // when(applicationControllerSupport.getInput(eq(Action.CheckLock.name()))).thenReturn(new CheckLockInput());
+ CheckLockInput checkLockInput =
+ (CheckLockInput) client.createRequest(Action.CheckLock, actionIdentifiers, null, "requestId");
+ assertEquals(checkLockInput.getAction().name(), "CheckLock");
+ }
- @Before
- public void setup(){
- when(applicationControllerConfiguration.getReadTopic()).thenReturn("APPC-TEST-AMDOCS2");
- when(applicationControllerConfiguration.getReadTimeout()).thenReturn("120000");
- when(applicationControllerConfiguration.getResponseTimeout()).thenReturn("120000");
- when(applicationControllerConfiguration.getWrite()).thenReturn("APPC-TEST-AMDOCS1-DEV3");
- when(applicationControllerConfiguration.getService()).thenReturn("ueb");
- when(applicationControllerConfiguration.getPoolMembers()).thenReturn("localhost:3904,localhost:3904,localhost:3904");
- when(applicationControllerConfiguration.getClientKey()).thenReturn("iaEMAfjsVsZnraBP");
- when(applicationControllerConfiguration.getClientSecret()).thenReturn("wcivUjsjXzmGFBfxMmyJu9dz");
- //client.buildClient();
- }
- @BeforeClass
- public static void beforeClass() {
- System.setProperty("mso.config.path", "src/test/resources");
- }
- @Ignore
- @Test
- public void createRequest_CheckLock_RequestBuilt() {
- ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
- actionIdentifiers.setVnfId("vnfId");
- // when(applicationControllerSupport.getInput(eq(Action.CheckLock.name()))).thenReturn(new CheckLockInput());
- CheckLockInput checkLockInput = (CheckLockInput) client.createRequest(Action.CheckLock, actionIdentifiers, null,
- "requestId");
- assertEquals(checkLockInput.getAction().name(), "CheckLock");
- }
- @Ignore
- @Test
- public void runCommand_liveAppc() {
- ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
- //actionIdentifiers.setVnfId("ca522254-2ba4-4fbd-b15b-0ef0d9cfda5f");
- actionIdentifiers.setVnfId("2d2bf10e-81a5-");
- Status status;
- //when(applicationControllerSupport.getInput(eq(Action.Lock.name()))).thenReturn(new LockInput());
- //when(applicationControllerSupport.getAPIMethod(anyString(),any(),anyBoolean())).thenCallRealMethod();
- try {
- status = client.runCommand(Action.Lock, actionIdentifiers, null, UUID.randomUUID().toString());
- } catch (ApplicationControllerOrchestratorException e) {
- status = new Status();
- status.setCode(e.getAppcCode());
- status.setMessage(e.getMessage());
- }
- assertEquals("Status of run command is correct", status.getCode(), 306);
- }
+ @Ignore
+ @Test
+ public void runCommand_liveAppc() {
+ ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
+ // actionIdentifiers.setVnfId("ca522254-2ba4-4fbd-b15b-0ef0d9cfda5f");
+ actionIdentifiers.setVnfId("2d2bf10e-81a5-");
+ Status status;
+ // when(applicationControllerSupport.getInput(eq(Action.Lock.name()))).thenReturn(new LockInput());
+ // when(applicationControllerSupport.getAPIMethod(anyString(),any(),anyBoolean())).thenCallRealMethod();
+ try {
+ status = client.runCommand(Action.Lock, actionIdentifiers, null, UUID.randomUUID().toString());
+ } catch (ApplicationControllerOrchestratorException e) {
+ status = new Status();
+ status.setCode(e.getAppcCode());
+ status.setMessage(e.getMessage());
+ }
+ assertEquals("Status of run command is correct", status.getCode(), 306);
+ }
- @Ignore
- @Test
- public void runCommand_CheckLock_RequestBuilt() {
- ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
- actionIdentifiers.setVnfId("fusion-vpp-vnf-001");
- Status status;
- try {
- status = client.runCommand(Action.Unlock, actionIdentifiers, null, "requestId");
- } catch (ApplicationControllerOrchestratorException e) {
- status = new Status();
- status.setCode(e.getAppcCode());
- status.setMessage(e.getMessage());
- }
- assertEquals("Status of run command is correct", status.getCode(), 309);
- }
+ @Ignore
+ @Test
+ public void runCommand_CheckLock_RequestBuilt() {
+ ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
+ actionIdentifiers.setVnfId("fusion-vpp-vnf-001");
+ Status status;
+ try {
+ status = client.runCommand(Action.Unlock, actionIdentifiers, null, "requestId");
+ } catch (ApplicationControllerOrchestratorException e) {
+ status = new Status();
+ status.setCode(e.getAppcCode());
+ status.setMessage(e.getMessage());
+ }
+ assertEquals("Status of run command is correct", status.getCode(), 309);
+ }
- @Ignore
- @Test
- public void test_getLCMPropertiesHelper() {
- Properties properties = client.getLCMProperties("");
- assertEquals(properties.get("topic.write"), "APPC-TEST-AMDOCS1-DEV3");
- assertEquals(properties.get("topic.read.timeout"), "120000");
- assertEquals(properties.get("client.response.timeout"), "120000");
- assertEquals(properties.get("topic.read"), "APPC-TEST-AMDOCS2");
- assertEquals(properties.get("poolMembers"),
- "localhost:3904,localhost:3904,localhost:3904");
- assertEquals(properties.get("client.key"), "iaEMAfjsVsZnraBP");
- assertEquals(properties.get("client.secret"), "wcivUjsjXzmGFBfxMmyJu9dz");
- }
+ @Ignore
+ @Test
+ public void test_getLCMPropertiesHelper() {
+ Properties properties = client.getLCMProperties("");
+ assertEquals(properties.get("topic.write"), "APPC-TEST-AMDOCS1-DEV3");
+ assertEquals(properties.get("topic.read.timeout"), "120000");
+ assertEquals(properties.get("client.response.timeout"), "120000");
+ assertEquals(properties.get("topic.read"), "APPC-TEST-AMDOCS2");
+ assertEquals(properties.get("poolMembers"), "localhost:3904,localhost:3904,localhost:3904");
+ assertEquals(properties.get("client.key"), "iaEMAfjsVsZnraBP");
+ assertEquals(properties.get("client.secret"), "wcivUjsjXzmGFBfxMmyJu9dz");
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerSupportTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerSupportTest.java
index b388d8ba0a..9a7e1716cd 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerSupportTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerSupportTest.java
@@ -21,7 +21,6 @@
package org.onap.so.client.appc;
import static org.assertj.core.api.Assertions.assertThat;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.appc.client.lcm.model.Status;
@@ -31,54 +30,39 @@ import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
@RunWith(JUnitParamsRunner.class)
-public class ApplicationControllerSupportTest{
+public class ApplicationControllerSupportTest {
- public static Object[][] statusesAndCategories() {
- return new Object[][]{
- {100, StatusCategory.NORMAL},
- {200, StatusCategory.ERROR},
- {300, StatusCategory.ERROR},
- {400, StatusCategory.NORMAL},
- {401, StatusCategory.ERROR},
- {500, StatusCategory.NORMAL},
- {501, StatusCategory.ERROR},
- {502, StatusCategory.WARNING},
- {800, StatusCategory.WARNING},
- };
- }
+ public static Object[][] statusesAndCategories() {
+ return new Object[][] {{100, StatusCategory.NORMAL}, {200, StatusCategory.ERROR}, {300, StatusCategory.ERROR},
+ {400, StatusCategory.NORMAL}, {401, StatusCategory.ERROR}, {500, StatusCategory.NORMAL},
+ {501, StatusCategory.ERROR}, {502, StatusCategory.WARNING}, {800, StatusCategory.WARNING},};
+ }
- public static Object[][] statusesAndFinalities() {
- return new Object[][]{
- {100, false},
- {200, true},
- {300, true},
- {400, true},
- {500, false},
- {800, true},
- };
- }
+ public static Object[][] statusesAndFinalities() {
+ return new Object[][] {{100, false}, {200, true}, {300, true}, {400, true}, {500, false}, {800, true},};
+ }
- @Test
- @Parameters(method = "statusesAndCategories")
- public void shouldReturnCategoryForCode(int code, StatusCategory category) throws Exception {
- // when
- StatusCategory detectedCategory = ApplicationControllerSupport.getCategoryOf(createStatus(code));
- // then
- assertThat(detectedCategory).isEqualTo(category);
- }
+ @Test
+ @Parameters(method = "statusesAndCategories")
+ public void shouldReturnCategoryForCode(int code, StatusCategory category) throws Exception {
+ // when
+ StatusCategory detectedCategory = ApplicationControllerSupport.getCategoryOf(createStatus(code));
+ // then
+ assertThat(detectedCategory).isEqualTo(category);
+ }
- @Test
- @Parameters(method = "statusesAndFinalities")
- public void shouldReturnFinalityForCode(int code, boolean expectedFinality) throws Exception {
- // when
- boolean finality = ApplicationControllerSupport.getFinalityOf(createStatus(code));
- // then
- assertThat(finality).isEqualTo(expectedFinality);
- }
+ @Test
+ @Parameters(method = "statusesAndFinalities")
+ public void shouldReturnFinalityForCode(int code, boolean expectedFinality) throws Exception {
+ // when
+ boolean finality = ApplicationControllerSupport.getFinalityOf(createStatus(code));
+ // then
+ assertThat(finality).isEqualTo(expectedFinality);
+ }
- private Status createStatus(int code) {
- Status status = new Status();
- status.setCode(code);
- return status;
- }
-} \ No newline at end of file
+ private Status createStatus(int code) {
+ Status status = new Status();
+ status.setCode(code);
+ return status;
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/avpn/dmaap/beans/AVPNDmaapBeansTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/avpn/dmaap/beans/AVPNDmaapBeansTest.java
index 30ab21b2dd..cb0d31b8ff 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/avpn/dmaap/beans/AVPNDmaapBeansTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/avpn/dmaap/beans/AVPNDmaapBeansTest.java
@@ -21,13 +21,10 @@
package org.onap.so.client.avpn.dmaap.beans;
import static org.junit.Assert.assertNotNull;
-
import java.util.List;
-
import org.junit.Test;
import org.onap.so.BaseTest;
import org.onap.so.openpojo.rules.ToStringTester;
-
import com.openpojo.reflection.PojoClass;
import com.openpojo.reflection.filters.FilterPackageInfo;
import com.openpojo.reflection.impl.PojoClassFactory;
@@ -39,28 +36,22 @@ import com.openpojo.validation.rule.impl.SetterMustExistRule;
import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
-public class AVPNDmaapBeansTest extends BaseTest{
+public class AVPNDmaapBeansTest extends BaseTest {
- private static final int EXPECTED_CLASS_COUNT = 5;
- private static final String POJO_PACKAGE = "org.onap.so.client.avpn.dmaap.beans";
+ private static final int EXPECTED_CLASS_COUNT = 5;
+ private static final String POJO_PACKAGE = "org.onap.so.client.avpn.dmaap.beans";
- @Test
- public void ensureExpectedPojoCount() {
- List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses( POJO_PACKAGE,
- new FilterPackageInfo());
- Affirm.affirmEquals("Classes added / removed?", EXPECTED_CLASS_COUNT, pojoClasses.size());
- }
+ @Test
+ public void ensureExpectedPojoCount() {
+ List<PojoClass> pojoClasses = PojoClassFactory.getPojoClasses(POJO_PACKAGE, new FilterPackageInfo());
+ Affirm.affirmEquals("Classes added / removed?", EXPECTED_CLASS_COUNT, pojoClasses.size());
+ }
- @Test
- public void testPojoStructureAndBehavior() {
- Validator validator = ValidatorBuilder.create()
- .with(new GetterMustExistRule())
- .with(new SetterMustExistRule())
- .with(new SetterTester())
- .with(new GetterTester())
- .with(new ToStringTester())
- .build();
+ @Test
+ public void testPojoStructureAndBehavior() {
+ Validator validator = ValidatorBuilder.create().with(new GetterMustExistRule()).with(new SetterMustExistRule())
+ .with(new SetterTester()).with(new GetterTester()).with(new ToStringTester()).build();
- validator.validate(POJO_PACKAGE, new FilterPackageInfo());
- }
+ validator.validate(POJO_PACKAGE, new FilterPackageInfo());
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java
index 161f879716..f558932d33 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractCDSProcessingBBUtilsTest.java
@@ -26,9 +26,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-
import java.util.UUID;
-
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.junit.Before;
import org.junit.Test;
@@ -49,8 +47,9 @@ public class AbstractCDSProcessingBBUtilsTest {
ExceptionBuilder exceptionUtil;
@Before
- public void init(){
- String requestObject = "{\"config-assign-request\":{\"resolution-key\":\"resolutionKey\", \"config-assign-properties\":{\"service-instance-id\":\"serviceInstanceId\", \"vnf-id\":\"vnfId\", \"vnf-name\":\"vnfName\", \"service-model-uuid\":\"serviceModelUuid\", \"vnf-customization-uuid\":\"vnfCustomizationUuid\",\"Instance1\":\"Instance1Value\",\"Instance2\":\"Instance2Value\",\"Param3\":\"Param3Value\"}}}";
+ public void init() {
+ String requestObject =
+ "{\"config-assign-request\":{\"resolution-key\":\"resolutionKey\", \"config-assign-properties\":{\"service-instance-id\":\"serviceInstanceId\", \"vnf-id\":\"vnfId\", \"vnf-name\":\"vnfName\", \"service-model-uuid\":\"serviceModelUuid\", \"vnf-customization-uuid\":\"vnfCustomizationUuid\",\"Instance1\":\"Instance1Value\",\"Instance2\":\"Instance2Value\",\"Param3\":\"Param3Value\"}}}";
String blueprintName = "blueprintName";
String blueprintVersion = "blueprintVersion";
String actionName = "actionName";
@@ -76,8 +75,8 @@ public class AbstractCDSProcessingBBUtilsTest {
when(execution.getVariable("executionObject")).thenReturn(abstractCDSPropertiesBean);
abstractCDSProcessingBBUtils.constructExecutionServiceInputObject(execution);
- verify(exceptionUtil, times(0))
- .buildAndThrowWorkflowException(any(DelegateExecution.class), anyInt(), any(Exception.class));
+ verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(DelegateExecution.class), anyInt(),
+ any(Exception.class));
}
@Test
@@ -86,8 +85,8 @@ public class AbstractCDSProcessingBBUtilsTest {
DelegateExecution execution = mock(DelegateExecution.class);
when(execution.getVariable("executionServiceInput")).thenReturn(abstractCDSPropertiesBean);
abstractCDSProcessingBBUtils.sendRequestToCDSClient(execution);
- verify(exceptionUtil, times(1))
- .buildAndThrowWorkflowException(any(DelegateExecution.class), anyInt(), any(Exception.class));
+ verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(DelegateExecution.class), anyInt(),
+ any(Exception.class));
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForPnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForPnfTest.java
index c294124e69..3eadd800ad 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForPnfTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForPnfTest.java
@@ -2,10 +2,8 @@ package org.onap.so.client.cds.beans;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Test;
public class ConfigAssignPropertiesForPnfTest {
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForVnfTest.java
index 8b732af6d0..4b91cdf803 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForVnfTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignPropertiesForVnfTest.java
@@ -2,10 +2,8 @@ package org.onap.so.client.cds.beans;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Test;
public class ConfigAssignPropertiesForVnfTest {
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignRequestPnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignRequestPnfTest.java
index e4f062ad05..da82721e5e 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignRequestPnfTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignRequestPnfTest.java
@@ -2,10 +2,8 @@ package org.onap.so.client.cds.beans;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Test;
public class ConfigAssignRequestPnfTest {
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignRequestVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignRequestVnfTest.java
index ad3af47453..a73fa6c01e 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignRequestVnfTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigAssignRequestVnfTest.java
@@ -2,10 +2,8 @@ package org.onap.so.client.cds.beans;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import java.util.HashMap;
import java.util.Map;
-
import org.junit.Test;
public class ConfigAssignRequestVnfTest {
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnfTest.java
index 8e16ce6337..771196d53c 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnfTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForPnfTest.java
@@ -2,7 +2,6 @@ package org.onap.so.client.cds.beans;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import org.junit.Before;
import org.junit.Test;
@@ -18,7 +17,7 @@ public class ConfigDeployPropertiesForPnfTest {
private static final String TEST_SERVICE_INSTANCE_ID = "service-instance-id";
@Before
- public void setUp(){
+ public void setUp() {
configDeployPropertiesForPnf.setServiceInstanceId(TEST_SERVICE_INSTANCE_ID);
configDeployPropertiesForPnf.setServiceModelUuid(TEST_SERVICE_MODEL_UUID);
configDeployPropertiesForPnf.setPnfCustomizationUuid(TEST_PNF_CUSTOMIZATION_UUID);
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForVnfTest.java
index 47c59b93e9..6039bd649c 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForVnfTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployPropertiesForVnfTest.java
@@ -2,7 +2,6 @@ package org.onap.so.client.cds.beans;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import org.junit.Test;
public class ConfigDeployPropertiesForVnfTest {
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployRequestPnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployRequestPnfTest.java
index df41bf23b8..a977f8dd9e 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployRequestPnfTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployRequestPnfTest.java
@@ -2,7 +2,6 @@ package org.onap.so.client.cds.beans;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import org.junit.Test;
public class ConfigDeployRequestPnfTest {
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployRequestVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployRequestVnfTest.java
index f771710f8b..4b86eeb438 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployRequestVnfTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/beans/ConfigDeployRequestVnfTest.java
@@ -2,7 +2,6 @@ package org.onap.so.client.cds.beans;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-
import org.junit.Test;
public class ConfigDeployRequestVnfTest {
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java
index 886025cb51..a6b97d086e 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/DmaapPropertiesClientTest.java
@@ -28,10 +28,8 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.io.File;
import java.io.IOException;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
@@ -41,61 +39,63 @@ import org.onap.so.client.avpn.dmaap.beans.AVPNDmaapBean;
import org.onap.so.client.exception.MapperException;
import org.onap.so.client.dmaapproperties.GlobalDmaapPublisher;
import org.springframework.beans.factory.annotation.Autowired;
-
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-public class DmaapPropertiesClientTest extends BaseTest{
-
- @Autowired
- private DmaapPropertiesClient dmaapPropertiesClient;
+public class DmaapPropertiesClientTest extends BaseTest {
+
+ @Autowired
+ private DmaapPropertiesClient dmaapPropertiesClient;
+
+
+ private final String file = "src/test/resources/org/onap/so/client/avpn/dmaap/avpnDmaapAsyncRequestStatus.json";
+ private String requestId = "rq1234d1-5a33-55df-13ab-12abad84e331";
+ private String clientSource = "SPP";
+ private String correlator = "myClientId123";
+ private String serviceInstanceId = "bc305d54-75b4-431b-adb2-eb6b9e546014";
+ private String startTime = "2017-11-17T09:30:47Z";
+ private String finishTime = "2017-11-17T09:30:47Z";
+ private String requestScope = "service";
+ private String requestType = "createInstance";
+ private String timestamp = "2017-11-17T09:30:47Z";
+ private String requestState = "COMPLETE";
+ private String statusMessage = "Success";
+ private String percentProgress = "100";
+
+ @Test
+ public void testBuildRequestJson() throws MapperException, IOException {
+ AVPNDmaapBean actualBean = dmaapPropertiesClient.buildRequestJson(requestId, clientSource, correlator,
+ serviceInstanceId, startTime, finishTime, requestScope, requestType, timestamp, requestState,
+ statusMessage, percentProgress, true);
+
+ AVPNDmaapBean expected = new ObjectMapper().readValue(new File(file), AVPNDmaapBean.class);
+
+ assertNotNull(actualBean);
+ assertThat(actualBean, sameBeanAs(expected));
+ }
+
+ @Test
+ public void testDmaapPublishRequest() throws JsonProcessingException, MapperException {
+ DmaapPropertiesClient client = Mockito.spy(DmaapPropertiesClient.class);
+ GlobalDmaapPublisher mockedClientDmaapPublisher = Mockito.mock(GlobalDmaapPublisher.class);
+ AVPNDmaapBean mockedDmaapBean = Mockito.mock(AVPNDmaapBean.class);
+ String request = "test";
+ doReturn(mockedDmaapBean).when(client).buildRequestJson(requestId, clientSource, correlator, serviceInstanceId,
+ startTime, finishTime, requestScope, requestType, timestamp, requestState, statusMessage,
+ percentProgress, false);
- private final String file = "src/test/resources/org/onap/so/client/avpn/dmaap/avpnDmaapAsyncRequestStatus.json";
- private String requestId = "rq1234d1-5a33-55df-13ab-12abad84e331";
- private String clientSource = "SPP";
- private String correlator = "myClientId123";
- private String serviceInstanceId = "bc305d54-75b4-431b-adb2-eb6b9e546014";
- private String startTime = "2017-11-17T09:30:47Z";
- private String finishTime = "2017-11-17T09:30:47Z";
- private String requestScope = "service";
- private String requestType = "createInstance";
- private String timestamp = "2017-11-17T09:30:47Z";
- private String requestState = "COMPLETE";
- private String statusMessage = "Success";
- private String percentProgress = "100";
-
- @Test
- public void testBuildRequestJson() throws MapperException, IOException {
- AVPNDmaapBean actualBean = dmaapPropertiesClient.buildRequestJson(requestId, clientSource, correlator, serviceInstanceId, startTime, finishTime, requestScope,
- requestType, timestamp, requestState, statusMessage, percentProgress, true);
+ AVPNDmaapBean actualDmaapBean =
+ client.buildRequestJson(requestId, clientSource, correlator, serviceInstanceId, startTime, finishTime,
+ requestScope, requestType, timestamp, requestState, statusMessage, percentProgress, false);
+ mockedClientDmaapPublisher.send(request);
- AVPNDmaapBean expected = new ObjectMapper().readValue(new File(file), AVPNDmaapBean.class);
+ doNothing().when(mockedClientDmaapPublisher).send(anyString());
- assertNotNull(actualBean);
- assertThat(actualBean, sameBeanAs(expected));
- }
+ verify(client, times(1)).buildRequestJson(requestId, clientSource, correlator, serviceInstanceId, startTime,
+ finishTime, requestScope, requestType, timestamp, requestState, statusMessage, percentProgress, false);
+ verify(mockedClientDmaapPublisher, times(1)).send(request);
- @Test
- public void testDmaapPublishRequest() throws JsonProcessingException, MapperException {
- DmaapPropertiesClient client = Mockito.spy(DmaapPropertiesClient.class);
- GlobalDmaapPublisher mockedClientDmaapPublisher = Mockito.mock(GlobalDmaapPublisher.class);
- AVPNDmaapBean mockedDmaapBean = Mockito.mock(AVPNDmaapBean.class);
- String request = "test";
-
- doReturn(mockedDmaapBean).when(client).buildRequestJson(requestId, clientSource, correlator, serviceInstanceId, startTime, finishTime, requestScope,
- requestType, timestamp, requestState, statusMessage, percentProgress, false);
-
- AVPNDmaapBean actualDmaapBean = client.buildRequestJson(requestId, clientSource, correlator, serviceInstanceId, startTime, finishTime, requestScope,
- requestType, timestamp, requestState, statusMessage, percentProgress, false);
- mockedClientDmaapPublisher.send(request);
-
- doNothing().when(mockedClientDmaapPublisher).send(anyString());
-
- verify(client, times(1)).buildRequestJson(requestId, clientSource, correlator, serviceInstanceId, startTime,
- finishTime, requestScope, requestType, timestamp, requestState, statusMessage, percentProgress, false);
- verify(mockedClientDmaapPublisher, times(1)).send(request);
-
- assertNotNull(actualDmaapBean);
- }
+ assertNotNull(actualDmaapBean);
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java
index 088b01873c..b71d5f9113 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/dmaapproperties/GlobalDmaapPublisherTest.java
@@ -21,27 +21,28 @@
package org.onap.so.client.dmaapproperties;
import static org.junit.Assert.assertEquals;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.so.BaseTest;
import org.springframework.beans.factory.annotation.Autowired;
-public class GlobalDmaapPublisherTest extends BaseTest{
+public class GlobalDmaapPublisherTest extends BaseTest {
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ System.setProperty("mso.global.dmaap.host", "http://test:1234");
+ }
+
+ @Autowired
+ private GlobalDmaapPublisher globalDmaapPublisher;
- @BeforeClass
- public static void setUp() throws Exception {
- System.setProperty("mso.global.dmaap.host", "http://test:1234");
- }
-
- @Autowired
- private GlobalDmaapPublisher globalDmaapPublisher;
-
- @Test
- public void testGetters() {
- assertEquals("81B7E3533B91A6706830611FB9A8ECE529BBCCE754B1F1520FA7C8698B42F97235BEFA993A387E664D6352C63A6185D68DA7F0B1D360637CBA102CB166E3E62C11EB1F75386D3506BCECE51E54", globalDmaapPublisher.getAuth());
- assertEquals("07a7159d3bf51a0e53be7a8f89699be7", globalDmaapPublisher.getKey());
- assertEquals("com.att.mso.asyncStatusUpdate", globalDmaapPublisher.getTopic());
- assertEquals("http://test:1234", globalDmaapPublisher.getHost().get());
- }
+ @Test
+ public void testGetters() {
+ assertEquals(
+ "81B7E3533B91A6706830611FB9A8ECE529BBCCE754B1F1520FA7C8698B42F97235BEFA993A387E664D6352C63A6185D68DA7F0B1D360637CBA102CB166E3E62C11EB1F75386D3506BCECE51E54",
+ globalDmaapPublisher.getAuth());
+ assertEquals("07a7159d3bf51a0e53be7a8f89699be7", globalDmaapPublisher.getKey());
+ assertEquals("com.att.mso.asyncStatusUpdate", globalDmaapPublisher.getTopic());
+ assertEquals("http://test:1234", globalDmaapPublisher.getHost().get());
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java
index 2e25449937..ef066853ca 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java
@@ -29,49 +29,52 @@ import org.onap.so.BaseTest;
public class ExceptionBuilderTest extends BaseTest {
- private static final String RESOURCE_PATH = "__files/";
- private static final String VALID_ERROR_MESSAGE = "{test error message}";
+ private static final String RESOURCE_PATH = "__files/";
+ private static final String VALID_ERROR_MESSAGE = "{test error message}";
- @Test
- public void buildAndThrowWorkflowExceptionTest() {
- try {
- ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, new NullPointerException(VALID_ERROR_MESSAGE));
- } catch (BpmnError bpmnException){
- assertEquals("MSOWorkflowException", bpmnException.getErrorCode());
- }
- }
+ @Test
+ public void buildAndThrowWorkflowExceptionTest() {
+ try {
+ ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,
+ new NullPointerException(VALID_ERROR_MESSAGE));
+ } catch (BpmnError bpmnException) {
+ assertEquals("MSOWorkflowException", bpmnException.getErrorCode());
+ }
+ }
- @Test
- public void buildAndThrowWorkflowExceptionInvalidMessageTest() {
- try{
- ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
- String invalidErrorMessage = FileUtil.readResourceFile(RESOURCE_PATH + "invalidErrorMessage.txt");
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, new NullPointerException(invalidErrorMessage));
- } catch (BpmnError bpmnException){
- assertEquals("MSOWorkflowException", bpmnException.getErrorCode());
- }
- }
-
- @Test
- public void buildAndThrowWorkflowExceptionInvalidMessageFlagTest() {
- try{
- ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
- String invalidErrorMessage = FileUtil.readResourceFile(RESOURCE_PATH + "invalidErrorMessageFlag.txt");
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, new NullPointerException(invalidErrorMessage));
- } catch (BpmnError bpmnException){
- assertEquals("MSOWorkflowException", bpmnException.getErrorCode());
- }
- }
-
- @Test
- public void buildAndThrowWorkflowExceptionNullMessageTest() {
- try{
- ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
- exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, new NullPointerException());
- } catch (BpmnError bpmnException){
- assertEquals("MSOWorkflowException", bpmnException.getErrorCode());
- }
- }
+ @Test
+ public void buildAndThrowWorkflowExceptionInvalidMessageTest() {
+ try {
+ ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
+ String invalidErrorMessage = FileUtil.readResourceFile(RESOURCE_PATH + "invalidErrorMessage.txt");
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,
+ new NullPointerException(invalidErrorMessage));
+ } catch (BpmnError bpmnException) {
+ assertEquals("MSOWorkflowException", bpmnException.getErrorCode());
+ }
+ }
+
+ @Test
+ public void buildAndThrowWorkflowExceptionInvalidMessageFlagTest() {
+ try {
+ ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
+ String invalidErrorMessage = FileUtil.readResourceFile(RESOURCE_PATH + "invalidErrorMessageFlag.txt");
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000,
+ new NullPointerException(invalidErrorMessage));
+ } catch (BpmnError bpmnException) {
+ assertEquals("MSOWorkflowException", bpmnException.getErrorCode());
+ }
+ }
+
+ @Test
+ public void buildAndThrowWorkflowExceptionNullMessageTest() {
+ try {
+ ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
+ exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, new NullPointerException());
+ } catch (BpmnError bpmnException) {
+ assertEquals("MSOWorkflowException", bpmnException.getErrorCode());
+ }
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/AAIPropertiesImplTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/AAIPropertiesImplTest.java
index 2e74d443bd..0d6fede4bf 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/AAIPropertiesImplTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/AAIPropertiesImplTest.java
@@ -21,30 +21,28 @@
package org.onap.so.client.restproperties;
import static org.junit.Assert.assertEquals;
-
import java.net.MalformedURLException;
import java.net.URL;
-
import org.junit.Test;
import org.onap.so.client.aai.AAIVersion;
-public class AAIPropertiesImplTest{
+public class AAIPropertiesImplTest {
+
+ private AAIPropertiesImpl aaiPropertiesImpl = new AAIPropertiesImpl();
+
+ @Test
+ public void getEndpointTest() throws MalformedURLException {
+ assertEquals("aai.endpoint", AAIPropertiesImpl.AAI_ENDPOINT);
+ }
+
+ @Test
+ public void getAuthTest() {
+ String expectedAuth = "aai.auth";
+ assertEquals(expectedAuth, AAIPropertiesImpl.AAI_AUTH);
+ }
- private AAIPropertiesImpl aaiPropertiesImpl = new AAIPropertiesImpl();
-
- @Test
- public void getEndpointTest() throws MalformedURLException {
- assertEquals("aai.endpoint", AAIPropertiesImpl.AAI_ENDPOINT);
- }
-
- @Test
- public void getAuthTest() {
- String expectedAuth = "aai.auth";
- assertEquals(expectedAuth, AAIPropertiesImpl.AAI_AUTH);
- }
-
- @Test
- public void getKeyTest() {
- assertEquals("mso.msoKey", AAIPropertiesImpl.MSO_MSO_KEY);
- }
+ @Test
+ public void getKeyTest() {
+ assertEquals("mso.msoKey", AAIPropertiesImpl.MSO_MSO_KEY);
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/PolicyRestPropertiesImplTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/PolicyRestPropertiesImplTest.java
index d1de702a81..528e4f99cb 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/PolicyRestPropertiesImplTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/PolicyRestPropertiesImplTest.java
@@ -21,32 +21,30 @@
package org.onap.so.client.restproperties;
import static org.junit.Assert.assertEquals;
-
import java.net.MalformedURLException;
import java.net.URL;
-
import org.junit.Test;
public class PolicyRestPropertiesImplTest {
-
-
- @Test
- public void getEndpointTest() throws MalformedURLException {
- assertEquals("policy.endpoint", PolicyRestPropertiesImpl.POLICY_ENDPOINT);
- }
-
- @Test
- public void getEnvironmentTest() {
- assertEquals("policy.environment", PolicyRestPropertiesImpl.POLICY_ENVIRONMENT);
- }
-
- @Test
- public void getClientAuthTest() {
- assertEquals("policy.auth", PolicyRestPropertiesImpl.POLICY_AUTH);
- }
-
- @Test
- public void getAuthTest() {
- assertEquals("policy.client.auth", PolicyRestPropertiesImpl.POLICY_CLIENT_AUTH);
- }
+
+
+ @Test
+ public void getEndpointTest() throws MalformedURLException {
+ assertEquals("policy.endpoint", PolicyRestPropertiesImpl.POLICY_ENDPOINT);
+ }
+
+ @Test
+ public void getEnvironmentTest() {
+ assertEquals("policy.environment", PolicyRestPropertiesImpl.POLICY_ENVIRONMENT);
+ }
+
+ @Test
+ public void getClientAuthTest() {
+ assertEquals("policy.auth", PolicyRestPropertiesImpl.POLICY_AUTH);
+ }
+
+ @Test
+ public void getAuthTest() {
+ assertEquals("policy.client.auth", PolicyRestPropertiesImpl.POLICY_CLIENT_AUTH);
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/ThreadedReadTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/ThreadedReadTest.java
index 08c92d33f0..badf444fc6 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/ThreadedReadTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/restproperties/ThreadedReadTest.java
@@ -22,7 +22,6 @@ package org.onap.so.client.restproperties;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
-
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -34,71 +33,70 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-
import org.junit.Test;
import org.onap.so.client.RestPropertiesLoader;
import org.onap.so.client.aai.AAIProperties;
import org.onap.so.BaseTest;
public class ThreadedReadTest {
- @Test
- public void allAtOnce() throws InterruptedException {
- ExecutorService executorService = Executors.newFixedThreadPool(10);
-
- Callable<AAIProperties> callableTask = () -> {
- return RestPropertiesLoader.getInstance().getNewImpl(AAIProperties.class);
- };
- List<Callable<AAIProperties>> callableTasks = new ArrayList<>();
-
- callableTasks.add(callableTask);
- callableTasks.add(callableTask);
- callableTasks.add(callableTask);
- callableTasks.add(callableTask);
- callableTasks.add(callableTask);
-
- List<Future<AAIProperties>> futures = executorService.invokeAll(callableTasks);
-
- Set<AAIProperties> results = new HashSet<>();
- futures.forEach(item -> {
- try {
- results.add(item.get());
- } catch (InterruptedException | ExecutionException e) {
- throw new RuntimeException(e);
- }
- });
-
- assertThat("expect all unique results", results.size(), equalTo(callableTasks.size()));
-
- }
-
- @Test
- public void executeOverTime() {
- ScheduledExecutorService executorService = Executors.newScheduledThreadPool(10);
-
- Callable<AAIProperties> callableTask = () -> {
- TimeUnit.MILLISECONDS.sleep(500);
- return RestPropertiesLoader.getInstance().getNewImpl(AAIProperties.class);
- };
- List<Callable<AAIProperties>> callableTasks = new ArrayList<>();
-
- callableTasks.add(callableTask);
- callableTasks.add(callableTask);
- callableTasks.add(callableTask);
- callableTasks.add(callableTask);
- callableTasks.add(callableTask);
-
- Set<AAIProperties> results = new HashSet<>();
- callableTasks.forEach(callable -> {
- try {
- TimeUnit.MILLISECONDS.sleep(300);
- Future<AAIProperties> result = executorService.submit(callable);
- results.add(result.get());
- } catch (InterruptedException | ExecutionException e) {
- throw new RuntimeException(e);
- }
- });
-
- assertThat("expect all unique results", results.size(), equalTo(callableTasks.size()));
- }
-
+ @Test
+ public void allAtOnce() throws InterruptedException {
+ ExecutorService executorService = Executors.newFixedThreadPool(10);
+
+ Callable<AAIProperties> callableTask = () -> {
+ return RestPropertiesLoader.getInstance().getNewImpl(AAIProperties.class);
+ };
+ List<Callable<AAIProperties>> callableTasks = new ArrayList<>();
+
+ callableTasks.add(callableTask);
+ callableTasks.add(callableTask);
+ callableTasks.add(callableTask);
+ callableTasks.add(callableTask);
+ callableTasks.add(callableTask);
+
+ List<Future<AAIProperties>> futures = executorService.invokeAll(callableTasks);
+
+ Set<AAIProperties> results = new HashSet<>();
+ futures.forEach(item -> {
+ try {
+ results.add(item.get());
+ } catch (InterruptedException | ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+ });
+
+ assertThat("expect all unique results", results.size(), equalTo(callableTasks.size()));
+
+ }
+
+ @Test
+ public void executeOverTime() {
+ ScheduledExecutorService executorService = Executors.newScheduledThreadPool(10);
+
+ Callable<AAIProperties> callableTask = () -> {
+ TimeUnit.MILLISECONDS.sleep(500);
+ return RestPropertiesLoader.getInstance().getNewImpl(AAIProperties.class);
+ };
+ List<Callable<AAIProperties>> callableTasks = new ArrayList<>();
+
+ callableTasks.add(callableTask);
+ callableTasks.add(callableTask);
+ callableTasks.add(callableTask);
+ callableTasks.add(callableTask);
+ callableTasks.add(callableTask);
+
+ Set<AAIProperties> results = new HashSet<>();
+ callableTasks.forEach(callable -> {
+ try {
+ TimeUnit.MILLISECONDS.sleep(300);
+ Future<AAIProperties> result = executorService.submit(callable);
+ results.add(result.get());
+ } catch (InterruptedException | ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+ });
+
+ assertThat("expect all unique results", results.size(), equalTo(callableTasks.size()));
+ }
+
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/test/categories/SpringAware.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/test/categories/SpringAware.java
index 21035fcd4d..2462e678d9 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/test/categories/SpringAware.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/test/categories/SpringAware.java
@@ -21,5 +21,5 @@
package org.onap.so.test.categories;
public interface SpringAware {
- /* category marker */
+ /* category marker */
}