private CeQueueDto makeInProgress(String workerUuid, long startedAt, CeQueueDto ceQueueDto) { CeQueueTesting.makeInProgress(db.getSession(), workerUuid, startedAt, ceQueueDto); return underTestAlwaysIncreasingSystem2.selectByUuid(db.getSession(), ceQueueDto.getUuid()).get(); }
private void insertInQueue(CeQueueDto.Status status, @Nullable ComponentDto componentDto) { dbClient.ceQueueDao().insert(dbSession, newCeQueueDto(Uuids.createFast()) .setStatus(status) .setComponent(componentDto)); db.commit(); }
@Test public void selectWornout_returns_task_pending_with_a_non_null_startedAt() { insertPending("p1"); makeInProgress("w1", alwaysIncreasingSystem2.now(), insertPending("i1")); CeQueueDto resetDto = makeInProgress("w1", alwaysIncreasingSystem2.now(), insertPending("i2")); makeInProgress("w1", alwaysIncreasingSystem2.now(), insertPending("i3")); reset(db.getSession(), alwaysIncreasingSystem2.now(), resetDto); List<CeQueueDto> ceQueueDtos = underTest.selectWornout(db.getSession()); assertThat(ceQueueDtos) .extracting(CeQueueDto::getStatus, CeQueueDto::getUuid) .containsOnly(tuple(PENDING, resetDto.getUuid())); }
private CeQueueDto insertInProgress(String uuid, String componentUuid) { CeQueueDto ceQueueDto = insertPending(uuid); CeQueueTesting.makeInProgress(db.getSession(), "workerUuid", System2.INSTANCE.now(), ceQueueDto); return underTest.selectByUuid(db.getSession(), uuid).get(); }
@Test public void json_example() { dbClient.ceQueueDao().insert(dbSession, newCeQueueDto("ce-queue-uuid-1").setStatus(CeQueueDto.Status.PENDING)); dbClient.ceQueueDao().insert(dbSession, newCeQueueDto("ce-queue-uuid-2").setStatus(CeQueueDto.Status.PENDING)); dbClient.ceQueueDao().insert(dbSession, newCeQueueDto("ce-queue-uuid-3").setStatus(CeQueueDto.Status.IN_PROGRESS)); for (int i = 0; i < 5; i++) { dbClient.ceActivityDao().insert(dbSession, new CeActivityDto(newCeQueueDto("ce-activity-uuid-" + i)) .setStatus(CeActivityDto.Status.FAILED)); } db.commit(); String result = ws.newRequest().execute().getInput(); assertJson(result).isSimilarTo(getClass().getResource("activity_status-example.json")); }
private CeQueueDto makeInProgress(CeQueueDto ceQueueDto, String workerUuid) { CeQueueTesting.makeInProgress(session, workerUuid, system2.now(), ceQueueDto); return db.getDbClient().ceQueueDao().selectByUuid(session, ceQueueDto.getUuid()).get(); }
private void insertActivity(CeActivityDto.Status status, @Nullable ComponentDto dto) { CeQueueDto ceQueueDto = newCeQueueDto(Uuids.createFast()); ceQueueDto.setComponent(dto); dbClient.ceActivityDao().insert(dbSession, new CeActivityDto(ceQueueDto) .setStatus(status)); db.commit(); }