Repository: pagopa/p4pa-payhub-activities
Pull request #289: feat: P4ADEV-2995 activity interface and support classes
Author: login: domenicogi
Labels: name: released
Created: 2025-05-22T21:24:28Z | Merged: 2025-05-23T08:37:59Z

#### Description
<!--- Please always add a PR description as if nobody knows anything about the context these changes come from. -->
<!--- Even if we are all from our internal team, we may not be on the same page. -->
<!--- Write this PR as you were contributing to a public OSS project, where nobody knows you and you have to earn their trust. -->
<!--- This will improve our projects in the long run! Thanks. -->

#### List of Changes
<!--- Describe your changes in detail -->

#### Motivation and Context
<!--- Why is this change required? What problem does it solve? -->

#### How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, tests ran to see how -->
<!--- your change affects other areas of the code, etc. -->
- Pre-Deploy Test
    - [x] Unit
    - [ ] Integration (Narrow)
- Post-Deploy Test
    - [ ] Isolated Microservice
    - [ ] Broader Integration
    - [ ] Acceptance
    - [ ] Performance & Load

#### Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] PATCH - Bug fix (backwards compatible bug fixes)
- [X] MINOR - New feature (add functionality in a backwards compatible manner)
- [ ] MAJOR - Breaking change (fix or feature that would cause existing functionality to not work as expected)

#### Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.



Diff:
diff --git a/src/main/java/it/gov/pagopa/payhub/activities/activity/ingestionflow/debtpositiontype/DebtPositionTypeIngestionActivity.java b/src/main/java/it/gov/pagopa/payhub/activities/activity/ingestionflow/debtpositiontype/DebtPositionTypeIngestionActivity.java
new file mode 100644
index 000000000..32f526773
--- /dev/null
+++ b/src/main/java/it/gov/pagopa/payhub/activities/activity/ingestionflow/debtpositiontype/DebtPositionTypeIngestionActivity.java
@@ -0,0 +1,25 @@
+package it.gov.pagopa.payhub.activities.activity.ingestionflow.debtpositiontype;
+
+import io.temporal.activity.ActivityInterface;
+import io.temporal.activity.ActivityMethod;
+import it.gov.pagopa.payhub.activities.dto.ingestion.debtpositiontype.DebtPositionTypeIngestionFlowFileResult;
+
+/**
+ * Interface for importing debt position type.
+ * Defines methods for processing debt position type import files and individual debt position type.
+ */
+
+@ActivityInterface
+public interface DebtPositionTypeIngestionActivity {
+
+
+  /**
+   * Processes a debt position type import file based on the provided IngestionFlowFile ID.
+   *
+   * @param ingestionFlowFileId the unique identifier of the file to process.
+   * @return {@link DebtPositionTypeIngestionFlowFileResult} containing the list of ipa code.
+   */
+  @ActivityMethod
+  DebtPositionTypeIngestionFlowFileResult processFile(Long ingestionFlowFileId);
+
+}
diff --git a/src/main/java/it/gov/pagopa/payhub/activities/connector/debtposition/DebtPositionTypeService.java b/src/main/java/it/gov/pagopa/payhub/activities/connector/debtposition/DebtPositionTypeService.java
new file mode 100644
index 000000000..fb11559d5
--- /dev/null
+++ b/src/main/java/it/gov/pagopa/payhub/activities/connector/debtposition/DebtPositionTypeService.java
@@ -0,0 +1,18 @@
+package it.gov.pagopa.payhub.activities.connector.debtposition;
+
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionType;
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionTypeRequestBody;
+
+/**
+ * This interface provides methods that manage debt positions type within the related microservice.
+ */
+public interface DebtPositionTypeService {
+    /**
+     * Creates a new debt position type using the provided request body.
+     *
+     * @param debtPositionTypeRequestBody the request body containing the details of the debt position type to create
+     * @return the created DebtPositionType
+     */
+    DebtPositionType createDebtPositionType(DebtPositionTypeRequestBody debtPositionTypeRequestBody);
+
+}
diff --git a/src/main/java/it/gov/pagopa/payhub/activities/connector/debtposition/DebtPositionTypeServiceImpl.java b/src/main/java/it/gov/pagopa/payhub/activities/connector/debtposition/DebtPositionTypeServiceImpl.java
new file mode 100644
index 000000000..b1de34d01
--- /dev/null
+++ b/src/main/java/it/gov/pagopa/payhub/activities/connector/debtposition/DebtPositionTypeServiceImpl.java
@@ -0,0 +1,32 @@
+package it.gov.pagopa.payhub.activities.connector.debtposition;
+
+import it.gov.pagopa.payhub.activities.connector.auth.AuthnService;
+import it.gov.pagopa.payhub.activities.connector.debtposition.client.DebtPositionTypeClient;
+import it.gov.pagopa.payhub.activities.connector.debtposition.client.DebtPositionTypeOrgClient;
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionType;
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionTypeRequestBody;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+
+@Lazy
+@Service
+@Slf4j
+public class DebtPositionTypeServiceImpl implements DebtPositionTypeService {
+
+    private final AuthnService authnService;
+    private final DebtPositionTypeClient debtPositionTypeClient;
+
+    public DebtPositionTypeServiceImpl(AuthnService authnService, DebtPositionTypeClient debtPositionTypeClient) {
+        this.authnService = authnService;
+        this.debtPositionTypeClient = debtPositionTypeClient;
+    }
+
+
+    @Override
+    public DebtPositionType createDebtPositionType(DebtPositionTypeRequestBody debtPositionTypeRequestBody) {
+        log.debug("Creating a new DebtPositionType with brokerId: {}, code: {} and description: {}",debtPositionTypeRequestBody.getBrokerId(),
+                debtPositionTypeRequestBody.getCode(),debtPositionTypeRequestBody.getDescription());
+        return debtPositionTypeClient.createDebtPositionType(debtPositionTypeRequestBody, authnService.getAccessToken());
+    }
+}
diff --git a/src/main/java/it/gov/pagopa/payhub/activities/connector/debtposition/client/DebtPositionTypeClient.java b/src/main/java/it/gov/pagopa/payhub/activities/connector/debtposition/client/DebtPositionTypeClient.java
new file mode 100644
index 000000000..0d2f752cd
--- /dev/null
+++ b/src/main/java/it/gov/pagopa/payhub/activities/connector/debtposition/client/DebtPositionTypeClient.java
@@ -0,0 +1,27 @@
+package it.gov.pagopa.payhub.activities.connector.debtposition.client;
+
+import it.gov.pagopa.payhub.activities.connector.debtposition.config.DebtPositionApisHolder;
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionType;
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionTypeRequestBody;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+
+@Lazy
+@Service
+@Slf4j
+public class DebtPositionTypeClient {
+
+    private final DebtPositionApisHolder debtPositionApisHolder;
+
+    public DebtPositionTypeClient(DebtPositionApisHolder debtPositionApisHolder) {
+        this.debtPositionApisHolder = debtPositionApisHolder;
+    }
+
+    public DebtPositionType createDebtPositionType(
+        DebtPositionTypeRequestBody debtPositionTypeRequestBody, String accessToken) {
+            return debtPositionApisHolder.getDebtPositionTypeEntityControllerApi(accessToken)
+                    .crudCreateDebtpositiontype(debtPositionTypeRequestBody);
+    }
+
+}
diff --git a/src/main/java/it/gov/pagopa/payhub/activities/connector/debtposition/config/DebtPositionApisHolder.java b/src/main/java/it/gov/pagopa/payhub/activities/connector/debtposition/config/DebtPositionApisHolder.java
index 163b672d8..db583c2b6 100644
--- a/src/main/java/it/gov/pagopa/payhub/activities/connector/debtposition/config/DebtPositionApisHolder.java
+++ b/src/main/java/it/gov/pagopa/payhub/activities/connector/debtposition/config/DebtPositionApisHolder.java
@@ -28,6 +28,7 @@ public class DebtPositionApisHolder {
     private final InstallmentNoPiiSearchControllerApi installmentNoPiiSearchControllerApi;
     private final InstallmentsEntityExtendedControllerApi installmentsEntityExtendedControllerApi;
     private final PaymentOptionEntityExtendedControllerApi paymentOptionEntityExtendedControllerApi;
+    private final DebtPositionTypeEntityControllerApi debtPositionTypeEntityControllerApi;
 
     /** it will store the actual accessToken and mappedExternalUserId */
     private final ThreadLocal<Pair<String, String>> authContextHolder = new ThreadLocal<>();
@@ -62,6 +63,7 @@ public DebtPositionApisHolder(
         this.installmentNoPiiSearchControllerApi = new InstallmentNoPiiSearchControllerApi(apiClient);
         this.installmentsEntityExtendedControllerApi = new InstallmentsEntityExtendedControllerApi(apiClient);
         this.paymentOptionEntityExtendedControllerApi = new PaymentOptionEntityExtendedControllerApi(apiClient);
+        this.debtPositionTypeEntityControllerApi = new DebtPositionTypeEntityControllerApi(apiClient);
     }
 
     @PreDestroy
@@ -133,6 +135,10 @@ public PaymentOptionEntityExtendedControllerApi getPaymentOptionEntityExtendedCo
         return getApi(accessToken, null, paymentOptionEntityExtendedControllerApi);
     }
 
+    public DebtPositionTypeEntityControllerApi getDebtPositionTypeEntityControllerApi(String accessToken) {
+        return getApi(accessToken, null, debtPositionTypeEntityControllerApi);
+    }
+
     private <T extends BaseApi> T getApi(String accessToken, String mappedExternalUserId, T api) {
         authContextHolder.set(Pair.of(accessToken, mappedExternalUserId));
         return api;
diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/ingestion/debtpositiontype/DebtPositionTypeErrorDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/ingestion/debtpositiontype/DebtPositionTypeErrorDTO.java
new file mode 100644
index 000000000..f156bd3e1
--- /dev/null
+++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/ingestion/debtpositiontype/DebtPositionTypeErrorDTO.java
@@ -0,0 +1,38 @@
+package it.gov.pagopa.payhub.activities.dto.ingestion.debtpositiontype;
+
+import it.gov.pagopa.payhub.activities.dto.ErrorFileDTO;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import lombok.experimental.SuperBuilder;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+@SuperBuilder
+@AllArgsConstructor
+@NoArgsConstructor
+@ToString(callSuper = true)
+public class DebtPositionTypeErrorDTO extends ErrorFileDTO {
+
+    private String debtPositionTypeCode;
+    private String brokerCf;
+    private Long rowNumber;
+
+    public DebtPositionTypeErrorDTO(String fileName, String debtPositionTypeCode, String brokerCf, Long rowNumber, String errorCode, String errorMessage) {
+        super(fileName, errorCode, errorMessage);
+        this.debtPositionTypeCode = debtPositionTypeCode;
+        this.brokerCf = brokerCf;
+        this.rowNumber = rowNumber;
+    }
+
+    @Override
+    public String[] toCsvRow() {
+        return new String[]{
+                getFileName(), debtPositionTypeCode,
+                brokerCf,rowNumber.toString(),
+                getErrorCode(), getErrorMessage()
+        };
+    }
+}
diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/ingestion/debtpositiontype/DebtPositionTypeIngestionFlowFileDTO.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/ingestion/debtpositiontype/DebtPositionTypeIngestionFlowFileDTO.java
new file mode 100644
index 000000000..ef0ca4158
--- /dev/null
+++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/ingestion/debtpositiontype/DebtPositionTypeIngestionFlowFileDTO.java
@@ -0,0 +1,56 @@
+package it.gov.pagopa.payhub.activities.dto.ingestion.debtpositiontype;
+
+import com.opencsv.bean.CsvBindByName;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+
+public class DebtPositionTypeIngestionFlowFileDTO {
+
+    @CsvBindByName(column = "broker_cf", required = true)
+    private String brokerCf;
+
+    @CsvBindByName(column = "debt_position_type_code", required = true)
+    private String debtPositionTypeCode;
+
+    @CsvBindByName(column = "description", required = true)
+    private String description;
+
+    @CsvBindByName(column = "org_type", required = true)
+    private String orgType;
+
+    @CsvBindByName(column = "macro_area", required = true)
+    private String macroArea;
+
+    @CsvBindByName(column = "service_type", required = true)
+    private String serviceType;
+
+    @CsvBindByName(column = "collecting_reason", required = true)
+    private String collectingReason;
+
+    @CsvBindByName(column = "taxonomy_code", required = true)
+    private String taxonomyCode;
+
+    @CsvBindByName(column = "flag_anonymous_fiscal_code", required = true)
+    private Boolean flagAnonymousFiscalCode;
+
+    @CsvBindByName(column = "flag_mandatory_due_date", required = true)
+    private Boolean flagMandatoryDueDate;
+
+    @CsvBindByName(column = "flag_notify_io", required = true)
+    private Boolean flagNotifyIo;
+
+    @CsvBindByName(column = "io_template_message")
+    private String ioTemplateMessage;
+
+    @CsvBindByName(column = "io_template_subject", required = true)
+    private String ioTemplateSubject;
+
+}
+
diff --git a/src/main/java/it/gov/pagopa/payhub/activities/dto/ingestion/debtpositiontype/DebtPositionTypeIngestionFlowFileResult.java b/src/main/java/it/gov/pagopa/payhub/activities/dto/ingestion/debtpositiontype/DebtPositionTypeIngestionFlowFileResult.java
new file mode 100644
index 000000000..345215b24
--- /dev/null
+++ b/src/main/java/it/gov/pagopa/payhub/activities/dto/ingestion/debtpositiontype/DebtPositionTypeIngestionFlowFileResult.java
@@ -0,0 +1,22 @@
+package it.gov.pagopa.payhub.activities.dto.ingestion.debtpositiontype;
+
+import it.gov.pagopa.payhub.activities.dto.ingestion.IngestionFlowFileResult;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import lombok.experimental.SuperBuilder;
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@SuperBuilder
+@ToString(callSuper = true)
+public class DebtPositionTypeIngestionFlowFileResult extends IngestionFlowFileResult {
+  private List<String> debtPositionTypeCodeList;
+  private String brokerFiscalCode;
+  private Long brokerId;
+}
diff --git a/src/main/java/it/gov/pagopa/payhub/activities/mapper/ingestionflow/debtpositiontype/DebtPositionTypeMapper.java b/src/main/java/it/gov/pagopa/payhub/activities/mapper/ingestionflow/debtpositiontype/DebtPositionTypeMapper.java
new file mode 100644
index 000000000..7a7e4fd3e
--- /dev/null
+++ b/src/main/java/it/gov/pagopa/payhub/activities/mapper/ingestionflow/debtpositiontype/DebtPositionTypeMapper.java
@@ -0,0 +1,29 @@
+package it.gov.pagopa.payhub.activities.mapper.ingestionflow.debtpositiontype;
+
+import it.gov.pagopa.payhub.activities.dto.ingestion.debtpositiontype.DebtPositionTypeIngestionFlowFileDTO;
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionTypeRequestBody;
+import org.springframework.stereotype.Service;
+
+@Service
+public class DebtPositionTypeMapper {
+
+  public DebtPositionTypeRequestBody map(DebtPositionTypeIngestionFlowFileDTO dto,Long brokerId) {
+
+    return DebtPositionTypeRequestBody.builder()
+        .brokerId(brokerId)
+        .code(dto.getDebtPositionTypeCode())
+        .description(dto.getDescription())
+        .orgType(dto.getOrgType())
+        .macroArea(dto.getMacroArea())
+        .serviceType(dto.getServiceType())
+        .collectingReason(dto.getCollectingReason())
+        .taxonomyCode(dto.getTaxonomyCode())
+        .flagAnonymousFiscalCode(dto.getFlagAnonymousFiscalCode())
+        .flagMandatoryDueDate(dto.getFlagMandatoryDueDate())
+        .flagNotifyIo(dto.getFlagNotifyIo())
+        .ioTemplateMessage(dto.getIoTemplateMessage())
+        .ioTemplateSubject(dto.getIoTemplateSubject())
+        .build();
+  }
+}
+
diff --git a/src/test/java/it/gov/pagopa/payhub/activities/connector/debtposition/DebtPositionTypeServiceTest.java b/src/test/java/it/gov/pagopa/payhub/activities/connector/debtposition/DebtPositionTypeServiceTest.java
new file mode 100644
index 000000000..6e8996885
--- /dev/null
+++ b/src/test/java/it/gov/pagopa/payhub/activities/connector/debtposition/DebtPositionTypeServiceTest.java
@@ -0,0 +1,63 @@
+package it.gov.pagopa.payhub.activities.connector.debtposition;
+
+import it.gov.pagopa.payhub.activities.connector.auth.AuthnService;
+import it.gov.pagopa.payhub.activities.connector.debtposition.client.DebtPositionTypeClient;
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionType;
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionTypeRequestBody;
+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)
+class DebtPositionTypeServiceTest {
+
+  @Mock
+  private AuthnService authnServiceMock;
+  @Mock
+  private DebtPositionTypeClient debtPositionTypeClientMock;
+
+  private DebtPositionTypeService service;
+
+  private final String accessToken = "ACCESSTOKEN";
+
+  @BeforeEach
+  void init() {
+    service = new DebtPositionTypeServiceImpl(
+        authnServiceMock,
+        debtPositionTypeClientMock
+    );
+
+    Mockito.when(authnServiceMock.getAccessToken())
+        .thenReturn(accessToken);
+  }
+
+  @AfterEach
+  void verifyNoMoreInteractions() {
+    Mockito.verifyNoMoreInteractions(
+        authnServiceMock,
+        debtPositionTypeClientMock
+    );
+  }
+
+
+  @Test
+  void givenDebtPositionTypeRequestBodyWhenCreateDebtPositionTypeThenReturnDebtPositionTypeType() {
+    // Given
+    DebtPositionTypeRequestBody requestBody = new DebtPositionTypeRequestBody();
+    DebtPositionType expectedDebtPositionType = new DebtPositionType();
+    Mockito.when(debtPositionTypeClientMock.createDebtPositionType(requestBody, accessToken))
+        .thenReturn(expectedDebtPositionType);
+
+    // When
+    DebtPositionType result = service.createDebtPositionType(requestBody);
+
+    // Then
+    Assertions.assertSame(expectedDebtPositionType, result);
+  }
+
+}
diff --git a/src/test/java/it/gov/pagopa/payhub/activities/connector/debtposition/client/DebtPositionTypeClientTest.java b/src/test/java/it/gov/pagopa/payhub/activities/connector/debtposition/client/DebtPositionTypeClientTest.java
new file mode 100644
index 000000000..908c3fa41
--- /dev/null
+++ b/src/test/java/it/gov/pagopa/payhub/activities/connector/debtposition/client/DebtPositionTypeClientTest.java
@@ -0,0 +1,58 @@
+package it.gov.pagopa.payhub.activities.connector.debtposition.client;
+
+import it.gov.pagopa.payhub.activities.connector.debtposition.config.DebtPositionApisHolder;
+import it.gov.pagopa.pu.debtposition.client.generated.DebtPositionTypeEntityControllerApi;
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionType;
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionTypeRequestBody;
+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)
+class DebtPositionTypeClientTest {
+
+    @Mock
+    private DebtPositionApisHolder debtPositionApisHolderMock;
+    @Mock
+    private DebtPositionTypeEntityControllerApi debtPositionTypeEntityControllerApiMock;
+
+    private DebtPositionTypeClient client;
+
+    @BeforeEach
+    void setUp() {
+        client = new DebtPositionTypeClient(debtPositionApisHolderMock);
+    }
+
+    @AfterEach
+    void verifyNoMoreInteractions(){
+        Mockito.verifyNoMoreInteractions(
+                debtPositionApisHolderMock
+        );
+    }
+
+    @Test
+    void testCreateDebtPositionType() {
+        // Given
+        String accessToken = "accessToken";
+        DebtPositionType expectedDebtPositionType = new DebtPositionType();
+        DebtPositionTypeRequestBody requestBody = new DebtPositionTypeRequestBody();
+
+        Mockito.when(debtPositionApisHolderMock.getDebtPositionTypeEntityControllerApi(accessToken))
+            .thenReturn(debtPositionTypeEntityControllerApiMock);
+        Mockito.when(debtPositionTypeEntityControllerApiMock.crudCreateDebtpositiontype(requestBody))
+            .thenReturn(expectedDebtPositionType);
+
+        // When
+        DebtPositionType result = client.createDebtPositionType(requestBody, accessToken);
+
+        // Then
+        Assertions.assertSame(expectedDebtPositionType, result);
+    }
+
+
+}
diff --git a/src/test/java/it/gov/pagopa/payhub/activities/connector/debtposition/config/DebtPositionApisHolderTest.java b/src/test/java/it/gov/pagopa/payhub/activities/connector/debtposition/config/DebtPositionApisHolderTest.java
index 037b42048..032d0186a 100644
--- a/src/test/java/it/gov/pagopa/payhub/activities/connector/debtposition/config/DebtPositionApisHolderTest.java
+++ b/src/test/java/it/gov/pagopa/payhub/activities/connector/debtposition/config/DebtPositionApisHolderTest.java
@@ -206,4 +206,13 @@ void whenGetInstallmentApiThenAuthenticationShouldBeSetInThreadSafeMode() throws
                 new ParameterizedTypeReference<>() {},
                 debtPositionApisHolder::unload);
     }
+
+    @Test
+    void whenGetDebtPositionTypeEntityControllerApiThenAuthenticationShouldBeSetInThreadSafeMode() throws InterruptedException {
+        assertAuthenticationShouldBeSetInThreadSafeMode(
+            accessToken -> debtPositionApisHolder.getDebtPositionTypeEntityControllerApi(accessToken)
+                .crudCreateDebtpositiontype(new DebtPositionTypeRequestBody()),
+            new ParameterizedTypeReference<>() {},
+            debtPositionApisHolder::unload);
+    }
 }
diff --git a/src/test/java/it/gov/pagopa/payhub/activities/mapper/ingestionflow/debtpositiontype/DebtPositionTypeMapperTest.java b/src/test/java/it/gov/pagopa/payhub/activities/mapper/ingestionflow/debtpositiontype/DebtPositionTypeMapperTest.java
new file mode 100644
index 000000000..924f6f9dd
--- /dev/null
+++ b/src/test/java/it/gov/pagopa/payhub/activities/mapper/ingestionflow/debtpositiontype/DebtPositionTypeMapperTest.java
@@ -0,0 +1,36 @@
+package it.gov.pagopa.payhub.activities.mapper.ingestionflow.debtpositiontype;
+
+import static it.gov.pagopa.payhub.activities.util.TestUtils.checkNotNullFields;
+
+import it.gov.pagopa.payhub.activities.dto.ingestion.debtpositiontype.DebtPositionTypeIngestionFlowFileDTO;
+import it.gov.pagopa.payhub.activities.util.TestUtils;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.junit.jupiter.MockitoExtension;
+import uk.co.jemos.podam.api.PodamFactory;
+
+@ExtendWith(MockitoExtension.class)
+class DebtPositionTypeMapperTest {
+
+  @InjectMocks
+  private DebtPositionTypeMapper debtPositionTypeMapper;
+
+  private final PodamFactory podamFactory = TestUtils.getPodamFactory();
+
+
+  @Test
+  void givenDebtPositionTypeIngestionFlowFileWithPodamFactoryWhenMapThenOk() {
+    DebtPositionTypeIngestionFlowFileDTO dto = podamFactory.manufacturePojo(
+        DebtPositionTypeIngestionFlowFileDTO.class);
+    Long brokerId = 123L;
+
+    var result = debtPositionTypeMapper.map(dto, brokerId);
+
+    Assertions.assertNotNull(result);
+    checkNotNullFields(result, "creationDate", "updateDate", "updateOperatorExternalId",
+        "updateTraceId", "debtPositionTypeId");
+  }
+
+}
\ No newline at end of file
diff --git a/version b/version
index 098a4229b..e728a2868 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-1.114.3
+1.114.3-SNAPSHOT


Reviews:
user: login: antonioT90
state: CHANGES_REQUESTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-23T07:25:52Z
user: login: antonioT90
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-05-23T08:28:16Z

Review comments:
diff_hunk: @@ -0,0 +1,31 @@
+package it.gov.pagopa.payhub.activities.connector.debtposition;
+
+import it.gov.pagopa.payhub.activities.connector.auth.AuthnService;
+import it.gov.pagopa.payhub.activities.connector.debtposition.client.DebtPositionTypeClient;
+import it.gov.pagopa.payhub.activities.connector.debtposition.client.DebtPositionTypeOrgClient;
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionType;
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionTypeRequestBody;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+
+@Lazy
+@Service
+@Slf4j
+public class DebtPositionTypeServiceImpl implements DebtPositionTypeService {
+
+    private final AuthnService authnService;
+    private final DebtPositionTypeClient debtPositionTypeClient;
+
+    public DebtPositionTypeServiceImpl(AuthnService authnService, DebtPositionTypeClient debtPositionTypeClient) {
+        this.authnService = authnService;
+        this.debtPositionTypeClient = debtPositionTypeClient;
+    }
+
+
+    @Override
+    public DebtPositionType createDebtPositionType(DebtPositionTypeRequestBody debtPositionTypeRequestBody) {
+        log.info("Creating a new DebtPositionType");
path: src/main/java/it/gov/pagopa/payhub/activities/connector/debtposition/DebtPositionTypeServiceImpl.java
user: login: antonioT90
body: we have already the REST INVOKE log, let's set this debug level
```suggestion
        log.debug("Creating a new DebtPositionType");
```
created_at: 2025-05-23T07:21:42Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,31 @@
+package it.gov.pagopa.payhub.activities.connector.debtposition;
+
+import it.gov.pagopa.payhub.activities.connector.auth.AuthnService;
+import it.gov.pagopa.payhub.activities.connector.debtposition.client.DebtPositionTypeClient;
+import it.gov.pagopa.payhub.activities.connector.debtposition.client.DebtPositionTypeOrgClient;
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionType;
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionTypeRequestBody;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.stereotype.Service;
+
+@Lazy
+@Service
+@Slf4j
+public class DebtPositionTypeServiceImpl implements DebtPositionTypeService {
+
+    private final AuthnService authnService;
+    private final DebtPositionTypeClient debtPositionTypeClient;
+
+    public DebtPositionTypeServiceImpl(AuthnService authnService, DebtPositionTypeClient debtPositionTypeClient) {
+        this.authnService = authnService;
+        this.debtPositionTypeClient = debtPositionTypeClient;
+    }
+
+
+    @Override
+    public DebtPositionType createDebtPositionType(DebtPositionTypeRequestBody debtPositionTypeRequestBody) {
+        log.info("Creating a new DebtPositionType");
path: src/main/java/it/gov/pagopa/payhub/activities/connector/debtposition/DebtPositionTypeServiceImpl.java
user: login: antonioT90
body: let's also some contextual information, eg the broker and the code... otherwise this log should be pretty useless
created_at: 2025-05-23T07:22:23Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,29 @@
+package it.gov.pagopa.payhub.activities.mapper.ingestionflow.debtpositiontype;
+
+import it.gov.pagopa.payhub.activities.dto.ingestion.debtpositiontype.DebtPositionTypeIngestionFlowFileDTO;
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionTypeRequestBody;
+import org.springframework.stereotype.Service;
+
+@Service
+public class DebtPositionTypeMapper {
+
+  public DebtPositionTypeRequestBody map(DebtPositionTypeIngestionFlowFileDTO dto,Long brokerId) {
+
+    return DebtPositionTypeRequestBody.builder()
+        .brokerId(brokerId)
+        .code(dto.getDebtPositionTypeCode())//todo corretto?
path: src/main/java/it/gov/pagopa/payhub/activities/mapper/ingestionflow/debtpositiontype/DebtPositionTypeMapper.java
user: login: antonioT90
body: let's resolve this TODO before to merge
created_at: 2025-05-23T07:23:51Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,64 @@
+package it.gov.pagopa.payhub.activities.connector.debtposition;
+
+import it.gov.pagopa.payhub.activities.connector.auth.AuthnService;
+import it.gov.pagopa.payhub.activities.connector.debtposition.client.DebtPositionTypeClient;
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionType;
+import it.gov.pagopa.pu.debtposition.dto.generated.DebtPositionTypeRequestBody;
+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)
+class DebtPositionTypeServiceTest {
+
+  @Mock
+  private AuthnService authnServiceMock;
+  @Mock
+  private DebtPositionTypeClient debtPositionTypeClientMock;
+
+  private DebtPositionTypeService service;
+
+  private final String accessToken = "ACCESSTOKEN";
+
+  @BeforeEach
+  void init() {
+    service = new DebtPositionTypeServiceImpl(
+        authnServiceMock,
+        debtPositionTypeClientMock
+    );
+
+    Mockito.when(authnServiceMock.getAccessToken())
+        .thenReturn(accessToken);
+  }
+
+  @AfterEach
+  void verifyNoMoreInteractions() {
+    Mockito.verifyNoMoreInteractions(
+        authnServiceMock,
+        debtPositionTypeClientMock
+    );
+  }
+
+
+  @Test
+  void givenDebtPositionTypeRequestBodyWhenCreateDebtPositionTypeThenReturnDebtPositionTypeType() {
+    // Given
+    DebtPositionTypeRequestBody requestBody = new DebtPositionTypeRequestBody();
+    DebtPositionType expectedDebtPositionType = new DebtPositionType();
+    Mockito.when(debtPositionTypeClientMock.createDebtPositionType(requestBody, accessToken))
+        .thenReturn(expectedDebtPositionType);
+
+    // When
+    DebtPositionType result = service.createDebtPositionType(requestBody);
+
+    // Then
+    Assertions.assertSame(expectedDebtPositionType, result);
+    Mockito.verify(debtPositionTypeClientMock).createDebtPositionType(requestBody, accessToken);
path: src/test/java/it/gov/pagopa/payhub/activities/connector/debtposition/DebtPositionTypeServiceTest.java
user: login: antonioT90
body: This verify is already covered by the when condition
created_at: 2025-05-23T07:24:27Z
author_association: CONTRIBUTOR

PR comments:
user: login: sonarqubecloud[bot]
created_at: 2025-05-23T08:09:31Z
body: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=pagopa_p4pa-payhub-activities&pullRequest=289) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=pagopa_p4pa-payhub-activities&pullRequest=289&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=pagopa_p4pa-payhub-activities&pullRequest=289&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=pagopa_p4pa-payhub-activities&pullRequest=289&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=pagopa_p4pa-payhub-activities&pullRequest=289&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=pagopa_p4pa-payhub-activities&pullRequest=289&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=pagopa_p4pa-payhub-activities&pullRequest=289)


author_association: NONE
user: login: github-actions[bot]
created_at: 2025-05-23T08:38:27Z
body: :tada: This PR is included in version 1.115.0 :tada:

The release is available on [GitHub release](https://github.com/pagopa/p4pa-payhub-activities/releases/tag/v1.115.0)

Your **[semantic-release](https://github.com/semantic-release/semantic-release)** bot :package::rocket:
author_association: CONTRIBUTOR