Search in sources :

Example 6 with JobExecutionEvent

use of com.dangdang.ddframe.job.event.type.JobExecutionEvent in project elastic-job by dangdangdotcom.

the class JobExecutionEventTest method assertExecutionSuccess.

@Test
public void assertExecutionSuccess() {
    JobExecutionEvent startEvent = new JobExecutionEvent("fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
    JobExecutionEvent successEvent = startEvent.executionSuccess();
    assertNotNull(successEvent.getCompleteTime());
    assertTrue(successEvent.isSuccess());
}
Also used : JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) Test(org.junit.Test)

Example 7 with JobExecutionEvent

use of com.dangdang.ddframe.job.event.type.JobExecutionEvent in project elastic-job by dangdangdotcom.

the class JobExecutionEventTest method assertExecutionFailure.

@Test
public void assertExecutionFailure() {
    JobExecutionEvent startEvent = new JobExecutionEvent("fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
    JobExecutionEvent failureEvent = startEvent.executionFailure(new RuntimeException("failure"));
    assertNotNull(failureEvent.getCompleteTime());
    assertFalse(failureEvent.isSuccess());
    assertThat(failureEvent.getFailureCause(), startsWith("java.lang.RuntimeException: failure"));
}
Also used : JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) Test(org.junit.Test)

Example 8 with JobExecutionEvent

use of com.dangdang.ddframe.job.event.type.JobExecutionEvent in project elastic-job by dangdangdotcom.

the class JobEventRdbSearchTest method assertFindJobExecutionEventsWithErrorSort.

@Test
public void assertFindJobExecutionEventsWithErrorSort() {
    Result<JobExecutionEvent> result = repository.findJobExecutionEvents(new Condition(10, 1, "jobName", "ERROR_SORT", null, null, null));
    assertThat(result.getTotal(), is(500));
    assertThat(result.getRows().size(), is(10));
    assertThat(result.getRows().get(0).getJobName(), is("test_job_1"));
    result = repository.findJobExecutionEvents(new Condition(10, 1, "notExistField", "ASC", null, null, null));
    assertThat(result.getTotal(), is(500));
    assertThat(result.getRows().size(), is(10));
}
Also used : Condition(com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition) JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) Test(org.junit.Test)

Example 9 with JobExecutionEvent

use of com.dangdang.ddframe.job.event.type.JobExecutionEvent in project elastic-job by dangdangdotcom.

the class JobEventRdbSearchTest method assertFindJobExecutionEventsWithFields.

@Test
public void assertFindJobExecutionEventsWithFields() {
    Map<String, Object> fields = new HashMap<>();
    fields.put("isSuccess", "1");
    Result<JobExecutionEvent> result = repository.findJobExecutionEvents(new Condition(10, 1, null, null, null, null, fields));
    assertThat(result.getTotal(), is(250));
    assertThat(result.getRows().size(), is(10));
    fields.put("isSuccess", null);
    fields.put("jobName", "test_job_1");
    result = repository.findJobExecutionEvents(new Condition(10, 1, null, null, null, null, fields));
    assertThat(result.getTotal(), is(1));
    assertThat(result.getRows().size(), is(1));
}
Also used : Condition(com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition) JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 10 with JobExecutionEvent

use of com.dangdang.ddframe.job.event.type.JobExecutionEvent in project elastic-job by dangdangdotcom.

the class JobEventRdbSearchTest method assertFindJobExecutionEventsWithErrorFields.

@Test
public void assertFindJobExecutionEventsWithErrorFields() {
    Map<String, Object> fields = new HashMap<>();
    fields.put("notExistField", "some value");
    Result<JobExecutionEvent> result = repository.findJobExecutionEvents(new Condition(10, 1, null, null, null, null, fields));
    assertThat(result.getTotal(), is(500));
    assertThat(result.getRows().size(), is(10));
}
Also used : Condition(com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition) JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

JobExecutionEvent (com.dangdang.ddframe.job.event.type.JobExecutionEvent)24 Test (org.junit.Test)20 Condition (com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition)8 Date (java.util.Date)2 HashMap (java.util.HashMap)2 ShardingContext (com.dangdang.ddframe.job.api.ShardingContext)1 TestJobEventConfiguration (com.dangdang.ddframe.job.event.fixture.TestJobEventConfiguration)1 JobExecutionEventThrowable (com.dangdang.ddframe.job.event.type.JobExecutionEventThrowable)1 JobStatusTraceEvent (com.dangdang.ddframe.job.event.type.JobStatusTraceEvent)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 LinkedList (java.util.LinkedList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1