-
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] added configuration for send fd event
- Loading branch information
1 parent
6c1fe53
commit c7b5eaa
Showing
14 changed files
with
360 additions
and
118 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
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
85 changes: 85 additions & 0 deletions
85
apps/user-cdc/src/test/java/it/pagopa/selfcare/user/event/mapper/NotificationMapperTest.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,85 @@ | ||
package it.pagopa.selfcare.user.event.mapper; | ||
|
||
import it.pagopa.selfcare.onboarding.common.PartyRole; | ||
import it.pagopa.selfcare.user.model.OnboardedProduct; | ||
import it.pagopa.selfcare.user.model.UserToNotify; | ||
import it.pagopa.selfcare.user.model.constants.OnboardedProductState; | ||
import org.junit.jupiter.api.Test; | ||
import org.openapi.quarkus.user_registry_json.model.CertifiableFieldResourceOfstring; | ||
import org.openapi.quarkus.user_registry_json.model.UserResource; | ||
import org.openapi.quarkus.user_registry_json.model.WorkContactResource; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
class NotificationMapperTest { | ||
|
||
@Test | ||
void mapUser_withValidData_shouldMapFieldsCorrectly() { | ||
UserResource userResource = new UserResource(); | ||
userResource.setId(UUID.randomUUID()); | ||
userResource.setName(new CertifiableFieldResourceOfstring().value("John")); | ||
userResource.setFamilyName(new CertifiableFieldResourceOfstring().value("Doe")); | ||
userResource.setWorkContacts(Map.of("mailUuid", new WorkContactResource().email(new CertifiableFieldResourceOfstring().value("john.doe@example.com")))); | ||
OnboardedProduct onboardedProduct = new OnboardedProduct(); | ||
onboardedProduct.setProductRole("Admin"); | ||
onboardedProduct.setRole(PartyRole.MANAGER); | ||
onboardedProduct.setStatus(OnboardedProductState.ACTIVE); | ||
|
||
UserToNotify result = new NotificationMapperImpl().mapUser(userResource, "mailUuid", onboardedProduct); | ||
|
||
assertEquals(userResource.getId().toString(), result.getUserId()); | ||
assertEquals("John", result.getName()); | ||
assertEquals("Doe", result.getFamilyName()); | ||
assertEquals("john.doe@example.com", result.getEmail()); | ||
assertEquals("Admin", result.getProductRole()); | ||
assertEquals("MANAGER", result.getRole()); | ||
assertEquals(OnboardedProductState.ACTIVE, result.getRelationshipStatus()); | ||
} | ||
|
||
@Test | ||
void mapUser_withNullFields_shouldHandleNullValues() { | ||
UserResource userResource = new UserResource(); | ||
OnboardedProduct onboardedProduct = new OnboardedProduct(); | ||
|
||
UserToNotify result = new NotificationMapperImpl().mapUser(userResource, null, onboardedProduct); | ||
|
||
assertNull(result.getUserId()); | ||
assertNull(result.getName()); | ||
assertNull(result.getFamilyName()); | ||
assertNull(result.getEmail()); | ||
assertNull(result.getProductRole()); | ||
assertNull(result.getRole()); | ||
assertNull(result.getRelationshipStatus()); | ||
} | ||
|
||
@Test | ||
void retrieveMailFromWorkContacts_withValidMailUuid_shouldReturnEmail() { | ||
UserResource userResource = new UserResource(); | ||
userResource.setWorkContacts(Map.of("mailUuid", new WorkContactResource().email(new CertifiableFieldResourceOfstring().value("john.doe@example.com")))); | ||
|
||
String result = new NotificationMapperImpl().retrieveMailFromWorkContacts(userResource, "mailUuid"); | ||
|
||
assertEquals("john.doe@example.com", result); | ||
} | ||
|
||
@Test | ||
void retrieveMailFromWorkContacts_withInvalidMailUuid_shouldReturnNull() { | ||
UserResource userResource = new UserResource(); | ||
userResource.setWorkContacts(Map.of("mailUuid", new WorkContactResource().email(new CertifiableFieldResourceOfstring().value("john.doe@example.com")))); | ||
|
||
String result = new NotificationMapperImpl().retrieveMailFromWorkContacts(userResource, "invalidUuid"); | ||
|
||
assertNull(result); | ||
} | ||
|
||
@Test | ||
void retrieveMailFromWorkContacts_withNullWorkContacts_shouldReturnNull() { | ||
UserResource userResource = new UserResource(); | ||
|
||
String result = new NotificationMapperImpl().retrieveMailFromWorkContacts(userResource, "mailUuid"); | ||
|
||
assertNull(result); | ||
} | ||
} |
Oops, something went wrong.