2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.mso.client.sdno;
23 import static org.junit.Assert.assertEquals;
25 import java.io.IOException;
26 import java.nio.file.Files;
27 import java.nio.file.Paths;
28 import java.util.Optional;
30 import org.junit.Test;
31 import org.openecomp.mso.client.sdno.beans.SDNO;
33 import com.fasterxml.jackson.databind.ObjectMapper;
35 public class SDNOHealthCheckClientTest {
39 private final String fileLocation = "src/test/resources/org/openecomp/mso/client/sdno/health-check/";
40 private static final String userId = "test-user";
41 private static final Optional<String> clliCode = Optional.of("test-clli");
42 private static final String requestId = "test-request-id";
43 private static final String configurationId = "test-configuration-id";
44 private static final String interfaceId = "test-interface-id";
47 public void verfyLPortMirrorPreCheckRequest() throws IOException{
48 String content = this.getJson("custom-lport-mirror-pre-check-request.json");
49 ObjectMapper mapper = new ObjectMapper();
50 SDNO expected = mapper.readValue(content, SDNO.class);
51 SDNOHealthCheckClient client = new SDNOHealthCheckClient();
52 String actual = client.buildLPortMirrorCheckPreRequest(userId, requestId, clliCode, configurationId, interfaceId);
53 assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual);
57 public void verfyLPortMirrorPostCheckRequest() throws IOException{
58 String content = this.getJson("custom-lport-mirror-post-check-request.json");
59 ObjectMapper mapper = new ObjectMapper();
60 SDNO expected = mapper.readValue(content, SDNO.class);
61 SDNOHealthCheckClient client = new SDNOHealthCheckClient();
62 String actual = client.buildLPortMirrorCheckPostRequest(userId, requestId, clliCode, configurationId, interfaceId);
63 assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual);
68 public void verifyPortMirrorPostCheckRequest() throws IOException{
69 String content = this.getJson("custom-port-mirror-post-check-request.json");
70 ObjectMapper mapper = new ObjectMapper();
71 SDNO expected = mapper.readValue(content, SDNO.class);
72 SDNOHealthCheckClient client = new SDNOHealthCheckClient();
73 String actual = client.buildPortMirrorPostCheckRequest(userId, requestId, clliCode, configurationId);
75 assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual);
79 public void verifyPortMirrorPreCheckRequest() throws IOException {
80 String content = this.getJson("custom-port-mirror-pre-check-request.json");
81 ObjectMapper mapper = new ObjectMapper();
82 SDNO expected = mapper.readValue(content, SDNO.class);
83 SDNOHealthCheckClient client = new SDNOHealthCheckClient();
84 String actual = client.buildPortMirrorPreCheckRequest(userId, requestId, clliCode, configurationId);
86 assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual);
90 private String getJson(String filename) throws IOException {
91 return new String(Files.readAllBytes(Paths.get(fileLocation + filename)));