Search in sources :

Example 6 with ConceptDatatype

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

the class ConceptValidatorTest method validate_shouldFailIfTheConceptClassIsNull.

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

Example 7 with ConceptDatatype

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

the class ConceptValidatorTest method validate_shouldPassIfFullySpecifiedNameIsTheSameAsShortName.

@Test
public void validate_shouldPassIfFullySpecifiedNameIsTheSameAsShortName() {
    ConceptName conceptFullySpecifiedName = new ConceptName("YES", new Locale("pl"));
    conceptFullySpecifiedName.setConceptNameType(ConceptNameType.FULLY_SPECIFIED);
    ConceptName conceptShortName = new ConceptName("yes", new Locale("pl"));
    conceptShortName.setConceptNameType(ConceptNameType.SHORT);
    concept.addName(conceptFullySpecifiedName);
    concept.addName(conceptShortName);
    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 : Locale(java.util.Locale) 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 8 with ConceptDatatype

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

the class ConceptValidatorTest method validate_shouldFailIfAnyNamesInTheSameLocaleForThisConceptAreSimilar.

@Test
public void validate_shouldFailIfAnyNamesInTheSameLocaleForThisConceptAreSimilar() {
    concept.addName(new ConceptName("same name", Context.getLocale()));
    concept.addName(new ConceptName("same name", Context.getLocale()));
    concept.addDescription(new ConceptDescription("some description", null));
    concept.setConceptClass(new ConceptClass());
    concept.setDatatype(new ConceptDatatype());
    expectedException.expect(DuplicateConceptNameException.class);
    expectedException.expectMessage("'same name' is a duplicate name in locale '" + Context.getLocale() + "'");
    validator.validate(concept, errors);
}
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 9 with ConceptDatatype

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

the class ConceptValidatorTest method validate_shouldPassForANewConceptWithAMapCreatedWithDeprecatedConceptMapMethods.

@Test
public void validate_shouldPassForANewConceptWithAMapCreatedWithDeprecatedConceptMapMethods() {
    concept.addName(new ConceptName("test name", Context.getLocale()));
    concept.addDescription(new ConceptDescription("some description", null));
    concept.setConceptClass(new ConceptClass());
    concept.setDatatype(new ConceptDatatype());
    ConceptMap map = new ConceptMap();
    map.getConceptReferenceTerm().setCode("unique code");
    map.getConceptReferenceTerm().setConceptSource(conceptService.getConceptSource(1));
    concept.addConceptMapping(map);
    ValidateUtil.validate(concept);
}
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)

Example 10 with ConceptDatatype

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

the class ConceptDatatypeValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.

/**
 * @see ConceptDatatypeValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
    ConceptDatatype cd = new ConceptDatatype();
    cd.setName("name");
    cd.setDescription("some text");
    cd.setHl7Abbreviation("hl7");
    cd.setRetireReason("retireReason");
    Errors errors = new BindException(cd, "cd");
    new ConceptDatatypeValidator().validate(cd, errors);
    Assert.assertFalse(errors.hasErrors());
}
Also used : Errors(org.springframework.validation.Errors) BindException(org.springframework.validation.BindException) ConceptDatatype(org.openmrs.ConceptDatatype) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

ConceptDatatype (org.openmrs.ConceptDatatype)54 Test (org.junit.Test)49 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)45 ConceptClass (org.openmrs.ConceptClass)38 ConceptName (org.openmrs.ConceptName)34 Concept (org.openmrs.Concept)32 ConceptDescription (org.openmrs.ConceptDescription)32 OpenmrsMatchers.hasConcept (org.openmrs.test.OpenmrsMatchers.hasConcept)13 Locale (java.util.Locale)12 BindException (org.springframework.validation.BindException)7 Errors (org.springframework.validation.Errors)7 Date (java.util.Date)4 ConceptNumeric (org.openmrs.ConceptNumeric)4 Obs (org.openmrs.Obs)4 ConceptMap (org.openmrs.ConceptMap)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