### Question:
ApplicationsService implements ApplicationsApi { @Override public Application getApplication(String applicationId) { log.info("Getting application {}", applicationId); ApplicationRecord applicationRecord = loadApplication(applicationId); return modelMapper.map(applicationRecord, Application.class); } @Inject  ApplicationsService(
        final TokenSerializer<Map<String, AttributeValue>> paginationTokenSerializer,
        final DynamoDbClient dynamodb, final ConfigProvider configProvider);  ApplicationsService(
        final TokenSerializer<Map<String, AttributeValue>> paginationTokenSerializer,
        final DynamoDbClient dynamodb, final ConfigProvider configProvider,
        final Clock clock); @Override Application createApplication(final CreateApplicationInput createApplicationInput); @Override void deleteApplication(final String applicationId); @Override Application getApplication(String applicationId); @Override ApplicationList listApplications(final String nextToken, final Integer maxItems); @Override Application updateApplication(final UpdateApplicationInput updateApplicationInput,
                                       final String applicationId);  }### Answer:
@Test public void getApplication_empty_notFound() { String userId = UUID.randomUUID().toString(); String applicationId = UUID.randomUUID().toString(); GetItemResponse response = GetItemResponse.builder().item(new HashMap<>()).build(); when(principal.getName()).thenReturn(userId); when(dynamodb.getItem(any(GetItemRequest.class))).thenReturn(response); assertThatThrownBy(() -> service.getApplication(applicationId)) .isInstanceOf(NotFoundApiException.class); }
@Test public void getApplication() { String userId = UUID.randomUUID().toString(); String applicationId = UUID.randomUUID().toString(); Map<String, AttributeValue> recordMap = keyMap(userId, applicationId); GetItemResponse response = GetItemResponse.builder() .item(recordMap) .build(); when(principal.getName()).thenReturn(userId); when(dynamodb.getItem(any(GetItemRequest.class))).thenReturn(response); GetItemRequest expectedGetItemRequest = GetItemRequest.builder() .tableName(TABLE_NAME) .consistentRead(Boolean.TRUE) .key(recordMap) .build(); Application application = service.getApplication(applicationId); ArgumentCaptor<GetItemRequest> getItemRequestArgumentCaptor = ArgumentCaptor.forClass(GetItemRequest.class); verify(dynamodb).getItem(getItemRequestArgumentCaptor.capture()); assertThat(application.getApplicationId()).isEqualTo(applicationId); assertThat(getItemRequestArgumentCaptor.getValue()).isEqualTo(expectedGetItemRequest); }
@Test public void getApplication_null_notFound() { String userId = UUID.randomUUID().toString(); String applicationId = UUID.randomUUID().toString(); GetItemResponse response = GetItemResponse.builder().build(); when(principal.getName()).thenReturn(userId); when(dynamodb.getItem(any(GetItemRequest.class))).thenReturn(response); assertThatThrownBy(() -> service.getApplication(applicationId)) .isInstanceOf(NotFoundApiException.class); }