Skip to content

Commit

Permalink
P4ADEV-1648 added test
Browse files Browse the repository at this point in the history
  • Loading branch information
macacia committed Dec 13, 2024
1 parent 5432d08 commit 8681837
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
package it.gov.pagopa.pu.worker.ingestionflowfile.mapper;

import it.gov.pagopa.payhub.activities.dto.IngestionFlowFileDTO;
import it.gov.pagopa.pu.worker.ingestionflowfile.model.IngestionFlowFile;
import org.springframework.stereotype.Service;

@Service
public class IngestionFlowFileMapper {

public IngestionFlowFileDTO mapIngestionFlowFile2DTO(IngestionFlowFile model) {
return IngestionFlowFileDTO.builder().build();
}

public IngestionFlowFile mapIngestionFlowFileDTO2Model(IngestionFlowFileDTO dto) {
return IngestionFlowFile.builder().build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package it.gov.pagopa.pu.worker.ingestionflowfile;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class IngestionFlowFileDaoImplTest {

@BeforeEach
void setUp() {
}

@Test
void findById() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package it.gov.pagopa.pu.worker.ingestionflowfile.mapper;

import it.gov.pagopa.payhub.activities.dto.IngestionFlowFileDTO;
import it.gov.pagopa.pu.worker.ingestionflowfile.model.IngestionFlowFile;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static it.gov.pagopa.pu.worker.util.TestUtils.checkNotNullFields;
import static org.junit.jupiter.api.Assertions.assertNotNull;

class IngestionFlowFileMapperTest {
private IngestionFlowFileMapper mapper;

@BeforeEach
void setUp() { mapper = new IngestionFlowFileMapper(); }

@Test
void mapIngestionFlowFile2DTO() {
IngestionFlowFile model = IngestionFlowFile.builder().ingestionFlowFileId(123L).build();;
IngestionFlowFileDTO result = mapper.mapIngestionFlowFile2DTO(model);

assertNotNull(result);
checkNotNullFields(result);
}

@Test
void mapIngestionFlowFileDTO2Model() {
IngestionFlowFileDTO dto = IngestionFlowFileDTO.builder().build();
IngestionFlowFile result = mapper.mapIngestionFlowFileDTO2Model(dto);
assertNotNull(result);
checkNotNullFields(result);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package it.gov.pagopa.pu.worker.ingestionflowfile.service;

import it.gov.pagopa.pu.worker.ingestionflowfile.model.IngestionFlowFile;
import it.gov.pagopa.pu.worker.ingestionflowfile.repository.IngestionFlowFileRepository;
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.Optional;

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

@ExtendWith(MockitoExtension.class)
class IngestionFlowFileServiceTest {

@Mock
private IngestionFlowFileRepository repositoryMock;

private IngestionFlowFileService service;

@BeforeEach
void setUp() { service = new IngestionFlowFileService(repositoryMock); }

@Test
void whenGetIngestionFlowFileThenGetResult() {
// Arrange
Long id = 123L;
IngestionFlowFile ingestionFlowFile = IngestionFlowFile.builder()
.ingestionFlowFileId(id)
.build();

when(repositoryMock.findById(id)).thenReturn(Optional.of(ingestionFlowFile));

// Act
Optional<IngestionFlowFile> result = service.getIngestionFlowFile(id);

// Assert
assertEquals(Optional.of(ingestionFlowFile), result);
verify(repositoryMock, times(1)).findById(id);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package it.gov.pagopa.pu.worker.service;
package it.gov.pagopa.pu.worker.paymentsreporting;

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.PaymentsReportingDaoImpl;
import it.gov.pagopa.pu.worker.paymentsreporting.model.PaymentsReporting;
import it.gov.pagopa.pu.worker.paymentsreporting.service.PaymentsReportingService;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -14,7 +13,7 @@
import java.util.List;

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

@ExtendWith(MockitoExtension.class)
class PaymentsReportingDaoImplTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package it.gov.pagopa.pu.worker.mapper;
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;
Expand All @@ -19,7 +19,6 @@ void setUp() {
mapper = new PaymentsReportingMapper();
}


@Test
void mapPaymentsReporting2DTO() {
PaymentsReporting model = buildPaymentsReporting();
Expand Down

0 comments on commit 8681837

Please sign in to comment.