Skip to content

Commit

Permalink
[SELC-5923] import sdk enum instead of constant for productId
Browse files Browse the repository at this point in the history
  • Loading branch information
flaminiaScarciofolo committed Nov 7, 2024
1 parent a416118 commit 877d3e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@

import static com.mongodb.client.model.Projections.fields;
import static com.mongodb.client.model.Projections.include;
import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_FD;
import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_FD_GARANTITO;
import static it.pagopa.selfcare.user.UserUtils.mapPropsForTrackEvent;
import static it.pagopa.selfcare.user.event.constant.CdcStartAtConstant.*;
import static it.pagopa.selfcare.user.model.TrackEventInput.toTrackEventInput;
Expand All @@ -57,8 +59,6 @@ public class UserInstitutionCdcService {
private static final String COLLECTION_NAME = "userInstitutions";
private static final String OPERATION_NAME = "USER-CDC-UserInfoUpdate";
public static final String USERS_FIELD_LIST_WITHOUT_FISCAL_CODE = "name,familyName,email,workContacts";
private static final String PROD_FD = "prod-fd";
private static final String PROD_FD_GARANTITO = "prod-fd-garantito";
public static final String ERROR_DURING_SUBSCRIBE_COLLECTION_EXCEPTION_MESSAGE = "Error during subscribe collection, exception: {} , message: {}";


Expand Down Expand Up @@ -251,7 +251,7 @@ public void consumerToSendUserEventForFD(ChangeStreamDocument<UserInstitution> d
userRegistryApi.findByIdUsingGET(USERS_FIELD_LIST_WITHOUT_FISCAL_CODE, userInstitutionChanged.getUserId())
.onFailure(this::checkIfIsRetryableException)
.retry().withBackOff(Duration.ofSeconds(retryMinBackOff), Duration.ofSeconds(retryMaxBackOff)).atMost(maxRetry)
.onItem().transformToUni(userResource -> Uni.createFrom().item(UserUtils.retrieveFdProductIfItChanged(userInstitutionChanged.getProducts(), List.of(PROD_FD, PROD_FD_GARANTITO)))
.onItem().transformToUni(userResource -> Uni.createFrom().item(UserUtils.retrieveFdProductIfItChanged(userInstitutionChanged.getProducts(), List.of(PROD_FD.name(), PROD_FD_GARANTITO.name())))
.onItem().ifNotNull().transform(onboardedProduct -> notificationMapper.toFdUserNotificationToSend(userInstitutionChanged, onboardedProduct, userResource, evaluateType(onboardedProduct)))
.onItem().ifNotNull().transformToUni(fdUserNotificationToSend -> {
log.info("Sending message to EventHubFdRestClient ... ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;

import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_FD;
import static it.pagopa.selfcare.onboarding.common.ProductId.PROD_FD_GARANTITO;
import static it.pagopa.selfcare.user.constant.CollectionUtil.MAIL_ID_PREFIX;


Expand All @@ -40,8 +42,6 @@
@Slf4j
public class UserRegistryServiceImpl implements UserRegistryService {
private static final String USERS_FIELD_LIST_WITHOUT_FISCAL_CODE = "name,familyName,email,workContacts";
public static final String PROD_FD_GARANTITO = "prod-fd-garantito";
public static final String PROD_FD = "prod-fd";

private final UserInstitutionService userInstitutionService;
private final UserMapper userMapper;
Expand Down Expand Up @@ -153,7 +153,7 @@ private Uni<UserInstitution> checkProductAndSendFdUserNotification(UserInstituti
}

private boolean checkIfExistActiveFdProduct(OnboardedProduct product) {
return List.of(PROD_FD, PROD_FD_GARANTITO).contains(product.getProductId()) && OnboardedProductState.ACTIVE.equals(product.getStatus());
return List.of(PROD_FD.name(), PROD_FD_GARANTITO.name()).contains(product.getProductId()) && OnboardedProductState.ACTIVE.equals(product.getStatus());
}

private String retrieveOldMail(UserResource userResource, String userMailUuid) {
Expand Down

0 comments on commit 877d3e6

Please sign in to comment.