Search in sources :

Example 31 with ConceptDescription

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

the class OrderFrequencyValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.

/**
 * @see OrderFrequencyValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
    ConceptService cs = Context.getConceptService();
    Concept concept = new Concept();
    ConceptName cn = new ConceptName("new name", Context.getLocale());
    concept.setDatatype(cs.getConceptDatatype(1));
    concept.setConceptClass(cs.getConceptClass(19));
    concept.addName(cn);
    concept.addDescription(new ConceptDescription("some description", null));
    cs.saveConcept(concept);
    OrderFrequency orderFrequency = new OrderFrequency();
    orderFrequency.setConcept(concept);
    orderFrequency.setRetireReason("retireReason");
    Errors errors = new BindException(orderFrequency, "orderFrequency");
    new OrderFrequencyValidator().validate(orderFrequency, errors);
    Assert.assertFalse(errors.hasErrors());
}
Also used : Concept(org.openmrs.Concept) Errors(org.springframework.validation.Errors) ConceptName(org.openmrs.ConceptName) BindException(org.springframework.validation.BindException) ConceptDescription(org.openmrs.ConceptDescription) ConceptService(org.openmrs.api.ConceptService) OrderFrequency(org.openmrs.OrderFrequency) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 32 with ConceptDescription

use of org.openmrs.ConceptDescription 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 33 with ConceptDescription

use of org.openmrs.ConceptDescription 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 34 with ConceptDescription

use of org.openmrs.ConceptDescription 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 35 with ConceptDescription

use of org.openmrs.ConceptDescription 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)

Aggregations

Test (org.junit.Test)48 ConceptDescription (org.openmrs.ConceptDescription)48 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)47 ConceptName (org.openmrs.ConceptName)42 Concept (org.openmrs.Concept)33 ConceptDatatype (org.openmrs.ConceptDatatype)32 ConceptClass (org.openmrs.ConceptClass)31 OpenmrsMatchers.hasConcept (org.openmrs.test.OpenmrsMatchers.hasConcept)20 Locale (java.util.Locale)14 OrderFrequency (org.openmrs.OrderFrequency)5 ConceptMap (org.openmrs.ConceptMap)4 ConceptNumeric (org.openmrs.ConceptNumeric)4 ConceptComplex (org.openmrs.ConceptComplex)3 ConceptService (org.openmrs.api.ConceptService)3 BindException (org.springframework.validation.BindException)3 Errors (org.springframework.validation.Errors)3 ConceptProposal (org.openmrs.ConceptProposal)2 OrderUtilTest (org.openmrs.order.OrderUtilTest)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1