Merge "Reorder modifiers"
[so.git] / mso-api-handlers / mso-api-handler-infra / src / test / java / org / openecomp / mso / 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.openecomp.mso.apihandlerinfra.tenantisolation.dmaap;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.mockito.Mockito.spy;
25
26 import java.io.IOException;
27 import java.nio.file.Files;
28 import java.nio.file.Paths;
29 import java.text.ParseException;
30
31 import org.junit.Test;
32 import org.openecomp.mso.apihandlerinfra.tenantisolation.dmaap.CreateEcompOperationEnvironmentBean;
33 import org.openecomp.mso.apihandlerinfra.tenantisolation.dmaap.DmaapOperationalEnvClient;
34
35 import com.fasterxml.jackson.databind.ObjectMapper;
36
37 public class DmaapOperationalEnvClientTest {
38         
39         private final String fileLocation = "src/test/resources/org/openecomp/mso/client/asdc/create-ecompoe/";
40         private static final String operationalEnvironmentId = "28122015552391";
41         private static final String operationalEnvironmentName = "OpEnv-name";
42         private static final String operationalEnvironmentType = "VNF";
43         private static final String tenantContext = "Test";
44         private static final String workloadContext = "VNF_E2E-IST";
45         private static final String action = "Create";
46         
47         
48         @Test
49         public void verifyCreateEcompOperationEnvironmentRequest() throws IOException, ParseException{
50                 String content = this.getJson("ecomp-openv-request.json");
51                 ObjectMapper mapper = new ObjectMapper();
52                 CreateEcompOperationEnvironmentBean expected = mapper.readValue(content, CreateEcompOperationEnvironmentBean.class);
53                 DmaapOperationalEnvClient client = new DmaapOperationalEnvClient();
54                 DmaapOperationalEnvClient spy = spy(client);
55                 
56                 String actual = spy.buildRequest(operationalEnvironmentId, operationalEnvironmentName, operationalEnvironmentType, 
57                                 tenantContext, workloadContext, action);
58                 
59                 assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual);
60         }
61         
62         
63         private String getJson(String filename) throws IOException {
64                 return new String(Files.readAllBytes(Paths.get(fileLocation + filename)));
65         }
66         
67 }
68