Skip to content

Commit

Permalink
Merge branch 'P4ADEV-1648-WF-PaymentsReportingIngestion-worker-dao-fo…
Browse files Browse the repository at this point in the history
…r-saving-data-' of https://github.com/pagopa/p4pa-workflow-worker into P4ADEV-1653-WF-IngestionFlowFile-worker-dao-for-saving-data
  • Loading branch information
macacia committed Dec 13, 2024
2 parents 8681837 + 46bceb5 commit a71eaef
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 86 deletions.
6 changes: 3 additions & 3 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ microservice-chart:
envSecret:
APPLICATIONINSIGHTS_CONNECTION_STRING: appinsights-connection-string

MYPAY_DB_HOST: db-host
MYPAY_DB_USER: db-mypay-login-username
MYPAY_DB_PASSWORD: db-mypay-login-password
PU_DB_HOST: db-host
PU_DB_USER: db-mypay-login-username
PU_DB_PASSWORD: db-mypay-login-password

# nodeSelector: {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
public class DataSourceConfiguration {

@Bean
@ConfigurationProperties("spring.data.mypay")
public DataSource myPayDataSource() {
@ConfigurationProperties("spring.data.pu")
public DataSource puDataSource() {
return DataSourceBuilder.create().build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
import it.gov.pagopa.payhub.activities.dto.paymentsreporting.PaymentsReportingDTO;
import it.gov.pagopa.pu.worker.paymentsreporting.mapper.PaymentsReportingMapper;
import it.gov.pagopa.pu.worker.paymentsreporting.model.PaymentsReporting;
import it.gov.pagopa.pu.worker.paymentsreporting.service.PaymentsReportingService;
import it.gov.pagopa.pu.worker.paymentsreporting.repository.PaymentsReportingRepository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PaymentsReportingDaoImpl implements PaymentsReportingDao {
private final PaymentsReportingService paymentsReportingService;
private final PaymentsReportingMapper paymentsReportingMapper;
private final PaymentsReportingRepository repository;
private final PaymentsReportingMapper paymentsReportingMapper;

public PaymentsReportingDaoImpl(PaymentsReportingService paymentsReportingService,
public PaymentsReportingDaoImpl(PaymentsReportingRepository repository,
PaymentsReportingMapper paymentsReportingMapper) {
this.paymentsReportingService = paymentsReportingService;
this.repository = repository;
this.paymentsReportingMapper = paymentsReportingMapper;
}

@Override
public List<PaymentsReportingDTO> saveAll(List<PaymentsReportingDTO> dtos) {
List<PaymentsReporting> paymentsReportings = paymentsReportingService
List<PaymentsReporting> paymentsReportings = repository
.saveAll(dtos.stream()
.map(paymentsReportingMapper::mapPaymentsReportingDTO2Model)
.toList());
Expand Down

This file was deleted.

10 changes: 6 additions & 4 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ spring:
version: ${version}
jmx.enabled: true
data:
mypay:
jdbc-url: "jdbc:postgresql://\${MYPAY_DB_HOST}:5432/mypay"
username: "\${MYPAY_DB_USER}"
password: "\${MYPAY_DB_PASSWORD}"
pu:
jdbc-url: "jdbc:postgresql://\${PU_DB_HOST}:\${PU_DB_PORT:5432}/\${PU_DB_NAME:dbname}"
username: "\${PU_DB_USER}"
password: "\${PU_DB_PASSWORD}"
driverClassName: "org.postgresql.Driver"


management:
endpoint:
health:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import it.gov.pagopa.payhub.activities.dto.paymentsreporting.PaymentsReportingDTO;
import it.gov.pagopa.pu.worker.paymentsreporting.mapper.PaymentsReportingMapper;
import it.gov.pagopa.pu.worker.paymentsreporting.model.PaymentsReporting;
import it.gov.pagopa.pu.worker.paymentsreporting.service.PaymentsReportingService;
import it.gov.pagopa.pu.worker.paymentsreporting.repository.PaymentsReportingRepository;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -19,7 +19,7 @@
class PaymentsReportingDaoImplTest {

@Mock
private PaymentsReportingService paymentsReportingServiceMock;
private PaymentsReportingRepository repositoryMock;

@Mock
private PaymentsReportingMapper paymentsReportingMapperMock;
Expand All @@ -28,7 +28,7 @@ class PaymentsReportingDaoImplTest {

@BeforeEach
void setUp() {
service = new PaymentsReportingDaoImpl(paymentsReportingServiceMock, paymentsReportingMapperMock);
service = new PaymentsReportingDaoImpl(repositoryMock, paymentsReportingMapperMock);
}

@Test
Expand All @@ -50,7 +50,7 @@ void testSaveAll() {
when(paymentsReportingMapperMock.mapPaymentsReportingDTO2Model(dto2)).thenReturn(entity2);
when(paymentsReportingMapperMock.mapPaymentsReporting2DTO(entity1)).thenReturn(returnedDto1);
when(paymentsReportingMapperMock.mapPaymentsReporting2DTO(entity2)).thenReturn(returnedDto2);
when(paymentsReportingServiceMock.saveAll(entities)).thenReturn(entities);
when(repositoryMock.saveAll(entities)).thenReturn(entities);

// Act
List<PaymentsReportingDTO> result = service.saveAll(dtos);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package it.gov.pagopa.pu.worker.paymentsreporting.mapper;

import it.gov.pagopa.payhub.activities.dto.paymentsreporting.PaymentsReportingDTO;
import it.gov.pagopa.pu.worker.paymentsreporting.mapper.PaymentsReportingMapper;
import it.gov.pagopa.pu.worker.paymentsreporting.model.PaymentsReporting;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static it.gov.pagopa.pu.worker.util.TestUtils.checkNotNullFields;
import static it.gov.pagopa.pu.worker.util.faker.PaymentsReportingFakerBuilder.buildPaymentsReporting;
import static it.gov.pagopa.pu.worker.util.faker.PaymentsReportingFakerBuilder.buildPaymentsReportingDTO;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertNotNull;

class PaymentsReportingMapperTest {
private PaymentsReportingMapper mapper;
Expand Down

This file was deleted.

0 comments on commit a71eaef

Please sign in to comment.