JobState { public JobRecord getJob(final long key) { jobKey.wrapLong(key); final JobRecordValue jobState = jobsColumnFamily.get(jobKey); return jobState == null ? null : jobState.getRecord(); } JobState(
      final ZeebeDb<ZbColumnFamilies> zeebeDb, final DbContext dbContext, final int partitionId); void create(final long key, final JobRecord record); void activate(final long key, final JobRecord record); void timeout(final long key, final JobRecord record); void complete(final long key, final JobRecord record); void cancel(final long key, final JobRecord record); void disable(final long key, final JobRecord record); void throwError(final long key, final JobRecord updatedValue); void delete(final long key, final JobRecord record); void fail(final long key, final JobRecord updatedValue); void resolve(final long key, final JobRecord updatedValue); void forEachTimedOutEntry(
      final long upperBound, final BiFunction<Long, JobRecord, Boolean> callback); boolean exists(final long jobKey); State getState(final long key); boolean isInState(final long key, final State state); void forEachActivatableJobs(
      final DirectBuffer type, final BiFunction<Long, JobRecord, Boolean> callback); JobRecord updateJobRetries(final long jobKey, final int retries); JobRecord getJob(final long key); void setJobsAvailableCallback(final Consumer<String> onJobsAvailableCallback);  }
@Test public void shouldNeverPersistJobVariables() { final long key = 1L; final JobRecord jobRecord = newJobRecord(); final List<BiConsumer<Long, JobRecord>> stateUpdates = Arrays.asList( jobState::create, jobState::activate, jobState::timeout, jobState::activate, jobState::fail); for (final BiConsumer<Long, JobRecord> stateUpdate : stateUpdates) { jobRecord.setVariables(MsgPackUtil.asMsgPack("foo", "bar")); stateUpdate.accept(key, jobRecord); final DirectBuffer variables = jobState.getJob(key).getVariablesBuffer(); BufferAssert.assertThatBuffer(variables).isEqualTo(DocumentValue.EMPTY_DOCUMENT); } }
@Test public void shouldReturnNullIfJobDoesNotExist() { final long key = 1L; Assertions.assertThat(jobState.getJob(key)).isNull(); }