@Test public void customPropertiesLog() throws JSONException { CustomPropertiesLog log = new CustomPropertiesLog(); Map<String, Object> properties = new HashMap<>(); properties.put("t1", "test"); properties.put("t2", new Date(0)); properties.put("t3", 0); properties.put("t4", false); //noinspection ConstantConditions properties.put("t5", null); log.setProperties(properties); UUID sid = UUIDUtils.randomUUID(); log.setSid(sid); log.setTimestamp(new Date()); /* Verify serialize and deserialize. */ LogSerializer serializer = new DefaultLogSerializer(); serializer.addLogFactory(CustomPropertiesLog.TYPE, new CustomPropertiesLogFactory()); String payload = serializer.serializeLog(log); Log actualContainer = serializer.deserializeLog(payload, null); assertEquals(log, actualContainer); }
@Test public void compare() { /* Empty objects. */ CustomPropertiesLog a = new CustomPropertiesLog(); CustomPropertiesLog b = new CustomPropertiesLog(); checkEquals(a, b); checkEquals(a.getType(), CustomPropertiesLog.TYPE); UUID sid = UUIDUtils.randomUUID(); a.setSid(sid); checkNotEquals(a, b); b.setSid(sid); checkEquals(a, b); /* Properties. */ Map<String, Object> properties = new HashMap<>(); properties.put("test", "test"); a.setProperties(properties); checkEquals(a.getProperties(), properties); checkNotEquals(a, b); b.setProperties(new HashMap<String, Object>()); checkNotEquals(a, b); b.setProperties(properties); checkEquals(a, b); } }