Search in sources :

Example 36 with Provider

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

the class ProviderServiceTest method getProviders_shouldFindProviderByIdentifier.

/**
 * @see ProviderService#getProviders(String,Integer,Integer,Map,boolean)
 */
@Test
public void getProviders_shouldFindProviderByIdentifier() {
    String identifier = "8a760";
    List<Provider> providers = service.getProviders(identifier, null, null, null, true);
    Provider provider = service.getProviderByIdentifier(identifier);
    Assert.assertTrue(providers.contains(provider));
}
Also used : Provider(org.openmrs.Provider) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 37 with Provider

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

the class ProviderValidatorTest method validate_shouldFailValidationIfFieldLengthsAreNotCorrect.

/**
 * @see ProviderValidator#validate(Object, Errors)
 */
@Test
public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() {
    Provider provider = new Provider();
    provider.setIdentifier("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
    provider.setRetireReason("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
    Errors errors = new BindException(provider, "type");
    providerValidator.validate(provider, errors);
    Assert.assertTrue(errors.hasFieldErrors("identifier"));
    Assert.assertTrue(errors.hasFieldErrors("retireReason"));
}
Also used : Errors(org.springframework.validation.Errors) BindException(org.springframework.validation.BindException) Provider(org.openmrs.Provider) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 38 with Provider

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

the class ProviderValidatorTest method validate_shouldAcceptADuplicateIdentifierForANewProviderWhichIsRetired.

/**
 * @see ProviderValidator#validate(Object, Errors)
 */
@Test
public void validate_shouldAcceptADuplicateIdentifierForANewProviderWhichIsRetired() {
    executeDataSet(OTHERS_PROVIDERS_XML);
    Provider duplicateProvider = providerService.getProvider(1);
    Assert.assertFalse(duplicateProvider.getRetired());
    Provider providerToValidate = providerService.getProvider(201);
    Assert.assertTrue(providerToValidate.getRetired());
    providerToValidate.setIdentifier(duplicateProvider.getIdentifier());
    providerValidator.validate(providerToValidate, errors);
    Assert.assertFalse(errors.hasErrors());
}
Also used : Provider(org.openmrs.Provider) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 39 with Provider

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

the class ProviderValidatorTest method validate_shouldPassValidationIfFieldLengthsAreCorrect.

/**
 * @see ProviderValidator#validate(Object, Errors)
 */
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
    Provider provider = new Provider();
    provider.setIdentifier("identifier");
    provider.setRetireReason("retireReason");
    Person person = new Person();
    Set<PersonName> personNames = new HashSet<>(1);
    PersonName personName = new PersonName();
    personName.setFamilyName("name");
    personNames.add(personName);
    person.setNames(personNames);
    provider.setPerson(person);
    providerValidator.validate(provider, errors);
    Assert.assertFalse(errors.hasErrors());
}
Also used : PersonName(org.openmrs.PersonName) Person(org.openmrs.Person) Provider(org.openmrs.Provider) HashSet(java.util.HashSet) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 40 with Provider

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

the class ProviderValidatorTest method validate_shouldAcceptDuplicateIdentifierIfTheExistingProviderIsNotRetired.

/**
 * @see ProviderValidator#validate(Object, Errors)
 */
@Test
public void validate_shouldAcceptDuplicateIdentifierIfTheExistingProviderIsNotRetired() {
    executeDataSet(OTHERS_PROVIDERS_XML);
    Provider duplicateProvider = providerService.getProvider(200);
    Provider existingProviderToEdit = providerService.getProvider(1);
    existingProviderToEdit.setIdentifier(duplicateProvider.getIdentifier());
    providerValidator.validate(existingProviderToEdit, errors);
    Assert.assertFalse(errors.hasErrors());
}
Also used : Provider(org.openmrs.Provider) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

Provider (org.openmrs.Provider)49 Test (org.junit.Test)40 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)33 Encounter (org.openmrs.Encounter)16 Date (java.util.Date)12 Person (org.openmrs.Person)10 Patient (org.openmrs.Patient)9 EncounterType (org.openmrs.EncounterType)8 EncounterRole (org.openmrs.EncounterRole)7 Location (org.openmrs.Location)7 PersonName (org.openmrs.PersonName)6 TestOrder (org.openmrs.TestOrder)5 Message (ca.uhn.hl7v2.model.Message)4 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)4 DrugOrder (org.openmrs.DrugOrder)4 Order (org.openmrs.Order)4 OrderUtilTest (org.openmrs.order.OrderUtilTest)4 Criteria (org.hibernate.Criteria)3 Concept (org.openmrs.Concept)3 User (org.openmrs.User)3