- public void testSerialization() {
- try {
- // TCA
- JpaToscaServiceTemplate serviceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_TCA_YAML);
- String serializedServiceTemplate1 = serializeMonitoringServiceTemplate(serviceTemplateFromYaml);
- JpaToscaServiceTemplate serviceTemplateFromJson = gson.fromJson(serializedServiceTemplate1,
- JpaToscaServiceTemplate.class);
- String serializedServiceTemplate2 = serializeMonitoringServiceTemplate(serviceTemplateFromJson);
- assertEquals(serializedServiceTemplate1, serializedServiceTemplate2);
-
- // Collector
- serviceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_COLLECTORS_YAML);
- serializedServiceTemplate1 = serializeMonitoringServiceTemplate(serviceTemplateFromYaml);
- serviceTemplateFromJson = gson.fromJson(serializedServiceTemplate1, JpaToscaServiceTemplate.class);
- serializedServiceTemplate2 = serializeMonitoringServiceTemplate(serviceTemplateFromJson);
- assertEquals(serializedServiceTemplate1, serializedServiceTemplate2);
-
- } catch (Exception e) {
- fail("No exception should be thrown");
- }
+ public void testSerialization() throws Exception {
+ // TCA v1
+ JpaToscaServiceTemplate tcaServiceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_TCA_YAML);
+ String serializedServiceTemplateTca = serializeMonitoringServiceTemplate(tcaServiceTemplateFromYaml);
+
+ ToscaServiceTemplate toscaServiceTemplateFromJsonTca =
+ coder.decode(serializedServiceTemplateTca, ToscaServiceTemplate.class);
+
+ JpaToscaServiceTemplate serviceTemplateFromJsonTca = new JpaToscaServiceTemplate();
+ serviceTemplateFromJsonTca.fromAuthorative(toscaServiceTemplateFromJsonTca);
+ String serializedServiceTemplateTcaOut = serializeMonitoringServiceTemplate(serviceTemplateFromJsonTca);
+ assertEquals(serializedServiceTemplateTca, serializedServiceTemplateTcaOut);
+
+ // TCA v2
+ tcaServiceTemplateFromYaml = deserializeMonitoringInputYaml(MONITORING_TCA_V2_YAML);
+ serializedServiceTemplateTca = serializeMonitoringServiceTemplate(tcaServiceTemplateFromYaml);
+
+ toscaServiceTemplateFromJsonTca =
+ coder.decode(serializedServiceTemplateTca, ToscaServiceTemplate.class);
+
+ serviceTemplateFromJsonTca = new JpaToscaServiceTemplate();
+ serviceTemplateFromJsonTca.fromAuthorative(toscaServiceTemplateFromJsonTca);
+ serializedServiceTemplateTcaOut = serializeMonitoringServiceTemplate(serviceTemplateFromJsonTca);
+ assertEquals(serializedServiceTemplateTca, serializedServiceTemplateTcaOut);
+
+ // Collector
+ JpaToscaServiceTemplate collectorServiceTemplateFromYaml =
+ deserializeMonitoringInputYaml(MONITORING_COLLECTORS_YAML);
+ String serializedServiceTemplateCollector =
+ serializeMonitoringServiceTemplate(collectorServiceTemplateFromYaml);
+ ToscaServiceTemplate toscaServiceTemplateFromJsonCollector =
+ coder.decode(serializedServiceTemplateCollector, ToscaServiceTemplate.class);
+ JpaToscaServiceTemplate serviceTemplateFromJsonCollector = new JpaToscaServiceTemplate();
+ serviceTemplateFromJsonCollector.fromAuthorative(toscaServiceTemplateFromJsonCollector);
+ String serializedServiceTemplateCollectorsOut =
+ serializeMonitoringServiceTemplate(serviceTemplateFromJsonCollector);
+ assertEquals(serializedServiceTemplateCollector, serializedServiceTemplateCollectorsOut);