diff --git a/build.gradle.kts b/build.gradle.kts index 24c670f4..5a7b4e50 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -47,7 +47,6 @@ dependencies { implementation("io.micrometer:micrometer-registry-prometheus") implementation("org.springframework.boot:spring-boot-starter-data-redis") implementation("org.springframework.boot:spring-boot-starter-data-mongodb") - implementation("org.springframework.boot:spring-boot-starter-data-jpa") implementation("org.springframework.boot:spring-boot-starter-security") implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:$springDocOpenApiVersion") implementation("org.codehaus.janino:janino:$janinoVersion") @@ -61,9 +60,6 @@ dependencies { implementation("io.jsonwebtoken:jjwt:$jjwtVersion") implementation("org.bouncycastle:bcprov-jdk18on:$bouncycastleVersion") - // PostgreSQL - runtimeOnly("org.postgresql:postgresql") - compileOnly("org.projectlombok:lombok") annotationProcessor("org.projectlombok:lombok") diff --git a/gradle.lockfile b/gradle.lockfile index e8629a2f..f1585259 100644 --- a/gradle.lockfile +++ b/gradle.lockfile @@ -15,7 +15,6 @@ com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2=compileClasspath com.fasterxml.jackson.module:jackson-module-parameter-names:2.18.2=compileClasspath com.fasterxml.jackson:jackson-bom:2.18.2=compileClasspath com.nimbusds:nimbus-jose-jwt:9.48=compileClasspath -com.zaxxer:HikariCP:5.1.0=compileClasspath io.jsonwebtoken:jjwt-api:0.12.6=compileClasspath io.jsonwebtoken:jjwt:0.12.6=compileClasspath io.lettuce:lettuce-core:6.4.1.RELEASE=compileClasspath @@ -55,22 +54,17 @@ io.swagger.core.v3:swagger-core-jakarta:2.2.25=compileClasspath io.swagger.core.v3:swagger-models-jakarta:2.2.25=compileClasspath jakarta.activation:jakarta.activation-api:2.1.3=compileClasspath jakarta.annotation:jakarta.annotation-api:2.1.1=compileClasspath -jakarta.persistence:jakarta.persistence-api:3.1.0=compileClasspath -jakarta.transaction:jakarta.transaction-api:2.0.1=compileClasspath jakarta.validation:jakarta.validation-api:3.0.2=compileClasspath jakarta.xml.bind:jakarta.xml.bind-api:4.0.2=compileClasspath -org.antlr:antlr4-runtime:4.13.0=compileClasspath org.apache.commons:commons-lang3:3.17.0=compileClasspath org.apache.logging.log4j:log4j-api:2.24.3=compileClasspath org.apache.logging.log4j:log4j-to-slf4j:2.24.3=compileClasspath org.apache.tomcat.embed:tomcat-embed-core:10.1.34=compileClasspath org.apache.tomcat.embed:tomcat-embed-el:10.1.34=compileClasspath org.apache.tomcat.embed:tomcat-embed-websocket:10.1.34=compileClasspath -org.aspectj:aspectjweaver:1.9.22.1=compileClasspath org.bouncycastle:bcprov-jdk18on:1.79=compileClasspath org.codehaus.janino:commons-compiler:3.1.12=compileClasspath org.codehaus.janino:janino:3.1.12=compileClasspath -org.hibernate.orm:hibernate-core:6.6.4.Final=compileClasspath org.jspecify:jspecify:1.0.0=compileClasspath org.mongodb:bson:5.2.1=compileClasspath org.mongodb:mongodb-driver-core:5.2.1=compileClasspath @@ -87,10 +81,8 @@ org.springframework.boot:spring-boot-actuator-autoconfigure:3.4.1=compileClasspa org.springframework.boot:spring-boot-actuator:3.4.1=compileClasspath org.springframework.boot:spring-boot-autoconfigure:3.4.1=compileClasspath org.springframework.boot:spring-boot-starter-actuator:3.4.1=compileClasspath -org.springframework.boot:spring-boot-starter-data-jpa:3.4.1=compileClasspath org.springframework.boot:spring-boot-starter-data-mongodb:3.4.1=compileClasspath org.springframework.boot:spring-boot-starter-data-redis:3.4.1=compileClasspath -org.springframework.boot:spring-boot-starter-jdbc:3.4.1=compileClasspath org.springframework.boot:spring-boot-starter-json:3.4.1=compileClasspath org.springframework.boot:spring-boot-starter-logging:3.4.1=compileClasspath org.springframework.boot:spring-boot-starter-security:3.4.1=compileClasspath @@ -99,7 +91,6 @@ org.springframework.boot:spring-boot-starter-web:3.4.1=compileClasspath org.springframework.boot:spring-boot-starter:3.4.1=compileClasspath org.springframework.boot:spring-boot:3.4.1=compileClasspath org.springframework.data:spring-data-commons:3.4.1=compileClasspath -org.springframework.data:spring-data-jpa:3.4.1=compileClasspath org.springframework.data:spring-data-keyvalue:3.4.1=compileClasspath org.springframework.data:spring-data-mongodb:4.4.1=compileClasspath org.springframework.data:spring-data-redis:3.4.1=compileClasspath @@ -108,15 +99,12 @@ org.springframework.security:spring-security-core:6.4.2=compileClasspath org.springframework.security:spring-security-crypto:6.4.2=compileClasspath org.springframework.security:spring-security-web:6.4.2=compileClasspath org.springframework:spring-aop:6.2.1=compileClasspath -org.springframework:spring-aspects:6.2.1=compileClasspath org.springframework:spring-beans:6.2.1=compileClasspath org.springframework:spring-context-support:6.2.1=compileClasspath org.springframework:spring-context:6.2.1=compileClasspath org.springframework:spring-core:6.2.1=compileClasspath org.springframework:spring-expression:6.2.1=compileClasspath org.springframework:spring-jcl:6.2.1=compileClasspath -org.springframework:spring-jdbc:6.2.1=compileClasspath -org.springframework:spring-orm:6.2.1=compileClasspath org.springframework:spring-oxm:6.2.1=compileClasspath org.springframework:spring-tx:6.2.1=compileClasspath org.springframework:spring-web:6.2.1=compileClasspath diff --git a/src/main/java/it/gov/pagopa/payhub/auth/mypay/config/MyPayPostgresConfig.java b/src/main/java/it/gov/pagopa/payhub/auth/mypay/config/MyPayPostgresConfig.java deleted file mode 100644 index f1c94f1a..00000000 --- a/src/main/java/it/gov/pagopa/payhub/auth/mypay/config/MyPayPostgresConfig.java +++ /dev/null @@ -1,59 +0,0 @@ -package it.gov.pagopa.payhub.auth.mypay.config; - -import it.gov.pagopa.payhub.auth.utils.Constants; -import jakarta.persistence.EntityManagerFactory; -import javax.sql.DataSource; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.jdbc.DataSourceBuilder; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -@Configuration -@EnableTransactionManagement -@EnableJpaRepositories( - entityManagerFactoryRef = "myPayEntityManagerFactory", - transactionManagerRef = "myPayTransactionManager", - basePackages = {"it.gov.pagopa.payhub.auth.mypay"} -) -public class MyPayPostgresConfig { - - private static final String PERSISTANCE_NAME = "mypay"; - - @Primary - @Bean(name = "myPayDataSource") - @ConfigurationProperties("spring.data.mypay") - public DataSource myPayDataSource() { - return DataSourceBuilder.create().build(); - } - - @Primary - @Bean(name = "myPayEntityManagerFactory") - public LocalContainerEntityManagerFactoryBean myPayEntityManagerFactory( - @Qualifier("myPayDataSource") DataSource dataSource, - EntityManagerFactoryBuilder builder) { - - return builder.dataSource(dataSource) - .packages("it.gov.pagopa.payhub.auth.mypay") - .properties(Constants.jpaProperties()) - .persistenceUnit(PERSISTANCE_NAME) - .build(); - } - - - @Primary - @Bean(name = "myPayTransactionManager") - public PlatformTransactionManager myPayTransactionManager( - @Qualifier("myPayEntityManagerFactory")EntityManagerFactory myPayEntityManagerFactory) { - - return new JpaTransactionManager(myPayEntityManagerFactory); - } - -} diff --git a/src/main/java/it/gov/pagopa/payhub/auth/mypay/model/MyPayUser.java b/src/main/java/it/gov/pagopa/payhub/auth/mypay/model/MyPayUser.java deleted file mode 100644 index f4aeb3ac..00000000 --- a/src/main/java/it/gov/pagopa/payhub/auth/mypay/model/MyPayUser.java +++ /dev/null @@ -1,30 +0,0 @@ -package it.gov.pagopa.payhub.auth.mypay.model; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.SequenceGenerator; -import jakarta.persistence.Table; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.FieldNameConstants; - -@Data -@Entity -@Table(name = "mygov_utente") -@NoArgsConstructor -@AllArgsConstructor -@Builder -@FieldNameConstants -public class MyPayUser { - - @Id - @SequenceGenerator(name = "myPayUserSeq", sequenceName = "mygov_utente_mygov_utente_id_seq", allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "myPayUserSeq") - private Long mygovUtenteId; - private String codFedUserId; - -} diff --git a/src/main/java/it/gov/pagopa/payhub/auth/mypay/repository/MyPayUsersRepository.java b/src/main/java/it/gov/pagopa/payhub/auth/mypay/repository/MyPayUsersRepository.java deleted file mode 100644 index bae26ccb..00000000 --- a/src/main/java/it/gov/pagopa/payhub/auth/mypay/repository/MyPayUsersRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package it.gov.pagopa.payhub.auth.mypay.repository; - -import it.gov.pagopa.payhub.auth.mypay.model.MyPayUser; -import java.util.Optional; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository("myPayUsersRepository") -public interface MyPayUsersRepository extends JpaRepository { - Optional findByCodFedUserId(String userId); -} diff --git a/src/main/java/it/gov/pagopa/payhub/auth/mypay/service/MyPayUsersService.java b/src/main/java/it/gov/pagopa/payhub/auth/mypay/service/MyPayUsersService.java deleted file mode 100644 index 128c6afc..00000000 --- a/src/main/java/it/gov/pagopa/payhub/auth/mypay/service/MyPayUsersService.java +++ /dev/null @@ -1,23 +0,0 @@ -package it.gov.pagopa.payhub.auth.mypay.service; - -import it.gov.pagopa.payhub.auth.mypay.model.MyPayUser; -import it.gov.pagopa.payhub.auth.mypay.repository.MyPayUsersRepository; -import java.util.Optional; -import org.springframework.stereotype.Service; - -@Service -public class MyPayUsersService { - - private final MyPayUsersRepository myPayUsersRepository; - - public MyPayUsersService(MyPayUsersRepository myPayUsersRepository) { - this.myPayUsersRepository = myPayUsersRepository; - } - - public void registerMyPayUser(String mappedExternalUserId) { - Optional existedUser = myPayUsersRepository.findByCodFedUserId(mappedExternalUserId); - existedUser.ifPresentOrElse(myPayUsersRepository::save, () -> myPayUsersRepository.save(MyPayUser.builder() - .codFedUserId(mappedExternalUserId) - .build())); - } -} diff --git a/src/main/java/it/gov/pagopa/payhub/auth/mypivot/config/MyPivotPostgresConfig.java b/src/main/java/it/gov/pagopa/payhub/auth/mypivot/config/MyPivotPostgresConfig.java deleted file mode 100644 index cd7032f5..00000000 --- a/src/main/java/it/gov/pagopa/payhub/auth/mypivot/config/MyPivotPostgresConfig.java +++ /dev/null @@ -1,56 +0,0 @@ -package it.gov.pagopa.payhub.auth.mypivot.config; - -import it.gov.pagopa.payhub.auth.utils.Constants; -import jakarta.persistence.EntityManagerFactory; -import javax.sql.DataSource; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.jdbc.DataSourceBuilder; -import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -@Configuration -@EnableTransactionManagement -@EnableJpaRepositories( - entityManagerFactoryRef = "myPivotEntityManagerFactory", - transactionManagerRef = "myPivotTransactionManager", - basePackages = {"it.gov.pagopa.payhub.auth.mypivot"} -) -public class MyPivotPostgresConfig { - - private static final String PERSISTANCE_NAME = "mypivot"; - - @Bean(name = "myPivotDataSource") - @ConfigurationProperties("spring.data.mypivot") - public DataSource myPivotDataSource() { - return DataSourceBuilder.create().build(); - } - - @Bean(name = "myPivotEntityManagerFactory") - public LocalContainerEntityManagerFactoryBean myPivotEntityManagerFactory( - @Qualifier("myPivotDataSource") DataSource dataSource, - EntityManagerFactoryBuilder builder) { - - return builder.dataSource(dataSource) - .packages("it.gov.pagopa.payhub.auth.mypivot") - .persistenceUnit(PERSISTANCE_NAME) - .properties(Constants.jpaProperties()) - .build(); - } - - @Bean(name = "myPivotTransactionManager") - public PlatformTransactionManager myPivotTransactionManager( - @Qualifier("myPivotEntityManagerFactory")EntityManagerFactory myPivotEntityManagerFactory) { - - return new JpaTransactionManager(myPivotEntityManagerFactory); - } - - - -} diff --git a/src/main/java/it/gov/pagopa/payhub/auth/mypivot/model/MyPivotUser.java b/src/main/java/it/gov/pagopa/payhub/auth/mypivot/model/MyPivotUser.java deleted file mode 100644 index ab03491b..00000000 --- a/src/main/java/it/gov/pagopa/payhub/auth/mypivot/model/MyPivotUser.java +++ /dev/null @@ -1,29 +0,0 @@ -package it.gov.pagopa.payhub.auth.mypivot.model; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.SequenceGenerator; -import jakarta.persistence.Table; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.FieldNameConstants; - -@Data -@Entity -@Table(name = "mygov_utente") -@NoArgsConstructor -@AllArgsConstructor -@Builder -@FieldNameConstants -public class MyPivotUser { - - @Id - @SequenceGenerator(name = "myPivotUserSeq", sequenceName = "mygov_utente_mygov_utente_id_seq", allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "myPivotUserSeq") - private Long mygovUtenteId; - private String codFedUserId; -} diff --git a/src/main/java/it/gov/pagopa/payhub/auth/mypivot/repository/MyPivotUsersRepository.java b/src/main/java/it/gov/pagopa/payhub/auth/mypivot/repository/MyPivotUsersRepository.java deleted file mode 100644 index 9e60ed4a..00000000 --- a/src/main/java/it/gov/pagopa/payhub/auth/mypivot/repository/MyPivotUsersRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package it.gov.pagopa.payhub.auth.mypivot.repository; - -import it.gov.pagopa.payhub.auth.mypivot.model.MyPivotUser; -import java.util.Optional; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository("myPivotUsersRepository") -public interface MyPivotUsersRepository extends JpaRepository { - Optional findByCodFedUserId(String userId); -} diff --git a/src/main/java/it/gov/pagopa/payhub/auth/mypivot/service/MyPivotUsersService.java b/src/main/java/it/gov/pagopa/payhub/auth/mypivot/service/MyPivotUsersService.java deleted file mode 100644 index 410d05f3..00000000 --- a/src/main/java/it/gov/pagopa/payhub/auth/mypivot/service/MyPivotUsersService.java +++ /dev/null @@ -1,24 +0,0 @@ -package it.gov.pagopa.payhub.auth.mypivot.service; - -import it.gov.pagopa.payhub.auth.mypivot.model.MyPivotUser; -import it.gov.pagopa.payhub.auth.mypivot.repository.MyPivotUsersRepository; -import java.util.Optional; -import org.springframework.stereotype.Service; - -@Service -public class MyPivotUsersService { - - private final MyPivotUsersRepository myPivotUsersRepository; - - public MyPivotUsersService(MyPivotUsersRepository myPivotUsersRepository){ - this.myPivotUsersRepository = myPivotUsersRepository; - } - - public void registerMyPivotUser(String mappedExternalUserId) { - Optional existedUser = myPivotUsersRepository.findByCodFedUserId(mappedExternalUserId); - existedUser.ifPresentOrElse(myPivotUsersRepository::save, () -> - myPivotUsersRepository.save(MyPivotUser.builder() - .codFedUserId(mappedExternalUserId) - .build())); - } -} diff --git a/src/main/java/it/gov/pagopa/payhub/auth/service/AuthzServiceImpl.java b/src/main/java/it/gov/pagopa/payhub/auth/service/AuthzServiceImpl.java index 63e17a19..b65d3697 100644 --- a/src/main/java/it/gov/pagopa/payhub/auth/service/AuthzServiceImpl.java +++ b/src/main/java/it/gov/pagopa/payhub/auth/service/AuthzServiceImpl.java @@ -13,7 +13,6 @@ import it.gov.pagopa.payhub.auth.service.user.retrieve.UserDTOMapper; import it.gov.pagopa.payhub.dto.generated.*; import it.gov.pagopa.payhub.dto.generated.UserInfo; -import jakarta.transaction.Transactional; import java.util.HashSet; import java.util.List; import java.util.Objects; @@ -75,7 +74,6 @@ public OperatorDTO getOrganizationOperator(String organizationIpaCode, } @Override - @Transactional public void deleteOrganizationOperator(String organizationIpaCode, String mappedExternalUserId) { operatorsRepository.deleteOrganizationOperator(organizationIpaCode, mappedExternalUserId); } diff --git a/src/main/java/it/gov/pagopa/payhub/auth/service/user/registration/UserRegistrationService.java b/src/main/java/it/gov/pagopa/payhub/auth/service/user/registration/UserRegistrationService.java index d29d4ed5..0878d436 100644 --- a/src/main/java/it/gov/pagopa/payhub/auth/service/user/registration/UserRegistrationService.java +++ b/src/main/java/it/gov/pagopa/payhub/auth/service/user/registration/UserRegistrationService.java @@ -1,8 +1,6 @@ package it.gov.pagopa.payhub.auth.service.user.registration; import it.gov.pagopa.payhub.auth.model.User; -import it.gov.pagopa.payhub.auth.mypay.service.MyPayUsersService; -import it.gov.pagopa.payhub.auth.mypivot.service.MyPivotUsersService; import it.gov.pagopa.payhub.auth.repository.UsersRepository; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -14,29 +12,17 @@ public class UserRegistrationService { private final ExternalUserIdObfuscatorService externalUserIdObfuscatorService; private final FiscalCodeObfuscatorService fiscalCodeObfuscatorService; private final UsersRepository usersRepository; - private final MyPayUsersService myPayUsersService; - private final MyPivotUsersService myPivotUsersService; public UserRegistrationService(ExternalUserIdObfuscatorService externalUserIdObfuscatorService, - FiscalCodeObfuscatorService fiscalCodeObfuscatorService, UsersRepository usersRepository, - MyPayUsersService myPayUsersService, MyPivotUsersService myPivotUsersService) { + FiscalCodeObfuscatorService fiscalCodeObfuscatorService, UsersRepository usersRepository) { this.externalUserIdObfuscatorService = externalUserIdObfuscatorService; this.fiscalCodeObfuscatorService = fiscalCodeObfuscatorService; this.usersRepository = usersRepository; - this.myPayUsersService = myPayUsersService; - this.myPivotUsersService = myPivotUsersService; } public User registerUser(String externalUserId, String fiscalCode, String iamIssuer, String firstName, String lastName){ User user = buildUser(externalUserId, fiscalCode, iamIssuer, firstName, lastName); log.info("Registering user having mappedExternalUserId {}", user.getMappedExternalUserId()); - - myPayUsersService.registerMyPayUser(user.getMappedExternalUserId()); - log.info("Registering user on MyPay having mappedExternalUserId {}", externalUserId); - - myPivotUsersService.registerMyPivotUser(user.getMappedExternalUserId()); - log.info("Registering user on MyPivot having mappedExternalUserId {}", externalUserId); - return usersRepository.registerUser(user); } diff --git a/src/main/java/it/gov/pagopa/payhub/auth/utils/Constants.java b/src/main/java/it/gov/pagopa/payhub/auth/utils/Constants.java index 012c9b55..2b6748f2 100644 --- a/src/main/java/it/gov/pagopa/payhub/auth/utils/Constants.java +++ b/src/main/java/it/gov/pagopa/payhub/auth/utils/Constants.java @@ -1,10 +1,6 @@ package it.gov.pagopa.payhub.auth.utils; import java.time.ZoneId; -import java.util.HashMap; -import java.util.Map; -import org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy; -import org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy; public class Constants { private Constants(){} @@ -13,13 +9,4 @@ private Constants(){} public static final String ROLE_ADMIN = "ROLE_ADMIN"; public static final String ROLE_OPER = "ROLE_OPER"; - - // Multiple datasource introduce an issue that we need to explicity CamelCaseToUnderscore properties - // to each EntityManagerFactory - public static Map jpaProperties() { - Map props = new HashMap<>(); - props.put("hibernate.physical_naming_strategy", CamelCaseToUnderscoresNamingStrategy.class.getName()); - props.put("hibernate.implicit_naming_strategy", SpringImplicitNamingStrategy.class.getName()); - return props; - } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 0570aec9..d1e84e97 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -12,16 +12,6 @@ spring: cache: type: redis data: - mypay: - jdbc-url: "jdbc:postgresql://\${MYPAY_DB_HOST}:5432/mypay" - username: "\${MYPAY_DB_USER}" - password: "\${MYPAY_DB_PASSWORD}" - driverClassName: "org.postgresql.Driver" - mypivot: - jdbc-url: "jdbc:postgresql://\${MYPIVOT_DB_HOST}:5432/mypivot" - username: "\${MYPIVOT_DB_USER}" - password: "\${MYPIVOT_DB_PASSWORD}" - driverClassName: "org.postgresql.Driver" redis: host: "\${REDIS_HOST:localhost}" port: "\${REDIS_PORT:6380}" diff --git a/src/test/java/it/gov/pagopa/payhub/auth/mypay/service/MyPayUsersServiceTest.java b/src/test/java/it/gov/pagopa/payhub/auth/mypay/service/MyPayUsersServiceTest.java deleted file mode 100644 index d42b5e21..00000000 --- a/src/test/java/it/gov/pagopa/payhub/auth/mypay/service/MyPayUsersServiceTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package it.gov.pagopa.payhub.auth.mypay.service; - -import static org.mockito.Mockito.*; - -import it.gov.pagopa.payhub.auth.mypay.model.MyPayUser; -import it.gov.pagopa.payhub.auth.mypay.repository.MyPayUsersRepository; -import java.util.Optional; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.ArgumentMatcher; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.junit.jupiter.MockitoExtension; - - -@ExtendWith(MockitoExtension.class) -class MyPayUsersServiceTest { - - @Mock - private MyPayUsersRepository myPayUsersRepositoryMock; - @InjectMocks - private MyPayUsersService myPayUsersService; - - @Test - void whenRegisterMyPayUserThenVerifyNewUser() { - // Arrange - String externalUserId = "EXTERNALUSERID"; - - Optional existedMyPayUser = Optional.empty(); - - // Mock behavior (no existing user) - Mockito.when(myPayUsersRepositoryMock.findByCodFedUserId(externalUserId)).thenReturn(existedMyPayUser); - - // Act - myPayUsersService.registerMyPayUser(externalUserId); - - //ArgumentMatcher to verify just userId due to lastLogin can be different - ArgumentMatcher userMatcher = new ArgumentMatcher() { - @Override - public boolean matches(MyPayUser user) { - return user.getCodFedUserId().equals(externalUserId); - } - }; - - // Assert - verify(myPayUsersRepositoryMock).save(argThat(userMatcher)); - } -} diff --git a/src/test/java/it/gov/pagopa/payhub/auth/mypivot/service/MyPivotUsersServiceTest.java b/src/test/java/it/gov/pagopa/payhub/auth/mypivot/service/MyPivotUsersServiceTest.java deleted file mode 100644 index dcc0e1b1..00000000 --- a/src/test/java/it/gov/pagopa/payhub/auth/mypivot/service/MyPivotUsersServiceTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package it.gov.pagopa.payhub.auth.mypivot.service; - -import static org.mockito.Mockito.*; - -import it.gov.pagopa.payhub.auth.mypivot.model.MyPivotUser; -import it.gov.pagopa.payhub.auth.mypivot.repository.MyPivotUsersRepository; -import java.util.Optional; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.ArgumentMatcher; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - - -@ExtendWith(MockitoExtension.class) -class MyPivotUsersServiceTest { - - @Mock - private MyPivotUsersRepository myPivotUsersRepositoryMock; - @InjectMocks - private MyPivotUsersService myPivotUsersService; - - @Test - void whenRegisterMyPivotUserThenVerifyNewUser() { - // Arrange - String externalUserId = "EXTERNALUSERID"; - Optional existedMyPivotUser = Optional.empty(); - - // Mock behavior (no existing user) - when(myPivotUsersRepositoryMock.findByCodFedUserId(externalUserId)).thenReturn(existedMyPivotUser); - - // Act - myPivotUsersService.registerMyPivotUser(externalUserId); - - //ArgumentMatcher to verify just userId due to lastLogin can be different - ArgumentMatcher userMatcher = new ArgumentMatcher() { - @Override - public boolean matches(MyPivotUser user) { - return user.getCodFedUserId().equals(externalUserId); - } - }; - - // Assert - verify(myPivotUsersRepositoryMock).save(argThat(userMatcher)); - } -} diff --git a/src/test/java/it/gov/pagopa/payhub/auth/service/user/registration/UserRegistrationServiceTest.java b/src/test/java/it/gov/pagopa/payhub/auth/service/user/registration/UserRegistrationServiceTest.java index 8222eeb2..e3505fdd 100644 --- a/src/test/java/it/gov/pagopa/payhub/auth/service/user/registration/UserRegistrationServiceTest.java +++ b/src/test/java/it/gov/pagopa/payhub/auth/service/user/registration/UserRegistrationServiceTest.java @@ -1,8 +1,6 @@ package it.gov.pagopa.payhub.auth.service.user.registration; import it.gov.pagopa.payhub.auth.model.User; -import it.gov.pagopa.payhub.auth.mypay.service.MyPayUsersService; -import it.gov.pagopa.payhub.auth.mypivot.service.MyPivotUsersService; import it.gov.pagopa.payhub.auth.repository.UsersRepository; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; @@ -22,10 +20,6 @@ class UserRegistrationServiceTest { private FiscalCodeObfuscatorService fiscalCodeObfuscatorServiceMock; @Mock private UsersRepository usersRepositoryMock; - @Mock - private MyPayUsersService myPayUsersServiceMock; - @Mock - private MyPivotUsersService myPivotUsersServiceMock; private UserRegistrationService service; @@ -34,9 +28,7 @@ void init(){ service = new UserRegistrationService( externalUserIdObfuscatorServiceMock, fiscalCodeObfuscatorServiceMock, - usersRepositoryMock, - myPayUsersServiceMock, - myPivotUsersServiceMock); + usersRepositoryMock); } @AfterEach