use of org.openmrs.ConceptSource in project openmrs-core by openmrs.
the class ConceptSourceValidatorTest method validate_shouldFailValidationIfDescriptionIsNullOrEmptyOrWhitespace.
/**
* @see ConceptSourceValidator#validate(Object, Errors)
*/
@Test
public void validate_shouldFailValidationIfDescriptionIsNullOrEmptyOrWhitespace() {
ConceptSource conceptSource = new ConceptSource();
conceptSource.setName("New name");
conceptSource.setDescription(null);
Errors errors = new BindException(conceptSource, "conceptSource");
new ConceptSourceValidator().validate(conceptSource, errors);
Assert.assertTrue(errors.hasFieldErrors("description"));
conceptSource.setDescription("");
errors = new BindException(conceptSource, "conceptSource");
new ConceptSourceValidator().validate(conceptSource, errors);
Assert.assertTrue(errors.hasFieldErrors("description"));
conceptSource.setDescription(" ");
errors = new BindException(conceptSource, "conceptSource");
new ConceptSourceValidator().validate(conceptSource, errors);
Assert.assertTrue(errors.hasFieldErrors("description"));
}
use of org.openmrs.ConceptSource in project openmrs-core by openmrs.
the class ConceptServiceImplTest method purgeConceptSource_shouldPurgetTheGivenConceptSource.
/**
* @see ConceptServiceImpl#purgeConceptSource(ConceptSource)
*/
@Test
public void purgeConceptSource_shouldPurgetTheGivenConceptSource() {
Integer conceptSourceId = 1;
ConceptSource conceptSource = conceptService.getConceptSource(conceptSourceId);
conceptService.purgeConceptSource(conceptSource);
assertNull(conceptService.getConceptSource(conceptSourceId));
}
use of org.openmrs.ConceptSource in project openmrs-core by openmrs.
the class ConceptServiceTest method saveConceptReferenceTerm_shouldAddAConceptReferenceTermToTheDatabaseAndAssignAnIdToIt.
/**
* @see ConceptService#saveConceptReferenceTerm(ConceptReferenceTerm)
*/
@Test
public void saveConceptReferenceTerm_shouldAddAConceptReferenceTermToTheDatabaseAndAssignAnIdToIt() {
ConceptReferenceTerm term = new ConceptReferenceTerm();
term.setName("test term");
term.setCode("test code");
ConceptSource source = Context.getConceptService().getConceptSource(1);
term.setConceptSource(source);
ConceptReferenceTerm savedTerm = Context.getConceptService().saveConceptReferenceTerm(term);
Assert.assertNotNull(savedTerm.getId());
Assert.assertNotNull(Context.getConceptService().getConceptReferenceTermByName("test term", source));
}
use of org.openmrs.ConceptSource in project openmrs-core by openmrs.
the class ConceptServiceTest method saveConceptSource_shouldNotSaveAConceptSourceIfVoidedIsNull.
@Test(expected = Exception.class)
public void saveConceptSource_shouldNotSaveAConceptSourceIfVoidedIsNull() {
ConceptSource source = new ConceptSource();
source.setRetired(null);
assertNull(source.getRetired());
conceptService.saveConceptSource(source);
}
use of org.openmrs.ConceptSource in project openmrs-core by openmrs.
the class ConceptServiceTest method getConceptReferenceTermByName_shouldBeCaseInsensitive.
/**
* @see ConceptService#getConceptReferenceTermByName(String,ConceptSource)
*/
@Test
public void getConceptReferenceTermByName_shouldBeCaseInsensitive() {
String name = "WEIGHT term";
ConceptReferenceTerm term = Context.getConceptService().getConceptReferenceTermByName(name, new ConceptSource(1));
Assert.assertNotNull(term);
Assert.assertNotSame(name, term.getName());
Assert.assertEquals(1, term.getId().intValue());
}
Aggregations