use of org.openmrs.ImplementationId in project openmrs-core by openmrs.
the class AdministrationServiceTest method setImplementationId_shouldThrowAPIExceptionIfGivenACaretInTheImplementationIdCode.
/**
* This uses a try/catch so that we can make sure no blank id is saved to the database.
*
* @see AdministrationService#setImplementationId(ImplementationId)
*/
@Test
public void setImplementationId_shouldThrowAPIExceptionIfGivenACaretInTheImplementationIdCode() {
// save an impl id with an invalid hl7 code
ImplementationId invalidId = new ImplementationId();
invalidId.setImplementationId("caret^caret");
invalidId.setName("an invalid impl id for a unit test");
invalidId.setPassphrase("some valid passphrase");
invalidId.setDescription("Some valid description");
try {
adminService.setImplementationId(invalidId);
fail("An exception should be thrown on an invalid impl id save");
} catch (APIException e) {
// expected exception
}
ImplementationId afterInvalid = adminService.getImplementationId();
assertNull("There shouldn't be an impl id defined after setting an invalid impl id", afterInvalid);
}
use of org.openmrs.ImplementationId in project openmrs-core by openmrs.
the class AdministrationServiceTest method setImplementationId_shouldSetUuidOnImplementationIdGlobalProperty.
/**
* @see AdministrationService#setImplementationId(ImplementationId)
*/
@Test
@Ignore
public void setImplementationId_shouldSetUuidOnImplementationIdGlobalProperty() {
ImplementationId validId = new ImplementationId();
validId.setImplementationId("JUNIT-TEST");
validId.setName("JUNIT-TEST implementation id");
validId.setPassphrase("This is the junit test passphrase");
validId.setDescription("This is the junit impl id used for testing of the openmrs API only.");
adminService.setImplementationId(validId);
GlobalProperty gp = adminService.getGlobalPropertyObject(OpenmrsConstants.GLOBAL_PROPERTY_IMPLEMENTATION_ID);
Assert.assertNotNull(gp.getUuid());
}
use of org.openmrs.ImplementationId in project openmrs-core by openmrs.
the class ImplementationIdValidatorTest method validate_shouldFailValidationIfImplementationIdIsNull.
/**
* @see ImplementationIdValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailValidationIfImplementationIdIsNull() {
ImplementationId implementationId = new ImplementationId();
implementationId.setPassphrase("PASSPHRASE");
implementationId.setDescription("Description");
Errors errors = new BindException(implementationId, "implementationId");
new ImplementationIdValidator().validate(implementationId, errors);
Assert.assertTrue(errors.hasFieldErrors("implementationId"));
Assert.assertFalse(errors.hasFieldErrors("passphrase"));
Assert.assertFalse(errors.hasFieldErrors("description"));
}
use of org.openmrs.ImplementationId in project openmrs-core by openmrs.
the class ImplementationIdValidatorTest method validate_shouldPassValidationIfDescriptionIsNull.
/**
* @see ImplementationIdValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldPassValidationIfDescriptionIsNull() {
ImplementationId implementationId = new ImplementationId();
implementationId.setImplementationId("IMPL_ID");
implementationId.setPassphrase("PASSPHRASE");
Errors errors = new BindException(implementationId, "implementationId");
new ImplementationIdValidator().validate(implementationId, errors);
Assert.assertFalse(errors.hasFieldErrors("description"));
Assert.assertFalse(errors.hasFieldErrors("implementationId"));
Assert.assertFalse(errors.hasFieldErrors("passphrase"));
}
use of org.openmrs.ImplementationId in project openmrs-core by openmrs.
the class ImplementationIdValidatorTest method validate_shouldFailIfGivenEmptyImplementationIdObject.
/**
* @see ImplementationIdValidator#validate(Object,Errors)
*/
@Test
public void validate_shouldFailIfGivenEmptyImplementationIdObject() {
// save a blank impl id. exception thrown
ImplementationId implementationId = new ImplementationId();
Errors errors = new BindException(implementationId, "implementationId");
new ImplementationIdValidator().validate(implementationId, errors);
Assert.assertTrue(errors.hasFieldErrors("passphrase"));
Assert.assertTrue(errors.hasFieldErrors("implementationId"));
Assert.assertFalse(errors.hasFieldErrors("description"));
}
Aggregations