Search in sources :

Example 1 with ImplementationId

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

the class AdministrationServiceTest method setImplementationId_shouldOverwriteImplementationIdInDatabaseIfExists.

/**
 * @see AdministrationService#setImplementationId(ImplementationId)
 */
@Test
@Ignore
public void setImplementationId_shouldOverwriteImplementationIdInDatabaseIfExists() {
    executeDataSet("org/openmrs/api/include/AdministrationServiceTest-general.xml");
    // sanity check to make sure we have an implementation id
    Assert.assertNotNull(adminService.getImplementationId());
    // so a NonUniqueObjectException doesn't occur on the global property later
    Context.clearSession();
    // save a second valid id
    ImplementationId validId2 = new ImplementationId();
    validId2.setImplementationId("JUNIT-TEST 2");
    validId2.setName("JUNIT-TEST (#2) implementation id");
    validId2.setPassphrase("This is the junit test passphrase 2");
    validId2.setDescription("This is the junit impl id (2) used for testing of the openmrs API only.");
    adminService.setImplementationId(validId2);
    assertEquals(validId2, adminService.getImplementationId());
}
Also used : ImplementationId(org.openmrs.ImplementationId) Ignore(org.junit.Ignore) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 2 with ImplementationId

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

the class AdministrationServiceTest method setImplementationId_shouldThrowAPIExceptionIfGivenAPipeInTheImplementationIdCode.

/**
 * @see AdministrationService#setImplementationId(ImplementationId)
 */
@Test
public void setImplementationId_shouldThrowAPIExceptionIfGivenAPipeInTheImplementationIdCode() {
    // save an impl id with an invalid hl7 code
    ImplementationId invalidId2 = new ImplementationId();
    invalidId2.setImplementationId("pipe|pipe");
    invalidId2.setName("an invalid impl id for a unit test");
    invalidId2.setPassphrase("some valid passphrase");
    invalidId2.setDescription("Some valid description");
    try {
        adminService.setImplementationId(invalidId2);
        fail("An exception should be thrown on an invalid impl id save");
    } catch (APIException e) {
    // expected exception
    }
    ImplementationId afterInvalid2 = adminService.getImplementationId();
    assertNull("There shouldn't be an impl id defined after setting an invalid impl id", afterInvalid2);
}
Also used : ImplementationId(org.openmrs.ImplementationId) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 3 with ImplementationId

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

the class AdministrationServiceTest method setImplementationId_shouldThrowAPIExceptionIfGivenEmptyImplementationIdObject.

/**
 * 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_shouldThrowAPIExceptionIfGivenEmptyImplementationIdObject() {
    // save a blank impl id. exception thrown
    try {
        adminService.setImplementationId(new ImplementationId());
        fail("An exception should be thrown on a blank impl id save");
    } catch (APIException e) {
    // expected exception
    }
    ImplementationId afterBlank = adminService.getImplementationId();
    assertNull("There shouldn't be an impl id defined after setting a blank impl id", afterBlank);
}
Also used : ImplementationId(org.openmrs.ImplementationId) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 4 with ImplementationId

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

the class AdministrationServiceTest method setImplementationId_shouldCreateImplementationIdInDatabase.

/**
 * @see AdministrationService#setImplementationId(ImplementationId)
 */
@Test
@Ignore
public void setImplementationId_shouldCreateImplementationIdInDatabase() {
    // save a valid impl id
    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);
    assertEquals(validId, adminService.getImplementationId());
}
Also used : ImplementationId(org.openmrs.ImplementationId) Ignore(org.junit.Ignore) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 5 with ImplementationId

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

the class AdministrationServiceTest method setImplementationId_shouldNotFailIfGivenImplementationIdIsNull.

/**
 * @see AdministrationService#setImplementationId(ImplementationId)
 */
@Test
public void setImplementationId_shouldNotFailIfGivenImplementationIdIsNull() {
    // save a null impl id. no exception thrown
    adminService.setImplementationId(null);
    ImplementationId afterNull = adminService.getImplementationId();
    assertNull("There shouldn't be an impl id defined after setting a null impl id", afterNull);
}
Also used : ImplementationId(org.openmrs.ImplementationId) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

ImplementationId (org.openmrs.ImplementationId)15 Test (org.junit.Test)14 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)14 BindException (org.springframework.validation.BindException)7 Errors (org.springframework.validation.Errors)7 Ignore (org.junit.Ignore)3 GlobalProperty (org.openmrs.GlobalProperty)1 APIException (org.openmrs.api.APIException)1