/**
- * Copyright 2017 ZTE Corporation.
+ * Copyright 2017-2020 ZTE Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.holmes.common.api.stat;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+
import java.util.Date;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertFalse;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.onap.holmes.common.api.entity.ServiceNode;
public class AlarmTest {
public void after() throws Exception {
}
- @Test
- public void testCompareLinkPosition_isEmpty() throws Exception {
- final Map<Integer, Integer> otherIdIdx = new HashMap<>();
- assertThat(999, equalTo(alarm.CompareLinkPosition(otherIdIdx)));
- }
-
- @Test
- public void testCompareLinkPosition_TempLinkId() throws Exception {
- final Map<Integer, Integer> otherIdIdx = new HashMap<>();
- otherIdIdx.put(1, 2);
- alarm.addLinkIdNodeIdx(1, 3);
- assertThat(1, equalTo(alarm.CompareLinkPosition(otherIdIdx)));
- }
-
@Test
public void testContainNode_NoContainLink() throws Exception {
alarm.addLinkIdNodeIdx(1, 2);
alarm.setCenterType(centerType);
assertThat(centerType, equalTo(alarm.getCenterType()));
}
-
@Test
- public void valueOf_exception() {
- thrown.expect(Exception.class);
- String xmlString = "";
- Alarm.valueOf(xmlString);
- }
+ public void TestJson(){
+ ServiceNode serviceNode = new ServiceNode();
+ serviceNode.setIp("111");
+ String jsonString = "{\"uid\":\"189024\", \"region\":\"SouthChina\", \"order\":123}";
+ String COMPLEX_JSON_STR = "{\"teacherName\":\"crystall\",\"teacherAge\":27,\"course\":{\"courseName\":\"english\",\"code\":1270},\"students\":[{\"studentName\":\"lily\",\"studentAge\":12},{\"studentName\":\"lucy\",\"studentAge\":15}]}";
- @Test
- public void valueOf_normal() {
- String xmlString = alarm.toString();
- Alarm alarmValue = Alarm.valueOf(xmlString);
- assertThat(alarmValue, equalTo(alarm));
+ JSONObject jsonObject = JSON.parseObject(COMPLEX_JSON_STR);
+ JSONArray jsonArray = jsonObject.getJSONArray("students");
+ System.out.printf("jsonObject:"+jsonArray);
+// System.out.println("uid:" + retMap.get("uid") + ", " + "region:" + retMap.get("region") + ", " + "order:" + retMap.get("order"));
}
}