use of org.openmrs.VisitType in project openmrs-core by openmrs.
the class VisitTypeValidatorTest method validate_shouldFailValidationIfFieldLengthsAreNotCorrect.
/**
* @see VisitTypeValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() {
VisitType visitType = new VisitType();
visitType.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");
visitType.setDescription("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 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 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 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");
visitType.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(visitType, "visitType");
new VisitTypeValidator().validate(visitType, errors);
Assert.assertTrue(errors.hasFieldErrors("name"));
Assert.assertTrue(errors.hasFieldErrors("description"));
Assert.assertTrue(errors.hasFieldErrors("retireReason"));
}
use of org.openmrs.VisitType in project openmrs-core by openmrs.
the class VisitServiceTest method retireVisitType_shouldRetireGivenVisitType.
@Test
public void retireVisitType_shouldRetireGivenVisitType() {
VisitType visitType = visitService.getVisitType(1);
assertNotNull(visitType);
Assert.assertFalse(visitType.getRetired());
assertNull(visitType.getRetireReason());
visitService.retireVisitType(visitType, "retire reason");
visitType = visitService.getVisitType(1);
assertNotNull(visitType);
assertTrue(visitType.getRetired());
assertEquals("retire reason", visitType.getRetireReason());
// Should not change the number of visit types.
assertEquals(3, visitService.getAllVisitTypes().size());
}
use of org.openmrs.VisitType in project openmrs-core by openmrs.
the class VisitServiceTest method unretireVisitType_shouldUnretireGivenVisitType.
@Test
public void unretireVisitType_shouldUnretireGivenVisitType() {
VisitType visitType = visitService.getVisitType(3);
assertNotNull(visitType);
assertTrue(visitType.getRetired());
assertEquals("Some Retire Reason", visitType.getRetireReason());
visitService.unretireVisitType(visitType);
visitType = visitService.getVisitType(3);
assertNotNull(visitType);
Assert.assertFalse(visitType.getRetired());
assertNull(visitType.getRetireReason());
// Should not change the number of visit types.
assertEquals(3, visitService.getAllVisitTypes().size());
}
use of org.openmrs.VisitType in project openmrs-core by openmrs.
the class VisitServiceTest method saveVisit_shouldSaveAVisitThoughChangedByAndDateCreatedAreNotSetForVisitAttributeExplictly.
/**
* @see VisitService#saveVisit(Visit)
*/
@Test
public void saveVisit_shouldSaveAVisitThoughChangedByAndDateCreatedAreNotSetForVisitAttributeExplictly() {
executeDataSet(VISITS_ATTRIBUTES_XML);
Visit visit = new Visit(new Patient(2), new VisitType(3), new Date());
VisitAttribute visitAttribute = createVisitAttributeWithoutCreatorAndDateCreated();
visit.setAttribute(visitAttribute);
visit = visitService.saveVisit(visit);
assertNotNull(visit.getId());
}
use of org.openmrs.VisitType in project openmrs-core by openmrs.
the class VisitServiceTest method saveVisitType_shouldSaveNewVisitType.
@Test
public void saveVisitType_shouldSaveNewVisitType() {
List<VisitType> visitTypes = visitService.getVisitTypes("Some Name");
assertEquals(0, visitTypes.size());
VisitType visitType = new VisitType("Some Name", "Description");
visitService.saveVisitType(visitType);
visitTypes = visitService.getVisitTypes("Some Name");
assertEquals(1, visitTypes.size());
// Should create a new visit type row.
assertEquals(4, visitService.getAllVisitTypes().size());
}
Aggregations