use of org.openmrs.VisitAttributeType in project openmrs-core by openmrs.
the class VisitServiceTest method unretireVisitAttributeType_shouldUnretireARetiredVisitAttributeType.
/**
* @see VisitService#unretireVisitAttributeType(VisitAttributeType)
*/
@Test
public void unretireVisitAttributeType_shouldUnretireARetiredVisitAttributeType() {
executeDataSet(VISITS_ATTRIBUTES_XML);
VisitAttributeType vat = visitService.getVisitAttributeType(2);
assertTrue(vat.getRetired());
assertNotNull(vat.getDateRetired());
assertNotNull(vat.getRetiredBy());
assertNotNull(vat.getRetireReason());
visitService.unretireVisitAttributeType(vat);
Assert.assertFalse(vat.getRetired());
assertNull(vat.getDateRetired());
assertNull(vat.getRetiredBy());
assertNull(vat.getRetireReason());
}
use of org.openmrs.VisitAttributeType in project openmrs-core by openmrs.
the class VisitServiceTest method retireVisitAttributeType_shouldRetireAVisitAttributeType.
/**
* @see VisitService#retireVisitAttributeType(VisitAttributeType,String)
*/
@Test
public void retireVisitAttributeType_shouldRetireAVisitAttributeType() {
executeDataSet(VISITS_ATTRIBUTES_XML);
VisitAttributeType vat = visitService.getVisitAttributeType(1);
Assert.assertFalse(vat.getRetired());
visitService.retireVisitAttributeType(vat, "for testing");
vat = visitService.getVisitAttributeType(1);
assertTrue(vat.getRetired());
assertNotNull(vat.getRetiredBy());
assertNotNull(vat.getDateRetired());
assertEquals("for testing", vat.getRetireReason());
}
use of org.openmrs.VisitAttributeType in project openmrs-core by openmrs.
the class VisitServiceTest method shouldVoidASimpleAttribute.
@Test
public void shouldVoidASimpleAttribute() {
executeDataSet(VISITS_ATTRIBUTES_XML);
Visit visit = visitService.getVisit(1);
VisitAttributeType attrType = visitService.getVisitAttributeType(1);
List<VisitAttribute> attributes = visit.getActiveAttributes(attrType);
assertTrue(attributes.size() > 0);
VisitAttribute attribute = attributes.get(0);
attribute.setVoided(true);
visitService.saveVisit(visit);
assertNotNull(attribute.getVoidedBy());
assertNotNull(attribute.getDateVoided());
}
use of org.openmrs.VisitAttributeType in project openmrs-core by openmrs.
the class VisitAttributeTypeValidatorTest method validate_shouldFailValidationIfFieldLengthsAreNotCorrect.
/**
* @see VisitAttributeTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() {
VisitAttributeType visitAttributeType = new VisitAttributeType();
visitAttributeType.setName("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
visitAttributeType.setMinOccurs(1);
visitAttributeType.setDatatypeConfig("[a-z]+");
visitAttributeType.setDatatypeClassname("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
visitAttributeType.setDescription(new String(new char[66000]));
visitAttributeType.setPreferredHandlerClassname("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
visitAttributeType.setRetireReason("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
Errors errors = new BindException(visitAttributeType, "visitAttributeType");
new VisitAttributeTypeValidator().validate(visitAttributeType, errors);
Assert.assertTrue(errors.hasFieldErrors("name"));
Assert.assertTrue(errors.hasFieldErrors("description"));
Assert.assertTrue(errors.hasFieldErrors("datatypeClassname"));
Assert.assertTrue(errors.hasFieldErrors("preferredHandlerClassname"));
Assert.assertTrue(errors.hasFieldErrors("retireReason"));
}
use of org.openmrs.VisitAttributeType in project openmrs-core by openmrs.
the class VisitAttributeTypeValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.
/**
* @see VisitAttributeTypeValidator#validate(Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
VisitAttributeType visitAttributeType = new VisitAttributeType();
visitAttributeType.setName("name");
visitAttributeType.setMinOccurs(1);
visitAttributeType.setDatatypeConfig("[a-z]+");
visitAttributeType.setDatatypeClassname(RegexValidatedTextDatatype.class.getName());
visitAttributeType.setDescription("some text");
visitAttributeType.setRetireReason("some text");
Errors errors = new BindException(visitAttributeType, "visitAttributeType");
new VisitAttributeTypeValidator().validate(visitAttributeType, errors);
Assert.assertFalse(errors.hasErrors());
}
Aggregations