Skip to content

Commit

Permalink
[SELC-5740] Added test con TrackEventInput
Browse files Browse the repository at this point in the history
  • Loading branch information
flaminiaScarciofolo committed Oct 16, 2024
1 parent 1694519 commit 0fa12f9
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
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());
}
}
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());
}

}

0 comments on commit 0fa12f9

Please sign in to comment.