Search in sources :

Example 81 with Concept

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

the class ConceptValidatorTest method validate_shouldPassIfTheConceptIsBeingUpdatedWithNoNameChange.

@Test
public void validate_shouldPassIfTheConceptIsBeingUpdatedWithNoNameChange() {
    Concept conceptToUpdate = cd4Count;
    conceptToUpdate.setCreator(Context.getAuthenticatedUser());
    Errors errors = new BindException(conceptToUpdate, "concept");
    validator.validate(conceptToUpdate, errors);
    Assert.assertFalse(errors.hasErrors());
}
Also used : Concept(org.openmrs.Concept) Errors(org.springframework.validation.Errors) HasFieldErrors.hasFieldErrors(org.openmrs.test.matchers.HasFieldErrors.hasFieldErrors) HasGlobalErrors.hasGlobalErrors(org.openmrs.test.matchers.HasGlobalErrors.hasGlobalErrors) BindException(org.springframework.validation.BindException) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 82 with Concept

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

the class ConceptValidatorTest method validate_shouldPassIfTheConceptBeingValidatedIsRetiredAndHasADuplicateName.

@Test
public void validate_shouldPassIfTheConceptBeingValidatedIsRetiredAndHasADuplicateName() {
    Context.setLocale(new Locale("en", "GB"));
    Concept concept = cd4Count;
    conceptService.saveConcept(concept);
    String duplicateName = concept.getFullySpecifiedName(Context.getLocale()).getName();
    Concept anotherConcept = weight;
    anotherConcept.setRetired(true);
    anotherConcept.getFullySpecifiedName(Context.getLocale()).setName(duplicateName);
    Errors errors = new BindException(anotherConcept, "concept");
    validator.validate(anotherConcept, errors);
    Assert.assertFalse(errors.hasErrors());
}
Also used : Locale(java.util.Locale) Concept(org.openmrs.Concept) Errors(org.springframework.validation.Errors) HasFieldErrors.hasFieldErrors(org.openmrs.test.matchers.HasFieldErrors.hasFieldErrors) HasGlobalErrors.hasGlobalErrors(org.openmrs.test.matchers.HasGlobalErrors.hasGlobalErrors) BindException(org.springframework.validation.BindException) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 83 with Concept

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

the class ConceptValidatorTest method validate_shouldFailIfCodedConceptContainsItselfAsAnAnswer.

@Test
public void validate_shouldFailIfCodedConceptContainsItselfAsAnAnswer() {
    Concept concept = conceptService.getConcept(30);
    ConceptAnswer conceptAnswer = new ConceptAnswer(concept);
    concept.addAnswer(conceptAnswer);
    Errors errors = new BindException(concept, "concept");
    validator.validate(concept, errors);
    assertThat(errors, hasGlobalErrors("Concept.contains.itself.as.answer"));
}
Also used : Concept(org.openmrs.Concept) Errors(org.springframework.validation.Errors) HasFieldErrors.hasFieldErrors(org.openmrs.test.matchers.HasFieldErrors.hasFieldErrors) HasGlobalErrors.hasGlobalErrors(org.openmrs.test.matchers.HasGlobalErrors.hasGlobalErrors) ConceptAnswer(org.openmrs.ConceptAnswer) BindException(org.springframework.validation.BindException) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 84 with Concept

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

the class ConceptValidatorTest method validate_shouldFailIfThereIsNoNameExplicitlyMarkedAsFullySpecified.

@Test
public void validate_shouldFailIfThereIsNoNameExplicitlyMarkedAsFullySpecified() {
    Concept concept = cd4Count;
    for (ConceptName name : concept.getNames()) {
        name.setConceptNameType(null);
    }
    Errors errors = new BindException(concept, "concept");
    validator.validate(concept, errors);
    assertThat(errors, hasGlobalErrors("Concept.error.no.FullySpecifiedName"));
}
Also used : Concept(org.openmrs.Concept) Errors(org.springframework.validation.Errors) HasFieldErrors.hasFieldErrors(org.openmrs.test.matchers.HasFieldErrors.hasFieldErrors) HasGlobalErrors.hasGlobalErrors(org.openmrs.test.matchers.HasGlobalErrors.hasGlobalErrors) ConceptName(org.openmrs.ConceptName) BindException(org.springframework.validation.BindException) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 85 with Concept

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

the class ConceptValidatorTest method validate_shouldPassIfTheConceptWithADuplicateNameIsRetired.

@Test
public void validate_shouldPassIfTheConceptWithADuplicateNameIsRetired() {
    Context.setLocale(new Locale("en", "GB"));
    Concept concept = cd4Count;
    concept.setRetired(true);
    conceptService.saveConcept(concept);
    String duplicateName = concept.getFullySpecifiedName(Context.getLocale()).getName();
    Concept anotherConcept = weight;
    anotherConcept.getFullySpecifiedName(Context.getLocale()).setName(duplicateName);
    Errors errors = new BindException(anotherConcept, "concept");
    validator.validate(anotherConcept, errors);
    Assert.assertFalse(errors.hasErrors());
}
Also used : Locale(java.util.Locale) Concept(org.openmrs.Concept) Errors(org.springframework.validation.Errors) HasFieldErrors.hasFieldErrors(org.openmrs.test.matchers.HasFieldErrors.hasFieldErrors) HasGlobalErrors.hasGlobalErrors(org.openmrs.test.matchers.HasGlobalErrors.hasGlobalErrors) BindException(org.springframework.validation.BindException) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

Concept (org.openmrs.Concept)294 Test (org.junit.Test)210 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)176 ConceptName (org.openmrs.ConceptName)62 OpenmrsMatchers.hasConcept (org.openmrs.test.OpenmrsMatchers.hasConcept)62 Obs (org.openmrs.Obs)49 Date (java.util.Date)48 Patient (org.openmrs.Patient)42 ConceptDescription (org.openmrs.ConceptDescription)33 Locale (java.util.Locale)32 ConceptDatatype (org.openmrs.ConceptDatatype)32 OrderUtilTest (org.openmrs.order.OrderUtilTest)29 ConceptClass (org.openmrs.ConceptClass)27 ArrayList (java.util.ArrayList)26 BindException (org.springframework.validation.BindException)26 DrugOrder (org.openmrs.DrugOrder)25 Encounter (org.openmrs.Encounter)25 Errors (org.springframework.validation.Errors)25 ConceptMapBuilder (org.openmrs.module.metadatadeploy.builder.ConceptMapBuilder)21 Location (org.openmrs.Location)19