@Test public void assertTaskContextFrom() { TaskContext actual = TaskContext.from(TaskNode.builder().build().getTaskNodeValue()); assertThat(actual.getId(), is(TaskNode.builder().build().getTaskNodeValue())); assertThat(actual.getMetaInfo().getJobName(), is("test_job")); assertThat(actual.getMetaInfo().getShardingItem(), is(0)); assertThat(actual.getType(), is(ExecutionType.READY)); assertThat(actual.getSlaveId(), is("slave-S0")); }
@Test public void assertNew() { TaskContext actual = new TaskContext("test_job", 0, ExecutionType.READY, "slave-S0"); assertThat(actual.getMetaInfo().getJobName(), is("test_job")); assertThat(actual.getMetaInfo().getShardingItem(), is(0)); assertThat(actual.getType(), is(ExecutionType.READY)); assertThat(actual.getSlaveId(), is("slave-S0")); assertThat( actual.getId(), startsWith( TaskNode.builder() .build() .getTaskNodeValue() .substring(0, TaskNode.builder().build().getTaskNodeValue().length() - 1))); }