Replaced all tabs with spaces in java and pom.xml
[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 import java.io.IOException;
25 import java.nio.file.Files;
26 import java.nio.file.Paths;
27 import java.text.ParseException;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.onap.so.apihandlerinfra.ApiHandlerApplication;
31 import org.onap.so.apihandlerinfra.BaseTest;
32 import org.onap.so.apihandlerinfra.exceptions.ApiException;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.boot.test.context.SpringBootTest;
35 import org.springframework.test.context.ActiveProfiles;
36 import org.springframework.test.context.junit4.SpringRunner;
37 import com.fasterxml.jackson.databind.ObjectMapper;
38
39 public class DmaapOperationalEnvClientTest extends BaseTest {
40
41     private final String fileLocation = "src/test/resources/org/onap/so/client/asdc/create-ecompoe/";
42     private static final String operationalEnvironmentId = "28122015552391";
43     private static final String operationalEnvironmentName = "OpEnv-name";
44     private static final String operationalEnvironmentType = "VNF";
45     private static final String tenantContext = "Test";
46     private static final String workloadContext = "VNF_E2E-IST";
47     private static final String action = "Create";
48     @Autowired
49     private DmaapOperationalEnvClient client;
50
51     @Test
52     public void verifyCreateEcompOperationEnvironmentRequest() throws IOException, ApiException {
53         String content = this.getJson("ecomp-openv-request.json");
54         ObjectMapper mapper = new ObjectMapper();
55         CreateEcompOperationEnvironmentBean expected =
56                 mapper.readValue(content, CreateEcompOperationEnvironmentBean.class);
57
58         String actual = client.buildRequest(operationalEnvironmentId, operationalEnvironmentName,
59                 operationalEnvironmentType, tenantContext, workloadContext, action);
60
61         assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual);
62     }
63
64
65     private String getJson(String filename) throws IOException {
66         return new String(Files.readAllBytes(Paths.get(fileLocation + filename)));
67     }
68
69 }
70