Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
[SELC-4383] Feat: Added dependency and configuration of product libs (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
manuraf authored May 3, 2024
1 parent f4f39b7 commit f48fc4c
Show file tree
Hide file tree
Showing 33 changed files with 204 additions and 178 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release_open_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
swagger_conflict_update:
runs-on: ubuntu-20.04
permissions: write-all
secrets: inherit
name: Swagger Detect Conflict and Update
steps:
- id: swagger-conflict-update
Expand Down
16 changes: 15 additions & 1 deletion Dockerfile.new
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@ FROM maven:3-eclipse-temurin-17@sha256:0d328fa6843bb26b60cf44d69833f241ffe96218f

COPY . .

RUN mvn clean package -DskipTests=true
RUN echo "<settings>\n" \
"<servers>\n" \
"<server>\n" \
"<id>\${repositoryOnboarding}</id>\n" \
"<username>\${repoLogin}</username>\n" \
"<password>\${repoPwd}</password>\n" \
"</server>\n" \
"</servers>\n" \
"</settings>\n" > settings.xml

ARG REPO_ONBOARDING
ARG REPO_USERNAME
ARG REPO_PASSWORD

RUN mvn --global-settings settings.xml -DrepositoryOnboarding=${REPO_ONBOARDING} -DrepoLogin=${REPO_USERNAME} -DrepoPwd=${REPO_PASSWORD} clean package -DskipTests=true

FROM openjdk:17-jdk@sha256:528707081fdb9562eb819128a9f85ae7fe000e2fbaeaf9f87662e7b3f38cb7d8 AS runtime

Expand Down
4 changes: 4 additions & 0 deletions app/src/main/resources/config/core-config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ scheduler.threads.max-number=${THREADS_SCHEDULE_MAX_NUMBER:1}
scheduler.fixed-delay.delay=${SCHEDULER_FIXED_DELAY:20000}
scheduler.regenerate-kafka-queue-config.name=${SCHEDULER_REGENERATE_KAFKA_QUEUE_CONFIG_NAME:KafkaScheduler}
scheduler.regenerate-kafka-queue.enabled=${SCHEDULER_REGENERATE_KAFKA_QUEUE_ENABLED:false}

mscore.blob-storage.container-product=${PRODUCT_STORAGE_CONTAINER:selc-d-product}
mscore.blob-storage.filepath-product = products.json
mscore.blob-storage.connection-string-product = ${BLOB_STORAGE_PRODUCT_CONNECTION_STRING:UseDevelopmentStorage=true;}
18 changes: 9 additions & 9 deletions app/src/main/resources/swagger/api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2153,7 +2153,7 @@
"200" : {
"description" : "OK",
"content" : {
"*/*" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/BulkInstitutions"
}
Expand Down Expand Up @@ -2299,7 +2299,7 @@
"200" : {
"description" : "OK",
"content" : {
"*/*" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/OnboardingInfoResponse"
}
Expand Down Expand Up @@ -2407,7 +2407,7 @@
"200" : {
"description" : "OK",
"content" : {
"*/*" : {
"application/json" : {
"schema" : {
"type" : "string",
"format" : "byte"
Expand Down Expand Up @@ -3030,7 +3030,7 @@
"204" : {
"description" : "No Content",
"content" : {
"*/*" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/OnboardedUsersResponse"
}
Expand Down Expand Up @@ -3083,7 +3083,7 @@
"200" : {
"description" : "OK",
"content" : {
"*/*" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/RelationshipResult"
}
Expand Down Expand Up @@ -3322,7 +3322,7 @@
"200" : {
"description" : "OK",
"content" : {
"*/*" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/UsersNotificationResponse"
}
Expand Down Expand Up @@ -3393,7 +3393,7 @@
"200" : {
"description" : "OK",
"content" : {
"*/*" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/UserResponse"
}
Expand Down Expand Up @@ -3633,7 +3633,7 @@
"200" : {
"description" : "OK",
"content" : {
"*/*" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/OnboardingInfoResponse"
}
Expand Down Expand Up @@ -3779,7 +3779,7 @@
"200" : {
"description" : "OK",
"content" : {
"*/*" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/UserProductsResponse"
}
Expand Down
14 changes: 14 additions & 0 deletions connector-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@
<groupId>it.pagopa.selfcare</groupId>
<artifactId>selc-commons-base</artifactId>
</dependency>

<dependency>
<groupId>it.pagopa.selfcare</groupId>
<artifactId>onboarding-sdk-product</artifactId>
<version>0.1.10</version>
</dependency>
</dependencies>

<repositories>
<repository>
<id>selfcare-onboarding</id>
<name>Selfcare Onboarding SDK</name>
<url>https://maven.pkg.github.com/pagopa/selfcare-onboarding</url>
</repository>
</repositories>

</project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package it.pagopa.selfcare.mscore.api;


import it.pagopa.selfcare.mscore.model.product.Product;
import it.pagopa.selfcare.product.entity.Product;

public interface ProductConnector {
Product getProductById(String productId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@ public class CoreConfig {
private Integer onboardingExpiringDate;
private boolean infoCamereEnable;
private boolean enableSendDelegationMail;
private BlobStorage blobStorage;

@Data
public static class BlobStorage {
private String containerProduct;
private String filepathProduct;
private String connectionStringProduct;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import it.pagopa.selfcare.mscore.exception.ResourceNotFoundException;
import it.pagopa.selfcare.mscore.model.institution.*;
import it.pagopa.selfcare.mscore.model.onboarding.VerifyOnboardingFilters;
import it.pagopa.selfcare.mscore.model.product.ProductStatus;
import it.pagopa.selfcare.product.entity.ProductStatus;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import it.pagopa.selfcare.mscore.connector.dao.model.inner.UserBindingEntity;
import it.pagopa.selfcare.mscore.connector.dao.model.mapper.UserEntityMapper;
import it.pagopa.selfcare.mscore.connector.dao.model.mapper.UserInstitutionAggregationMapper;
import it.pagopa.selfcare.mscore.connector.rest.client.ProductsRestClient;
import it.pagopa.selfcare.mscore.constant.Env;
import it.pagopa.selfcare.mscore.constant.RelationshipState;
import it.pagopa.selfcare.mscore.exception.InvalidRequestException;
Expand All @@ -19,10 +18,11 @@
import it.pagopa.selfcare.mscore.model.onboarding.OnboardedProduct;
import it.pagopa.selfcare.mscore.model.onboarding.OnboardedUser;
import it.pagopa.selfcare.mscore.model.onboarding.Token;
import it.pagopa.selfcare.mscore.model.product.Product;
import it.pagopa.selfcare.mscore.model.product.ProductRoleInfo;
import it.pagopa.selfcare.mscore.model.user.UserBinding;
import it.pagopa.selfcare.mscore.model.user.UserInfo;
import it.pagopa.selfcare.product.entity.Product;
import it.pagopa.selfcare.product.entity.ProductRoleInfo;
import it.pagopa.selfcare.product.service.ProductService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.PageRequest;
Expand Down Expand Up @@ -65,7 +65,7 @@ public class UserConnectorImpl implements UserConnector {

private final MongoOperations mongoOperations;

private final ProductsRestClient productRestClient;
private final ProductService productService;


/**
Expand Down Expand Up @@ -370,8 +370,8 @@ public List<UserInstitutionAggregation> getUserInfo(String userId, String instit
private void checkRoles(String productId, PartyRole role, String productRole) {
if (StringUtils.hasText(productRole)) {
Assert.notNull(role, ROLE_IS_NULL.getMessage());
Product product = productRestClient.getProductById(productId, null);
ProductRoleInfo productRoleInfo = product.getRoleMappings().get(role);
Product product = productService.getProduct(productId);
ProductRoleInfo productRoleInfo = product.getRoleMappings().get(it.pagopa.selfcare.onboarding.common.PartyRole.valueOf(role.name()));
if (productRoleInfo == null) {
throw new InvalidRequestException(ROLE_NOT_FOUND.getMessage(), ROLE_NOT_FOUND.getCode());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import it.pagopa.selfcare.mscore.connector.dao.model.inner.OnboardingEntity;
import it.pagopa.selfcare.mscore.connector.dao.model.inner.UserBindingEntity;
import it.pagopa.selfcare.mscore.connector.dao.model.mapper.*;
import it.pagopa.selfcare.mscore.connector.rest.client.ProductsRestClient;
import it.pagopa.selfcare.mscore.constant.Env;
import it.pagopa.selfcare.mscore.constant.RelationshipState;
import it.pagopa.selfcare.mscore.exception.ResourceNotFoundException;
Expand All @@ -22,9 +21,11 @@
import it.pagopa.selfcare.mscore.model.onboarding.OnboardedProduct;
import it.pagopa.selfcare.mscore.model.onboarding.OnboardedUser;
import it.pagopa.selfcare.mscore.model.onboarding.Token;
import it.pagopa.selfcare.mscore.model.product.Product;
import it.pagopa.selfcare.mscore.model.product.ProductRoleInfo;
import it.pagopa.selfcare.mscore.model.user.UserBinding;
import it.pagopa.selfcare.product.entity.Product;
import it.pagopa.selfcare.product.entity.ProductRole;
import it.pagopa.selfcare.product.entity.ProductRoleInfo;
import it.pagopa.selfcare.product.service.ProductService;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -62,7 +63,7 @@ class UserConnectorImplTest {
private UserEntityMapper userMapper = new UserEntityMapperImpl();

@Mock
private ProductsRestClient productsRestClient;
private ProductService productService;

@Spy
private OnboardedProductMapper productMapper = new OnboardedProductMapperImpl();
Expand Down Expand Up @@ -220,15 +221,15 @@ void findAndUpdateStateByInstitutionAndProduct() {
when(userRepository.findAndModify(any(), any(), any(), any()))
.thenReturn(new UserEntity());
Product product = mock(Product.class);
EnumMap<PartyRole, ProductRoleInfo> map = mock(EnumMap.class);
EnumMap<it.pagopa.selfcare.onboarding.common.PartyRole, ProductRoleInfo> map = mock(EnumMap.class);
ProductRoleInfo productRoleInfo = mock(ProductRoleInfo.class);
ProductRoleInfo.ProductRole productRole = mock(ProductRoleInfo.ProductRole.class);
ProductRole productRole = mock(ProductRole.class);
when(productRole.getCode()).thenReturn("productRole");
when(productRoleInfo.getRoles()).thenReturn(List.of(productRole));
when(map.get(PartyRole.DELEGATE)).thenReturn(productRoleInfo);
when(map.get(it.pagopa.selfcare.onboarding.common.PartyRole.DELEGATE)).thenReturn(productRoleInfo);
when(product.getRoleMappings()).thenReturn(map);

when(productsRestClient.getProductById(anyString(), any())).thenReturn(product);
when(productService.getProduct(anyString())).thenReturn(product);
Assertions.assertDoesNotThrow(() -> userConnectorImpl.findAndUpdateStateWithOptionalFilter("42", "42", "productId", PartyRole.DELEGATE, "productRole", RelationshipState.PENDING));
}

Expand All @@ -250,10 +251,6 @@ void findAndUpdateStateByProductId() {
void findAndUpdateStateWithoutFilter() {
when(userRepository.findAndModify(any(), any(), any(), any()))
.thenReturn(new UserEntity());
Product product = mock(Product.class);
EnumMap<PartyRole, ProductRoleInfo> map = mock(EnumMap.class);
ProductRoleInfo productRoleInfo = mock(ProductRoleInfo.class);
ProductRoleInfo.ProductRole productRole = mock(ProductRoleInfo.ProductRole.class);
Assertions.assertDoesNotThrow(() -> userConnectorImpl.findAndUpdateStateWithOptionalFilter("42", null, null, null, null, RelationshipState.PENDING));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import it.pagopa.selfcare.commons.base.logging.LogUtils;
import it.pagopa.selfcare.mscore.api.ProductConnector;
import it.pagopa.selfcare.mscore.connector.rest.client.ProductsRestClient;
import it.pagopa.selfcare.mscore.model.product.Product;
import it.pagopa.selfcare.product.entity.Product;
import it.pagopa.selfcare.product.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
Expand All @@ -12,17 +12,17 @@
@Service
public class ProductConnectorImpl implements ProductConnector {

private final ProductsRestClient restClient;
private final ProductService productService;

public ProductConnectorImpl(ProductsRestClient productsRestClient) {
this.restClient = productsRestClient;
public ProductConnectorImpl(ProductService productService) {
this.productService = productService;
}

@Override
public Product getProductById(String productId) {
log.debug(LogUtils.CONFIDENTIAL_MARKER, "getProductById productId = {}", productId);
Assert.hasText(productId, "A productId is required");
Product result = restClient.getProductById(productId, null);
Product result = productService.getProduct(productId);
log.debug(LogUtils.CONFIDENTIAL_MARKER, "getProductById result = {}", result);
return result;
}
Expand All @@ -31,7 +31,7 @@ public Product getProductById(String productId) {
public Product getProductValidById(String productId) {
log.debug(LogUtils.CONFIDENTIAL_MARKER, "getProductValidById productId = {}", productId);
Assert.hasText(productId, "A productId is required");
Product result = restClient.getProductValid(productId);
Product result = productService.getProductIsValid(productId);
log.debug(LogUtils.CONFIDENTIAL_MARKER, "getProductValidById result = {}", result);
return result;
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit f48fc4c

Please sign in to comment.