2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
24 package org.onap.clamp.clds.it;
26 import static org.junit.Assert.assertEquals;
27 import static org.junit.Assert.assertNotNull;
28 import static org.junit.Assert.assertTrue;
30 import java.io.IOException;
31 import java.security.GeneralSecurityException;
32 import java.util.List;
34 import org.apache.commons.codec.DecoderException;
35 import org.json.JSONException;
36 import org.junit.Before;
37 import org.junit.Test;
38 import org.junit.runner.RunWith;
39 import org.onap.clamp.clds.client.req.sdc.SdcRequests;
40 import org.onap.clamp.clds.model.CldsEvent;
41 import org.onap.clamp.clds.model.properties.ModelProperties;
42 import org.onap.clamp.clds.util.ResourceFileUtil;
43 import org.skyscreamer.jsonassert.JSONAssert;
44 import org.springframework.beans.factory.annotation.Autowired;
45 import org.springframework.boot.test.context.SpringBootTest;
46 import org.springframework.test.context.junit4.SpringRunner;
48 @RunWith(SpringRunner.class)
50 public class SdcReqItCase {
53 private SdcRequests sdcReq;
54 private String modelBpmnProp;
55 private String modelBpmn;
56 private String modelName;
57 private String controlName;
58 private ModelProperties modelProperties;
59 private String jsonWithYamlInside;
65 public void setUp() throws IOException {
66 modelBpmnProp = ResourceFileUtil.getResourceAsString("example/model-properties/tca/modelBpmnProperties.json");
67 modelBpmn = ResourceFileUtil.getResourceAsString("example/model-properties/tca/modelBpmn.json");
68 modelName = "example-model01";
69 controlName = "ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf";
70 modelProperties = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, false, modelBpmn,
72 jsonWithYamlInside = ResourceFileUtil.getResourceAsString("example/tca-policy-req/prop-text.json");
76 public void formatBlueprintTest() throws IOException {
77 String blueprintFormatted = sdcReq.formatBlueprint(modelProperties, jsonWithYamlInside);
78 assertEquals(ResourceFileUtil.getResourceAsString("example/tca-policy-req/blueprint-expected.yaml"),
83 public void formatSdcLocationsReqTest() {
84 String blueprintFormatted = sdcReq.formatSdcLocationsReq(modelProperties, "testos");
86 "{\"artifactName\":\"testos\",\"locations\":[\"SNDGCA64\",\"ALPRGAED\",\"LSLEILAA\",\"MDTWNJC1\"]}",
91 public void formatSdcReqTest() throws JSONException {
92 String jsonResult = sdcReq.formatSdcReq("payload", "artifactName",
93 "artifactLabel", "artifactType");
94 JSONAssert.assertEquals(
95 "{\"payloadData\" : \"cGF5bG9hZA==\",\"artifactLabel\" : \"artifactLabel\"," +
96 "\"artifactName\" :\"artifactName\",\"artifactType\" : \"artifactType\","
97 + "\"artifactGroupType\" : \"DEPLOYMENT\",\"description\" : \"from CLAMP Cockpit\"}",
102 public void getSdcReqUrlsListTest() throws GeneralSecurityException, DecoderException {
103 List<String> listUrls = sdcReq.getSdcReqUrlsList(modelProperties);
104 assertNotNull(listUrls);
105 assertTrue(listUrls.size() == 1);
106 assertTrue(listUrls.get(0).contains(
107 "/sdc/v1/catalog/services/56441b4b-0467-41dc-9a0e-e68613838219/resourceInstances/vpacketgen0/artifacts"));