public JobRecordStream withRetries(final int retries) { return valueFilter(v -> v.getRetries() == retries); }
public JobRecordStream withRetries(final int retries) { return valueFilter(v -> v.getRetries() == retries); }
/** * Verifies that the actual JobRecordValue's retries is equal to the given one. * @param retries the given retries to compare the actual JobRecordValue's retries to. * @return this assertion object. * @throws AssertionError - if the actual JobRecordValue's retries is not equal to the given one. */ public S hasRetries(int retries) { // check that actual JobRecordValue we want to make assertions on is not null. isNotNull(); // overrides the default error message with a more explicit one String assertjErrorMessage = "\nExpecting retries of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; // check int actualRetries = actual.getRetries(); if (actualRetries != retries) { failWithMessage(assertjErrorMessage, actual, retries, actualRetries); } // return the current assertion for method chaining return myself; }
@Test public void shouldUpdateRetriesIfJobCreated() { // given final long jobKey = client.createJob(JOB_TYPE); // when final ExecuteCommandResponse response = client.updateJobRetries(jobKey, NEW_RETRIES); // then assertThat(response.getRecordType()).isEqualTo(RecordType.EVENT); assertThat(response.getIntent()).isEqualTo(JobIntent.RETRIES_UPDATED); assertThat(response.getKey()).isEqualTo(jobKey); final Record<JobRecordValue> updatedRetries = client.receiveJobs().withIntent(JobIntent.RETRIES_UPDATED).withType(JOB_TYPE).getFirst(); assertThat(updatedRetries.getValue().getRetries()).isEqualTo(NEW_RETRIES); }
@Test public void shouldUpdateRetriesIfJobCreated() { // given final long jobKey = client.createJob(JOB_TYPE); // when final ExecuteCommandResponse response = client.updateJobRetries(jobKey, NEW_RETRIES); // then assertThat(response.getRecordType()).isEqualTo(RecordType.EVENT); assertThat(response.getIntent()).isEqualTo(JobIntent.RETRIES_UPDATED); assertThat(response.getKey()).isEqualTo(jobKey); final Record<JobRecordValue> updatedRetries = client.receiveJobs().withIntent(JobIntent.RETRIES_UPDATED).withType(JOB_TYPE).getFirst(); assertThat(updatedRetries.getValue().getRetries()).isEqualTo(NEW_RETRIES); }
@Test public void shouldUpdateRetriesIfJobActivated() { // given client.createJob(JOB_TYPE); apiRule.activateJobs(JOB_TYPE).await(); final Record<JobRecordValue> jobEvent = client.receiveFirstJobEvent(JobIntent.ACTIVATED); // when final ExecuteCommandResponse response = client.updateJobRetries(jobEvent.getKey(), NEW_RETRIES); // then assertThat(response.getRecordType()).isEqualTo(RecordType.EVENT); assertThat(response.getIntent()).isEqualTo(JobIntent.RETRIES_UPDATED); assertThat(response.getKey()).isEqualTo(jobEvent.getKey()); final Record<JobRecordValue> loggedEvent = client.receiveJobs().withIntent(JobIntent.RETRIES_UPDATED).withType(JOB_TYPE).getFirst(); assertThat(loggedEvent.getValue().getRetries()).isEqualTo(NEW_RETRIES); }
@Test public void shouldUpdateRetriesIfJobActivated() { // given client.createJob(JOB_TYPE); apiRule.activateJobs(JOB_TYPE).await(); final Record<JobRecordValue> jobEvent = client.receiveFirstJobEvent(JobIntent.ACTIVATED); // when final ExecuteCommandResponse response = client.updateJobRetries(jobEvent.getKey(), NEW_RETRIES); // then assertThat(response.getRecordType()).isEqualTo(RecordType.EVENT); assertThat(response.getIntent()).isEqualTo(JobIntent.RETRIES_UPDATED); assertThat(response.getKey()).isEqualTo(jobEvent.getKey()); final Record<JobRecordValue> loggedEvent = client.receiveJobs().withIntent(JobIntent.RETRIES_UPDATED).withType(JOB_TYPE).getFirst(); assertThat(loggedEvent.getValue().getRetries()).isEqualTo(NEW_RETRIES); }
@Test public void shouldCompleteJob() { // given createJob(JOB_TYPE); apiRule.activateJobs(JOB_TYPE).await(); final Record<JobRecordValue> jobEvent = receiveSingleJobEvent(); // when final JobRecordValue jobEventValue = jobEvent.getValue(); final ExecuteCommandResponse response = testClient.completeJob(jobEvent.getKey(), jobEventValue.getPayload()); // then assertThat(response.getRecordType()).isEqualTo(RecordType.EVENT); assertThat(response.getIntent()).isEqualTo(JobIntent.COMPLETED); assertThat(response.getValue()) .contains( entry("worker", jobEventValue.getWorker()), entry("type", jobEventValue.getType()), entry("retries", (long) jobEventValue.getRetries()), entry("deadline", jobEventValue.getDeadline().toEpochMilli())); final Record<JobRecordValue> loggedEvent = RecordingExporter.jobRecords(JobIntent.COMPLETED).getFirst(); assertThat(loggedEvent.getValue().getType()).isEqualTo(JOB_TYPE); }
@Test public void shouldCompleteJob() { // given createJob(JOB_TYPE); apiRule.activateJobs(JOB_TYPE).await(); final Record<JobRecordValue> jobEvent = receiveSingleJobEvent(); // when final JobRecordValue jobEventValue = jobEvent.getValue(); final ExecuteCommandResponse response = testClient.completeJob(jobEvent.getKey(), jobEventValue.getPayload()); // then assertThat(response.getRecordType()).isEqualTo(RecordType.EVENT); assertThat(response.getIntent()).isEqualTo(JobIntent.COMPLETED); assertThat(response.getValue()) .contains( entry("worker", jobEventValue.getWorker()), entry("type", jobEventValue.getType()), entry("retries", (long) jobEventValue.getRetries()), entry("deadline", jobEventValue.getDeadline().toEpochMilli())); final Record<JobRecordValue> loggedEvent = RecordingExporter.jobRecords(JobIntent.COMPLETED).getFirst(); assertThat(loggedEvent.getValue().getType()).isEqualTo(JOB_TYPE); }