Search in sources :

Example 41 with ConceptClass

use of org.openmrs.ConceptClass in project openmrs-core by openmrs.

the class ConceptValidatorTest method validate_shouldFailIfAnyNameIsANullValue.

@Test
public void validate_shouldFailIfAnyNameIsANullValue() {
    concept.addDescription(new ConceptDescription("some description", null));
    concept.setConceptClass(new ConceptClass(1));
    concept.setDatatype(new ConceptDatatype(1));
    concept.addName(new ConceptName("name", Context.getLocale()));
    concept.addName(new ConceptName(null, Context.getLocale()));
    validator.validate(concept, errors);
    assertThat(errors, hasGlobalErrors("Concept.name.empty"));
}
Also used : ConceptClass(org.openmrs.ConceptClass) ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) ConceptDatatype(org.openmrs.ConceptDatatype) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 42 with ConceptClass

use of org.openmrs.ConceptClass in project openmrs-core by openmrs.

the class ConceptValidatorTest method validate_shouldFailIfAnyNameIsAnEmptyString.

@Test
public void validate_shouldFailIfAnyNameIsAnEmptyString() {
    concept.addDescription(new ConceptDescription("some description", null));
    concept.setConceptClass(new ConceptClass(1));
    concept.setDatatype(new ConceptDatatype(1));
    concept.addName(new ConceptName("name", Context.getLocale()));
    concept.addName(new ConceptName("", Context.getLocale()));
    validator.validate(concept, errors);
    assertThat(errors, hasGlobalErrors("Concept.name.empty"));
}
Also used : ConceptClass(org.openmrs.ConceptClass) ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) ConceptDatatype(org.openmrs.ConceptDatatype) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 43 with ConceptClass

use of org.openmrs.ConceptClass in project openmrs-core by openmrs.

the class ConceptValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.

@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
    concept.addName(new ConceptName("CD4", Context.getLocale()));
    concept.addDescription(new ConceptDescription("some description", null));
    concept.setVersion("version");
    concept.setRetireReason("retireReason");
    concept.setConceptClass(new ConceptClass());
    concept.setDatatype(new ConceptDatatype());
    validator.validate(concept, errors);
    Assert.assertFalse(errors.hasErrors());
}
Also used : ConceptClass(org.openmrs.ConceptClass) ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) ConceptDatatype(org.openmrs.ConceptDatatype) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 44 with ConceptClass

use of org.openmrs.ConceptClass in project openmrs-core by openmrs.

the class ConceptValidatorTest method validate_shouldPassIfTheConceptHasAtleastOneFullySpecifiedNameAddedToIt.

@Test
public void validate_shouldPassIfTheConceptHasAtleastOneFullySpecifiedNameAddedToIt() {
    concept.addName(new ConceptName("one name", Context.getLocale()));
    concept.addDescription(new ConceptDescription("some description", null));
    concept.setConceptClass(new ConceptClass());
    concept.setDatatype(new ConceptDatatype());
    validator.validate(concept, errors);
    Assert.assertFalse(errors.hasErrors());
}
Also used : ConceptClass(org.openmrs.ConceptClass) ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) ConceptDatatype(org.openmrs.ConceptDatatype) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 45 with ConceptClass

use of org.openmrs.ConceptClass in project openmrs-core by openmrs.

the class ConceptValidatorTest method validate_shouldFailIfATermIsMappedMultipleTimesToTheSameConcept.

@Test
public void validate_shouldFailIfATermIsMappedMultipleTimesToTheSameConcept() {
    concept.setConceptClass(new ConceptClass());
    concept.setDatatype(new ConceptDatatype());
    concept.addName(new ConceptName("my name", Context.getLocale()));
    concept.addDescription(new ConceptDescription("some description", null));
    ConceptMap map1 = new ConceptMap(conceptService.getConceptReferenceTerm(1), conceptService.getConceptMapType(1));
    concept.addConceptMapping(map1);
    ConceptMap map2 = new ConceptMap(conceptService.getConceptReferenceTerm(1), conceptService.getConceptMapType(1));
    concept.addConceptMapping(map2);
    validator.validate(concept, errors);
    assertThat(errors, hasFieldErrors("conceptMappings[1]"));
}
Also used : ConceptClass(org.openmrs.ConceptClass) ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) ConceptMap(org.openmrs.ConceptMap) ConceptDatatype(org.openmrs.ConceptDatatype) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

ConceptClass (org.openmrs.ConceptClass)55 Test (org.junit.Test)50 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)46 ConceptDatatype (org.openmrs.ConceptDatatype)38 ConceptName (org.openmrs.ConceptName)33 ConceptDescription (org.openmrs.ConceptDescription)31 Concept (org.openmrs.Concept)27 Locale (java.util.Locale)12 OpenmrsMatchers.hasConcept (org.openmrs.test.OpenmrsMatchers.hasConcept)12 BindException (org.springframework.validation.BindException)9 Errors (org.springframework.validation.Errors)9 OrderType (org.openmrs.OrderType)5 HashSet (java.util.HashSet)4 ConceptMap (org.openmrs.ConceptMap)3 ConceptNumeric (org.openmrs.ConceptNumeric)3 ConceptBuilder (org.openmrs.module.emrapi.test.builder.ConceptBuilder)3 ConceptComplex (org.openmrs.ConceptComplex)2 ConceptMapType (org.openmrs.ConceptMapType)2 ConceptSearchResult (org.openmrs.ConceptSearchResult)2 ConceptSource (org.openmrs.ConceptSource)2