Merge "fixed CandidateType json serialization"
[so.git] / bpmn / mso-infrastructure-bpmn / src / test / java / org / onap / so / bpmn / infrastructure / pnf / delegate / CreateAndActivatePnfResourceTest.java
index 74e5a6c..db6cbe0 100644 (file)
@@ -4,6 +4,8 @@
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright 2018 Nokia
+ * ================================================================================
  * 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
@@ -22,19 +24,26 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate;
 
 import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat;
 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
+import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
 
 import java.util.HashMap;
 import java.util.Map;
 
+import java.util.UUID;
 import org.assertj.core.api.Assertions;
+import org.assertj.core.data.MapEntry;
 import org.camunda.bpm.engine.runtime.ProcessInstance;
+import org.junit.Before;
 import org.junit.Test;
 import org.onap.so.BaseIntegrationTest;
 import org.springframework.beans.factory.annotation.Autowired;
 
 public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest {
 
-    private static final String TIMEOUT_10_S = "PT10S";
+    private static final String VALID_UUID = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString();
+    private static final String SERVICE_INSTANCE_ID = "serviceForInstance";
+
+    private Map<String, Object> variables;
 
     @Autowired
     private AaiConnectionTestImpl aaiConnection;
@@ -42,12 +51,17 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest {
     @Autowired
     private DmaapClientTestImpl dmaapClientTestImpl;
 
+    @Before
+    public void setup() {
+        aaiConnection.reset();
+        variables = new HashMap<>();
+        variables.put("serviceInstanceId", SERVICE_INSTANCE_ID);
+        variables.put(PNF_UUID, VALID_UUID);
+    }
+
     @Test
     public void shouldWaitForMessageFromDmaapAndUpdateAaiEntryWhenAaiEntryExists() {
         // given
-        aaiConnection.reset();       
-        Map<String, Object> variables = new HashMap<>();
-        variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S);
         variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITH_ENTRY);
         // when
         ProcessInstance instance = runtimeService
@@ -64,17 +78,16 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest {
                 "AaiEntryExists",
                 "InformDmaapClient",
                 "WaitForDmaapPnfReadyNotification",
+                "CreateRelationId",
                 "AaiEntryUpdated"
         );
+        Assertions.assertThat(aaiConnection.getServiceAndPnfRelationMap()).
+                containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID,AaiConnectionTestImpl.ID_WITH_ENTRY));
     }
 
     @Test
     public void shouldCreateAaiEntryWaitForMessageFromDmaapAndUpdateAaiEntryWhenNoAaiEntryExists() {
         // given
-        aaiConnection.reset();
-       
-        Map<String, Object> variables = new HashMap<>();
-        variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S);
         variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITHOUT_ENTRY);
         // when
         ProcessInstance instance = runtimeService
@@ -88,12 +101,15 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest {
                 "CheckInputs",
                 "CheckAiiForCorrelationId",
                 "DoesAaiContainInfoAboutPnf",
-                "CreateAndActivatePnf_CreateAaiEntry",
+                "CreatePnfEntryInAai",
                 "AaiEntryExists",
                 "InformDmaapClient",
                 "WaitForDmaapPnfReadyNotification",
+                "CreateRelationId",
                 "AaiEntryUpdated"
         );
         Assertions.assertThat(aaiConnection.getCreated()).containsOnlyKeys(AaiConnectionTestImpl.ID_WITHOUT_ENTRY);
+        Assertions.assertThat(aaiConnection.getServiceAndPnfRelationMap()).
+                containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID,AaiConnectionTestImpl.ID_WITHOUT_ENTRY));
     }
 }