use of org.openmrs.LocationAttributeType in project openmrs-core by openmrs.
the class LocationAttributeTypeValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.
/**
* @see LocationAttributeTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
LocationAttributeType type = new LocationAttributeType();
type.setName("name");
type.setDatatypeClassname("org.openmrs.customdatatype.datatype.FreeTextDatatype");
type.setDescription("description");
type.setRetireReason("retireReason");
Errors errors = new BindException(type, "type");
new LocationAttributeTypeValidator().validate(type, errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.openmrs.LocationAttributeType in project openmrs-core by openmrs.
the class LocationServiceTest method unretireLocationAttributeType_shouldUnretireARetiredLocationAttributeType.
/**
* @see LocationService#unretireLocationAttributeType(LocationAttributeType)
*/
@Test
public void unretireLocationAttributeType_shouldUnretireARetiredLocationAttributeType() {
executeDataSet(LOC_ATTRIBUTE_DATA_XML);
LocationService service = Context.getLocationService();
LocationAttributeType lat = service.getLocationAttributeType(2);
Assert.assertTrue(lat.getRetired());
Assert.assertNotNull(lat.getDateRetired());
Assert.assertNotNull(lat.getRetiredBy());
Assert.assertNotNull(lat.getRetireReason());
service.unretireLocationAttributeType(lat);
Assert.assertFalse(lat.getRetired());
Assert.assertNull(lat.getDateRetired());
Assert.assertNull(lat.getRetiredBy());
Assert.assertNull(lat.getRetireReason());
}
use of org.openmrs.LocationAttributeType in project openmrs-core by openmrs.
the class LocationServiceTest method saveLocationAttributeType_shouldEditAnExistingLocationAttributeType.
/**
* @see LocationService#saveLocationAttributeType(LocationAttributeType)
*/
@Test
public void saveLocationAttributeType_shouldEditAnExistingLocationAttributeType() {
executeDataSet(LOC_ATTRIBUTE_DATA_XML);
LocationService service = Context.getLocationService();
Assert.assertEquals(2, service.getAllLocationAttributeTypes().size());
LocationAttributeType lat = service.getLocationAttributeType(1);
lat.setName("A new name");
service.saveLocationAttributeType(lat);
Assert.assertEquals(2, service.getAllLocationAttributeTypes().size());
Assert.assertEquals("A new name", service.getLocationAttributeType(1).getName());
}
use of org.openmrs.LocationAttributeType in project openmrs-core by openmrs.
the class LocationServiceTest method getLocationAttributeTypeByName_shouldReturnTheLocationAttributeTypeWithTheSpecifiedName.
/**
* @see LocationService#getLocationAttributeTypeByName(String)
*/
@Test
public void getLocationAttributeTypeByName_shouldReturnTheLocationAttributeTypeWithTheSpecifiedName() {
executeDataSet(LOC_ATTRIBUTE_DATA_XML);
LocationAttributeType locationAttributeType = Context.getLocationService().getLocationAttributeTypeByName("Audit Date");
Assert.assertNotNull(locationAttributeType);
Assert.assertEquals("Audit Date", locationAttributeType.getName());
}
use of org.openmrs.LocationAttributeType in project openmrs-core by openmrs.
the class LocationServiceTest method saveLocationAttributeType_shouldCreateANewLocationAttributeType.
/**
* @see LocationService#saveLocationAttributeType(LocationAttributeType)
*/
@Test
public void saveLocationAttributeType_shouldCreateANewLocationAttributeType() {
executeDataSet(LOC_ATTRIBUTE_DATA_XML);
Assert.assertEquals(2, Context.getLocationService().getAllLocationAttributeTypes().size());
LocationAttributeType lat = new LocationAttributeType();
lat.setName("Another one");
lat.setDatatypeClassname(FreeTextDatatype.class.getName());
Context.getLocationService().saveLocationAttributeType(lat);
Assert.assertNotNull(lat.getId());
Assert.assertEquals(3, Context.getLocationService().getAllLocationAttributeTypes().size());
}
Aggregations