Search in sources :

Example 6 with ConceptStateConversion

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

the class StateConversionValidatorTest method validate_shouldFailValidationIfConceptIsNullOrEmptyOrWhitespace.

/**
 * @see StateConversionValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfConceptIsNullOrEmptyOrWhitespace() {
    ConceptStateConversion csc = new ConceptStateConversion();
    ProgramWorkflow workflow = Context.getProgramWorkflowService().getProgram(1).getAllWorkflows().iterator().next();
    csc.setProgramWorkflow(workflow);
    csc.setProgramWorkflowState(workflow.getState(1));
    Errors errors = new BindException(csc, "csc");
    new StateConversionValidator().validate(csc, errors);
    Assert.assertTrue(errors.hasFieldErrors("concept"));
}
Also used : ProgramWorkflow(org.openmrs.ProgramWorkflow) Errors(org.springframework.validation.Errors) BindException(org.springframework.validation.BindException) ConceptStateConversion(org.openmrs.ConceptStateConversion) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 7 with ConceptStateConversion

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

the class StateConversionValidatorTest method validate_shouldPassValidationIfAllRequiredFieldsHaveProperValues.

/**
 * @see StateConversionValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldPassValidationIfAllRequiredFieldsHaveProperValues() {
    ConceptStateConversion csc = new ConceptStateConversion();
    ProgramWorkflow workflow = Context.getProgramWorkflowService().getProgram(1).getAllWorkflows().iterator().next();
    csc.setConcept(Context.getConceptService().getConcept(3));
    csc.setProgramWorkflow(workflow);
    csc.setProgramWorkflowState(workflow.getState(1));
    Errors errors = new BindException(csc, "csc");
    new StateConversionValidator().validate(csc, errors);
    Assert.assertFalse(errors.hasErrors());
}
Also used : ProgramWorkflow(org.openmrs.ProgramWorkflow) Errors(org.springframework.validation.Errors) BindException(org.springframework.validation.BindException) ConceptStateConversion(org.openmrs.ConceptStateConversion) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

ConceptStateConversion (org.openmrs.ConceptStateConversion)7 Test (org.junit.Test)5 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)5 ProgramWorkflow (org.openmrs.ProgramWorkflow)4 BindException (org.springframework.validation.BindException)4 Errors (org.springframework.validation.Errors)4 Criteria (org.hibernate.Criteria)1