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.camunda.bpm.engine.runtime.ProcessInstance;
35 import org.junit.Test;
36 import org.onap.so.BaseIntegrationTest;
37 import org.springframework.beans.factory.annotation.Autowired;
39 public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest {
41 private static final String TIMEOUT_10_S = "PT10S";
42 private static final String VALID_UUID = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString();
45 private AaiConnectionTestImpl aaiConnection;
48 private DmaapClientTestImpl dmaapClientTestImpl;
51 public void shouldWaitForMessageFromDmaapAndUpdateAaiEntryWhenAaiEntryExists() {
53 aaiConnection.reset();
54 Map<String, Object> variables = new HashMap<>();
55 variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S);
56 variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITH_ENTRY);
57 variables.put(PNF_UUID, VALID_UUID);
59 ProcessInstance instance = runtimeService
60 .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
61 assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage");
62 dmaapClientTestImpl.sendMessage();
65 assertThat(instance).isEnded().hasPassedInOrder(
66 "CreateAndActivatePnf_StartEvent",
68 "CheckAiiForCorrelationId",
69 "DoesAaiContainInfoAboutPnf",
72 "WaitForDmaapPnfReadyNotification",
78 public void shouldCreateAaiEntryWaitForMessageFromDmaapAndUpdateAaiEntryWhenNoAaiEntryExists() {
80 aaiConnection.reset();
82 Map<String, Object> variables = new HashMap<>();
83 variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S);
84 variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITHOUT_ENTRY);
85 variables.put(PNF_UUID, VALID_UUID);
87 ProcessInstance instance = runtimeService
88 .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
89 assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage");
90 dmaapClientTestImpl.sendMessage();
93 assertThat(instance).isEnded().hasPassedInOrder(
94 "CreateAndActivatePnf_StartEvent",
96 "CheckAiiForCorrelationId",
97 "DoesAaiContainInfoAboutPnf",
98 "CreatePnfEntryInAai",
101 "WaitForDmaapPnfReadyNotification",
104 Assertions.assertThat(aaiConnection.getCreated()).containsOnlyKeys(AaiConnectionTestImpl.ID_WITHOUT_ENTRY);