use of org.kie.kogito.timer.impl.PointInTimeTrigger in project kogito-apps by kiegroup.
the class BaseJobRepositoryTest method createAndSaveJob.
private void createAndSaveJob(String id) throws Exception {
job = JobDetails.builder().id(id).trigger(//
new PointInTimeTrigger(System.currentTimeMillis(), null, null)).priority(1).recipient(new Recipient.HTTPRecipient("url")).build();
tested().save(job).toCompletableFuture().get();
}
use of org.kie.kogito.timer.impl.PointInTimeTrigger in project kogito-apps by kiegroup.
the class VertxTimerServiceSchedulerTest method schedule.
private ManageableJobHandle schedule(ZonedDateTime time) {
final long timestamp = time.toInstant().toEpochMilli();
trigger = new PointInTimeTrigger(timestamp, null, null);
jobDetails = JobDetails.builder().build();
context = new HttpJobContext(jobDetails);
job = new HttpJob(executor);
return tested.scheduleJob(job, context, trigger);
}
use of org.kie.kogito.timer.impl.PointInTimeTrigger in project kogito-apps by kiegroup.
the class TriggerMarshaller method readFrom.
@Override
public Trigger readFrom(ProtoStreamReader reader) throws IOException {
String classType = reader.readString("classType");
Date startTime = fromInstant(reader.readInstant("startTime"));
Date endTime = fromInstant(reader.readInstant("endTime"));
Integer repeatLimit = reader.readInt("repeatLimit");
Integer repeatCount = reader.readInt("repeatCount");
Date nextFireTime = fromInstant(reader.readInstant("nextFireTime"));
Long period = reader.readLong("period");
return Optional.ofNullable(classType).filter(IntervalTrigger.class.getName()::equals).<Trigger>map(c -> {
IntervalTrigger intervalTrigger = new IntervalTrigger();
intervalTrigger.setStartTime(startTime);
intervalTrigger.setEndTime(endTime);
intervalTrigger.setRepeatLimit(repeatLimit);
intervalTrigger.setRepeatCount(repeatCount);
intervalTrigger.setNextFireTime(nextFireTime);
intervalTrigger.setPeriod(period);
return intervalTrigger;
}).orElseGet(() -> Optional.ofNullable(nextFireTime).map(Date::getTime).map(t -> new PointInTimeTrigger(t, null, null)).orElse(null));
}
use of org.kie.kogito.timer.impl.PointInTimeTrigger in project kogito-apps by kiegroup.
the class TriggerMarshallerTest method marshallPointInTimeTriggerAccessor.
@Test
void marshallPointInTimeTriggerAccessor() {
Date time = new Date();
PointInTimeTrigger trigger = new PointInTimeTrigger(time.getTime(), null, null);
JsonObject jsonObject = marshaller.marshall(trigger);
assertEquals(new JsonObject().put("nextFireTime", time.getTime()).put("classType", PointInTimeTrigger.class.getName()), jsonObject);
}
use of org.kie.kogito.timer.impl.PointInTimeTrigger in project kogito-apps by kiegroup.
the class TriggerMarshallerTest method unmarshallPointInTimeTriggerAccessor.
@Test
void unmarshallPointInTimeTriggerAccessor() {
Date time = new Date();
JsonObject jsonObject = new JsonObject().put("nextFireTime", time.getTime()).put("classType", PointInTimeTrigger.class.getName());
Trigger trigger = marshaller.unmarshall(jsonObject);
assertEquals(new PointInTimeTrigger(time.getTime(), null, null).toString(), trigger.toString());
}
Aggregations