use of org.openmrs.ConceptReferenceTerm in project openmrs-core by openmrs.
the class ConceptServiceTest method getConceptReferenceTermByName_shouldReturnAConceptReferenceTermThatMatchesTheGivenNameFromTheGivenSource.
/**
* @see ConceptService#getConceptReferenceTermByName(String,ConceptSource)
*/
@Test
public void getConceptReferenceTermByName_shouldReturnAConceptReferenceTermThatMatchesTheGivenNameFromTheGivenSource() {
ConceptReferenceTerm term = Context.getConceptService().getConceptReferenceTermByName("weight term", new ConceptSource(1));
Assert.assertNotNull(term);
Assert.assertEquals("weight term", term.getName());
}
use of org.openmrs.ConceptReferenceTerm in project openmrs-core by openmrs.
the class ConceptServiceImplTest method purgeConceptReferenceTerm_shouldFailIfGivenConceptReferenceTermIsInUse.
/**
* @see ConceptServiceImpl#purgeConceptReferenceTerm(ConceptReferenceTerm)
*/
@Test
public void purgeConceptReferenceTerm_shouldFailIfGivenConceptReferenceTermIsInUse() {
ConceptReferenceTerm refTerm = conceptService.getConceptReferenceTerm(1);
assertNotNull(refTerm);
expectedException.expect(APIException.class);
expectedException.expectMessage("Reference term is in use");
conceptService.purgeConceptReferenceTerm(refTerm);
}
use of org.openmrs.ConceptReferenceTerm in project openmrs-core by openmrs.
the class ConceptServiceImplTest method purgeConceptReferenceTerm_shouldPurgeTheGivenConceptReferenceTerm.
/**
* @see ConceptServiceImpl#purgeConceptReferenceTerm(ConceptReferenceTerm)
*/
@Test
public void purgeConceptReferenceTerm_shouldPurgeTheGivenConceptReferenceTerm() {
Integer conceptReferenceTermId = 11;
ConceptReferenceTerm refTerm = conceptService.getConceptReferenceTerm(conceptReferenceTermId);
conceptService.purgeConceptReferenceTerm(refTerm);
assertNull(conceptService.getConceptReferenceTerm(conceptReferenceTermId));
}
use of org.openmrs.ConceptReferenceTerm in project openmrs-core by openmrs.
the class OpenmrsObjectSaveHandlerTest method handle_shouldTrimStringsWithoutAllowLeadingOrTrailingWhitespaceAnnotation.
/**
* @see OpenmrsObjectSaveHandler#handle(OpenmrsObject,User,Date,String)
*/
@Test
public void handle_shouldTrimStringsWithoutAllowLeadingOrTrailingWhitespaceAnnotation() {
ConceptReferenceTerm term = new ConceptReferenceTerm();
term.setCode(" code ");
term.setConceptSource(new ConceptSource(1));
new OpenmrsObjectSaveHandler().handle(term, null, null, null);
Assert.assertEquals("code", term.getCode());
}
use of org.openmrs.ConceptReferenceTerm in project openmrs-core by openmrs.
the class ConceptReferenceTermValidatorTest method validate_shouldFailIfTheCodeIsAWhiteSpaceCharacter.
/**
* @see ConceptReferenceTermValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfTheCodeIsAWhiteSpaceCharacter() {
ConceptReferenceTerm term = new ConceptReferenceTerm();
term.setName("name");
term.setCode(" ");
term.setConceptSource(Context.getConceptService().getConceptSource(1));
Errors errors = new BindException(term, "term");
new ConceptReferenceTermValidator().validate(term, errors);
Assert.assertEquals(true, errors.hasFieldErrors("code"));
}
Aggregations