-
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-5740] Added test con TrackEventInput
- Loading branch information
1 parent
1694519
commit 0fa12f9
Showing
2 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
libs/user-sdk-event/src/test/java/it/pagopa/selfcare/user/TrackEventInputTest.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,52 @@ | ||
package it.pagopa.selfcare.user; | ||
|
||
import it.pagopa.selfcare.user.model.TrackEventInput; | ||
import it.pagopa.selfcare.user.model.UserGroupNotificationToSend; | ||
import it.pagopa.selfcare.user.model.UserNotificationToSend; | ||
import it.pagopa.selfcare.user.model.UserToNotify; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.Instant; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class TrackEventInputTest { | ||
|
||
@Test | ||
void toTrackEventInput_withUserNotification() { | ||
UserNotificationToSend userNotification = new UserNotificationToSend(); | ||
userNotification.setId("docKey"); | ||
UserToNotify user = new UserToNotify(); | ||
user.setUserId("userId"); | ||
user.setProductRole("productRole"); | ||
userNotification.setUser(user); | ||
userNotification.setInstitutionId("institutionId"); | ||
userNotification.setProductId("productId"); | ||
|
||
TrackEventInput result = TrackEventInput.toTrackEventInput(userNotification); | ||
|
||
assertEquals("docKey", result.getDocumentKey()); | ||
assertEquals("userId", result.getUserId()); | ||
assertEquals("institutionId", result.getInstitutionId()); | ||
assertEquals("productId", result.getProductId()); | ||
assertEquals("productRole", result.getProductRole()); | ||
} | ||
|
||
@Test | ||
void toTrackEventInputForUserGroup_withUserGroupNotification() { | ||
UserGroupNotificationToSend userGroupNotification = new UserGroupNotificationToSend(); | ||
userGroupNotification.setId("docKey"); | ||
userGroupNotification.setInstitutionId("institutionId"); | ||
userGroupNotification.setProductId("productId"); | ||
userGroupNotification.setMembers(Set.of("member1", "member2")); | ||
|
||
TrackEventInput result = TrackEventInput.toTrackEventInputForUserGroup(userGroupNotification); | ||
|
||
assertEquals("docKey", result.getDocumentKey()); | ||
assertEquals("institutionId", result.getInstitutionId()); | ||
assertEquals("productId", result.getProductId()); | ||
assertEquals(List.of("member1", "member2"), result.getGroupMembers()); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...user-sdk-event/src/test/java/it/pagopa/selfcare/user/UserGroupNotificationToSendTest.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,39 @@ | ||
package it.pagopa.selfcare.user; | ||
|
||
import it.pagopa.selfcare.user.model.UserGroupNotificationToSend; | ||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
import java.time.Instant; | ||
import java.util.Set; | ||
|
||
class UserGroupNotificationToSendTest { | ||
|
||
@Test | ||
void userGroupNotificationToSend_withValidData_shouldMapFieldsCorrectly() { | ||
UserGroupNotificationToSend notification = new UserGroupNotificationToSend(); | ||
notification.setId("id"); | ||
notification.setInstitutionId("institutionId"); | ||
notification.setProductId("productId"); | ||
notification.setName("name"); | ||
notification.setDescription("description"); | ||
notification.setStatus("status"); | ||
notification.setMembers(Set.of("member1", "member2")); | ||
notification.setCreatedAt(Instant.now()); | ||
notification.setCreatedBy("createdBy"); | ||
notification.setModifiedAt(Instant.now()); | ||
notification.setModifiedBy("modifiedBy"); | ||
|
||
assertEquals("id", notification.getId()); | ||
assertEquals("institutionId", notification.getInstitutionId()); | ||
assertEquals("productId", notification.getProductId()); | ||
assertEquals("name", notification.getName()); | ||
assertEquals("description", notification.getDescription()); | ||
assertEquals("status", notification.getStatus()); | ||
assertEquals(Set.of("member1", "member2"), notification.getMembers()); | ||
assertNotNull(notification.getCreatedAt()); | ||
assertEquals("createdBy", notification.getCreatedBy()); | ||
assertNotNull(notification.getModifiedAt()); | ||
assertEquals("modifiedBy", notification.getModifiedBy()); | ||
} | ||
|
||
} |