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));
}
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"));
}
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());
}
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());
}
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());
}
Aggregations