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.bpmn.subprocess;
23 import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.assertThat;
24 import static org.mockito.Mockito.doReturn;
26 import java.io.IOException;
27 import java.nio.file.Files;
28 import java.nio.file.Paths;
29 import java.util.HashMap;
32 import org.camunda.bpm.engine.runtime.ProcessInstance;
33 import org.junit.Test;
34 import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation;
35 import org.onap.so.bpmn.BaseBPMNTest;
36 import org.onap.so.client.exception.BadResponseException;
37 import org.onap.so.client.exception.MapperException;
38 import org.onap.so.client.sdnc.beans.SDNCRequest;
39 import org.onap.so.client.sdnc.endpoint.SDNCTopology;
41 import com.fasterxml.jackson.core.JsonParseException;
42 import com.fasterxml.jackson.databind.JsonMappingException;
43 import com.fasterxml.jackson.databind.ObjectMapper;
45 public class SDNCHandlerTest extends BaseBPMNTest{
47 public void sunnyDay_SDNCHandler_Sync_Final_Test() throws InterruptedException, MapperException, BadResponseException, IOException {
48 final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/SDNCClientPut200Response.json")));
49 doReturn(sdncResponse).when(sdncClient).post(createSDNCRequest().getSDNCPayload(),SDNCTopology.CONFIGURATION);
50 Map<String, Object> startVariables = new HashMap<>();
51 startVariables.put("SDNCRequest", createSDNCRequest());
52 ProcessInstance pi = runtimeService.startProcessInstanceByKey("SDNCHandler", startVariables);
53 assertThat(pi).isNotNull().isStarted().hasPassedInOrder("SDNC_Start","SNDC_SetupCallback","Call_SDNC","isAsync_Gateway","SDNC_End").isEnded();
57 public SDNCRequest createSDNCRequest(){
58 SDNCRequest request = new SDNCRequest();
59 request.setCorrelationName("correlationName");
60 request.setCorrelationValue("correlationValue");
61 request.setTopology(SDNCTopology.CONFIGURATION);
62 ObjectMapper mapper = new ObjectMapper();
64 GenericResourceApiServiceOperationInformation sdncReq =
65 mapper.readValue(Files.readAllBytes(Paths.get("src/test/resources/SDNC_Client_Request.json")), GenericResourceApiServiceOperationInformation.class);
66 request.setSDNCPayload(sdncReq);
67 } catch (JsonParseException e) {
69 } catch (JsonMappingException e) {
71 } catch (IOException e) {