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.junit.Before;
36 import org.junit.Test;
37 import org.junit.runner.RunWith;
38 import org.onap.clamp.clds.client.req.sdc.SdcRequests;
39 import org.onap.clamp.clds.model.CldsEvent;
40 import org.onap.clamp.clds.model.properties.ModelProperties;
41 import org.onap.clamp.clds.util.ResourceFileUtil;
42 import org.skyscreamer.jsonassert.JSONAssert;
43 import org.springframework.beans.factory.annotation.Autowired;
44 import org.springframework.boot.test.context.SpringBootTest;
45 import org.springframework.test.context.junit4.SpringRunner;
47 @RunWith(SpringRunner.class)
49 public class SdcReqItCase {
52 private SdcRequests sdcReq;
53 private String modelBpmnProp;
54 private String modelBpmn;
55 private String modelName;
56 private String controlName;
57 private ModelProperties modelProperties;
58 private String jsonWithYamlInside;
64 public void setUp() throws IOException {
65 modelBpmnProp = ResourceFileUtil.getResourceAsString("example/model-properties/tca/modelBpmnProperties.json");
66 modelBpmn = ResourceFileUtil.getResourceAsString("example/model-properties/tca/modelBpmn.json");
67 modelName = "example-model01";
68 controlName = "ClosedLoop_FRWL_SIG_fad4dcae_e498_11e6_852e_0050568c4ccf";
69 modelProperties = new ModelProperties(modelName, controlName, CldsEvent.ACTION_SUBMIT, false, modelBpmn,
71 jsonWithYamlInside = ResourceFileUtil.getResourceAsString("example/tca-policy-req/prop-text.json");
75 public void formatBlueprintTest() throws IOException {
76 String blueprintFormatted = sdcReq.formatBlueprint(modelProperties, jsonWithYamlInside);
77 assertEquals(ResourceFileUtil.getResourceAsString("example/tca-policy-req/blueprint-expected.yaml"),
82 public void formatSdcLocationsReqTest() {
83 String blueprintFormatted = sdcReq.formatSdcLocationsReq(modelProperties, "testos");
85 "{\"artifactName\":\"testos\",\"locations\":[\"SNDGCA64\",\"ALPRGAED\",\"LSLEILAA\",\"MDTWNJC1\"]}",
90 public void formatSdcReqTest() {
91 String jsonResult = sdcReq.formatSdcReq("payload", "artifactName", "artifactLabel", "artifactType");
92 JSONAssert.assertEquals(
93 "{\"payloadData\" : \"cGF5bG9hZA==\",\"artifactLabel\" : \"artifactLabel\",\"artifactName\" :\"artifactName\",\"artifactType\" : \"artifactType\","
94 + "\"artifactGroupType\" : \"DEPLOYMENT\",\"description\" : \"from CLAMP Cockpit\"}",
99 public void getSdcReqUrlsListTest() throws GeneralSecurityException, DecoderException {
100 List<String> listUrls = sdcReq.getSdcReqUrlsList(modelProperties);
101 assertNotNull(listUrls);
102 assertTrue(listUrls.size() == 1);
103 assertTrue(listUrls.get(0).contains(
104 "/sdc/v1/catalog/services/56441b4b-0467-41dc-9a0e-e68613838219/resourceInstances/vpacketgen0/artifacts"));