public CompletableFuture<Boolean> mayHaveMessages(final UUID accountIdentifier, final Device device) {
    final List<CompletableFuture<Boolean>> mayHaveMessagesFutures =
        Stream.of(convertPartitionKeyDeprecated(accountIdentifier, device), convertPartitionKey(accountIdentifier, device))
            .distinct()
            .map(partitionKey -> dbAsyncClient.query(QueryRequest.builder()
                    .tableName(tableName)
                    .consistentRead(false)
                    .limit(1)
                    .keyConditionExpression("#part = :part")
                    .expressionAttributeNames(Map.of("#part", KEY_PARTITION))
                    .expressionAttributeValues(Map.of(":part", partitionKey)).build())
                .thenApply(queryResponse -> queryResponse.count() > 0))
            .toList();

    return CompletableFuture.allOf(mayHaveMessagesFutures.toArray(EMPTY_FUTURE_ARRAY))
        .thenApply(ignored -> mayHaveMessagesFutures.stream().anyMatch(CompletableFuture::join));
  }
@Test
  void mayHaveMessages() {
    final UUID destinationUuid = UUID.randomUUID();
    final byte destinationDeviceId = (byte) (random.nextInt(Device.MAXIMUM_DEVICE_ID) + 1);
    final Device destinationDevice = DevicesHelper.createDevice(destinationDeviceId);

    assertThat(messagesDynamoDb.mayHaveMessages(destinationUuid, destinationDevice).join()).isFalse();

    messagesDynamoDb.store(List.of(MESSAGE1, MESSAGE2, MESSAGE3), destinationUuid, destinationDevice);

    assertThat(messagesDynamoDb.mayHaveMessages(destinationUuid, destinationDevice).join()).isTrue();
  }