Give mock devices unique IDs when testing whether a capability is supported

This commit is contained in:
Katherine 2024-08-21 11:40:02 -04:00 committed by GitHub
parent 4c0a5ac3b2
commit 8699d94de6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 3 deletions

View File

@ -67,18 +67,23 @@ class AccountTest {
when(oldSecondaryDevice.getLastSeen()).thenReturn(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(366)); when(oldSecondaryDevice.getLastSeen()).thenReturn(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(366));
when(oldSecondaryDevice.getId()).thenReturn(deviceId2); when(oldSecondaryDevice.getId()).thenReturn(deviceId2);
when(paymentActivationCapableDevice.getId()).thenReturn((byte) 1);
when(paymentActivationCapableDevice.getCapabilities()) when(paymentActivationCapableDevice.getCapabilities())
.thenReturn(new DeviceCapabilities(true, true, true, false, false)); .thenReturn(new DeviceCapabilities(true, true, true, false, false));
when(paymentActivationIncapableDevice.getId()).thenReturn((byte) 2);
when(paymentActivationIncapableDevice.getCapabilities()) when(paymentActivationIncapableDevice.getCapabilities())
.thenReturn(new DeviceCapabilities(true, true, false, false, false)); .thenReturn(new DeviceCapabilities(true, true, false, false, false));
when(paymentActivationIncapableDeviceWithoutDeliveryChannel.getId()).thenReturn((byte) 3);
when(paymentActivationIncapableDeviceWithoutDeliveryChannel.getCapabilities()) when(paymentActivationIncapableDeviceWithoutDeliveryChannel.getCapabilities())
.thenReturn(new DeviceCapabilities(true, true, false, false, false)); .thenReturn(new DeviceCapabilities(true, true, false, false, false));
when(deleteSyncCapableDevice.getId()).thenReturn((byte) 1);
when(deleteSyncCapableDevice.getCapabilities()) when(deleteSyncCapableDevice.getCapabilities())
.thenReturn(new DeviceCapabilities(true, true, true, true, false)); .thenReturn(new DeviceCapabilities(true, true, true, true, false));
when(deleteSyncIncapableDevice.getId()).thenReturn((byte) 2);
when(deleteSyncIncapableDevice.getCapabilities()) when(deleteSyncIncapableDevice.getCapabilities())
.thenReturn(new DeviceCapabilities(true, true, true, false, false)); .thenReturn(new DeviceCapabilities(true, true, true, false, false));
@ -158,10 +163,10 @@ class AccountTest {
List.of(paymentActivationCapableDevice), List.of(paymentActivationCapableDevice),
"1234".getBytes(StandardCharsets.UTF_8)).isPaymentActivationSupported()).isTrue(); "1234".getBytes(StandardCharsets.UTF_8)).isPaymentActivationSupported()).isTrue();
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(),
List.of(paymentActivationCapableDevice, paymentActivationIncapableDevice), List.of(paymentActivationIncapableDevice, paymentActivationCapableDevice),
"1234".getBytes(StandardCharsets.UTF_8)).isPaymentActivationSupported()).isFalse(); "1234".getBytes(StandardCharsets.UTF_8)).isPaymentActivationSupported()).isFalse();
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(),
List.of(paymentActivationCapableDevice, paymentActivationIncapableDeviceWithoutDeliveryChannel), List.of(paymentActivationIncapableDeviceWithoutDeliveryChannel, paymentActivationCapableDevice),
"1234".getBytes(StandardCharsets.UTF_8)).isPaymentActivationSupported()).isFalse(); "1234".getBytes(StandardCharsets.UTF_8)).isPaymentActivationSupported()).isFalse();
} }
@ -171,7 +176,7 @@ class AccountTest {
List.of(deleteSyncCapableDevice), List.of(deleteSyncCapableDevice),
"1234".getBytes(StandardCharsets.UTF_8)).isDeleteSyncSupported()); "1234".getBytes(StandardCharsets.UTF_8)).isDeleteSyncSupported());
assertFalse(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), assertFalse(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(),
List.of(deleteSyncCapableDevice, deleteSyncIncapableDevice), List.of(deleteSyncIncapableDevice, deleteSyncCapableDevice),
"1234".getBytes(StandardCharsets.UTF_8)).isDeleteSyncSupported()); "1234".getBytes(StandardCharsets.UTF_8)).isDeleteSyncSupported());
} }