-
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.
P4ADEV-791-P4PA-AUTH-API-censimento-client-id new refactoring accordi…
…ng to requested changes
- Loading branch information
Showing
14 changed files
with
86 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,4 @@ | |
|
||
public interface ClientRepository extends MongoRepository<Client, String> { | ||
|
||
Client insert(Client client); | ||
} |
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
3 changes: 2 additions & 1 deletion
3
src/main/java/it/gov/pagopa/payhub/auth/service/a2a/ClientService.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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
package it.gov.pagopa.payhub.auth.service.a2a; | ||
|
||
import it.gov.pagopa.payhub.auth.model.Client; | ||
import it.gov.pagopa.payhub.model.generated.ClientDTO; | ||
|
||
public interface ClientService { | ||
|
||
Client registerClient(String clientId, String organizationIpaCode); | ||
ClientDTO registerClient(String clientId, String organizationIpaCode); | ||
} |
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
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
57 changes: 57 additions & 0 deletions
57
src/test/java/it/gov/pagopa/payhub/auth/service/a2a/ClientServiceTest.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,57 @@ | ||
package it.gov.pagopa.payhub.auth.service.a2a; | ||
|
||
import it.gov.pagopa.payhub.auth.model.Client; | ||
import it.gov.pagopa.payhub.auth.service.a2a.registration.ClientRegistrationService; | ||
import it.gov.pagopa.payhub.auth.service.a2a.retreive.ClientMapper; | ||
import it.gov.pagopa.payhub.model.generated.ClientDTO; | ||
import it.gov.pagopa.payhub.model.generated.CreateClientRequest; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class ClientServiceTest { | ||
|
||
@Mock | ||
private ClientRegistrationService clientRegistrationServiceMock; | ||
|
||
@Mock | ||
private ClientMapper clientMapper; | ||
|
||
private ClientService service; | ||
|
||
@BeforeEach | ||
void init(){ | ||
service = new ClientServiceImpl(clientRegistrationServiceMock, clientMapper); | ||
} | ||
|
||
@AfterEach | ||
void verifyNotMoreInteractions(){ | ||
Mockito.verifyNoMoreInteractions( | ||
clientRegistrationServiceMock, | ||
clientMapper | ||
); | ||
} | ||
|
||
@Test | ||
void whenCreateClientThenVerifyClient() { | ||
String organizationIpaCode = "organizationIpaCode"; | ||
String clientId = "clientId"; | ||
|
||
Client mockClient = new Client(); | ||
ClientDTO expectedClientDTO = new ClientDTO(); | ||
|
||
Mockito.when(clientRegistrationServiceMock.registerClient(clientId, organizationIpaCode)).thenReturn(mockClient); | ||
|
||
Mockito.when(clientMapper.mapToDTO(mockClient)).thenReturn(expectedClientDTO); | ||
|
||
ClientDTO actualClientDTO = service.registerClient(clientId, organizationIpaCode); | ||
|
||
Assertions.assertEquals(expectedClientDTO, actualClientDTO); | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
...ration/ClientRegistrationServiceTest.java → ...ration/ClientRegistrationServiceTest.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
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