X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=bpmn%2Fmso-infrastructure-bpmn%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fso%2Fbpmn%2Finfrastructure%2Fpnf%2Fdelegate%2FCreateAndActivatePnfResourceTest.java;h=db6cbe06ae69c8e0be840dc8991be2eb74151207;hb=f1435439699e4e08d2bf912634208e18c894722f;hp=2348af5decc5fe48f119ef2f74e07dbfceb02759;hpb=edc2a33664f9bc46c070663e9392fe8ab983c80b;p=so.git diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java index 2348af5dec..db6cbe06ae 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java @@ -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 @@ -20,36 +22,28 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; -import org.assertj.core.api.Assertions; -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.runtime.ProcessInstance; -import org.camunda.bpm.engine.test.Deployment; -import org.camunda.bpm.engine.test.ProcessEngineRule; -import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions; -import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; +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 static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID; +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; -@RunWith(SpringRunner.class) -@ContextConfiguration(locations = "/applicationContext_forPnfTesting.xml") -public class CreateAndActivatePnfResourceTest { +public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { - private static final String TIMEOUT_10_S = "PT10S"; - @Autowired - private RuntimeService runtimeService; + private static final String VALID_UUID = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString(); + private static final String SERVICE_INSTANCE_ID = "serviceForInstance"; - @Autowired - @Rule - public ProcessEngineRule processEngineRule; + private Map variables; @Autowired private AaiConnectionTestImpl aaiConnection; @@ -57,23 +51,26 @@ public class CreateAndActivatePnfResourceTest { @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 - @Deployment(resources = {"process/CreateAndActivatePnfResource.bpmn"}) public void shouldWaitForMessageFromDmaapAndUpdateAaiEntryWhenAaiEntryExists() { // given - aaiConnection.reset(); - BpmnAwareTests.init(processEngineRule.getProcessEngine()); - Map variables = new HashMap<>(); - variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S); variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITH_ENTRY); // when ProcessInstance instance = runtimeService .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); - BpmnAwareAssertions.assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage"); + assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage"); dmaapClientTestImpl.sendMessage(); // then - BpmnAwareAssertions.assertThat(instance).isEnded().hasPassedInOrder( + assertThat(instance).isEnded().hasPassedInOrder( "CreateAndActivatePnf_StartEvent", "CheckInputs", "CheckAiiForCorrelationId", @@ -81,37 +78,38 @@ public class CreateAndActivatePnfResourceTest { "AaiEntryExists", "InformDmaapClient", "WaitForDmaapPnfReadyNotification", + "CreateRelationId", "AaiEntryUpdated" ); + Assertions.assertThat(aaiConnection.getServiceAndPnfRelationMap()). + containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID,AaiConnectionTestImpl.ID_WITH_ENTRY)); } @Test - @Deployment(resources = {"process/CreateAndActivatePnfResource.bpmn"}) public void shouldCreateAaiEntryWaitForMessageFromDmaapAndUpdateAaiEntryWhenNoAaiEntryExists() { // given - aaiConnection.reset(); - BpmnAwareTests.init(processEngineRule.getProcessEngine()); - Map variables = new HashMap<>(); - variables.put("timeoutForPnfEntryNotification", TIMEOUT_10_S); variables.put(CORRELATION_ID, AaiConnectionTestImpl.ID_WITHOUT_ENTRY); // when ProcessInstance instance = runtimeService .startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); - BpmnAwareAssertions.assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage"); + assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage"); dmaapClientTestImpl.sendMessage(); // then - BpmnAwareAssertions.assertThat(instance).isEnded().hasPassedInOrder( + assertThat(instance).isEnded().hasPassedInOrder( "CreateAndActivatePnf_StartEvent", "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)); } }