2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.bpmn.infrastructure.pnf.delegate;
23 import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat;
24 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
26 import java.util.HashMap;
29 import org.assertj.core.api.Assertions;
30 import org.camunda.bpm.engine.runtime.ProcessInstance;
31 import org.junit.Test;
32 import org.onap.so.BaseIntegrationTest;
33 import org.springframework.beans.factory.annotation.Autowired;
35 public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest {
37 private static final String TIMEOUT_10_S = "PT10S";
40 private AaiConnectionTestImpl aaiConnection;
43 private DmaapClientTestImpl dmaapClientTestImpl;
46 public void shouldWaitForMessageFromDmaapAndUpdateAaiEntryWhenAaiEntryExists() {
48 aaiConnection.reset();
49 Map<String, Object> variables = new HashMap<>();
50 variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S);
51 variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITH_ENTRY);
53 ProcessInstance instance = runtimeService
54 .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
55 assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage");
56 dmaapClientTestImpl.sendMessage();
59 assertThat(instance).isEnded().hasPassedInOrder(
60 "CreateAndActivatePnf_StartEvent",
62 "CheckAiiForCorrelationId",
63 "DoesAaiContainInfoAboutPnf",
66 "WaitForDmaapPnfReadyNotification",
72 public void shouldCreateAaiEntryWaitForMessageFromDmaapAndUpdateAaiEntryWhenNoAaiEntryExists() {
74 aaiConnection.reset();
76 Map<String, Object> variables = new HashMap<>();
77 variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S);
78 variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITHOUT_ENTRY);
80 ProcessInstance instance = runtimeService
81 .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables);
82 assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage");
83 dmaapClientTestImpl.sendMessage();
86 assertThat(instance).isEnded().hasPassedInOrder(
87 "CreateAndActivatePnf_StartEvent",
89 "CheckAiiForCorrelationId",
90 "DoesAaiContainInfoAboutPnf",
91 "CreateAndActivatePnf_CreateAaiEntry",
94 "WaitForDmaapPnfReadyNotification",
97 Assertions.assertThat(aaiConnection.getCreated()).containsOnlyKeys(AaiConnectionTestImpl.ID_WITHOUT_ENTRY);