2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 * SPDX-License-Identifier: Apache-2.0
17 * ============LICENSE_END=========================================================
20 package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda;
22 import static org.assertj.core.api.Assertions.assertThat;
23 import static org.assertj.core.api.AssertionsForClassTypes.fail;
24 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MODEL_UUID;
25 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MSO_REQUEST_ID;
26 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_CORRELATION_ID;
27 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
28 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_NAME;
29 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_VERSION;
30 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CUSTOMIZATION_UUID;
31 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_INSTANCE_NAME;
32 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_INSTANCE_ID;
33 import com.google.protobuf.Struct;
34 import java.util.List;
35 import org.junit.Before;
36 import org.junit.Test;
37 import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers;
38 import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader;
39 import org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput;
40 import org.onap.so.BaseIntegrationTest;
41 import org.onap.so.GrpcNettyServer;
42 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
43 import org.slf4j.Logger;
44 import org.slf4j.LoggerFactory;
45 import org.springframework.beans.factory.annotation.Autowired;
47 public class ControllerExecutionDETestIT extends BaseIntegrationTest {
49 private Logger logger = LoggerFactory.getLogger(this.getClass());
52 private ControllerExecutionDE controllerExecutionDE;
55 private GrpcNettyServer grpcNettyServer;
57 private GenericVnf genericVnf;
59 private static String TEST_MODEL_UUID = "6bc0b04d-1873-4721-b53d-6615225b2a28";
60 private static String TEST_SERVICE_INSTANCE_ID = "test_service_id";
61 private static String TEST_PROCESS_KEY = "processKey1";
62 private static String TEST_MSO_REQUEST_ID = "ff874603-4222-11e7-9252-005056850d2e";
64 private static String TEST_CDS_ACTION = "config-assign";
65 private static String TEST_APPC_ACTION = "HealthCheck";
67 private static String TEST_PNF_RESOURCE_INSTANCE_NAME = "PNF_demo_resource";
68 private static String TEST_PNF_CORRELATION_ID = "PNFDemo";
69 private static String TEST_PNF_RESOURCE_BLUEPRINT_NAME = "blueprintOnap";
70 private static String TEST_PNF_RESOURCE_BLUEPRINT_VERSION = "1.0.1";
71 private static String TEST_PNF_RESOURCE_CUSTOMIZATION_UUID = "9acb3a83-8a52-412c-9a45-901764938144";
72 private static String TEST_PNF_UUID = "5df8b6de-2083-11e7-93ae-92361f002671";
76 delegateExecution.setVariable(MODEL_UUID, TEST_MODEL_UUID);
77 delegateExecution.setVariable(SERVICE_INSTANCE_ID, TEST_SERVICE_INSTANCE_ID);
78 delegateExecution.setVariable(MSO_REQUEST_ID, TEST_MSO_REQUEST_ID);
79 delegateExecution.setVariable("testProcessKey", TEST_PROCESS_KEY);
81 grpcNettyServer.cleanMessage();
85 public void testExecution_cdsConfigAssign_actionExecuted() {
87 configureCdsConfigAssign();
89 controllerExecutionDE.execute(delegateExecution);
90 List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages();
91 assertThat(detailedMessages).hasSize(1);
93 checkConfigAssign(detailedMessages.get(0));
94 } catch (Exception e) {
96 fail("ConfigAssign request exception", e);
100 private void configureCdsConfigAssign() {
101 delegateExecution.setVariable("actor", "cds");
102 delegateExecution.setVariable("action", TEST_CDS_ACTION);
103 delegateExecution.setVariable("scope", "pnf");
105 delegateExecution.setVariable(PNF_CORRELATION_ID, TEST_PNF_CORRELATION_ID);
106 delegateExecution.setVariable(PNF_UUID, TEST_PNF_UUID);
107 delegateExecution.setVariable(PRC_INSTANCE_NAME, TEST_PNF_RESOURCE_INSTANCE_NAME);
108 delegateExecution.setVariable(PRC_CUSTOMIZATION_UUID, TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);
109 delegateExecution.setVariable(PRC_BLUEPRINT_NAME, TEST_PNF_RESOURCE_BLUEPRINT_NAME);
110 delegateExecution.setVariable(PRC_BLUEPRINT_VERSION, TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
113 private void checkConfigAssign(ExecutionServiceInput executionServiceInput) {
115 logger.info("Checking the configAssign request");
116 ActionIdentifiers actionIdentifiers = executionServiceInput.getActionIdentifiers();
119 * the fields of actionIdentifiers should match the one in the
120 * response/createVcpeResCustServiceSimplifiedTest_catalogdb.json.
122 assertThat(actionIdentifiers.getBlueprintName()).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_NAME);
123 assertThat(actionIdentifiers.getBlueprintVersion()).isEqualTo(TEST_PNF_RESOURCE_BLUEPRINT_VERSION);
124 assertThat(actionIdentifiers.getActionName()).isEqualTo(TEST_CDS_ACTION);
125 assertThat(actionIdentifiers.getMode()).isEqualTo("sync");
127 CommonHeader commonHeader = executionServiceInput.getCommonHeader();
128 assertThat(commonHeader.getOriginatorId()).isEqualTo("SO");
129 assertThat(commonHeader.getRequestId()).isEqualTo(TEST_MSO_REQUEST_ID);
131 Struct payload = executionServiceInput.getPayload();
132 Struct requeststruct = payload.getFieldsOrThrow("config-assign-request").getStructValue();
134 assertThat(requeststruct.getFieldsOrThrow("resolution-key").getStringValue())
135 .isEqualTo(TEST_PNF_CORRELATION_ID);
136 Struct propertiesStruct = requeststruct.getFieldsOrThrow("config-assign-properties").getStructValue();
138 assertThat(propertiesStruct.getFieldsOrThrow("pnf-name").getStringValue()).isEqualTo(TEST_PNF_CORRELATION_ID);
139 assertThat(propertiesStruct.getFieldsOrThrow("service-model-uuid").getStringValue()).isEqualTo(TEST_MODEL_UUID);
140 assertThat(propertiesStruct.getFieldsOrThrow("pnf-customization-uuid").getStringValue())
141 .isEqualTo(TEST_PNF_RESOURCE_CUSTOMIZATION_UUID);