/** * @see EncounterService#retireEncounterType(EncounterType,String) */ @Test(expected = IllegalArgumentException.class) public void retireEncounterType_shouldThrowErrorIfGivenNullReasonParameter() { EncounterService encounterService = Context.getEncounterService(); EncounterType type = encounterService.getEncounterType(1); encounterService.retireEncounterType(type, null); }
/** * @see EncounterService#retireEncounterType(EncounterType, String) */ @Test(expected = EncounterTypeLockedException.class) public void retireEncounterType_shouldThrowErrorWhenTryingToRetireEncounterTypeWhenEncounterTypesAreLocked() { GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_ENCOUNTER_TYPES_LOCKED); gp.setPropertyValue("true"); Context.getAdministrationService().saveGlobalProperty(gp); EncounterService encounterService = Context.getEncounterService(); EncounterType encounterType = Context.getEncounterService().getEncounterType(1); Assert.assertNotNull(encounterType); encounterService.retireEncounterType(encounterType, "reason"); }
/** * @see EncounterService#retireEncounterType(EncounterType,String) */ @Test public void retireEncounterType_shouldRetireTypeAndSetAttributes() { EncounterService encounterService = Context.getEncounterService(); EncounterType type = encounterService.getEncounterType(1); assertFalse(type.getRetired()); assertNull(type.getRetiredBy()); assertNull(type.getRetireReason()); assertNull(type.getDateRetired()); EncounterType retiredEncType = encounterService.retireEncounterType(type, "Just Testing"); // make sure its still the same object assertEquals(retiredEncType, type); // make sure that all the values were filled in assertTrue(retiredEncType.getRetired()); assertNotNull(retiredEncType.getDateRetired()); assertEquals(Context.getAuthenticatedUser(), retiredEncType.getRetiredBy()); assertEquals("Just Testing", retiredEncType.getRetireReason()); }