portfolioDocument.setPortfolio(portfolio);
when(portfolioMaster.add(any(PortfolioDocument.class))).thenReturn(portfolioDocument);
// file to masters
PortfolioReader portfolioReader =
new SingleSheetSimplePortfolioReader(PORTFOLIO_FILE, SECURITY_TYPE);
PortfolioWriter portfolioWriter =
new MasterPortfolioWriter(PORTFOLIO_NAME, portfolioMaster, positionMaster, securityMaster, false, false, false);
portfolioCopier.copy(portfolioReader, portfolioWriter);
portfolioReader.close();
portfolioWriter.close();
portSearchResult.setDocuments(Collections.singletonList(portfolioDocument));
// Masters to file
portfolioReader = new MasterPortfolioReader(PORTFOLIO_NAME, portfolioMaster, positionMaster, securitySource);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
portfolioWriter = new SingleSheetSimplePortfolioWriter(SheetFormat.CSV, outputStream, SECURITY_TYPE);
portfolioCopier.copy(portfolioReader, portfolioWriter);
portfolioReader.close();
portfolioWriter.close();
// Compare source and destination
try (CSVReader sourceReader = new CSVReader(new InputStreamReader(new FileInputStream(PORTFOLIO_FILE)))) {
try (CSVReader destReader = new CSVReader(new InputStreamReader(new ByteArrayInputStream(outputStream.toByteArray())))) {