-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SELC-5887] refactor for change requests
- Loading branch information
1 parent
b02715a
commit 45a96ac
Showing
4 changed files
with
122 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
libs/user-sdk-event/src/test/java/it/pagopa/selfcare/user/FdUserNotificationToSendTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package it.pagopa.selfcare.user; | ||
|
||
import it.pagopa.selfcare.user.model.FdUserNotificationToSend; | ||
import it.pagopa.selfcare.user.model.NotificationUserType; | ||
import it.pagopa.selfcare.user.model.UserToNotify; | ||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
import java.time.OffsetDateTime; | ||
|
||
class FdUserNotificationToSendTest { | ||
|
||
@Test | ||
void fdUserNotificationToSend_ACTIVE() { | ||
FdUserNotificationToSend notification = new FdUserNotificationToSend(); | ||
notification.setId("123"); | ||
notification.setInstitutionId("inst-456"); | ||
notification.setProduct("product-789"); | ||
notification.setCreatedAt(OffsetDateTime.now().minusDays(1)); | ||
notification.setUpdatedAt(OffsetDateTime.now()); | ||
notification.setOnboardingTokenId("token-101112"); | ||
notification.setType(NotificationUserType.ACTIVE_USER); | ||
UserToNotify user = new UserToNotify(); | ||
notification.setUser(user); | ||
|
||
assertEquals("123", notification.getId()); | ||
assertEquals("inst-456", notification.getInstitutionId()); | ||
assertEquals("product-789", notification.getProduct()); | ||
assertNotNull(notification.getCreatedAt()); | ||
assertNotNull(notification.getUpdatedAt()); | ||
assertEquals("token-101112", notification.getOnboardingTokenId()); | ||
assertEquals(NotificationUserType.ACTIVE_USER, notification.getType()); | ||
assertEquals(user, notification.getUser()); | ||
} | ||
|
||
@Test | ||
void fdUserNotificationToSend_DELETE() { | ||
FdUserNotificationToSend notification = new FdUserNotificationToSend(); | ||
notification.setId("123"); | ||
notification.setInstitutionId("inst-456"); | ||
notification.setProduct("product-789"); | ||
notification.setCreatedAt(OffsetDateTime.now().minusDays(1)); | ||
notification.setUpdatedAt(OffsetDateTime.now()); | ||
notification.setOnboardingTokenId("token-101112"); | ||
notification.setType(NotificationUserType.DELETE_USER); | ||
UserToNotify user = new UserToNotify(); | ||
notification.setUser(user); | ||
|
||
assertEquals("123", notification.getId()); | ||
assertEquals("inst-456", notification.getInstitutionId()); | ||
assertEquals("product-789", notification.getProduct()); | ||
assertNotNull(notification.getCreatedAt()); | ||
assertNotNull(notification.getUpdatedAt()); | ||
assertEquals("token-101112", notification.getOnboardingTokenId()); | ||
assertEquals(NotificationUserType.DELETE_USER, notification.getType()); | ||
assertEquals(user, notification.getUser()); | ||
} | ||
|
||
@Test | ||
void fdUserNotificationToSend_SUSPEND() { | ||
FdUserNotificationToSend notification = new FdUserNotificationToSend(); | ||
notification.setId("123"); | ||
notification.setInstitutionId("inst-456"); | ||
notification.setProduct("product-789"); | ||
notification.setCreatedAt(OffsetDateTime.now().minusDays(1)); | ||
notification.setUpdatedAt(OffsetDateTime.now()); | ||
notification.setOnboardingTokenId("token-101112"); | ||
notification.setType(NotificationUserType.SUSPEND_USER); | ||
UserToNotify user = new UserToNotify(); | ||
notification.setUser(user); | ||
|
||
assertEquals("123", notification.getId()); | ||
assertEquals("inst-456", notification.getInstitutionId()); | ||
assertEquals("product-789", notification.getProduct()); | ||
assertNotNull(notification.getCreatedAt()); | ||
assertNotNull(notification.getUpdatedAt()); | ||
assertEquals("token-101112", notification.getOnboardingTokenId()); | ||
assertEquals(NotificationUserType.SUSPEND_USER, notification.getType()); | ||
assertEquals(user, notification.getUser()); | ||
} | ||
|
||
@Test | ||
void fdUserNotificationToSend_withNullFields_shouldHandleNullValues() { | ||
FdUserNotificationToSend notification = new FdUserNotificationToSend(); | ||
|
||
assertNull(notification.getId()); | ||
assertNull(notification.getInstitutionId()); | ||
assertNull(notification.getProduct()); | ||
assertNull(notification.getCreatedAt()); | ||
assertNull(notification.getUpdatedAt()); | ||
assertNull(notification.getOnboardingTokenId()); | ||
assertNull(notification.getType()); | ||
assertNull(notification.getUser()); | ||
} | ||
|
||
@Test | ||
void fdUserNotificationToSend_withPartialData_shouldSetFieldsCorrectly() { | ||
FdUserNotificationToSend notification = new FdUserNotificationToSend(); | ||
notification.setId("123"); | ||
notification.setProduct("product-789"); | ||
|
||
assertEquals("123", notification.getId()); | ||
assertNull(notification.getInstitutionId()); | ||
assertEquals("product-789", notification.getProduct()); | ||
assertNull(notification.getCreatedAt()); | ||
assertNull(notification.getUpdatedAt()); | ||
assertNull(notification.getOnboardingTokenId()); | ||
assertNull(notification.getType()); | ||
assertNull(notification.getUser()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters