org.springframework.validation.Errors.hasFieldErrors()

Here are the examples of the java api org.springframework.validation.Errors.hasFieldErrors() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

296 Examples 7

19 View Source File : OrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see OrderValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfConceptIsNull() {
    Order order = new Order();
    order.setPatient(Context.getPatientService().getPatient(2));
    order.setOrderer(Context.getProviderService().getProvider(1));
    Errors errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);
    replacedert.replacedertFalse(errors.hasFieldErrors("discontinued"));
    replacedert.replacedertTrue(errors.hasFieldErrors("concept"));
    replacedert.replacedertFalse(errors.hasFieldErrors("patient"));
    replacedert.replacedertFalse(errors.hasFieldErrors("orderer"));
}

18 View Source File : MappedPayloadsUnitTests.java
License : Apache License 2.0
Project Creator : odrotbohm

@Test
void rejectsFieldByMethodReference() {
    createPayload(new Payload()).rejectField("someField", "error.code").peekErrors(errors -> {
        replacedertThat(errors.hasFieldErrors("someField")).isTrue();
    });
}

18 View Source File : OrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see OrderValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfUrgencyIsNull() {
    Order order = new Order();
    order.setConcept(Context.getConceptService().getConcept(88));
    order.setPatient(Context.getPatientService().getPatient(2));
    order.setUrgency(null);
    Errors errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("urgency"));
}

18 View Source File : OrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see OrderValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailValidationIfScheduledDateIsNullWhenUrgencyIsON_SCHEDULED_DATE() {
    Order order = new Order();
    order.setConcept(Context.getConceptService().getConcept(88));
    order.setPatient(Context.getPatientService().getPatient(2));
    order.setOrderer(Context.getProviderService().getProvider(1));
    order.setUrgency(Order.Urgency.ON_SCHEDULED_DATE);
    order.setScheduledDate(null);
    Errors errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("scheduledDate"));
    order.setScheduledDate(new Date());
    order.setUrgency(Order.Urgency.STAT);
    errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);
    replacedert.replacedertFalse(errors.hasFieldErrors("scheduledDate"));
}

18 View Source File : OrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see OrderValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfOrdererIsNull() {
    Order order = new Order();
    order.setConcept(Context.getConceptService().getConcept(88));
    order.setPatient(Context.getPatientService().getPatient(2));
    Errors errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);
    replacedert.replacedertFalse(errors.hasFieldErrors("discontinued"));
    replacedert.replacedertFalse(errors.hasFieldErrors("concept"));
    replacedert.replacedertTrue(errors.hasFieldErrors("orderer"));
    replacedert.replacedertFalse(errors.hasFieldErrors("patient"));
}

18 View Source File : OrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see OrderValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfActionIsNull() {
    Order order = new Order();
    order.setConcept(Context.getConceptService().getConcept(88));
    order.setPatient(Context.getPatientService().getPatient(2));
    order.setAction(null);
    Errors errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("action"));
}

18 View Source File : OrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see OrderValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailValidationIfScheduledDateIsSetAndUrgencyIsNotSetAsON_SCHEDULED_DATE() {
    Order order = new Order();
    order.setConcept(Context.getConceptService().getConcept(88));
    order.setPatient(Context.getPatientService().getPatient(2));
    order.setOrderer(Context.getProviderService().getProvider(1));
    order.setScheduledDate(new Date());
    order.setUrgency(Order.Urgency.ROUTINE);
    Errors errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("urgency"));
    order.setScheduledDate(new Date());
    order.setUrgency(Order.Urgency.ON_SCHEDULED_DATE);
    errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);
    replacedert.replacedertFalse(errors.hasFieldErrors("urgency"));
}

18 View Source File : OrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see OrderValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfVoidedIsNull() {
    Order order = new Order();
    order.setVoided(null);
    order.setConcept(Context.getConceptService().getConcept(88));
    order.setPatient(Context.getPatientService().getPatient(2));
    order.setOrderer(Context.getProviderService().getProvider(1));
    Errors errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);
    replacedert.replacedertFalse(errors.hasFieldErrors("discontinued"));
    replacedert.replacedertTrue(errors.hasFieldErrors("voided"));
    replacedert.replacedertFalse(errors.hasFieldErrors("concept"));
    replacedert.replacedertFalse(errors.hasFieldErrors("patient"));
    replacedert.replacedertFalse(errors.hasFieldErrors("orderer"));
}

18 View Source File : OrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see OrderValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfPatientIsNull() {
    Order order = new Order();
    order.setConcept(Context.getConceptService().getConcept(88));
    order.setOrderer(Context.getProviderService().getProvider(1));
    Errors errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);
    replacedert.replacedertFalse(errors.hasFieldErrors("discontinued"));
    replacedert.replacedertFalse(errors.hasFieldErrors("concept"));
    replacedert.replacedertTrue(errors.hasFieldErrors("patient"));
    replacedert.replacedertFalse(errors.hasFieldErrors("orderer"));
}

18 View Source File : DrugOrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see DrugOrderValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldNotFailValidationIfDrugIsNull() {
    DrugOrder order = new DrugOrder();
    order.setDrug(null);
    Errors errors = new BindException(order, "order");
    new DrugOrderValidator().validate(order, errors);
    replacedert.replacedertFalse(errors.hasFieldErrors("drug"));
}

18 View Source File : DrugOrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailIfConceptIsNullAndDrugIsNotSpecified() {
    DrugOrder order = new DrugOrder();
    Errors errors = new BindException(order, "order");
    new DrugOrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("concept"));
}

18 View Source File : AlertValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

private void replacedertThatFieldTextHasError() {
    replacedert.replacedertTrue(errors.hasFieldErrors("text"));
}

17 View Source File : ProviderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see ProviderValidator#validate(Object, Errors)
 */
@Test
public void validate_shouldBeValidIfIdentifierIsSet() {
    // given
    provider.setIdentifier("id");
    // when
    providerValidator.validate(provider, errors);
    // then
    replacedert.replacedertFalse(errors.hasFieldErrors("identifier"));
}

17 View Source File : OrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see OrderValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfEncounterIsNull() {
    Order order = new Order();
    order.setConcept(Context.getConceptService().getConcept(88));
    order.setPatient(Context.getPatientService().getPatient(2));
    order.setEncounter(null);
    Errors errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("encounter"));
}

17 View Source File : OrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see OrderValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldPreplacedValidationIfTheClreplacedOfTheOrderIsASubclreplacedOfOrderTypejavaClreplaced() {
    SomeDrugOrder order = new SomeDrugOrder();
    order.setConcept(Context.getConceptService().getConcept(88));
    order.setPatient(Context.getPatientService().getPatient(2));
    order.setOrderer(Context.getProviderService().getProvider(1));
    order.setOrderType(Context.getOrderService().getOrderTypeByName("Drug order"));
    Errors errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);
    replacedert.replacedertFalse(errors.hasFieldErrors("orderType"));
}

17 View Source File : OrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see OrderValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfOrderAndEncounterHaveDifferentPatients() {
    Order order = new Order();
    order.setConcept(Context.getConceptService().getConcept(88));
    order.setPatient(Context.getPatientService().getPatient(2));
    order.setEncounter(Context.getEncounterService().getEncounter(3));
    order.setOrderer(Context.getProviderService().getProvider(1));
    Errors errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("encounter"));
}

17 View Source File : OrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @throws Exception
 * @see OrderValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfDateActivatedAfterDateStopped() throws Exception {
    Order order = new Order();
    order.setConcept(Context.getConceptService().getConcept(88));
    order.setPatient(Context.getPatientService().getPatient(2));
    order.setOrderer(Context.getProviderService().getProvider(1));
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) - 1);
    order.setDateActivated(new Date());
    OrderUtilTest.setDateStopped(order, cal.getTime());
    Errors errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("dateActivated"));
    replacedert.replacedertTrue(errors.hasFieldErrors("dateStopped"));
}

17 View Source File : EncounterValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see EncounterValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailIfEncounterTypeIsNotSet() {
    encounterValidator.validate(encounter, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("encounterType"));
}

17 View Source File : EncounterValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see EncounterValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailIfPatientIsNotSet() {
    encounterValidator.validate(encounter, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("patient"));
}

17 View Source File : EncounterValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see EncounterValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailIfEncounterDateTimeIsNotSet() {
    encounterValidator.validate(encounter, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("encounterDatetime"));
}

17 View Source File : DrugOrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailValidationIfDoseUnitsIsNullForSimpleDosingInstructionsDosingType() {
    DrugOrder order = new DrugOrder();
    order.setDosingType(SimpleDosingInstructions.clreplaced);
    order.setDoseUnits(null);
    Errors errors = new BindException(order, "order");
    new DrugOrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("doseUnits"));
}

17 View Source File : DrugOrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailValidationIfDoseIsNullForSimpleDosingInstructionsDosingType() {
    DrugOrder order = new DrugOrder();
    order.setDosingType(SimpleDosingInstructions.clreplaced);
    order.setDose(null);
    Errors errors = new BindException(order, "order");
    new DrugOrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("dose"));
}

17 View Source File : DrugOrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see DrugOrderValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfAsNeededIsNull() {
    DrugOrder order = new DrugOrder();
    order.setAsNeeded(null);
    order.setDrug(Context.getConceptService().getDrug(3));
    Errors errors = new BindException(order, "order");
    new DrugOrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("asNeeded"));
}

17 View Source File : DrugOrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldNotValidateACustomDosingTypeAgainstAnyOtherDosingTypeValidation() {
    DrugOrder order = new DrugOrder();
    order.setDosingType(CustomDosingInstructions.clreplaced);
    order.setDosingInstructions(null);
    Errors errors = new BindException(order, "order");
    new DrugOrderValidator().validate(order, errors);
    replacedert.replacedertFalse(errors.hasFieldErrors("dosingInstructions"));
}

17 View Source File : DrugOrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailValidationIfDosingInstructionsIsNullForFreeTextDosingInstructionsDosingType() {
    DrugOrder order = new DrugOrder();
    order.setDosingType(FreeTextDosingInstructions.clreplaced);
    order.setDosingInstructions(null);
    Errors errors = new BindException(order, "order");
    new DrugOrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("dosingInstructions"));
}

17 View Source File : DrugOrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailValidationIfDoseUnitsIsNullWhenDoseIsPresent() {
    DrugOrder order = new DrugOrder();
    order.setDosingType(FreeTextDosingInstructions.clreplaced);
    order.setDose(20.0);
    order.setDoseUnits(null);
    Errors errors = new BindException(order, "order");
    new DrugOrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("doseUnits"));
}

17 View Source File : DiagnosisValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

@Test
public void validate_shouldFailValidationIfCertaintyIsNull() {
    diagnosis.setCertainty(null);
    new DiagnosisValidator().validate(diagnosis, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("certainty"));
}

17 View Source File : DiagnosisValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

@Test
public void validate_shouldFailValidationIfDiagnosisIsNull() {
    diagnosis.setDiagnosis(null);
    new DiagnosisValidator().validate(diagnosis, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("diagnosis"));
}

17 View Source File : ConditionValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

@Test
public void shouldFailIfGivenConditionWithNullConditionProperties() {
    Condition condition = new Condition();
    validator.validate(condition, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("condition"));
    replacedert.replacedertTrue(errors.hasFieldErrors("clinicalStatus"));
}

17 View Source File : ConceptAttributeTypeValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

private void replacedertThatFieldExceedsMaxLength(String field) {
    replacedert.replacedertTrue(String.format("Field '%s' has error(s)", field), errors.hasFieldErrors(field));
    replacedertThat(errors.getFieldErrors(field).get(0).getCode(), is("error.exceededMaxLengthOfField"));
}

17 View Source File : CohortValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

@Test
public void validate_shouldPreplacedIfPatientIsNonVoided() {
    validator.validate(cohort, errors);
    replacedert.replacedertFalse(errors.hasErrors());
    replacedert.replacedertFalse(errors.hasFieldErrors("memberships"));
}

17 View Source File : CohortValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

@Test
public void validate_shouldPreplacedIfMembershipisVoided() {
    cohortMembership.setVoided(true);
    validator.validate(cohort, errors);
    replacedert.replacedertFalse(errors.hasErrors());
    replacedert.replacedertFalse(errors.hasFieldErrors("memberships"));
}

17 View Source File : AllergyValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see AllergyValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailIfPatientIsNull() {
    validator.validate(allergy, errors);
    replacedertTrue(errors.hasFieldErrors("patient"));
    replacedertThat(errors.getFieldError("patient").getCode(), is("allergyapi.patient.required"));
}

17 View Source File : AllergyValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see AllergyValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailIfAllergenIsNull() {
    validator.validate(allergy, errors);
    replacedertTrue(errors.hasFieldErrors("allergen"));
    replacedertThat(errors.getFieldError("allergen").getCode(), is("allergyapi.allergen.required"));
}

16 View Source File : PersonValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see org.openmrs.validator.PersonValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldPreplacedValidationIfGenderIsBlankForPersons() {
    Person person = new Person(1);
    Errors errors = new BindException(person, "person");
    PersonValidator personValidator = new PersonValidator();
    personValidator.validate(person, errors);
    replacedert.replacedertFalse(errors.hasFieldErrors("gender"));
}

16 View Source File : PersonMergeLogValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see PersonMergeLogValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldPreplacedValidationIfAllFieldsAreCorrect() {
    PersonMergeLog personMergeLog = new PersonMergeLog();
    personMergeLog.setWinner(new Person());
    personMergeLog.setLoser(new Person());
    personMergeLog.setPersonMergeLogData(new PersonMergeLogData());
    PersonMergeLogValidator validator = new PersonMergeLogValidator();
    Errors errors = new BindException(personMergeLog, "personMergeLog");
    validator.validate(personMergeLog, errors);
    replacedert.replacedertFalse(errors.hasFieldErrors());
}

16 View Source File : PatientValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see org.openmrs.validator.PatientValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfGenderIsBlank() {
    Patient pa = new Patient(1);
    Errors errors = new BindException(pa, "patient");
    validator.validate(pa, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("gender"));
}

16 View Source File : OrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see OrderValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfDateActivatedAfterAutoExpireDate() {
    Order order = new Order();
    order.setConcept(Context.getConceptService().getConcept(88));
    order.setPatient(Context.getPatientService().getPatient(2));
    order.setOrderer(Context.getProviderService().getProvider(1));
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.DAY_OF_MONTH, cal.get(Calendar.DAY_OF_MONTH) - 1);
    order.setDateActivated(new Date());
    order.setAutoExpireDate(cal.getTime());
    Errors errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("dateActivated"));
    replacedert.replacedertTrue(errors.hasFieldErrors("autoExpireDate"));
}

16 View Source File : OrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

@Test
public void saveOrder_shouldNotSaveOrderIfInvalidOrderGroupPatient() {
    executeDataSet(ORDER_SET);
    OrderGroup orderGroup = new OrderGroup();
    orderGroup.setEncounter(Context.getEncounterService().getEncounter(5));
    orderGroup.setPatient(Context.getPatientService().getPatient(2));
    Order order = new OrderBuilder().withAction(Order.Action.NEW).withPatient(7).withConcept(1000).withCareSetting(1).withOrderer(1).withEncounter(3).withDateActivated(new Date()).withOrderType(17).withUrgency(Order.Urgency.ON_SCHEDULED_DATE).withScheduledDate(new Date()).withOrderGroup(orderGroup).build();
    Errors errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("patient"));
    replacedert.replacedertEquals("Order.error.orderPatientAndOrderGroupPatientMismatch", errors.getFieldError("patient").getCode());
}

16 View Source File : OrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see OrderValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailValidationIfDateActivatedIsBeforeEncountersEncounterDatetime() {
    Date encounterDate = new Date();
    Date orderDate = DateUtils.addDays(encounterDate, -1);
    Encounter encounter = Context.getEncounterService().getEncounter(3);
    encounter.setEncounterDatetime(encounterDate);
    Order order = new Order();
    order.setDateActivated(orderDate);
    order.setConcept(Context.getConceptService().getConcept(88));
    order.setPatient(Context.getPatientService().getPatient(2));
    order.setEncounter(encounter);
    order.setOrderer(Context.getProviderService().getProvider(1));
    Errors errors = new BindException(order, "order");
    new OrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("dateActivated"));
}

16 View Source File : DrugOrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see DrugOrderValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfDosingTypeIsNull() {
    DrugOrder order = new DrugOrder();
    order.setDosingType(null);
    order.setDrug(Context.getConceptService().getDrug(3));
    Errors errors = new BindException(order, "order");
    new DrugOrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("dosingType"));
}

16 View Source File : DrugOrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailValidationIfRouteIsNullForSimpleDosingInstructionsDosingType() {
    DrugOrder order = new DrugOrder();
    order.setDosingType(SimpleDosingInstructions.clreplaced);
    order.setRoute(null);
    Errors errors = new BindException(order, "order");
    new DrugOrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("route"));
}

16 View Source File : DrugOrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailValidationIfNumberOfRefillsIsNullForOutpatientCareSetting() {
    DrugOrder OutpatientOrder = new DrugOrder();
    OutpatientOrder.setCareSetting(Context.getOrderService().getCareSetting(1));
    OutpatientOrder.setNumRefills(null);
    Errors OutpatientOrderErrors = new BindException(OutpatientOrder, "order");
    new DrugOrderValidator().validate(OutpatientOrder, OutpatientOrderErrors);
    replacedert.replacedertTrue(OutpatientOrderErrors.hasFieldErrors("numRefills"));
    DrugOrder inPatientOrder = new DrugOrder();
    inPatientOrder.setCareSetting(Context.getOrderService().getCareSetting(2));
    inPatientOrder.setNumRefills(null);
    Errors InpatientOrderErrors = new BindException(inPatientOrder, "order");
    new DrugOrderValidator().validate(inPatientOrder, InpatientOrderErrors);
    replacedert.replacedertFalse(InpatientOrderErrors.hasFieldErrors("numRefills"));
}

16 View Source File : DrugOrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailValidationIfDurationUnitsIsNullWhenDurationIsPresent() {
    DrugOrder order = new DrugOrder();
    order.setDosingType(FreeTextDosingInstructions.clreplaced);
    order.setDuration(20);
    order.setDurationUnits(null);
    Errors errors = new BindException(order, "order");
    new DrugOrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("durationUnits"));
}

16 View Source File : DrugOrderValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see DrugOrderValidator#validate(Object, org.springframework.validation.Errors)
 */
@Test
public void validate_shouldFailValidationIfFrequencyIsNullForSimpleDosingInstructionsDosingType() {
    DrugOrder order = new DrugOrder();
    order.setDosingType(SimpleDosingInstructions.clreplaced);
    order.setFrequency(null);
    Errors errors = new BindException(order, "order");
    new DrugOrderValidator().validate(order, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("frequency"));
}

16 View Source File : DiagnosisValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

/**
 * @see DiagnosisValidator#validate(Object, Errors)
 */
@Test
public void validate_shouldFailValidationIfEncounterIsNull() {
    diagnosis.setEncounter(null);
    new DiagnosisValidator().validate(diagnosis, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("encounter"));
}

16 View Source File : DiagnosisValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

@Test
public void validate_shouldFailValidationIfRankIsNonPositive() {
    diagnosis.setRank(-1);
    new DiagnosisValidator().validate(diagnosis, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("rank"));
}

16 View Source File : DiagnosisValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

@Test
public void validate_shouldFailValidationIfRankIsNull() {
    diagnosis.setRank(null);
    new DiagnosisValidator().validate(diagnosis, errors);
    replacedert.replacedertTrue(errors.hasFieldErrors("rank"));
}

16 View Source File : ConditionValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

@Test
public void shouldPreplacedIfConditionClreplacedIsPreplacededWithRequiredConditionProperties() {
    Condition condition = new Condition();
    condition.setCondition(new CodedOrFreeText(new Concept(), new ConceptName("name", new Locale("en")), "nonCoded"));
    condition.setClinicalStatus(ConditionClinicalStatus.ACTIVE);
    validator.validate(condition, errors);
    replacedert.replacedertFalse(errors.hasFieldErrors("condition"));
    replacedert.replacedertFalse(errors.hasFieldErrors("clinicalStatus"));
}

16 View Source File : ConceptClassValidatorTest.java
License : Apache License 2.0
Project Creator : isstac

@Test
public void validate_shouldPreplacedValidationIfDescriptionIsNullOrEmptyOrWhitespace() {
    ConceptClreplaced cc = new ConceptClreplaced();
    cc.setName("name");
    cc.setDescription(null);
    Errors errors = new BindException(cc, "cc");
    new ConceptClreplacedValidator().validate(cc, errors);
    replacedert.replacedertFalse(errors.hasFieldErrors("description"));
    cc.setDescription("");
    errors = new BindException(cc, "cc");
    new ConceptClreplacedValidator().validate(cc, errors);
    replacedert.replacedertFalse(errors.hasFieldErrors("description"));
    cc.setDescription(" ");
    errors = new BindException(cc, "cc");
    new ConceptClreplacedValidator().validate(cc, errors);
    replacedert.replacedertFalse(errors.hasFieldErrors("description"));
}

See More Examples