package com.dim4tech.nest.service.serializer;

import com.dim4tech.nest.domain.payload.Thermostat;
import com.dim4tech.nest.domain.payload.constant.HvacMode;
import com.dim4tech.nest.helper.writebuilder.ThermostatBuilder;
import com.dim4tech.nest.service.deserializer.DeserializationService;
import com.dim4tech.nest.service.deserializer.DeserializationServiceImpl;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class SerializationServiceImplTest {
    private final SerializationService serializationService  = new SerializationServiceImpl();
    private final DeserializationService deserializationService = new DeserializationServiceImpl();

    @Test
    public void thermostatSerialize() throws Exception {
        Thermostat thermostat = new ThermostatBuilder().setLabel("Test").setHvacMode(HvacMode.HEAT).build();
        String serializedThermostat = serializationService.serialize(thermostat);
        assertTrue(serializedThermostat.contains("\"hvac_mode\":\"heat\""));
        assertTrue(serializedThermostat.contains("\"label\":\"Test\""));
        assertEquals(thermostat, deserializationService.deserialize(serializedThermostat, Thermostat.class));
    }

}
@@ -84,77 +84,314 @@
 oad.
-Thermostat;%0Aimport com.dim4tech.nest.domain.payload.constant.HvacMode
+ProductData;%0Aimport com.dim4tech.nest.domain.payload.Software;%0Aimport com.dim4tech.nest.domain.payload.Thermostat;%0Aimport com.dim4tech.nest.domain.payload.constant.HvacMode;%0Aimport com.dim4tech.nest.helper.writebuilder.ProductDataBuilder;%0Aimport com.dim4tech.nest.helper.writebuilder.ProductResourceBuilder
 ;%0Aim
@@ -596,16 +596,47 @@
 ceImpl;%0A
+import org.joda.time.DateTime;%0A
 import o
@@ -1505,9 +1505,1089 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void productDataSerialize() throws Exception %7B%0A        ProductData productData = new ProductDataBuilder().setSoftware(new Software(%221.0%22))%0A                .addResourceUse(%22electricity%22, new ProductResourceBuilder().setValue(42.789).setMeasurementResetTime(DateTime.parse(%222016-01-01T01:01:01.000Z%22)).setMeasurementTime(DateTime.parse(%222016-01-01T01:02:35.000Z%22)).build())%0A                .addResourceUse(%22gas%22, new ProductResourceBuilder().setValue(0.345234545).setMeasurementResetTime(DateTime.parse(%222016-01-01T01:01:01.000Z%22)).setMeasurementTime(DateTime.parse(%222016-01-01T01:02:35.000Z%22)).build())%0A                .addResourceUse(%22water%22, new ProductResourceBuilder().setValue(10000.3).setMeasurementResetTime(DateTime.parse(%222016-01-01T01:01:01.000Z%22)).setMeasurementTime(DateTime.parse(%222016-01-01T01:02:35.000Z%22)).build())%0A                .build();%0A        String serializedProductData = serializationService.serialize(productData);%0A        assertEquals(productData, deserializationService.deserialize(serializedProductData, ProductData.class));%0A    %7D%0A
 %7D

Test was updated