### Question:
Obs extends BaseChangeableOpenmrsData { public boolean isDirty() { return dirty; } Obs();  Obs(Person person, Concept question, Date obsDatetime, Location location);  Obs(Integer obsId); static Obs newInstance(Obs obsToCopy); String getComment(); void setComment(String comment); Concept getConcept(); void setConcept(Concept concept); ConceptDescription getConceptDescription(); Encounter getEncounter(); void setEncounter(Encounter encounter); Location getLocation(); void setLocation(Location location); Date getObsDatetime(); void setObsDatetime(Date obsDatetime); Obs getObsGroup(); void setObsGroup(Obs obsGroup); boolean isObsGrouping(); boolean hasGroupMembers(); boolean hasGroupMembers(boolean includeVoided); Set<Obs> getGroupMembers(); Set<Obs> getGroupMembers(boolean includeVoided); void setGroupMembers(Set<Obs> groupMembers); void addGroupMember(Obs member); void removeGroupMember(Obs member); Set<Obs> getRelatedObservations(); Integer getObsId(); void setObsId(Integer obsId); Order getOrder(); void setOrder(Order order); Integer getPersonId(); Person getPerson(); void setPerson(Person person); void setValueBoolean(Boolean valueBoolean); Boolean getValueAsBoolean(); Boolean getValueBoolean(); Concept getValueCoded(); void setValueCoded(Concept valueCoded); ConceptName getValueCodedName(); void setValueCodedName(ConceptName valueCodedName); Drug getValueDrug(); void setValueDrug(Drug valueDrug); Date getValueDatetime(); void setValueDatetime(Date valueDatetime); Date getValueDate(); void setValueDate(Date valueDate); Date getValueTime(); void setValueTime(Date valueTime); Integer getValueGroupId(); void setValueGroupId(Integer valueGroupId); String getValueModifier(); void setValueModifier(String valueModifier); Double getValueNumeric(); void setValueNumeric(Double valueNumeric); String getValueText(); void setValueText(String valueText); boolean isComplex(); String getValueComplex(); void setValueComplex(String valueComplex); void setComplexData(ComplexData complexData); ComplexData getComplexData(); String getAccessionNumber(); void setAccessionNumber(String accessionNumber); String getValueAsString(Locale locale); void setValueAsString(String s); @Override String toString(); @Override Integer getId(); @Override void setId(Integer id); Obs getPreviousVersion(); void setPreviousVersion(Obs previousVersion); Boolean hasPreviousVersion(); @Override void setCreator(User creator); @Override void setDateCreated(Date dateCreated); String getFormFieldNamespace(); String getFormFieldPath(); void setFormField(String namespace, String formFieldPath); boolean isDirty(); Interpretation getInterpretation(); void setInterpretation(Interpretation interpretation); Status getStatus(); void setStatus(Status status); static final long serialVersionUID; }### Answer:
@Test public void isDirty_shouldReturnTrueWhenAnyImmutableFieldHasBeenChangedForEditedObs() throws Exception { Obs obs = createObs(2); assertFalse(obs.isDirty()); updateImmutableFieldsAndAssert(obs, true); }
@Test public void isDirty_shouldReturnFalseWhenAnyImmutableFieldHasBeenChangedForNewObs() throws Exception { Obs obs = createObs(null); assertFalse(obs.isDirty()); updateImmutableFieldsAndAssert(obs, false); }
@Test public void isDirty_shouldReturnFalseWhenOnlyMutableFieldsAreChanged() throws Exception { Obs obs = new Obs(); obs.setVoided(true); obs.setVoidedBy(new User(1000)); obs.setVoidReason("some other reason"); obs.setDateVoided(new Date()); assertFalse(obs.isDirty()); Obs obsEdited = new Obs(5); obsEdited.setVoided(true); obsEdited.setVoidedBy(new User(1000)); obsEdited.setVoidReason("some other reason"); obsEdited.setDateVoided(new Date()); assertFalse(obsEdited.isDirty()); }