|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2020 ForgeRock. All rights reserved. |
| 2 | + * Copyright (c) 2020 - 2025 Ping Identity. All rights reserved. |
3 | 3 | *
|
4 | 4 | * This software may be modified and distributed under the terms
|
5 | 5 | * of the MIT license. See the LICENSE file for details.
|
@@ -389,6 +389,39 @@ public void testShouldGetNotificationById() {
|
389 | 389 | assertEquals(pushNotificationFromStorage.getMessageId(), MESSAGE_ID);
|
390 | 390 | }
|
391 | 391 |
|
| 392 | + @Test |
| 393 | + public void testShouldGetNotificationByMessageId() { |
| 394 | + DefaultStorageClient defaultStorage = new DefaultStorageClient(context); |
| 395 | + defaultStorage.setAccountData(context.getApplicationContext() |
| 396 | + .getSharedPreferences(TEST_SHARED_PREFERENCES_DATA_ACCOUNT, Context.MODE_PRIVATE)); |
| 397 | + defaultStorage.setMechanismData(context.getApplicationContext() |
| 398 | + .getSharedPreferences(TEST_SHARED_PREFERENCES_DATA_MECHANISM, Context.MODE_PRIVATE)); |
| 399 | + defaultStorage.setNotificationData(context.getApplicationContext() |
| 400 | + .getSharedPreferences(TEST_SHARED_PREFERENCES_DATA_NOTIFICATIONS, Context.MODE_PRIVATE)); |
| 401 | + |
| 402 | + Calendar timeAdded = Calendar.getInstance(); |
| 403 | + |
| 404 | + Account account = createAccountWithoutAdditionalData(ISSUER, ACCOUNT_NAME); |
| 405 | + Mechanism mechanism = createPushMechanism(MECHANISM_UID, ISSUER, ACCOUNT_NAME, SECRET, |
| 406 | + REGISTRATION_ENDPOINT, AUTHENTICATION_ENDPOINT); |
| 407 | + PushNotification pushNotification = createPushNotification(MECHANISM_UID, MESSAGE_ID, CHALLENGE, |
| 408 | + AMLB_COOKIE, timeAdded, TTL); |
| 409 | + |
| 410 | + defaultStorage.setAccount(account); |
| 411 | + defaultStorage.setMechanism(mechanism); |
| 412 | + defaultStorage.setNotification(pushNotification); |
| 413 | + |
| 414 | + Account accountFromStorage = defaultStorage.getAccount(account.getId()); |
| 415 | + PushMechanism pushMechanismFromStorage = (PushMechanism) defaultStorage.getMechanismsForAccount(accountFromStorage).get(0); |
| 416 | + PushNotification pushNotificationFromStorage = defaultStorage.getNotificationByMessageId(pushNotification.getMessageId()); |
| 417 | + |
| 418 | + assertNotNull(accountFromStorage); |
| 419 | + assertNotNull(pushMechanismFromStorage); |
| 420 | + assertNotNull(pushNotificationFromStorage); |
| 421 | + assertEquals(pushNotificationFromStorage.getMechanismUID(), MECHANISM_UID); |
| 422 | + assertEquals(pushNotificationFromStorage.getMessageId(), MESSAGE_ID); |
| 423 | + } |
| 424 | + |
392 | 425 | @Test
|
393 | 426 | public void testStoreMultipleNotificationsForSameAccount() {
|
394 | 427 | DefaultStorageClient defaultStorage = new DefaultStorageClient(context);
|
|
0 commit comments