use of org.motechproject.tasks.contract.json.ActionEventRequestDeserializer in project motech by motech.
the class ActionParametersBundleIT method loadChannel.
private Channel loadChannel() throws IOException {
Type type = new TypeToken<ChannelRequest>() {
}.getType();
HashMap<Type, Object> typeAdapters = new HashMap<>();
typeAdapters.put(ActionEventRequest.class, new ActionEventRequestDeserializer());
StringWriter writer = new StringWriter();
try (InputStream stream = getClass().getResourceAsStream("/task-testmodule-channel.json")) {
IOUtils.copy(stream, writer);
}
ChannelRequest channelRequest = (ChannelRequest) motechJsonReader.readFromString(writer.toString(), type, typeAdapters);
channelRequest.setModuleName(TASK_TEST_CHANNEL_NAME);
channelRequest.setModuleVersion("0.29.0.SNAPSHOT");
return ChannelBuilder.fromChannelRequest(channelRequest).build();
}
use of org.motechproject.tasks.contract.json.ActionEventRequestDeserializer in project motech by motech.
the class ChannelsDataServiceBundleIT method loadChannels.
private List<Channel> loadChannels() throws IOException {
Type type = new TypeToken<ChannelRequest>() {
}.getType();
HashMap<Type, Object> typeAdapters = new HashMap<>();
typeAdapters.put(ActionEventRequest.class, new ActionEventRequestDeserializer());
List<StringWriter> writers = new ArrayList<>(2);
for (String json : Arrays.asList("/message-campaign-test-channel.json", "/pillreminder-test-channel.json")) {
try (InputStream stream = getClass().getResourceAsStream(json)) {
StringWriter writer = new StringWriter();
IOUtils.copy(stream, writer);
writers.add(writer);
}
}
List<Channel> channelRequests = new ArrayList<>(2);
for (StringWriter writer : writers) {
ChannelRequest channelRequest = (ChannelRequest) motechJsonReader.readFromString(writer.toString(), type, typeAdapters);
channelRequest.setModuleName(channelRequest.getDisplayName());
channelRequest.setModuleVersion("1.0");
channelRequests.add(ChannelBuilder.fromChannelRequest(channelRequest).build());
}
return channelRequests;
}
Aggregations