use of org.motechproject.tasks.domain.mds.channel.Channel in project motech by motech.
the class ChannelServiceImplTest method shouldGetAllChannels.
@Test
public void shouldGetAllChannels() {
List<Channel> expected = new ArrayList<>();
expected.add(new Channel(null, "symbolic", null));
expected.add(new Channel(null, "symbolic", null));
when(bundleContext.getBundles()).thenReturn(new Bundle[] { bundle });
when(bundle.getSymbolicName()).thenReturn("symbolic");
when(channelsDataService.executeQuery(any(QueryExecution.class))).thenReturn(expected);
List<Channel> actual = channelService.getAllChannels();
assertNotNull(actual);
assertEquals(expected, actual);
}
use of org.motechproject.tasks.domain.mds.channel.Channel in project motech by motech.
the class ChannelServiceImplTest method shouldUnregisterChannel.
@Test
public void shouldUnregisterChannel() {
Channel channel = new Channel("Channel to delete", BUNDLE_SYMBOLIC_NAME, VERSION);
when(channelsDataService.findByModuleName(channel.getModuleName())).thenReturn(channel);
when(bundleContext.getBundles()).thenReturn(new Bundle[] { bundle });
when(bundle.getSymbolicName()).thenReturn(BUNDLE_SYMBOLIC_NAME);
channelService.unregisterChannel(channel.getModuleName());
ArgumentCaptor<Channel> captor = ArgumentCaptor.forClass(Channel.class);
verify(channelsDataService).delete(captor.capture());
Channel deletedChannel = captor.getValue();
assertEquals("Channel to delete", deletedChannel.getDisplayName());
assertEquals(BUNDLE_SYMBOLIC_NAME, deletedChannel.getModuleName());
assertEquals(VERSION, deletedChannel.getModuleVersion());
}
use of org.motechproject.tasks.domain.mds.channel.Channel in project motech by motech.
the class ChannelServiceImplTest method shouldSendEventWhenChannelWasUpdated.
@Test
public void shouldSendEventWhenChannelWasUpdated() {
Channel channel = new Channel("displayName", BUNDLE_SYMBOLIC_NAME, VERSION);
EventParameter eventParameter = new EventParameter("displayName", "eventKey");
TriggerEvent triggerEvent = new TriggerEvent("displayName", "subject", null, Arrays.asList(eventParameter), "");
channel.getTriggerTaskEvents().add(triggerEvent);
when(channelsDataService.findByModuleName(channel.getModuleName())).thenReturn(channel);
when(bundleContext.getBundles()).thenReturn(new Bundle[] { bundle });
when(bundle.getSymbolicName()).thenReturn(BUNDLE_SYMBOLIC_NAME);
ArgumentCaptor<MotechEvent> captor = ArgumentCaptor.forClass(MotechEvent.class);
Channel updatedChannel = new Channel("displayName2", BUNDLE_SYMBOLIC_NAME, VERSION);
updatedChannel.getTriggerTaskEvents().add(triggerEvent);
channelService.addOrUpdate(updatedChannel);
verify(channelsDataService).update(channel);
verify(eventRelay).sendEventMessage(captor.capture());
MotechEvent event = captor.getValue();
assertEquals(CHANNEL_UPDATE_SUBJECT, event.getSubject());
assertEquals(BUNDLE_SYMBOLIC_NAME, event.getParameters().get(CHANNEL_MODULE_NAME));
}
use of org.motechproject.tasks.domain.mds.channel.Channel in project motech by motech.
the class ActionParametersBundleIT method setUp.
@Before
public void setUp() throws IOException, InterruptedException {
createAdminUser();
login();
Channel channel = loadChannel();
setUpSecurityContext("motech", "motech", "manageTasks");
channelService.addOrUpdate(channel);
waitForChannel(MDS_CHANNEL_NAME);
}
use of org.motechproject.tasks.domain.mds.channel.Channel in project motech by motech.
the class TasksBundleIT method testChannelService.
private void testChannelService() throws InterruptedException {
assertNotNull(fromFileChannel);
ChannelsDataService channelsDataService = getTasksContext().getBean(ChannelsDataService.class);
Channel fromDB = channelsDataService.findByModuleName(testBundleName);
assertNotNull(fromDB);
assertEquals(fromDB, fromFileChannel);
}
Aggregations