### Question:
SpiCardTransactionListToXs2aAccountReportMapper { public Optional<Xs2aCardAccountReport> mapToXs2aCardAccountReport(BookingStatus bookingStatus, List<SpiCardTransaction> spiCardTransactions, byte[] rawTransactionsResponse) { if (ArrayUtils.isNotEmpty(rawTransactionsResponse)) { return Optional.of(new Xs2aCardAccountReport(null, null, null, rawTransactionsResponse)); } if (CollectionUtils.isEmpty(spiCardTransactions)) { return Optional.empty(); } if (bookingStatus == BookingStatus.INFORMATION) { return Optional.of(new Xs2aCardAccountReport(null, null, toXs2aCardTransactionMapper.mapToXs2aCardTransactionList(spiCardTransactions), null)); } List<CardTransaction> booked = Collections.emptyList(); List<CardTransaction> pending = Collections.emptyList(); if (bookingStatus != BookingStatus.PENDING) { booked = filterTransaction(spiCardTransactions, BOOKED_PREDICATE); } if (bookingStatus != BookingStatus.BOOKED) { pending = filterTransaction(spiCardTransactions, PENDING_PREDICATE); } return Optional.of(new Xs2aCardAccountReport(booked, pending, null, null)); }  Optional<Xs2aCardAccountReport> mapToXs2aCardAccountReport(BookingStatus bookingStatus, List<SpiCardTransaction> spiCardTransactions, byte[] rawTransactionsResponse);  }### Answer:
@Test void mapToXs2aCardAccountReport() { BookingStatus bookingStatus = BookingStatus.BOTH; List<SpiCardTransaction> spiCardTransactions = jsonReader.getObjectFromFile("json/SpiCardTransactions.json", new TypeReference<List<SpiCardTransaction>>() { }); Xs2aCardAccountReport expectedXs2aCardAccountReport = jsonReader.getObjectFromFile("json/Xs2aCardAccountReport.json", Xs2aCardAccountReport.class); Optional<Xs2aCardAccountReport> xs2aCardAccountReport = spiCardTransactionListToXs2aAccountReportMapper.mapToXs2aCardAccountReport(bookingStatus, spiCardTransactions, null); assertTrue(xs2aCardAccountReport.isPresent()); assertEquals(expectedXs2aCardAccountReport, xs2aCardAccountReport.get()); }
@Test void mapToXs2aCardAccountReport_rawTransactionsResponse() { byte[] rawData = "some raw data".getBytes(); Xs2aCardAccountReport expectedReport= new Xs2aCardAccountReport(null, null, null, rawData); Optional<Xs2aCardAccountReport> xs2aCardAccountReport = spiCardTransactionListToXs2aAccountReportMapper.mapToXs2aCardAccountReport(BookingStatus.BOTH, Collections.emptyList(), rawData); assertTrue(xs2aCardAccountReport.isPresent()); assertEquals(expectedReport, xs2aCardAccountReport.get()); }
@Test void mapToXs2aCardAccountReport_emptyTransactions() { Optional<Xs2aCardAccountReport> xs2aCardAccountReport = spiCardTransactionListToXs2aAccountReportMapper.mapToXs2aCardAccountReport(BookingStatus.BOTH, Collections.emptyList(), null); assertFalse(xs2aCardAccountReport.isPresent()); }