Search in sources :

Example 1 with DefaultPartitionTriggerInfo

use of co.cask.cdap.internal.app.runtime.schedule.trigger.DefaultPartitionTriggerInfo in project cdap by caskdata.

the class TriggeringScheduleInfoAdapterTest method testSerDeserScheduleInfo.

@Test
public void testSerDeserScheduleInfo() {
    BasicWorkflowToken token = new BasicWorkflowToken(1);
    token.setCurrentNode("node");
    token.put("tokenKey", "tokenVal");
    List<TriggerInfo> triggerInfos = ImmutableList.<TriggerInfo>of(new DefaultProgramStatusTriggerInfo("ns", Specifications.from(new WebCrawlApp()), ProgramType.WORKFLOW, "workflow", RunIds.generate(), ProgramStatus.COMPLETED, token, Collections.<String, String>emptyMap()), new DefaultPartitionTriggerInfo("ns", "ds", 10, 11), new DefaultTimeTriggerInfo("1 * * * *", 0L));
    TriggeringScheduleInfo scheduleInfo = new DefaultTriggeringScheduleInfo("schedule", "description", triggerInfos, ImmutableMap.of("key", "value"));
    String scheduleInfoJson = GSON.toJson(scheduleInfo);
    TriggeringScheduleInfo deserializedScheduleInfo = GSON.fromJson(scheduleInfoJson, TriggeringScheduleInfo.class);
    Assert.assertEquals(scheduleInfoJson, GSON.toJson(deserializedScheduleInfo));
    DefaultProgramStatusTriggerInfo expectedProgramStatusTriggerInfo = (DefaultProgramStatusTriggerInfo) triggerInfos.get(0);
    DefaultProgramStatusTriggerInfo deserializedProgramStatusTriggerInfo = (DefaultProgramStatusTriggerInfo) deserializedScheduleInfo.getTriggerInfos().get(0);
    Assert.assertEquals(expectedProgramStatusTriggerInfo.getApplicationSpecification().getName(), deserializedProgramStatusTriggerInfo.getApplicationSpecification().getName());
    Assert.assertEquals(expectedProgramStatusTriggerInfo.getWorkflowToken().getAll(), deserializedProgramStatusTriggerInfo.getWorkflowToken().getAll());
}
Also used : DefaultPartitionTriggerInfo(co.cask.cdap.internal.app.runtime.schedule.trigger.DefaultPartitionTriggerInfo) WebCrawlApp(co.cask.cdap.WebCrawlApp) DefaultTimeTriggerInfo(co.cask.cdap.internal.app.runtime.schedule.trigger.DefaultTimeTriggerInfo) DefaultPartitionTriggerInfo(co.cask.cdap.internal.app.runtime.schedule.trigger.DefaultPartitionTriggerInfo) DefaultProgramStatusTriggerInfo(co.cask.cdap.internal.app.runtime.schedule.trigger.DefaultProgramStatusTriggerInfo) TriggerInfo(co.cask.cdap.api.schedule.TriggerInfo) DefaultTimeTriggerInfo(co.cask.cdap.internal.app.runtime.schedule.trigger.DefaultTimeTriggerInfo) TriggeringScheduleInfo(co.cask.cdap.api.schedule.TriggeringScheduleInfo) BasicWorkflowToken(co.cask.cdap.internal.app.runtime.workflow.BasicWorkflowToken) DefaultProgramStatusTriggerInfo(co.cask.cdap.internal.app.runtime.schedule.trigger.DefaultProgramStatusTriggerInfo) Test(org.junit.Test)

Aggregations

WebCrawlApp (co.cask.cdap.WebCrawlApp)1 TriggerInfo (co.cask.cdap.api.schedule.TriggerInfo)1 TriggeringScheduleInfo (co.cask.cdap.api.schedule.TriggeringScheduleInfo)1 DefaultPartitionTriggerInfo (co.cask.cdap.internal.app.runtime.schedule.trigger.DefaultPartitionTriggerInfo)1 DefaultProgramStatusTriggerInfo (co.cask.cdap.internal.app.runtime.schedule.trigger.DefaultProgramStatusTriggerInfo)1 DefaultTimeTriggerInfo (co.cask.cdap.internal.app.runtime.schedule.trigger.DefaultTimeTriggerInfo)1 BasicWorkflowToken (co.cask.cdap.internal.app.runtime.workflow.BasicWorkflowToken)1 Test (org.junit.Test)1