  @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);
  }