package be.raildelays.batch.processor;

import be.raildelays.batch.bean.BatchExcelRow;
import be.raildelays.domain.Sens;
import be.raildelays.domain.xls.ExcelRow;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner;

import java.time.Instant;
import java.util.Date;

@RunWith(BlockJUnit4ClassRunner.class)
public class SplitExcelSheetProcessorTest {

    private static Date THRESHOLD_DATE = Date.from(Instant.parse("2014-02-18T00:00:00.00Z"));
    private SplitExcelSheetProcessor processor;

    @Before
    public void setUp() {
        processor = new SplitExcelSheetProcessor();
        processor.setThresholdDate(THRESHOLD_DATE);
    }

    @Test
    public void testFiltered() throws Exception {
        BatchExcelRow item = new BatchExcelRow
                .Builder(Date.from(Instant.parse("2014-01-01T00:00:00.00Z")), Sens.DEPARTURE)
                .build(false);
        ExcelRow result = processor.process(item);

        Assert.assertNull(result);
    }

    @Test
    public void testNotFiltered() throws Exception {
        BatchExcelRow item = new BatchExcelRow
                .Builder(Date.from(Instant.parse("2014-12-31T00:00:00.00Z")), Sens.DEPARTURE)
                .build(false);
        ExcelRow result = processor.process(item);

        Assert.assertNotNull(result);
    }

}

@@ -768,32 +768,38 @@
 oid testFiltered
+Before
 () throws Except
@@ -796,32 +796,1719 @@
 ows Exception %7B%0A
+        processor.setMode(SplitExcelSheetProcessor.Mode.BEFORE);%0A%0A        BatchExcelRow item = new BatchExcelRow%0A                .Builder(Date.from(Instant.parse(%222014-12-31T00:00:00.00Z%22)), Sens.DEPARTURE)%0A                .build(false);%0A        ExcelRow result = processor.process(item);%0A%0A        Assert.assertNull(result);%0A    %7D%0A%0A    @Test%0A    public void testNotFilteredBefore() throws Exception %7B%0A        processor.setMode(SplitExcelSheetProcessor.Mode.BEFORE);%0A%0A        BatchExcelRow item = new BatchExcelRow%0A                .Builder(Date.from(Instant.parse(%222014-01-01T00:00:00.00Z%22)), Sens.DEPARTURE)%0A                .build(false);%0A        ExcelRow result = processor.process(item);%0A%0A        Assert.assertNotNull(result);%0A    %7D%0A%0A    @Test%0A    public void testNotFilteredEquals() throws Exception %7B%0A        processor.setMode(SplitExcelSheetProcessor.Mode.BEFORE);%0A%0A        BatchExcelRow item = new BatchExcelRow%0A                .Builder(Date.from(Instant.parse(%222014-01-18T00:00:00.00Z%22)), Sens.DEPARTURE)%0A                .build(false);%0A        ExcelRow result = processor.process(item);%0A%0A        Assert.assertNotNull(result);%0A    %7D%0A%0A    @Test%0A    public void testFilteredEquals() throws Exception %7B%0A        processor.setMode(SplitExcelSheetProcessor.Mode.AFTER_OR_EQUALS);%0A%0A        BatchExcelRow item = new BatchExcelRow%0A                .Builder(Date.from(Instant.parse(%222014-01-18T00:00:00.00Z%22)), Sens.DEPARTURE)%0A                .build(false);%0A        ExcelRow result = processor.process(item);%0A%0A        Assert.assertNull(result);%0A    %7D%0A%0A    @Test%0A    public void testFilteredAfter() throws Exception %7B%0A        processor.setMode(SplitExcelSheetProcessor.Mode.AFTER_OR_EQUALS);%0A%0A
         BatchExc
@@ -2798,16 +2798,21 @@
 Filtered
+After
 () throw
@@ -2817,32 +2817,107 @@
 ows Exception %7B%0A
+        processor.setMode(SplitExcelSheetProcessor.Mode.AFTER_OR_EQUALS);%0A%0A
         BatchExc

Split before / split after a threshold date