Search in sources :

Example 6 with ConceptSource

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"));
}
Also used : Errors(org.springframework.validation.Errors) BindException(org.springframework.validation.BindException) ConceptSource(org.openmrs.ConceptSource) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 7 with ConceptSource

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));
}
Also used : ConceptSource(org.openmrs.ConceptSource) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 8 with ConceptSource

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));
}
Also used : ConceptSource(org.openmrs.ConceptSource) ConceptReferenceTerm(org.openmrs.ConceptReferenceTerm) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 9 with ConceptSource

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);
}
Also used : ConceptSource(org.openmrs.ConceptSource) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 10 with ConceptSource

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());
}
Also used : ConceptSource(org.openmrs.ConceptSource) ConceptReferenceTerm(org.openmrs.ConceptReferenceTerm) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Aggregations

ConceptSource (org.openmrs.ConceptSource)39 Test (org.junit.Test)29 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)28 ConceptMapType (org.openmrs.ConceptMapType)6 ConceptReferenceTerm (org.openmrs.ConceptReferenceTerm)6 BindException (org.springframework.validation.BindException)6 Errors (org.springframework.validation.Errors)6 Drug (org.openmrs.Drug)5 ArrayList (java.util.ArrayList)4 Concept (org.openmrs.Concept)4 Locale (java.util.Locale)3 Criteria (org.hibernate.Criteria)3 ConceptClass (org.openmrs.ConceptClass)2 ConceptDatatype (org.openmrs.ConceptDatatype)2 ConceptSearchResult (org.openmrs.ConceptSearchResult)2 GlobalProperty (org.openmrs.GlobalProperty)2 User (org.openmrs.User)2 ConceptBuilder (org.openmrs.module.metadatadeploy.builder.ConceptBuilder)2 ConceptMapBuilder (org.openmrs.module.metadatadeploy.builder.ConceptMapBuilder)2 SimpleObject (org.openmrs.ui.framework.SimpleObject)2