Source:
public void shouldUpdateANonCodedCondition() throws Exception { String conditionUuid = RestTestConstants2_2.NON_CODED_CONDITION_UUID; Condition condition = conditionService.getConditionByUuid(conditionUuid); Assert.assertNotNull(condition); String oldCondition = condition.getCondition().getNonCoded(); SimpleObject codedOrFreeText = new SimpleObject(); codedOrFreeText.add("nonCoded", "Updated non coded condition"); SimpleObject attributes = new SimpleObject(); attributes.add("condition", codedOrFreeText); attributes.add("clinicalStatus", ConditionClinicalStatus.ACTIVE); attributes.add("verificationStatus", ConditionVerificationStatus.CONFIRMED); attributes.add("onsetDate", "2018-02-23 00:00:00"); attributes.add("voided", false); String json = new ObjectMapper().writeValueAsString(attributes); MockHttpServletRequest req = request(RequestMethod.POST, getURI() + "/" + conditionUuid); req.setContent(json.getBytes()); handle(req); condition = conditionService.getConditionByUuid(conditionUuid); Assert.assertNotNull(condition); Assert.assertNotEquals(oldCondition, condition.getCondition().getNonCoded()); Assert.assertEquals(ConditionClinicalStatus.ACTIVE, condition.getClinicalStatus()); Assert.assertEquals(ConditionVerificationStatus.CONFIRMED, condition.getVerificationStatus()); Assert.assertNotNull(condition.getOnsetDate()); }

Target:
public void shouldUpdateANonCodedCondition() throws Exception { final String newNonCoded = "Updated non coded condition"; final ConditionClinicalStatus newClinicalStatus = ConditionClinicalStatus.INACTIVE; final ConditionVerificationStatus newVerificationStatus = ConditionVerificationStatus.PROVISIONAL; final Date newOnsetDate = new Date(); final Date newEndDate = new Date(); final String newAdditionalDetail = "Some extra details."; Condition condition = conditionService.getConditionByUuid(RestTestConstants2_2.NON_CODED_CONDITION_UUID); Assert.assertNotNull(condition); Assert.assertFalse(newNonCoded.equalsIgnoreCase(condition.getCondition().getNonCoded())); Assert.assertFalse(newClinicalStatus.equals(condition.getClinicalStatus())); Assert.assertFalse(newVerificationStatus.equals(condition.getVerificationStatus())); Assert.assertFalse(newOnsetDate.equals(condition.getOnsetDate())); Assert.assertFalse(newEndDate.equals(condition.getEndDate())); Assert.assertFalse(newAdditionalDetail.equalsIgnoreCase(condition.getAdditionalDetail())); String json = "{ \"condition\":{\"coded\":null,\"specificName\":null,\"nonCoded\":\"" + newNonCoded + "\"},\"clinicalStatus\":\"" + newClinicalStatus + "\",\"verificationStatus\":\"" + newVerificationStatus + "\",\"onsetDate\":\"" + DATE_FORMAT.format(newOnsetDate) + "\",\"endDate\":\"" + DATE_FORMAT.format(newEndDate) + "\",\"additionalDetail\":\"" + newAdditionalDetail + "\"}"; handle(newPostRequest(getURI() + "/" + RestTestConstants2_2.NON_CODED_CONDITION_UUID, json)); Condition updatedCondition = conditionService.getConditionByUuid(RestTestConstants2_2.NON_CODED_CONDITION_UUID); Assert.assertNotNull(updatedCondition); Assert.assertEquals(newNonCoded, updatedCondition.getCondition().getNonCoded()); Assert.assertEquals(newClinicalStatus, updatedCondition.getClinicalStatus()); Assert.assertEquals(newVerificationStatus, updatedCondition.getVerificationStatus()); Assert.assertEquals(newOnsetDate.toString(), updatedCondition.getOnsetDate().toString()); Assert.assertEquals(newEndDate.toString(), updatedCondition.getEndDate().toString()); Assert.assertEquals(newAdditionalDetail, updatedCondition.getAdditionalDetail()); }