@Test public void shouldWriteValuesToCSVBasedOnFieldOrderInTemplate() throws Exception { csvHelper.writeCsvFile(order, orderFileTemplate, writer); verify(writer, times(2)).write(orderId.toString()); verify(writer, times(2)).write("22/12/13"); verify(writer, atLeast(2)).write(System.getProperty("line.separator")); }
public void writeCsvFile(Order order, OrderFileTemplateDTO orderFileTemplateDTO, Writer writer) throws IOException { List<OrderFileColumn> orderFileColumns = orderFileTemplateDTO.getOrderFileColumns(); removeExcludedColumns(orderFileColumns); if (orderFileTemplateDTO.getOrderConfiguration().isHeaderInFile()) { writeHeader(orderFileColumns, writer); } List<RnrLineItem> nonFullSupplyLineItems = order.getRnr().getNonFullSupplyLineItems(); Collections.sort(nonFullSupplyLineItems, new LineItemComparator()); writeLineItems(order, order.getRnr().getFullSupplyLineItems(), orderFileColumns, writer); writeLineItems(order, nonFullSupplyLineItems, orderFileColumns, writer); }
OrderCsvHelper { public void writeCsvFile(Order order, OrderFileTemplateDTO orderFileTemplateDTO, Writer writer) throws IOException { List<OrderFileColumn> orderFileColumns = orderFileTemplateDTO.getOrderFileColumns(); removeExcludedColumns(orderFileColumns); if (orderFileTemplateDTO.getOrderConfiguration().isHeaderInFile()) { writeHeader(orderFileColumns, writer); } List<RnrLineItem> nonFullSupplyLineItems = order.getRnr().getNonFullSupplyLineItems(); Collections.sort(nonFullSupplyLineItems, new LineItemComparator()); writeLineItems(order, order.getRnr().getFullSupplyLineItems(), orderFileColumns, writer); writeLineItems(order, nonFullSupplyLineItems, orderFileColumns, writer); } }
OrderCsvHelper { public void writeCsvFile(Order order, OrderFileTemplateDTO orderFileTemplateDTO, Writer writer) throws IOException { List<OrderFileColumn> orderFileColumns = orderFileTemplateDTO.getOrderFileColumns(); removeExcludedColumns(orderFileColumns); if (orderFileTemplateDTO.getOrderConfiguration().isHeaderInFile()) { writeHeader(orderFileColumns, writer); } List<RnrLineItem> nonFullSupplyLineItems = order.getRnr().getNonFullSupplyLineItems(); Collections.sort(nonFullSupplyLineItems, new LineItemComparator()); writeLineItems(order, order.getRnr().getFullSupplyLineItems(), orderFileColumns, writer); writeLineItems(order, nonFullSupplyLineItems, orderFileColumns, writer); } OrderCsvHelper(); }
OrderCsvHelper { public void writeCsvFile(Order order, OrderFileTemplateDTO orderFileTemplateDTO, Writer writer) throws IOException { List<OrderFileColumn> orderFileColumns = orderFileTemplateDTO.getOrderFileColumns(); removeExcludedColumns(orderFileColumns); if (orderFileTemplateDTO.getOrderConfiguration().isHeaderInFile()) { writeHeader(orderFileColumns, writer); } List<RnrLineItem> nonFullSupplyLineItems = order.getRnr().getNonFullSupplyLineItems(); Collections.sort(nonFullSupplyLineItems, new LineItemComparator()); writeLineItems(order, order.getRnr().getFullSupplyLineItems(), orderFileColumns, writer); writeLineItems(order, nonFullSupplyLineItems, orderFileColumns, writer); } OrderCsvHelper(); void writeCsvFile(Order order, OrderFileTemplateDTO orderFileTemplateDTO, Writer writer); }
OrderCsvHelper { public void writeCsvFile(Order order, OrderFileTemplateDTO orderFileTemplateDTO, Writer writer) throws IOException { List<OrderFileColumn> orderFileColumns = orderFileTemplateDTO.getOrderFileColumns(); removeExcludedColumns(orderFileColumns); if (orderFileTemplateDTO.getOrderConfiguration().isHeaderInFile()) { writeHeader(orderFileColumns, writer); } List<RnrLineItem> nonFullSupplyLineItems = order.getRnr().getNonFullSupplyLineItems(); Collections.sort(nonFullSupplyLineItems, new LineItemComparator()); writeLineItems(order, order.getRnr().getFullSupplyLineItems(), orderFileColumns, writer); writeLineItems(order, nonFullSupplyLineItems, orderFileColumns, writer); } OrderCsvHelper(); void writeCsvFile(Order order, OrderFileTemplateDTO orderFileTemplateDTO, Writer writer); static final String STRING; static final String LINE_NO; static final String ORDER; }