@Test public void compareAttribute() throws Exception { assertThat(attributeUpdateService.compareAttribute("EFO trait", null, "asthma")).isEqualTo( "EFO trait set to 'asthma'"); assertThat(attributeUpdateService.compareAttribute("EFO trait", "acne", "asthma")).isEqualTo( "EFO trait updated from 'acne' to 'asthma'"); assertThat(attributeUpdateService.compareAttribute("EFO trait", "acne", null)).isEqualTo( "EFO trait value removed"); assertThat(attributeUpdateService.compareAttribute("EFO trait", null, null)).isNull(); }
public String compareAttribute(String attribute, String existingValue, String newValue) { String updateDescription = null; if (existingValue == null) { if (newValue != null) { updateDescription = attribute.concat(" set to ").concat("'").concat(newValue).concat("'"); } } else if (newValue == null) { updateDescription = attribute.concat(" value removed"); } else { if (!existingValue.equals(newValue)) { updateDescription = attribute.concat(" updated from ") .concat("'") .concat(existingValue) .concat("'") .concat(" to ") .concat("'") .concat(newValue) .concat("'"); } } return updateDescription; }
AttributeUpdateService { public String compareAttribute(String attribute, String existingValue, String newValue) { String updateDescription = null; if (existingValue == null) { if (newValue != null) { updateDescription = attribute.concat(" set to ").concat("'").concat(newValue).concat("'"); } } else if (newValue == null) { updateDescription = attribute.concat(" value removed"); } else { if (!existingValue.equals(newValue)) { updateDescription = attribute.concat(" updated from ") .concat("'") .concat(existingValue) .concat("'") .concat(" to ") .concat("'") .concat(newValue) .concat("'"); } } return updateDescription; } }
AttributeUpdateService { public String compareAttribute(String attribute, String existingValue, String newValue) { String updateDescription = null; if (existingValue == null) { if (newValue != null) { updateDescription = attribute.concat(" set to ").concat("'").concat(newValue).concat("'"); } } else if (newValue == null) { updateDescription = attribute.concat(" value removed"); } else { if (!existingValue.equals(newValue)) { updateDescription = attribute.concat(" updated from ") .concat("'") .concat(existingValue) .concat("'") .concat(" to ") .concat("'") .concat(newValue) .concat("'"); } } return updateDescription; }  }
AttributeUpdateService { public String compareAttribute(String attribute, String existingValue, String newValue) { String updateDescription = null; if (existingValue == null) { if (newValue != null) { updateDescription = attribute.concat(" set to ").concat("'").concat(newValue).concat("'"); } } else if (newValue == null) { updateDescription = attribute.concat(" value removed"); } else { if (!existingValue.equals(newValue)) { updateDescription = attribute.concat(" updated from ") .concat("'") .concat(existingValue) .concat("'") .concat(" to ") .concat("'") .concat(newValue) .concat("'"); } } return updateDescription; }  String compareAttribute(String attribute, String existingValue, String newValue); }
AttributeUpdateService { public String compareAttribute(String attribute, String existingValue, String newValue) { String updateDescription = null; if (existingValue == null) { if (newValue != null) { updateDescription = attribute.concat(" set to ").concat("'").concat(newValue).concat("'"); } } else if (newValue == null) { updateDescription = attribute.concat(" value removed"); } else { if (!existingValue.equals(newValue)) { updateDescription = attribute.concat(" updated from ") .concat("'") .concat(existingValue) .concat("'") .concat(" to ") .concat("'") .concat(newValue) .concat("'"); } } return updateDescription; }  String compareAttribute(String attribute, String existingValue, String newValue);  }