DynamoJobMetaRepository extends AbstractDynamoRepository implements JobMetaRepository { @Override public JobMeta getJobMeta(String jobType) { GetItemResponse response = getItem(jobType); Map<String, AttributeValue> responseItem = response.item(); if (!responseItem.isEmpty()) { final boolean isRunning = responseItem.containsKey(KEY_RUNNING); final boolean isDisabled = responseItem.containsKey(KEY_DISABLED); final AttributeValue attributeValueComment = responseItem.get(KEY_DISABLED); String comment = null; if (attributeValueComment != null) { comment = attributeValueComment.s(); } Map<String, String> metaMap = responseItem.entrySet().stream() .filter(e -> !e.getKey().startsWith(KEY_PREFIX)) .filter(e -> !e.getKey().equals(JOB_TYPE_KEY)) .filter(e -> !e.getKey().equals(ETAG_KEY)) .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().s())); return new JobMeta(jobType, isRunning, isDisabled, comment, metaMap); } else { return new JobMeta(jobType, false, false, "", emptyMap()); } } DynamoJobMetaRepository(final DynamoDbClient dynamoDbClient, final String tableName); @Override JobMeta getJobMeta(String jobType); @Override boolean createValue(String jobType, String key, String value); @Override boolean setRunningJob(String jobType, String jobId); @Override String getRunningJob(String jobType); @Override void clearRunningJob(String jobType); @Override void disable(String jobType, String comment); @Override void enable(String jobType); @Override String setValue(String jobType, String key, String value); @Override String getValue(String jobType, String key); @Override Set<String> findAllJobTypes(); @Override void deleteAll();  }
@Test public void shouldReturnEmptyJobMetaWhenJobTypeDoesNotExist() { JobMeta jobMeta = dynamoJobMetaRepository.getJobMeta("someJobType"); assertThat(jobMeta.getJobType(), is("someJobType")); assertThat(jobMeta.isDisabled(), is(false)); assertThat(jobMeta.getDisabledComment(), is("")); assertThat(jobMeta.isRunning(), is(false)); assertThat(jobMeta.getAll(), is(Collections.emptyMap())); }