Search in sources :

Example 26 with TaskDataProvider

use of org.motechproject.tasks.domain.mds.task.TaskDataProvider in project motech by motech.

the class DataProviderManagerTest method shouldRemoveProviderFromHandler.

@Test
public void shouldRemoveProviderFromHandler() throws IOException {
    DataProviderManager mgr = new DataProviderManager(taskTriggerHandler, taskDataProviderService);
    TaskDataProvider provider = new TaskDataProvider();
    provider.setId(TASK_DATA_PROVIDER_ID);
    when(dataProvider.getName()).thenReturn(TASK_DATA_PROVIDER_NAME);
    when(taskDataProviderService.getProvider(TASK_DATA_PROVIDER_NAME)).thenReturn(provider);
    mgr.unbind(dataProvider, null);
    verify(taskTriggerHandler).removeDataProvider(TASK_DATA_PROVIDER_NAME);
}
Also used : TaskDataProvider(org.motechproject.tasks.domain.mds.task.TaskDataProvider) Test(org.junit.Test)

Example 27 with TaskDataProvider

use of org.motechproject.tasks.domain.mds.task.TaskDataProvider in project motech by motech.

the class DataProviderManagerTest method shouldNotRemoveProviderFromHandler.

@Test
public void shouldNotRemoveProviderFromHandler() throws IOException {
    DataProviderManager mgr = new DataProviderManager(taskDataProviderService);
    TaskDataProvider provider = new TaskDataProvider();
    provider.setId(TASK_DATA_PROVIDER_ID);
    when(taskDataProviderService.getProvider(TASK_DATA_PROVIDER_NAME)).thenReturn(provider);
    mgr.unbind(dataProvider, null);
    verify(taskTriggerHandler, never()).removeDataProvider(TASK_DATA_PROVIDER_NAME);
}
Also used : TaskDataProvider(org.motechproject.tasks.domain.mds.task.TaskDataProvider) Test(org.junit.Test)

Example 28 with TaskDataProvider

use of org.motechproject.tasks.domain.mds.task.TaskDataProvider in project motech by motech.

the class DataProviderManagerTest method shouldRegisterProvider.

@Test
public void shouldRegisterProvider() throws IOException {
    DataProviderManager mgr = new DataProviderManager(taskDataProviderService);
    TaskDataProvider provider = new TaskDataProvider();
    provider.setId(TASK_DATA_PROVIDER_ID);
    String json = String.format("{ name: '%s', objects: []", TASK_DATA_PROVIDER_NAME);
    when(dataProvider.toJSON()).thenReturn(json);
    mgr.bind(dataProvider, null);
    verify(taskDataProviderService).registerProvider(json);
    verify(taskTriggerHandler, never()).addDataProvider(dataProvider);
}
Also used : TaskDataProvider(org.motechproject.tasks.domain.mds.task.TaskDataProvider) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

TaskDataProvider (org.motechproject.tasks.domain.mds.task.TaskDataProvider)28 Test (org.junit.Test)20 TaskDataProviderObject (org.motechproject.tasks.domain.mds.task.TaskDataProviderObject)14 LookupFieldsParameter (org.motechproject.tasks.domain.mds.task.LookupFieldsParameter)9 ArrayList (java.util.ArrayList)8 DataSource (org.motechproject.tasks.domain.mds.task.DataSource)8 Task (org.motechproject.tasks.domain.mds.task.Task)8 TriggerEvent (org.motechproject.tasks.domain.mds.channel.TriggerEvent)7 TaskError (org.motechproject.tasks.domain.mds.task.TaskError)7 Type (java.lang.reflect.Type)6 HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)6 Channel (org.motechproject.tasks.domain.mds.channel.Channel)6 EventParameter (org.motechproject.tasks.domain.mds.channel.EventParameter)6 ActionEventBuilder (org.motechproject.tasks.domain.mds.channel.builder.ActionEventBuilder)6 Lookup (org.motechproject.tasks.domain.mds.task.Lookup)6 FieldParameter (org.motechproject.tasks.domain.mds.task.FieldParameter)5 TaskConfig (org.motechproject.tasks.domain.mds.task.TaskConfig)5 LinkedHashMap (java.util.LinkedHashMap)3 ActionEvent (org.motechproject.tasks.domain.mds.channel.ActionEvent)3