use of com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition in project elastic-job by dangdangdotcom.
the class JobEventRdbSearchTest method assertFindJobExecutionEventsWithTime.
@Test
public void assertFindJobExecutionEventsWithTime() {
Date now = new Date();
Date tenMinutesBefore = new Date(now.getTime() - 10 * 60 * 1000);
Result<JobExecutionEvent> result = repository.findJobExecutionEvents(new Condition(10, 1, null, null, tenMinutesBefore, null, null));
assertThat(result.getTotal(), is(500));
assertThat(result.getRows().size(), is(10));
result = repository.findJobExecutionEvents(new Condition(10, 1, null, null, now, null, null));
assertThat(result.getTotal(), is(0));
assertThat(result.getRows().size(), is(0));
result = repository.findJobExecutionEvents(new Condition(10, 1, null, null, null, tenMinutesBefore, null));
assertThat(result.getTotal(), is(0));
assertThat(result.getRows().size(), is(0));
result = repository.findJobExecutionEvents(new Condition(10, 1, null, null, null, now, null));
assertThat(result.getTotal(), is(500));
assertThat(result.getRows().size(), is(10));
result = repository.findJobExecutionEvents(new Condition(10, 1, null, null, tenMinutesBefore, now, null));
assertThat(result.getTotal(), is(500));
assertThat(result.getRows().size(), is(10));
}
use of com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition in project elastic-job by dangdangdotcom.
the class JobEventRdbSearchTest method assertFindJobExecutionEventsWithErrorPageSizeAndNumber.
@Test
public void assertFindJobExecutionEventsWithErrorPageSizeAndNumber() {
Result<JobExecutionEvent> result = repository.findJobExecutionEvents(new Condition(-1, -1, null, null, null, null, null));
assertThat(result.getTotal(), is(500));
assertThat(result.getRows().size(), is(10));
}
use of com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition in project elastic-job by dangdangdotcom.
the class JobEventRdbSearchTest method assertFindJobExecutionEventsWithSort.
@Test
public void assertFindJobExecutionEventsWithSort() {
Result<JobExecutionEvent> result = repository.findJobExecutionEvents(new Condition(10, 1, "jobName", "ASC", 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, "jobName", "DESC", null, null, null));
assertThat(result.getTotal(), is(500));
assertThat(result.getRows().size(), is(10));
assertThat(result.getRows().get(0).getJobName(), is("test_job_99"));
}
use of com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition in project elastic-job by dangdangdotcom.
the class JobEventRdbSearchTest method assertFindJobStatusTraceEventsWithTime.
@Test
public void assertFindJobStatusTraceEventsWithTime() {
Date now = new Date();
Date tenMinutesBefore = new Date(now.getTime() - 10 * 60 * 1000);
Result<JobStatusTraceEvent> result = repository.findJobStatusTraceEvents(new Condition(10, 1, null, null, tenMinutesBefore, null, null));
assertThat(result.getTotal(), is(500));
assertThat(result.getRows().size(), is(10));
result = repository.findJobStatusTraceEvents(new Condition(10, 1, null, null, now, null, null));
assertThat(result.getTotal(), is(0));
assertThat(result.getRows().size(), is(0));
result = repository.findJobStatusTraceEvents(new Condition(10, 1, null, null, null, tenMinutesBefore, null));
assertThat(result.getTotal(), is(0));
assertThat(result.getRows().size(), is(0));
result = repository.findJobStatusTraceEvents(new Condition(10, 1, null, null, null, now, null));
assertThat(result.getTotal(), is(500));
assertThat(result.getRows().size(), is(10));
result = repository.findJobStatusTraceEvents(new Condition(10, 1, null, null, tenMinutesBefore, now, null));
assertThat(result.getTotal(), is(500));
assertThat(result.getRows().size(), is(10));
}
use of com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition in project elastic-job by dangdangdotcom.
the class CloudJobRestfulApi method buildCondition.
private Condition buildCondition(final UriInfo info, final String[] params) throws ParseException {
int perPage = 10;
int page = 1;
if (!Strings.isNullOrEmpty(info.getQueryParameters().getFirst("per_page"))) {
perPage = Integer.parseInt(info.getQueryParameters().getFirst("per_page"));
}
if (!Strings.isNullOrEmpty(info.getQueryParameters().getFirst("page"))) {
page = Integer.parseInt(info.getQueryParameters().getFirst("page"));
}
String sort = info.getQueryParameters().getFirst("sort");
String order = info.getQueryParameters().getFirst("order");
Date startTime = null;
Date endTime = null;
Map<String, Object> fields = getQueryParameters(info, params);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (!Strings.isNullOrEmpty(info.getQueryParameters().getFirst("startTime"))) {
startTime = simpleDateFormat.parse(info.getQueryParameters().getFirst("startTime"));
}
if (!Strings.isNullOrEmpty(info.getQueryParameters().getFirst("endTime"))) {
endTime = simpleDateFormat.parse(info.getQueryParameters().getFirst("endTime"));
}
return new Condition(perPage, page, sort, order, startTime, endTime, fields);
}
Aggregations