Containerization feature of SO
[so.git] / mso-api-handlers / mso-api-handler-infra / src / test / java / org / onap / so / apihandlerinfra / tenantisolation / dmaap / DmaapOperationalEnvClientTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.so.apihandlerinfra.tenantisolation.dmaap;
22
23 import static org.junit.Assert.assertEquals;
24
25 import java.io.IOException;
26 import java.nio.file.Files;
27 import java.nio.file.Paths;
28 import java.text.ParseException;
29
30 import org.junit.Test;
31 import org.junit.runner.RunWith;
32 import org.onap.so.apihandlerinfra.ApiHandlerApplication;
33 import org.onap.so.apihandlerinfra.BaseTest;
34 import org.onap.so.apihandlerinfra.exceptions.ApiException;
35 import org.springframework.beans.factory.annotation.Autowired;
36 import org.springframework.boot.test.context.SpringBootTest;
37 import org.springframework.test.context.ActiveProfiles;
38 import org.springframework.test.context.junit4.SpringRunner;
39
40 import com.fasterxml.jackson.databind.ObjectMapper;
41
42 public class DmaapOperationalEnvClientTest extends BaseTest{
43         
44         private final String fileLocation = "src/test/resources/org/onap/so/client/asdc/create-ecompoe/";
45         private static final String operationalEnvironmentId = "28122015552391";
46         private static final String operationalEnvironmentName = "OpEnv-name";
47         private static final String operationalEnvironmentType = "VNF";
48         private static final String tenantContext = "Test";
49         private static final String workloadContext = "VNF_E2E-IST";
50         private static final String action = "Create";
51         @Autowired
52         private DmaapOperationalEnvClient client;
53         
54         @Test
55         public void verifyCreateEcompOperationEnvironmentRequest() throws IOException, ApiException {
56                 String content = this.getJson("ecomp-openv-request.json");
57                 ObjectMapper mapper = new ObjectMapper();
58                 CreateEcompOperationEnvironmentBean expected = mapper.readValue(content, CreateEcompOperationEnvironmentBean.class);
59                 
60                 String actual = client.buildRequest(operationalEnvironmentId, operationalEnvironmentName, operationalEnvironmentType, 
61                                 tenantContext, workloadContext, action);
62                 
63                 assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual);
64         }
65         
66         
67         private String getJson(String filename) throws IOException {
68                 return new String(Files.readAllBytes(Paths.get(fileLocation + filename)));
69         }
70         
71 }
72