private void addIfValueChanged(final Collection<ChangedField> inputList, final String key, final String oldData, final String newData, final DateTime changeDate) { // If both null => no changes if (newData == null && oldData == null) { // If only one is null } else if (newData == null || oldData == null) { inputList.add(new DefaultChangedField(key, oldData, newData, changeDate)); // If neither are null we can safely compare values } else if (!newData.equals(oldData)) { inputList.add(new DefaultChangedField(key, oldData, newData, changeDate)); } } }
@Test(groups = "fast", description="Test Account event deserialization") public void testDefaultAccountChangeEvent() throws Exception { final List<ChangedField> changes = new ArrayList<ChangedField>(); changes.add(new DefaultChangedField("fieldXX", "valueX", "valueXXX", clock.getUTCNow())); changes.add(new DefaultChangedField("fieldYY", "valueY", "valueYYY", clock.getUTCNow())); final AccountChangeInternalEvent e = new DefaultAccountChangeEvent(changes, UUID.randomUUID(), 1L, 2L, null); final String json = mapper.writeValueAsString(e); final Class<?> claz = Class.forName("org.killbill.billing.account.api.user.DefaultAccountChangeEvent"); final Object obj = mapper.readValue(json, claz); Assert.assertTrue(obj.equals(e)); }
private void addIfValueChanged(final Collection<ChangedField> inputList, final String key, final String oldData, final String newData, final DateTime changeDate) { // If both null => no changes if (newData == null && oldData == null) { // If only one is null } else if (newData == null || oldData == null) { inputList.add(new DefaultChangedField(key, oldData, newData, changeDate)); // If neither are null we can safely compare values } else if (!newData.equals(oldData)) { inputList.add(new DefaultChangedField(key, oldData, newData, changeDate)); } } }