Search in sources :

Example 21 with ConceptReferenceTerm

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

Example 22 with ConceptReferenceTerm

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

Example 23 with ConceptReferenceTerm

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

Example 24 with ConceptReferenceTerm

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

Example 25 with ConceptReferenceTerm

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

Aggregations

ConceptReferenceTerm (org.openmrs.ConceptReferenceTerm)37 Test (org.junit.Test)33 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)31 BindException (org.springframework.validation.BindException)19 Errors (org.springframework.validation.Errors)19 ConceptSource (org.openmrs.ConceptSource)7 ConceptReferenceTermMap (org.openmrs.ConceptReferenceTermMap)5 ArrayList (java.util.ArrayList)3 Ignore (org.junit.Ignore)3 Drug (org.openmrs.Drug)3 APIException (org.openmrs.api.APIException)3 HashSet (java.util.HashSet)2 List (java.util.List)2 Criteria (org.hibernate.Criteria)2 ConceptMap (org.openmrs.ConceptMap)2 ConceptMapType (org.openmrs.ConceptMapType)2 ConceptName (org.openmrs.ConceptName)2 DrugReferenceMap (org.openmrs.DrugReferenceMap)2 OpenmrsObject (org.openmrs.OpenmrsObject)2 ConceptService (org.openmrs.api.ConceptService)2