2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright 2018 Nokia
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.infrastructure.pnf.delegate;
25 import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat;
26 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
27 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
29 import java.util.HashMap;
32 import java.util.UUID;
33 import org.assertj.core.api.Assertions;
34 import org.assertj.core.data.MapEntry;
35 import org.camunda.bpm.engine.runtime.ProcessInstance;
36 import org.junit.Before;
37 import org.junit.Test;
38 import org.onap.so.BaseIntegrationTest;
39 import org.springframework.beans.factory.annotation.Autowired;
41 public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest {
43 private static final String VALID_UUID = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString();
44 private static final String SERVICE_INSTANCE_ID = "serviceForInstance";
46 private Map<String, Object> variables;
49 private PnfManagementTestImpl pnfManagementTest;
52 private DmaapClientTestImpl dmaapClientTestImpl;
56 pnfManagementTest.reset();
57 variables = new HashMap<>();
58 variables.put("serviceInstanceId", SERVICE_INSTANCE_ID);
59 variables.put(PNF_UUID, VALID_UUID);
63 public void shouldWaitForMessageFromDmaapAndUpdateAaiEntryWhenAaiEntryExists() {
65 variables.put(CORRELATION_ID, PnfManagementTestImpl.ID_WITH_ENTRY);
67 ProcessInstance instance = runtimeService
68 .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
69 assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage");
70 dmaapClientTestImpl.sendMessage();
73 assertThat(instance).isEnded().hasPassedInOrder(
74 "CreateAndActivatePnf_StartEvent",
76 "CheckAiiForCorrelationId",
77 "DoesAaiContainInfoAboutPnf",
80 "WaitForDmaapPnfReadyNotification",
84 Assertions.assertThat(pnfManagementTest.getServiceAndPnfRelationMap()).
85 containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID, PnfManagementTestImpl.ID_WITH_ENTRY));
89 public void shouldCreateAaiEntryWaitForMessageFromDmaapAndUpdateAaiEntryWhenNoAaiEntryExists() {
91 variables.put(CORRELATION_ID, PnfManagementTestImpl.ID_WITHOUT_ENTRY);
93 ProcessInstance instance = runtimeService
94 .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
95 assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage");
96 dmaapClientTestImpl.sendMessage();
99 assertThat(instance).isEnded().hasPassedInOrder(
100 "CreateAndActivatePnf_StartEvent",
102 "CheckAiiForCorrelationId",
103 "DoesAaiContainInfoAboutPnf",
104 "CreatePnfEntryInAai",
107 "WaitForDmaapPnfReadyNotification",
111 Assertions.assertThat(pnfManagementTest.getCreated()).containsOnlyKeys(PnfManagementTestImpl.ID_WITHOUT_ENTRY);
112 Assertions.assertThat(pnfManagementTest.getServiceAndPnfRelationMap()).
113 containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID, PnfManagementTestImpl.ID_WITHOUT_ENTRY));