### Question:
ApplicationsService implements ApplicationsApi { @Override public void deleteApplication(final String applicationId) { log.info("Deleting application {}", applicationId); ApplicationRecord applicationRecord = loadApplication(applicationId); Map<String, AttributeValue> expressionAttributeValues = new HashMap<>(); expressionAttributeValues.put(":v", AttributeValue.builder() .n(applicationRecord.getVersion().toString()) .build()); dynamodb.deleteItem(DeleteItemRequest.builder() .tableName(tableName) .key(toKeyRecord(applicationId)) .conditionExpression(String.format("%s = :v", ApplicationRecord.VERSION_ATTRIBUTE_NAME)) .expressionAttributeValues(expressionAttributeValues) .build()); } @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 deleteApplication() { String userId = UUID.randomUUID().toString(); String applicationId = UUID.randomUUID().toString(); Long version = 1L; Map<String, AttributeValue> recordMap = keyMap(userId, applicationId); recordMap.put("version", AttributeValue.builder().n(version.toString()).build()); GetItemResponse response = GetItemResponse.builder() .item(recordMap) .build(); when(principal.getName()).thenReturn(userId); when(dynamodb.getItem(any(GetItemRequest.class))).thenReturn(response); Map<String, AttributeValue> expectedAttributeValueMap = new HashMap<>(); expectedAttributeValueMap.put(":v", AttributeValue.builder().n(version.toString()).build()); DeleteItemRequest expectedDeleteItemRequest = DeleteItemRequest.builder() .tableName(TABLE_NAME) .key(keyMap(userId, applicationId)) .conditionExpression("version = :v") .expressionAttributeValues(expectedAttributeValueMap) .build(); service.deleteApplication(applicationId); ArgumentCaptor<DeleteItemRequest> deleteItemRequestArgumentCaptor = ArgumentCaptor.forClass(DeleteItemRequest.class); verify(dynamodb).deleteItem(deleteItemRequestArgumentCaptor.capture()); DeleteItemRequest deleteItemRequest = deleteItemRequestArgumentCaptor.getValue(); assertThat(deleteItemRequest).isEqualTo(expectedDeleteItemRequest); }