diff --git a/src/main/java/it/gov/pagopa/arc/dto/mapper/BizEventsCartItem2CartItemDTOMapper.java b/src/main/java/it/gov/pagopa/arc/dto/mapper/BizEventsCartItem2CartItemDTOMapper.java index ff2d64f2..b22d6a9a 100644 --- a/src/main/java/it/gov/pagopa/arc/dto/mapper/BizEventsCartItem2CartItemDTOMapper.java +++ b/src/main/java/it/gov/pagopa/arc/dto/mapper/BizEventsCartItem2CartItemDTOMapper.java @@ -2,25 +2,14 @@ import it.gov.pagopa.arc.connector.bizevents.dto.BizEventsCartItemDTO; import it.gov.pagopa.arc.model.generated.CartItemDTO; -import it.gov.pagopa.arc.utils.Utilities; -import org.springframework.stereotype.Component; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.NullValueCheckStrategy; -@Component -public class BizEventsCartItem2CartItemDTOMapper { - private final BizEventsUserDetail2UserDetailDTOMapper userDetailsMapper; +@Mapper(componentModel = "spring", uses = {MapperUtilities.class, BizEventsUserDetail2UserDetailDTOMapper.class}) +public interface BizEventsCartItem2CartItemDTOMapper { - public BizEventsCartItem2CartItemDTOMapper(BizEventsUserDetail2UserDetailDTOMapper userDetailsMapper) { - this.userDetailsMapper = userDetailsMapper; - } + @Mapping(source = "amount", target = "amount", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, qualifiedByName = "euroToCents") + CartItemDTO mapCart(BizEventsCartItemDTO bizEventsCartItemDTO); - public CartItemDTO mapCart(BizEventsCartItemDTO bizEventsCartItemDTO){ - return CartItemDTO.builder() - .subject(bizEventsCartItemDTO.getSubject()) - .amount(bizEventsCartItemDTO.getAmount() != null ? Utilities.euroToCents(bizEventsCartItemDTO.getAmount()) : null) - .payee(userDetailsMapper.mapUserDetail(bizEventsCartItemDTO.getPayee())) - .debtor(userDetailsMapper.mapUserDetail(bizEventsCartItemDTO.getDebtor())) - .refNumberType(bizEventsCartItemDTO.getRefNumberType()) - .refNumberValue(bizEventsCartItemDTO.getRefNumberValue()) - .build(); - } } diff --git a/src/main/java/it/gov/pagopa/arc/dto/mapper/bizevents/paidnotice/BizEventsInfoPaidNoticeDTO2InfoNoticeDTOMapper.java b/src/main/java/it/gov/pagopa/arc/dto/mapper/bizevents/paidnotice/BizEventsInfoPaidNoticeDTO2InfoNoticeDTOMapper.java new file mode 100644 index 00000000..84f99e78 --- /dev/null +++ b/src/main/java/it/gov/pagopa/arc/dto/mapper/bizevents/paidnotice/BizEventsInfoPaidNoticeDTO2InfoNoticeDTOMapper.java @@ -0,0 +1,19 @@ +package it.gov.pagopa.arc.dto.mapper.bizevents.paidnotice; + +import it.gov.pagopa.arc.connector.bizevents.dto.paidnotice.BizEventsInfoPaidNoticeDTO; +import it.gov.pagopa.arc.dto.mapper.BizEventsUserDetail2UserDetailDTOMapper; +import it.gov.pagopa.arc.dto.mapper.BizEventsWalletInfo2WalletInfoDTOMapper; +import it.gov.pagopa.arc.dto.mapper.MapperUtilities; +import it.gov.pagopa.arc.model.generated.InfoNoticeDTO; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.NullValueCheckStrategy; + +@Mapper(componentModel = "spring", uses = {MapperUtilities.class, BizEventsWalletInfo2WalletInfoDTOMapper.class, BizEventsUserDetail2UserDetailDTOMapper.class}) +public interface BizEventsInfoPaidNoticeDTO2InfoNoticeDTOMapper { + + @Mapping(source = "amount", target = "amount", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, qualifiedByName = "euroToCents") + @Mapping(source = "fee", target = "fee", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, qualifiedByName = "euroToCents") + @Mapping(source = "noticeDate", target = "noticeDate", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS, qualifiedByName = "dateStringToZonedDateTime") + InfoNoticeDTO toInfoNoticeDTO(BizEventsInfoPaidNoticeDTO bizEventsInfoPaidNoticeDTO); +} diff --git a/src/main/java/it/gov/pagopa/arc/dto/mapper/bizevents/paidnotice/BizEventsPaidNoticeDetailsDTO2NoticeDetailsDTOMapper.java b/src/main/java/it/gov/pagopa/arc/dto/mapper/bizevents/paidnotice/BizEventsPaidNoticeDetailsDTO2NoticeDetailsDTOMapper.java new file mode 100644 index 00000000..f09c0ed8 --- /dev/null +++ b/src/main/java/it/gov/pagopa/arc/dto/mapper/bizevents/paidnotice/BizEventsPaidNoticeDetailsDTO2NoticeDetailsDTOMapper.java @@ -0,0 +1,11 @@ +package it.gov.pagopa.arc.dto.mapper.bizevents.paidnotice; + +import it.gov.pagopa.arc.connector.bizevents.dto.paidnotice.BizEventsPaidNoticeDetailsDTO; +import it.gov.pagopa.arc.dto.mapper.BizEventsCartItem2CartItemDTOMapper; +import it.gov.pagopa.arc.model.generated.NoticeDetailsDTO; +import org.mapstruct.Mapper; + +@Mapper(componentModel = "spring", uses = {BizEventsInfoPaidNoticeDTO2InfoNoticeDTOMapper.class, BizEventsCartItem2CartItemDTOMapper.class}) +public interface BizEventsPaidNoticeDetailsDTO2NoticeDetailsDTOMapper { + NoticeDetailsDTO toNoticeDetailsDTO(BizEventsPaidNoticeDetailsDTO bizEventsPaidNoticeDetailsDTO); +} diff --git a/src/test/java/it/gov/pagopa/arc/dto/mapper/BizEventsCartItem2CartItemDTOMapperTest.java b/src/test/java/it/gov/pagopa/arc/dto/mapper/BizEventsCartItem2CartItemDTOMapperTest.java index e0aeb53f..8d7a5ad1 100644 --- a/src/test/java/it/gov/pagopa/arc/dto/mapper/BizEventsCartItem2CartItemDTOMapperTest.java +++ b/src/test/java/it/gov/pagopa/arc/dto/mapper/BizEventsCartItem2CartItemDTOMapperTest.java @@ -6,9 +6,10 @@ import it.gov.pagopa.arc.fakers.bizEvents.BizEventsCartItemDTOFaker; import it.gov.pagopa.arc.model.generated.CartItemDTO; import it.gov.pagopa.arc.model.generated.UserDetailDTO; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; +import org.mapstruct.factory.Mappers; +import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; @@ -20,15 +21,11 @@ @ExtendWith(MockitoExtension.class) class BizEventsCartItem2CartItemDTOMapperTest { - private BizEventsCartItem2CartItemDTOMapper cartItemMapper; - @Mock private BizEventsUserDetail2UserDetailDTOMapper userDetailsMapperMock; - @BeforeEach - void setUp() { - cartItemMapper = new BizEventsCartItem2CartItemDTOMapper(userDetailsMapperMock); - } + @InjectMocks + private final BizEventsCartItem2CartItemDTOMapper cartItemMapper = Mappers.getMapper(BizEventsCartItem2CartItemDTOMapper.class); @Test void givenBizEventsCartItemDTOWhenMapCartThenReturnCartItemDTO() { diff --git a/src/test/java/it/gov/pagopa/arc/dto/mapper/bizevents/paidnotice/BizEventsInfoPaidNoticeDTO2InfoNoticeDTOMapperTest.java b/src/test/java/it/gov/pagopa/arc/dto/mapper/bizevents/paidnotice/BizEventsInfoPaidNoticeDTO2InfoNoticeDTOMapperTest.java new file mode 100644 index 00000000..3cdbfdb1 --- /dev/null +++ b/src/test/java/it/gov/pagopa/arc/dto/mapper/bizevents/paidnotice/BizEventsInfoPaidNoticeDTO2InfoNoticeDTOMapperTest.java @@ -0,0 +1,69 @@ +package it.gov.pagopa.arc.dto.mapper.bizevents.paidnotice; + +import it.gov.pagopa.arc.connector.bizevents.dto.BizEventsUserDetailDTO; +import it.gov.pagopa.arc.connector.bizevents.dto.BizEventsWalletInfoDTO; +import it.gov.pagopa.arc.connector.bizevents.dto.paidnotice.BizEventsInfoPaidNoticeDTO; +import it.gov.pagopa.arc.dto.mapper.BizEventsUserDetail2UserDetailDTOMapper; +import it.gov.pagopa.arc.dto.mapper.BizEventsWalletInfo2WalletInfoDTOMapper; +import it.gov.pagopa.arc.fakers.CommonUserDetailDTOFaker; +import it.gov.pagopa.arc.fakers.CommonWalletInfoDTOFaker; +import it.gov.pagopa.arc.fakers.bizEvents.paidnotice.BizEventsInfoPaidNoticeDTOFaker; +import it.gov.pagopa.arc.model.generated.InfoNoticeDTO; +import it.gov.pagopa.arc.model.generated.UserDetailDTO; +import it.gov.pagopa.arc.model.generated.WalletInfoDTO; +import it.gov.pagopa.arc.utils.TestUtils; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mapstruct.factory.Mappers; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.time.ZonedDateTime; + +import static org.junit.jupiter.api.Assertions.assertEquals; +@ExtendWith(MockitoExtension.class) +class BizEventsInfoPaidNoticeDTO2InfoNoticeDTOMapperTest { + @Mock + private BizEventsUserDetail2UserDetailDTOMapper bizEventsUserDetail2UserDetailDTOMapperMock; + @Mock + private BizEventsWalletInfo2WalletInfoDTOMapper bizEventsWalletInfo2WalletInfoDTOMapperMock; + + @InjectMocks + private final BizEventsInfoPaidNoticeDTO2InfoNoticeDTOMapper mapper = Mappers.getMapper(BizEventsInfoPaidNoticeDTO2InfoNoticeDTOMapper.class); + + @AfterEach + void afterMethod() { + Mockito.verifyNoMoreInteractions( bizEventsUserDetail2UserDetailDTOMapperMock, bizEventsWalletInfo2WalletInfoDTOMapperMock); + } + @Test + void givenBizEventsInfoPaidNoticeDTOWhenCallMapperThenReturnInfoNoticeDTO() { + //given + BizEventsWalletInfoDTO bizEventsWalletInfo = CommonWalletInfoDTOFaker.mockBizEventsWalletInfoDTO(false); + BizEventsUserDetailDTO payer = CommonUserDetailDTOFaker.mockBizEventsUserDetailDTO(CommonUserDetailDTOFaker.USER_DETAIL_PAYER); + BizEventsInfoPaidNoticeDTO bizEventsInfoPaidNoticeDTO = BizEventsInfoPaidNoticeDTOFaker.mockInstance(bizEventsWalletInfo, payer); + + WalletInfoDTO walletInfoDTO = CommonWalletInfoDTOFaker.mockWalletInfoDTO(false); + UserDetailDTO userDetailDTO = CommonUserDetailDTOFaker.mockUserDetailDTO(CommonUserDetailDTOFaker.USER_DETAIL_PAYER); + + Mockito.when(bizEventsWalletInfo2WalletInfoDTOMapperMock.mapWalletInfo(bizEventsWalletInfo)).thenReturn(walletInfoDTO); + Mockito.when(bizEventsUserDetail2UserDetailDTOMapperMock.mapUserDetail(payer)).thenReturn(userDetailDTO); + //when + InfoNoticeDTO infoNoticeDTO = mapper.toInfoNoticeDTO(bizEventsInfoPaidNoticeDTO); + //then + Assertions.assertEquals("EVENT_ID", infoNoticeDTO.getEventId()); + Assertions.assertEquals("250863", infoNoticeDTO.getAuthCode()); + Assertions.assertEquals("51561651", infoNoticeDTO.getRrn()); + Assertions.assertEquals("51561651", infoNoticeDTO.getRrn()); + Assertions.assertEquals(ZonedDateTime.parse("2024-06-27T13:07:25Z"), infoNoticeDTO.getNoticeDate()); + Assertions.assertEquals("Worldline Merchant Services Italia S.p.A.", infoNoticeDTO.getPspName()); + assertEquals( 565430L, infoNoticeDTO.getAmount()); + assertEquals( 29L, infoNoticeDTO.getFee()); + assertEquals(InfoNoticeDTO.OriginEnum.PM, infoNoticeDTO.getOrigin()); + + TestUtils.assertNotNullFields(infoNoticeDTO); + } +} \ No newline at end of file diff --git a/src/test/java/it/gov/pagopa/arc/dto/mapper/bizevents/paidnotice/BizEventsPaidNoticeDetailsDTO2NoticeDetailsDTOMapperTest.java b/src/test/java/it/gov/pagopa/arc/dto/mapper/bizevents/paidnotice/BizEventsPaidNoticeDetailsDTO2NoticeDetailsDTOMapperTest.java new file mode 100644 index 00000000..8e846b40 --- /dev/null +++ b/src/test/java/it/gov/pagopa/arc/dto/mapper/bizevents/paidnotice/BizEventsPaidNoticeDetailsDTO2NoticeDetailsDTOMapperTest.java @@ -0,0 +1,54 @@ +package it.gov.pagopa.arc.dto.mapper.bizevents.paidnotice; + +import it.gov.pagopa.arc.connector.bizevents.dto.paidnotice.BizEventsPaidNoticeDetailsDTO; +import it.gov.pagopa.arc.dto.mapper.BizEventsCartItem2CartItemDTOMapper; +import it.gov.pagopa.arc.fakers.NoticeDetailsDTOFaker; +import it.gov.pagopa.arc.fakers.bizEvents.paidnotice.BizEventsPaidNoticeDetailsDTOFaker; +import it.gov.pagopa.arc.model.generated.NoticeDetailsDTO; +import it.gov.pagopa.arc.utils.TestUtils; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mapstruct.factory.Mappers; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +@ExtendWith(MockitoExtension.class) +class BizEventsPaidNoticeDetailsDTO2NoticeDetailsDTOMapperTest { + @Mock + private BizEventsInfoPaidNoticeDTO2InfoNoticeDTOMapper bizEventsInfoPaidNoticeDTO2InfoNoticeDTOMapperMock; + @Mock + private BizEventsCartItem2CartItemDTOMapper bizEventsCartItem2CartItemDTOMapperMock; + @InjectMocks + private final BizEventsPaidNoticeDetailsDTO2NoticeDetailsDTOMapper mapper = Mappers.getMapper(BizEventsPaidNoticeDetailsDTO2NoticeDetailsDTOMapper.class); + + @AfterEach + void afterMethod() { + Mockito.verifyNoMoreInteractions( bizEventsInfoPaidNoticeDTO2InfoNoticeDTOMapperMock,bizEventsCartItem2CartItemDTOMapperMock); + } + + @Test + void givenBizEventsPaidNoticeDetailsDTOWhenCallToNoticeDetailsDTOThenReturnNoticeDetailsDTO() { + //given + BizEventsPaidNoticeDetailsDTO bizEventsPaidNoticeDetailsDTO = BizEventsPaidNoticeDetailsDTOFaker.mockInstance(); + + NoticeDetailsDTO noticeDetailsDTO = NoticeDetailsDTOFaker.mockInstance(); + + Mockito.when(bizEventsInfoPaidNoticeDTO2InfoNoticeDTOMapperMock.toInfoNoticeDTO(bizEventsPaidNoticeDetailsDTO.getInfoNotice())).thenReturn(noticeDetailsDTO.getInfoNotice()); + Mockito.when(bizEventsCartItem2CartItemDTOMapperMock.mapCart( bizEventsPaidNoticeDetailsDTO.getCarts().get(0))).thenReturn(noticeDetailsDTO.getCarts().get(0)); + Mockito.when(bizEventsCartItem2CartItemDTOMapperMock.mapCart( bizEventsPaidNoticeDetailsDTO.getCarts().get(1))).thenReturn(noticeDetailsDTO.getCarts().get(1)); + //when + NoticeDetailsDTO result = mapper.toNoticeDetailsDTO(bizEventsPaidNoticeDetailsDTO); + //then + assertNotNull(result); + assertEquals(noticeDetailsDTO.getInfoNotice(), result.getInfoNotice()); + assertEquals(2, result.getCarts().size()); + assertEquals(noticeDetailsDTO.getCarts(), result.getCarts()); + + TestUtils.assertNotNullFields(result); + } +} \ No newline at end of file diff --git a/src/test/java/it/gov/pagopa/arc/fakers/InfoNoticeDTOFaker.java b/src/test/java/it/gov/pagopa/arc/fakers/InfoNoticeDTOFaker.java new file mode 100644 index 00000000..51d7320f --- /dev/null +++ b/src/test/java/it/gov/pagopa/arc/fakers/InfoNoticeDTOFaker.java @@ -0,0 +1,31 @@ +package it.gov.pagopa.arc.fakers; + +import it.gov.pagopa.arc.model.generated.InfoNoticeDTO; +import it.gov.pagopa.arc.model.generated.UserDetailDTO; +import it.gov.pagopa.arc.model.generated.WalletInfoDTO; +import it.gov.pagopa.arc.utils.TestUtils; + +import java.time.ZonedDateTime; + +public class InfoNoticeDTOFaker { + public static InfoNoticeDTO mockInstance(WalletInfoDTO walletInfo, UserDetailDTO payer){ + return mockInstanceBuilder(walletInfo, payer).build(); + } + private static InfoNoticeDTO.InfoNoticeDTOBuilder mockInstanceBuilder(WalletInfoDTO walletInfo, UserDetailDTO payer){ + InfoNoticeDTO.InfoNoticeDTOBuilder infoNoticeDTOBuilder = InfoNoticeDTO.builder() + .eventId("EVENT_ID") + .authCode("250863") + .rrn("51561651") + .noticeDate(ZonedDateTime.parse("2024-06-27T13:07:25Z")) + .pspName("Worldline Merchant Services Italia S.p.A.") + .walletInfo(walletInfo) + .paymentMethod(InfoNoticeDTO.PaymentMethodEnum.PO) + .payer(payer) + .amount(565430L) + .fee(29L) + .origin(InfoNoticeDTO.OriginEnum.UNKNOWN); + + TestUtils.assertNotNullFields(infoNoticeDTOBuilder); + return infoNoticeDTOBuilder; + } +} diff --git a/src/test/java/it/gov/pagopa/arc/fakers/NoticeDetailsDTOFaker.java b/src/test/java/it/gov/pagopa/arc/fakers/NoticeDetailsDTOFaker.java new file mode 100644 index 00000000..6d050aee --- /dev/null +++ b/src/test/java/it/gov/pagopa/arc/fakers/NoticeDetailsDTOFaker.java @@ -0,0 +1,31 @@ +package it.gov.pagopa.arc.fakers; + +import it.gov.pagopa.arc.model.generated.*; +import it.gov.pagopa.arc.utils.TestUtils; + +import java.util.List; + +public class NoticeDetailsDTOFaker { + public static NoticeDetailsDTO mockInstance(){ + return mockInstanceBuilder().build(); + } + + public static NoticeDetailsDTO.NoticeDetailsDTOBuilder mockInstanceBuilder(){ + WalletInfoDTO walletInfo = CommonWalletInfoDTOFaker.mockWalletInfoDTO(false); + UserDetailDTO payerMapped = CommonUserDetailDTOFaker.mockUserDetailDTO(CommonUserDetailDTOFaker.USER_DETAIL_PAYER); + InfoNoticeDTO infoNotice = InfoNoticeDTOFaker.mockInstance(walletInfo, payerMapped); + + UserDetailDTO payeeResponse = CommonUserDetailDTOFaker.mockUserDetailDTO(CommonUserDetailDTOFaker.USER_DETAIL_PAYEE); + UserDetailDTO debtorResponse = CommonUserDetailDTOFaker.mockUserDetailDTO(CommonUserDetailDTOFaker.USER_DETAIL_DEBTOR); + CartItemDTO cartItem1 = CartItemDTOFaker.mockInstance(payeeResponse, debtorResponse); + CartItemDTO cartItem2 = CartItemDTOFaker.mockInstance(payeeResponse, debtorResponse); + List cartsList = List.of(cartItem1, cartItem2); + + NoticeDetailsDTO.NoticeDetailsDTOBuilder noticeDetailsDTOBuilder = NoticeDetailsDTO.builder() + .infoNotice(infoNotice) + .carts(cartsList); + TestUtils.assertNotNullFields(noticeDetailsDTOBuilder); + + return noticeDetailsDTOBuilder; + } +} diff --git a/src/test/java/it/gov/pagopa/arc/fakers/bizEvents/paidnotice/BizEventsInfoPaidNoticeDTOFaker.java b/src/test/java/it/gov/pagopa/arc/fakers/bizEvents/paidnotice/BizEventsInfoPaidNoticeDTOFaker.java new file mode 100644 index 00000000..50394e2d --- /dev/null +++ b/src/test/java/it/gov/pagopa/arc/fakers/bizEvents/paidnotice/BizEventsInfoPaidNoticeDTOFaker.java @@ -0,0 +1,31 @@ +package it.gov.pagopa.arc.fakers.bizEvents.paidnotice; + +import it.gov.pagopa.arc.connector.bizevents.dto.BizEventsUserDetailDTO; +import it.gov.pagopa.arc.connector.bizevents.dto.BizEventsWalletInfoDTO; +import it.gov.pagopa.arc.connector.bizevents.dto.paidnotice.BizEventsInfoPaidNoticeDTO; +import it.gov.pagopa.arc.connector.bizevents.enums.Origin; +import it.gov.pagopa.arc.connector.bizevents.enums.PaymentMethod; +import it.gov.pagopa.arc.utils.TestUtils; + +public class BizEventsInfoPaidNoticeDTOFaker { + public static BizEventsInfoPaidNoticeDTO mockInstance(BizEventsWalletInfoDTO walletInfo, BizEventsUserDetailDTO payer){ + return mockInstanceBuilder(walletInfo, payer).build(); + } + private static BizEventsInfoPaidNoticeDTO.BizEventsInfoPaidNoticeDTOBuilder mockInstanceBuilder(BizEventsWalletInfoDTO walletInfo, BizEventsUserDetailDTO payer){ + BizEventsInfoPaidNoticeDTO.BizEventsInfoPaidNoticeDTOBuilder bizEventsInfoPaidNoticeDTOBuilder = BizEventsInfoPaidNoticeDTO.builder() + .eventId("EVENT_ID") + .authCode("250863") + .rrn("51561651") + .noticeDate("2024-06-27T13:07:25Z") + .pspName("Worldline Merchant Services Italia S.p.A.") + .walletInfo(walletInfo) + .paymentMethod(PaymentMethod.PO) + .payer(payer) + .amount("5,654.3") + .fee("0.29") + .origin(Origin.PM); + + TestUtils.assertNotNullFields(bizEventsInfoPaidNoticeDTOBuilder); + return bizEventsInfoPaidNoticeDTOBuilder; + } +} diff --git a/src/test/java/it/gov/pagopa/arc/fakers/bizEvents/paidnotice/BizEventsPaidNoticeDetailsDTOFaker.java b/src/test/java/it/gov/pagopa/arc/fakers/bizEvents/paidnotice/BizEventsPaidNoticeDetailsDTOFaker.java new file mode 100644 index 00000000..87955d70 --- /dev/null +++ b/src/test/java/it/gov/pagopa/arc/fakers/bizEvents/paidnotice/BizEventsPaidNoticeDetailsDTOFaker.java @@ -0,0 +1,40 @@ +package it.gov.pagopa.arc.fakers.bizEvents.paidnotice; + +import it.gov.pagopa.arc.connector.bizevents.dto.BizEventsCartItemDTO; +import it.gov.pagopa.arc.connector.bizevents.dto.BizEventsUserDetailDTO; +import it.gov.pagopa.arc.connector.bizevents.dto.BizEventsWalletInfoDTO; +import it.gov.pagopa.arc.connector.bizevents.dto.paidnotice.BizEventsInfoPaidNoticeDTO; +import it.gov.pagopa.arc.connector.bizevents.dto.paidnotice.BizEventsPaidNoticeDetailsDTO; +import it.gov.pagopa.arc.fakers.CommonUserDetailDTOFaker; +import it.gov.pagopa.arc.fakers.CommonWalletInfoDTOFaker; +import it.gov.pagopa.arc.fakers.bizEvents.BizEventsCartItemDTOFaker; +import it.gov.pagopa.arc.utils.TestUtils; + +import java.util.List; + +public class BizEventsPaidNoticeDetailsDTOFaker { + public static BizEventsPaidNoticeDetailsDTO mockInstance(){ + return mockInstanceBuilder().build(); + } + + public static BizEventsPaidNoticeDetailsDTO.BizEventsPaidNoticeDetailsDTOBuilder mockInstanceBuilder(){ + BizEventsWalletInfoDTO bizEventsWalletInfo = CommonWalletInfoDTOFaker.mockBizEventsWalletInfoDTO(false); + BizEventsUserDetailDTO payer = CommonUserDetailDTOFaker.mockBizEventsUserDetailDTO(CommonUserDetailDTOFaker.USER_DETAIL_PAYER); + BizEventsInfoPaidNoticeDTO bizEventsInfoPaidNoticeDTO = BizEventsInfoPaidNoticeDTOFaker.mockInstance(bizEventsWalletInfo, payer); + + BizEventsUserDetailDTO payeeResponse = CommonUserDetailDTOFaker.mockBizEventsUserDetailDTO(CommonUserDetailDTOFaker.USER_DETAIL_PAYEE); + BizEventsUserDetailDTO debtorResponse = CommonUserDetailDTOFaker.mockBizEventsUserDetailDTO(CommonUserDetailDTOFaker.USER_DETAIL_DEBTOR); + + BizEventsCartItemDTO bizEventsCartItem1 = BizEventsCartItemDTOFaker.mockInstance(payeeResponse,debtorResponse); + BizEventsCartItemDTO bizEventsCartItem2 = BizEventsCartItemDTOFaker.mockInstance(payeeResponse,debtorResponse); + List bizEventsCartsList = List.of(bizEventsCartItem1, bizEventsCartItem2); + + BizEventsPaidNoticeDetailsDTO.BizEventsPaidNoticeDetailsDTOBuilder bizEventsPaidNoticeDetailsDTO = BizEventsPaidNoticeDetailsDTO.builder() + .infoNotice(bizEventsInfoPaidNoticeDTO) + .carts(bizEventsCartsList); + + TestUtils.assertNotNullFields(bizEventsPaidNoticeDetailsDTO); + + return bizEventsPaidNoticeDetailsDTO; + } +}