From 8699d94de66e2cfad6df7b21ff29863b28976e82 Mon Sep 17 00:00:00 2001 From: Katherine Date: Wed, 21 Aug 2024 11:40:02 -0400 Subject: [PATCH] Give mock devices unique IDs when testing whether a capability is supported --- .../textsecuregcm/storage/AccountTest.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/storage/AccountTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/storage/AccountTest.java index 22d77ff6..77343419 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/storage/AccountTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/storage/AccountTest.java @@ -67,18 +67,23 @@ class AccountTest { when(oldSecondaryDevice.getLastSeen()).thenReturn(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(366)); when(oldSecondaryDevice.getId()).thenReturn(deviceId2); + when(paymentActivationCapableDevice.getId()).thenReturn((byte) 1); when(paymentActivationCapableDevice.getCapabilities()) .thenReturn(new DeviceCapabilities(true, true, true, false, false)); + when(paymentActivationIncapableDevice.getId()).thenReturn((byte) 2); when(paymentActivationIncapableDevice.getCapabilities()) .thenReturn(new DeviceCapabilities(true, true, false, false, false)); + when(paymentActivationIncapableDeviceWithoutDeliveryChannel.getId()).thenReturn((byte) 3); when(paymentActivationIncapableDeviceWithoutDeliveryChannel.getCapabilities()) .thenReturn(new DeviceCapabilities(true, true, false, false, false)); + when(deleteSyncCapableDevice.getId()).thenReturn((byte) 1); when(deleteSyncCapableDevice.getCapabilities()) .thenReturn(new DeviceCapabilities(true, true, true, true, false)); + when(deleteSyncIncapableDevice.getId()).thenReturn((byte) 2); when(deleteSyncIncapableDevice.getCapabilities()) .thenReturn(new DeviceCapabilities(true, true, true, false, false)); @@ -158,10 +163,10 @@ class AccountTest { List.of(paymentActivationCapableDevice), "1234".getBytes(StandardCharsets.UTF_8)).isPaymentActivationSupported()).isTrue(); assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), - List.of(paymentActivationCapableDevice, paymentActivationIncapableDevice), + List.of(paymentActivationIncapableDevice, paymentActivationCapableDevice), "1234".getBytes(StandardCharsets.UTF_8)).isPaymentActivationSupported()).isFalse(); assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), - List.of(paymentActivationCapableDevice, paymentActivationIncapableDeviceWithoutDeliveryChannel), + List.of(paymentActivationIncapableDeviceWithoutDeliveryChannel, paymentActivationCapableDevice), "1234".getBytes(StandardCharsets.UTF_8)).isPaymentActivationSupported()).isFalse(); } @@ -171,7 +176,7 @@ class AccountTest { List.of(deleteSyncCapableDevice), "1234".getBytes(StandardCharsets.UTF_8)).isDeleteSyncSupported()); assertFalse(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), - List.of(deleteSyncCapableDevice, deleteSyncIncapableDevice), + List.of(deleteSyncIncapableDevice, deleteSyncCapableDevice), "1234".getBytes(StandardCharsets.UTF_8)).isDeleteSyncSupported()); }