ProductInventoryEntry { public String toCSVString() { StringBuilder sb = new StringBuilder(); sb.append(formatUTCDate(startTime)); sb.append("\t"); sb.append(formatUTCDate(stopTime)); sb.append("\t"); sb.append(length); sb.append("\t"); sb.append(processStartLine); sb.append("\t"); sb.append(processLength); sb.append("\t"); sb.append(message); return sb.toString(); } private  ProductInventoryEntry(ProductData.UTC startTime, ProductData.UTC stopTime, int length, int processStartLine, int processLength, String message); static ProductInventoryEntry create(String startTime, String stopTime, String length, String processStartLine, String processLength, String message); static ProductInventoryEntry createEmpty(String message); static ProductInventoryEntry createForGoodProduct(Product product, String message); static ProductInventoryEntry createForBadProduct(Product product, String message); ProductData.UTC getStartTime(); ProductData.UTC getStopTime(); int getLength(); void setProcessStartLine(int processStartLine); int getProcessStartLine(); void setProcessLength(int processLength); int getProcessLength(); String getMessage(); String getProductName(); void setProductName(String productName); String toCSVString(); static final int NUM_ENTRIES; static final String DATE_PATTERN; }
@Test public void testToCsvString() throws Exception { Product product = new Product("name", "desc", 23, 45); ProductInventoryEntry entry = ProductInventoryEntry.createForGoodProduct(product, "foo"); assertEquals("2000-01-01-00-00-00.000000\t2000-01-01-00-00-00.000000\t45\t0\t45\tfoo", entry.toCSVString()); ProductData.UTC startTime = ProductData.UTC.parse("02-Jul-1990 13:10:11.1234"); product.setStartTime(startTime); ProductData.UTC endTime = ProductData.UTC.parse("02-Jul-2001 13:12:14.5678"); product.setEndTime(endTime); entry = ProductInventoryEntry.createForGoodProduct(product, "bar"); assertEquals("1990-07-02-13-10-11.123400\t2001-07-02-13-12-14.567800\t45\t0\t45\tbar", entry.toCSVString()); }