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.grm;
24 import java.nio.file.Files;
25 import java.util.List;
26 import static org.junit.Assert.*;
27 import org.junit.Test;
28 import org.openecomp.mso.client.grm.beans.ServiceEndPoint;
29 import org.openecomp.mso.client.grm.beans.ServiceEndPointList;
31 import com.fasterxml.jackson.databind.ObjectMapper;
33 public class ServiceEndPointListTest {
35 private ObjectMapper mapper = new ObjectMapper();
38 public void testUnmarshall() throws Exception {
39 String endpointsJson = getFileContentsAsString("__files/grm/endpoints.json");
40 ServiceEndPointList sel = mapper.readValue(endpointsJson, ServiceEndPointList.class);
42 List<ServiceEndPoint> list = sel.getServiceEndPointList();
43 ServiceEndPoint se = list.get(0);
45 assertEquals(3, list.size());
46 assertEquals("dummy.pod.ns.dummy-pod3", se.getName());
47 assertEquals(Integer.valueOf(1), Integer.valueOf(se.getVersion().getMajor()));
48 assertEquals(Integer.valueOf(0), Integer.valueOf(se.getVersion().getMinor()));
49 assertEquals(Integer.valueOf(0), Integer.valueOf(se.getVersion().getPatch()));
50 assertEquals("135.144.120.218", se.getHostAddress());
51 assertEquals("32004", se.getListenPort());
52 assertEquals("37.7022", se.getLatitude());
53 assertEquals("121.9358", se.getLongitude());
54 assertEquals("/", se.getContextPath());
55 assertEquals("edge", se.getOperationalInfo().getCreatedBy());
56 assertEquals("edge", se.getOperationalInfo().getUpdatedBy());
57 assertEquals("Environment", se.getProperties().get(0).getName());
58 assertEquals("DEV", se.getProperties().get(0).getValue());
61 protected String getFileContentsAsString(String fileName) {
65 ClassLoader classLoader = this.getClass().getClassLoader();
66 File file = new File(classLoader.getResource(fileName).getFile());
67 content = new String(Files.readAllBytes(file.toPath()));
71 System.out.println("Exception encountered reading " + fileName + ". Error: " + e.getMessage());