Search in sources :

Example 6 with ComplexObsHandler

use of org.openmrs.obs.ComplexObsHandler in project openmrs-core by openmrs.

the class ObsServiceTest method registerHandler_shouldRegisterHandlerWithTheGivenKey.

/**
 * @see ObsService#registerHandler(String,ComplexObsHandler)
 */
@Test
public void registerHandler_shouldRegisterHandlerWithTheGivenKey() {
    ObsService os = Context.getObsService();
    os.registerHandler("DummyHandler", new ImageHandler());
    ComplexObsHandler dummyHandler = os.getHandler("DummyHandler");
    Assert.assertNotNull(dummyHandler);
}
Also used : ImageHandler(org.openmrs.obs.handler.ImageHandler) ComplexObsHandler(org.openmrs.obs.ComplexObsHandler) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 7 with ComplexObsHandler

use of org.openmrs.obs.ComplexObsHandler in project openmrs-core by openmrs.

the class ObsServiceTest method removeHandler_shouldRemoveHandlerWithMatchingKey.

/**
 * @see ObsService#removeHandler(String)
 */
@Test
public void removeHandler_shouldRemoveHandlerWithMatchingKey() {
    ObsService os = Context.getObsService();
    // add the handler and make sure its there
    os.registerHandler("DummyHandler3", "org.openmrs.obs.handler.ImageHandler");
    ComplexObsHandler dummyHandler = os.getHandler("DummyHandler3");
    Assert.assertNotNull(dummyHandler);
    // now remove the handler and make sure its gone
    os.removeHandler("DummyHandler3");
    ComplexObsHandler dummyHandlerAgain = os.getHandler("DummyHandler3");
    Assert.assertNull(dummyHandlerAgain);
}
Also used : ComplexObsHandler(org.openmrs.obs.ComplexObsHandler) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 8 with ComplexObsHandler

use of org.openmrs.obs.ComplexObsHandler in project openmrs-core by openmrs.

the class ObsServiceTest method setHandlers_shouldAddNewHandlersWithNewKeys.

/**
 * @see ObsService#setHandlers(Map<QString;QComplexObsHandler;>)}
 */
@Test
public void setHandlers_shouldAddNewHandlersWithNewKeys() {
    ObsService os = Context.getObsService();
    Map<String, ComplexObsHandler> handlers = new HashMap<>();
    handlers.put("DummyHandler4", new ImageHandler());
    handlers.put("DummyHandler5", new BinaryDataHandler());
    handlers.put("DummyHandler6", new TextHandler());
    // set the handlers and make sure they're there
    os.setHandlers(handlers);
    ComplexObsHandler dummyHandler4 = os.getHandler("DummyHandler4");
    Assert.assertNotNull(dummyHandler4);
    ComplexObsHandler dummyHandler5 = os.getHandler("DummyHandler5");
    Assert.assertNotNull(dummyHandler5);
    ComplexObsHandler dummyHandler6 = os.getHandler("DummyHandler6");
    Assert.assertNotNull(dummyHandler6);
}
Also used : ImageHandler(org.openmrs.obs.handler.ImageHandler) BinaryDataHandler(org.openmrs.obs.handler.BinaryDataHandler) HashMap(java.util.HashMap) TextHandler(org.openmrs.obs.handler.TextHandler) ComplexObsHandler(org.openmrs.obs.ComplexObsHandler) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 9 with ComplexObsHandler

use of org.openmrs.obs.ComplexObsHandler in project openmrs-core by openmrs.

the class ObsServiceTest method getHandler_shouldHaveDefaultImageAndTextHandlersRegisteredBySpring.

/**
 * @see ObsService#getHandler(String)
 */
@Test
public void getHandler_shouldHaveDefaultImageAndTextHandlersRegisteredBySpring() {
    ObsService os = Context.getObsService();
    ComplexObsHandler imgHandler = os.getHandler("ImageHandler");
    Assert.assertNotNull(imgHandler);
    ComplexObsHandler textHandler = os.getHandler("TextHandler");
    Assert.assertNotNull(textHandler);
}
Also used : ComplexObsHandler(org.openmrs.obs.ComplexObsHandler) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Aggregations

ComplexObsHandler (org.openmrs.obs.ComplexObsHandler)9 Test (org.junit.Test)7 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)7 ImageHandler (org.openmrs.obs.handler.ImageHandler)4 HashMap (java.util.HashMap)2 Concept (org.openmrs.Concept)2 BinaryDataHandler (org.openmrs.obs.handler.BinaryDataHandler)2 Date (java.util.Date)1 Field (org.openmrs.Field)1 FormField (org.openmrs.FormField)1 APIException (org.openmrs.api.APIException)1 ComplexData (org.openmrs.obs.ComplexData)1 SerializableComplexObsHandler (org.openmrs.obs.SerializableComplexObsHandler)1 TextHandler (org.openmrs.obs.handler.TextHandler)1