use of org.openmrs.LocationTag in project openmrs-core by openmrs.
the class LocationServiceTest method saveLocationTag_shouldReturnSavedObject.
/**
* @see LocationService#saveLocationTag(LocationTag)
*/
@Test
public void saveLocationTag_shouldReturnSavedObject() {
LocationTag locationTag = new LocationTag("Some tag name", "Some description");
LocationTag savedLocationTag = Context.getLocationService().saveLocationTag(locationTag);
Assert.assertEquals(locationTag, savedLocationTag);
}
use of org.openmrs.LocationTag in project openmrs-core by openmrs.
the class LocationServiceTest method purgeLocationTag_shouldDeleteLocationTag.
/**
* Make sure that purging a location tag removes the row from the database
*
* @see LocationService#purgeLocationTag(LocationTag)
*/
@Test
public void purgeLocationTag_shouldDeleteLocationTag() {
LocationService ls = Context.getLocationService();
// Fetch the encounter to delete from the db
LocationTag tag = ls.getLocationTag(5);
ls.purgeLocationTag(tag);
// Try to refetch the location. should get a null object
LocationTag t = ls.getLocationTag(tag.getLocationTagId());
assertNull("We shouldn't find the tag after deletion", t);
}
use of org.openmrs.LocationTag in project openmrs-core by openmrs.
the class LocationServiceTest method retireLocation_shouldNotRetireIndependentField.
/**
* @see LocationService#retireLocation(Location location, String reason)
*/
@Test
public void retireLocation_shouldNotRetireIndependentField() {
LocationService locationService = Context.getLocationService();
Location location = new Location(1);
location.setName("location to retire");
LocationTag tag = new LocationTag(1);
location.addTag(tag);
locationService.retireLocation(location, "test retire reason");
Assert.assertFalse(tag.getRetired());
}
use of org.openmrs.LocationTag in project openmrs-core by openmrs.
the class LocationServiceTest method saveLocationTag_shouldThrowExceptionIfTagNameIsNull.
/**
* @see LocationService#saveLocationTag(LocationTag)
*/
@Test(expected = APIException.class)
public void saveLocationTag_shouldThrowExceptionIfTagNameIsNull() {
LocationTag tag = new LocationTag();
tag.setName(null);
tag.setDescription("desc");
Context.getLocationService().saveLocationTag(tag);
}
use of org.openmrs.LocationTag in project openmrs-core by openmrs.
the class LocationTagValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.
/**
* @see LocationTagValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
LocationTag locationTag = new LocationTag();
locationTag.setName("name");
locationTag.setDescription("description");
locationTag.setRetireReason("retireReason");
Errors errors = new BindException(locationTag, "locationTag");
new LocationTagValidator().validate(locationTag, errors);
Assert.assertFalse(errors.hasErrors());
}
Aggregations