\r
package org.onap.holmes.common.config;\r
\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-import javax.validation.constraints.NotNull;\r
-\r
public class MQConfig {\r
\r
- @JsonProperty\r
- @NotNull\r
public String brokerIp;\r
\r
- @JsonProperty\r
- @NotNull\r
public int brokerPort;\r
\r
- @JsonProperty\r
public String brokerUsername;\r
\r
- @JsonProperty\r
public String brokerPassword;\r
}\r
\r
package org.onap.holmes.common.dmaap.entity;\r
\r
-import com.fasterxml.jackson.annotation.JsonProperty;\r
+import com.google.gson.annotations.SerializedName;\r
import java.util.HashMap;\r
import java.util.Map;\r
import lombok.Getter;\r
private String policyName;\r
private String policyScope;\r
private String from = "DCAE";\r
- @JsonProperty(value = "target_type")\r
+ @SerializedName(value = "target_type")\r
private String targetType = "VM";\r
private String target;\r
- @JsonProperty(value = "AAI")\r
+ @SerializedName(value = "AAI")\r
private Map<String, Object> aai = new HashMap<>();\r
\r
public static enum EVENT_STATUS {\r
+++ /dev/null
-/**\r
- * Copyright 2017 ZTE Corporation.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package org.onap.holmes.common.utils;\r
-\r
-import com.fasterxml.jackson.core.JsonProcessingException;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-import java.io.IOException;\r
-\r
-public class JacksonUtil {\r
-\r
- private JacksonUtil() {\r
-\r
- }\r
-\r
- public static String beanToJson(Object obj) throws JsonProcessingException {\r
- ObjectMapper objectMapper = new ObjectMapper();\r
- return objectMapper.writeValueAsString(obj);\r
- }\r
-\r
- public static <T> T jsonToBean(String json, Class<T> cls) throws IOException {\r
- ObjectMapper objectMapper = new ObjectMapper();\r
- if (json == null) {\r
- return objectMapper.readValue("{}", cls);\r
- }\r
- return objectMapper.readValue(json, cls);\r
- }\r
-}\r
+++ /dev/null
-/**\r
- * Copyright 2016 ZTE Corporation.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-\r
-package org.onap.holmes.common.utils;\r
-\r
-import static org.hamcrest.core.IsEqual.equalTo;\r
-import static org.junit.Assert.assertThat;\r
-\r
-import com.google.gson.Gson;\r
-import com.google.gson.GsonBuilder;\r
-import com.google.gson.JsonDeserializationContext;\r
-import com.google.gson.JsonDeserializer;\r
-import com.google.gson.JsonElement;\r
-import com.google.gson.JsonParseException;\r
-import com.google.gson.JsonSerializationContext;\r
-import com.google.gson.JsonSerializer;\r
-import java.lang.reflect.Type;\r
-import org.junit.Test;\r
-import org.onap.holmes.common.utils.bean.TestBean;\r
-\r
-public class JacksonUtilTest {\r
-\r
- @Test\r
- public void testBeanToJson() throws Exception {\r
- TestBean o = new TestBean();\r
- o.setId("id");\r
- String result = GsonUtil.beanToJson(o);\r
- assertThat("{\"id\":\"id\"}", equalTo(result));\r
- }\r
-\r
- @Test\r
- public void jsonToBean_json_null() throws Exception {\r
- String jsonNull = null;\r
- TestBean testBean = GsonUtil.jsonToBean(jsonNull, TestBean.class);\r
- assertThat(testBean, equalTo(null));\r
- }\r
-\r
- @Test\r
- public void jsonToBean_json_normal() throws Exception {\r
- String json = "{\"id\":\"id\"}";\r
- TestBean testBean = GsonUtil.jsonToBean(json, TestBean.class);\r
- assertThat(testBean.getId(), equalTo("id"));\r
- }\r
-\r
-}
\ No newline at end of file
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;
-import com.fasterxml.jackson.core.JsonProcessingException;
import org.junit.Test;
import org.onap.holmes.common.dcae.entity.DcaeConfigurations;
import org.onap.holmes.common.dcae.entity.SecurityInfo;