package org.onap.policy.models.tosca.simple.serialization;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-
import java.util.Map;
-
import org.junit.Test;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
private static final String VERSION = "version";
- private static final String YAML_VERSION = "tosca_simple_yaml_1_0_0";
+ private static final String YAML_VERSION = "tosca_simple_yaml_1_1_0";
private static final String DEFINITION_VERSION = "tosca_definitions_version";
@Test
public void testSerialization() {
- try {
+ assertThatCode(() -> {
// vCPE
JpaToscaServiceTemplate serviceTemplate = deserializeMonitoringInputJson(VCPE_MON_INPUT_JSON);
String serializedServiceTemplate = serializeMonitoringServiceTemplate(serviceTemplate);
serializedServiceTemplate = serializeMonitoringServiceTemplate(serviceTemplate);
verifyVfwMonitoringOutputserialization(serializedServiceTemplate);
- } catch (Exception e) {
- LOGGER.warn("No exception should be thrown", e);
- fail("No exception should be thrown");
- }
+ }).as("No exception should be thrown").doesNotThrowAnyException();
}
private JpaToscaServiceTemplate deserializeMonitoringInputJson(String resourcePath) throws Exception {
private void verifyVcpeMonitoringOutputserialization(String serializedServiceTemplate) {
- JsonObject serviceTemplateJsonObject = new JsonParser().parse(serializedServiceTemplate).getAsJsonObject();
+ JsonObject serviceTemplateJsonObject = JsonParser.parseString(serializedServiceTemplate).getAsJsonObject();
assertEquals(YAML_VERSION, serviceTemplateJsonObject.get(DEFINITION_VERSION).getAsString());
JsonObject topologyTemplateJsonObject = serviceTemplateJsonObject.get(TOPOLOGY_TEMPLATE).getAsJsonObject();
JsonArray policiesJsonArray = topologyTemplateJsonObject.get(POLICIES).getAsJsonArray();
private void verifyVdnsMonitoringOutputserialization(String serializedServiceTemplate) {
- JsonObject serviceTemplateJsonObject = new JsonParser().parse(serializedServiceTemplate).getAsJsonObject();
+ JsonObject serviceTemplateJsonObject = JsonParser.parseString(serializedServiceTemplate).getAsJsonObject();
assertEquals(YAML_VERSION, serviceTemplateJsonObject.get(DEFINITION_VERSION).getAsString());
JsonObject topologyTemplateJsonObject = serviceTemplateJsonObject.get(TOPOLOGY_TEMPLATE).getAsJsonObject();
JsonArray policiesJsonArray = topologyTemplateJsonObject.get(POLICIES).getAsJsonArray();
private void verifyVfwMonitoringOutputserialization(String serializedServiceTemplate) {
- JsonObject serviceTemplateJsonObject = new JsonParser().parse(serializedServiceTemplate).getAsJsonObject();
+ JsonObject serviceTemplateJsonObject = JsonParser.parseString(serializedServiceTemplate).getAsJsonObject();
assertEquals(YAML_VERSION, serviceTemplateJsonObject.get(DEFINITION_VERSION).getAsString());
JsonObject topologyTemplateJsonObject = serviceTemplateJsonObject.get(TOPOLOGY_TEMPLATE).getAsJsonObject();
JsonArray policiesJsonArray = topologyTemplateJsonObject.get(POLICIES).getAsJsonArray();