Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: P4ADEV-1639 wf iuv classification activity implementation classify iuv activity retrieve iuv #61

Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
74cc711
P4ADEV-1635 added implementation
macacia Dec 19, 2024
74e4112
P4ADEV-1635 added unit test
macacia Dec 19, 2024
74f51f9
P4ADEV-1635 refactor activity
macacia Dec 20, 2024
22974ee
Merge branch 'main' into P4ADEV-1635-WF-IUV-Classification-implementa…
macacia Dec 20, 2024
0adbb20
P4ADEV-1635 refactoring according to new documentation
macacia Dec 20, 2024
ad50971
Merge remote-tracking branch 'origin/P4ADEV-1635-WF-IUV-Classificatio…
macacia Dec 20, 2024
66c2450
P4ADEV-1635 arrange javadoc
macacia Dec 20, 2024
ab2e6f1
P4ADEV-1635 clean
macacia Dec 20, 2024
67f7423
P4ADEV-1639 added dao
macacia Dec 20, 2024
517d2d6
P4ADEV-1635 resolved change request
macacia Dec 20, 2024
f34634c
Merge branch 'P4ADEV-1635-WF-IUV-Classification-implementation-activi…
macacia Dec 20, 2024
614f347
Merge remote-tracking branch 'origin/main' into P4ADEV-1639-WF-IUV-cl…
macacia Dec 20, 2024
324a089
P4ADEV-1639 added implementation
macacia Dec 20, 2024
3f37348
Update src/main/java/it/gov/pagopa/payhub/activities/dao/TransferDao.…
antonioT90 Dec 23, 2024
a5bb6de
Update src/main/java/it/gov/pagopa/payhub/activities/activity/classif…
antonioT90 Dec 23, 2024
34251c7
Update src/test/java/it/gov/pagopa/payhub/activities/activity/classif…
antonioT90 Dec 23, 2024
86d83ed
Update src/test/java/it/gov/pagopa/payhub/activities/activity/classif…
antonioT90 Dec 23, 2024
d565c30
Update src/test/java/it/gov/pagopa/payhub/activities/activity/classif…
antonioT90 Dec 23, 2024
2bdbeb0
Merge branch 'main' into P4ADEV-1639-WF-IUV-classification-activity-i…
antonioT90 Dec 23, 2024
fee8f86
Update src/test/java/it/gov/pagopa/payhub/activities/activity/classif…
antonioT90 Dec 23, 2024
1d7634a
Update src/test/java/it/gov/pagopa/payhub/activities/activity/classif…
antonioT90 Dec 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
@ActivityInterface
public interface TransferClassificationActivity {

/**
* Processes Transfer classification based on the provided parameters.
*
* @param orgId the unique identifier of the organization
* @param iuv the unique identifier of the payment (IUV)
* @param iur the identifier of the receipt associated with the payment
* @param transferIndex the index of the transfer to be classified
*/
@ActivityMethod
void classify(Long orgId, String iuv, String iur, int transferIndex);
/**
* Processes Transfer classification based on the provided parameters.
*
* @param orgId the unique identifier of the organization
* @param iuv the unique identifier of the payment (IUV)
* @param iur the identifier of the receipt associated with the payment
* @param transferIndex the index of the transfer to be classified
*/
@ActivityMethod
void classify(Long orgId, String iuv, String iur, int transferIndex);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package it.gov.pagopa.payhub.activities.activity.classifications;

import it.gov.pagopa.payhub.activities.dao.ClassificationDao;
import it.gov.pagopa.payhub.activities.dao.TransferDao;
import it.gov.pagopa.payhub.activities.exception.ClassificationException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
Expand All @@ -11,9 +12,12 @@
@Component
public class TransferClassificationActivityImpl implements TransferClassificationActivity {
private final ClassificationDao classificationDao;
private final TransferDao transferDao;

public TransferClassificationActivityImpl(ClassificationDao classificationDao) {
public TransferClassificationActivityImpl(ClassificationDao classificationDao,
TransferDao transferDao) {
this.classificationDao = classificationDao;
this.transferDao = transferDao;
}

@Override
Expand All @@ -22,6 +26,6 @@ public void classify(Long orgId, String iuv, String iur, int transferIndex) {
if (!classificationDao.deleteTransferClassification(orgId, iuv, iur, transferIndex)) {
throw new ClassificationException("Error occurred while clean up current processing Requests due to failed deletion");
}
transferDao.findBySemanticKey(orgId, iuv, iur, transferIndex);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package it.gov.pagopa.payhub.activities.dao;

import it.gov.pagopa.payhub.activities.dto.TransferDTO;

import java.util.List;

/**
* Data Access Object (DAO) interface for handling operations related to
* `Transfer` objects.
*
* @see TransferDTO
*/
public interface TransferDao {

TransferDTO findBySemanticKey(Long orgId, String iuv, String iur, int transferIndex);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package it.gov.pagopa.payhub.activities.activity.classifications;

import it.gov.pagopa.payhub.activities.dao.ClassificationDao;
import it.gov.pagopa.payhub.activities.dao.TransferDao;
import it.gov.pagopa.payhub.activities.dto.TransferDTO;
import it.gov.pagopa.payhub.activities.exception.ClassificationException;
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.junit.jupiter.MockitoExtension;

import java.util.List;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.when;

Expand All @@ -21,22 +25,33 @@ class TransferClassificationActivityImplTest {
@Mock
private ClassificationDao classificationDaoMock;

@Mock
private TransferDao transferDaoMock;

private TransferClassificationActivity activity;

@BeforeEach
void setUp() {
activity = new TransferClassificationActivityImpl(classificationDaoMock);
activity = new TransferClassificationActivityImpl(classificationDaoMock, transferDaoMock);
}

@Test
void classificationSuccess() {
when(classificationDaoMock.deleteTransferClassification(ORGANIZATION, IUV, IUR, INDEX)).thenReturn(Boolean.TRUE);
when(transferDaoMock.retrieveTransferByLogicalKey(ORGANIZATION, IUV, IUR, INDEX)).thenReturn(List.of(new TransferDTO()));
antonioT90 marked this conversation as resolved.
Show resolved Hide resolved
assertDoesNotThrow(() -> activity.classify(ORGANIZATION, IUV, IUR, INDEX));
}

@Test
void classificationFailed() {
void givenFailedDeletePreviousClassificationWhenClassifyThenClassificationFailed() {
when(classificationDaoMock.deleteTransferClassification(ORGANIZATION, IUV, IUR, INDEX)).thenReturn(Boolean.FALSE);
assertThrows(ClassificationException.class, () -> activity.classify(ORGANIZATION, IUV, IUR, INDEX), "classification failed");
}

@Test
void givenFailedFindTransferWhenClassifyThenClassificationFailed() {
when(classificationDaoMock.deleteTransferClassification(ORGANIZATION, IUV, IUR, INDEX)).thenReturn(Boolean.TRUE);
when(transferDaoMock.findBySemanticKey(ORGANIZATION, IUV, IUR, INDEX)).thenThrow(new ClassificationException("retrieving failed"));
assertThrows(ClassificationException.class, () -> activity.classify(ORGANIZATION, IUV, IUR, INDEX), "classification failed");
}
}
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.19.0
1.19.0-SNAPSHOT
Loading