@Test public void filterFormatterShouldNotClearExampleTags() { FilterFormatter filterFormatter = new FilterFormatter(mock(Formatter.class), Arrays.asList("@filter")); final ArrayList<Tag> originalTags = new ArrayList<Tag>(); originalTags.add(new Tag("@tag", 0)); Examples examples1 = new Examples(Collections.EMPTY_LIST, new ArrayList<Tag>(originalTags), "keyword1", "name1", "description1", 0, "id1", Collections.EMPTY_LIST); Examples examples2 = new Examples(Collections.EMPTY_LIST, new ArrayList<Tag>(originalTags), "keyword2", "name2", "description2", 0, "id2", Collections.EMPTY_LIST); filterFormatter.examples(examples1); filterFormatter.examples(examples2); assertEquals("Example tags should not be modified", originalTags, examples1.getTags()); assertEquals("Example tags should not be modified", originalTags, examples2.getTags()); }
@Override public void examples(Examples examples) { replay(); examplesTags.addAll(examples.getTags()); examplesName = examples.getName(); Range tableBodyRange; switch (examples.getRows().size()) { case 0: tableBodyRange = new Range(examples.getLineRange().getLast(), examples.getLineRange().getLast()); break; case 1: tableBodyRange = new Range(examples.getRows().get(0).getLine(), examples.getRows().get(0).getLine()); break; default: tableBodyRange = new Range(examples.getRows().get(1).getLine(), examples.getRows().get(examples.getRows().size() - 1).getLine()); } examplesRange = new Range(examples.getLineRange().getFirst(), tableBodyRange.getLast()); if (filter.evaluate(Collections.<Tag>emptyList(), Collections.<String>emptyList(), Collections.singletonList(tableBodyRange))) { examples.setRows(filter.filterTableBodyRows(examples.getRows())); } examplesEvents = new ArrayList<BasicStatement>(); examplesEvents.add(examples); }
FilterFormatter implements Formatter { @Override public void examples(Examples examples) { replay(); examplesTags.addAll(examples.getTags()); examplesName = examples.getName(); Range tableBodyRange; switch (examples.getRows().size()) { case 0: tableBodyRange = new Range(examples.getLineRange().getLast(), examples.getLineRange().getLast()); break; case 1: tableBodyRange = new Range(examples.getRows().get(0).getLine(), examples.getRows().get(0).getLine()); break; default: tableBodyRange = new Range(examples.getRows().get(1).getLine(), examples.getRows().get(examples.getRows().size() - 1).getLine()); } examplesRange = new Range(examples.getLineRange().getFirst(), tableBodyRange.getLast()); if (filter.evaluate(Collections.<Tag>emptyList(), Collections.<String>emptyList(), Collections.singletonList(tableBodyRange))) { examples.setRows(filter.filterTableBodyRows(examples.getRows())); } examplesEvents = new ArrayList<BasicStatement>(); examplesEvents.add(examples); } }
FilterFormatter implements Formatter { @Override public void examples(Examples examples) { replay(); examplesTags.addAll(examples.getTags()); examplesName = examples.getName(); Range tableBodyRange; switch (examples.getRows().size()) { case 0: tableBodyRange = new Range(examples.getLineRange().getLast(), examples.getLineRange().getLast()); break; case 1: tableBodyRange = new Range(examples.getRows().get(0).getLine(), examples.getRows().get(0).getLine()); break; default: tableBodyRange = new Range(examples.getRows().get(1).getLine(), examples.getRows().get(examples.getRows().size() - 1).getLine()); } examplesRange = new Range(examples.getLineRange().getFirst(), tableBodyRange.getLast()); if (filter.evaluate(Collections.<Tag>emptyList(), Collections.<String>emptyList(), Collections.singletonList(tableBodyRange))) { examples.setRows(filter.filterTableBodyRows(examples.getRows())); } examplesEvents = new ArrayList<BasicStatement>(); examplesEvents.add(examples); } FilterFormatter(Formatter formatter, List filters); }
FilterFormatter implements Formatter { @Override public void examples(Examples examples) { replay(); examplesTags.addAll(examples.getTags()); examplesName = examples.getName(); Range tableBodyRange; switch (examples.getRows().size()) { case 0: tableBodyRange = new Range(examples.getLineRange().getLast(), examples.getLineRange().getLast()); break; case 1: tableBodyRange = new Range(examples.getRows().get(0).getLine(), examples.getRows().get(0).getLine()); break; default: tableBodyRange = new Range(examples.getRows().get(1).getLine(), examples.getRows().get(examples.getRows().size() - 1).getLine()); } examplesRange = new Range(examples.getLineRange().getFirst(), tableBodyRange.getLast()); if (filter.evaluate(Collections.<Tag>emptyList(), Collections.<String>emptyList(), Collections.singletonList(tableBodyRange))) { examples.setRows(filter.filterTableBodyRows(examples.getRows())); } examplesEvents = new ArrayList<BasicStatement>(); examplesEvents.add(examples); } FilterFormatter(Formatter formatter, List filters); @Override void uri(String uri); @Override void feature(Feature feature); @Override void background(Background background); @Override void scenario(Scenario scenario); @Override void scenarioOutline(ScenarioOutline scenarioOutline); @Override void examples(Examples examples); @Override void step(Step step); void table(List<Row> table); @Override void eof(); @Override void syntaxError(String state, String event, List<String> legalEvents, String uri, Integer line); @Override void done(); @Override void close(); @Override void startOfScenarioLifeCycle(Scenario scenario); @Override void endOfScenarioLifeCycle(Scenario scenario); }
FilterFormatter implements Formatter { @Override public void examples(Examples examples) { replay(); examplesTags.addAll(examples.getTags()); examplesName = examples.getName(); Range tableBodyRange; switch (examples.getRows().size()) { case 0: tableBodyRange = new Range(examples.getLineRange().getLast(), examples.getLineRange().getLast()); break; case 1: tableBodyRange = new Range(examples.getRows().get(0).getLine(), examples.getRows().get(0).getLine()); break; default: tableBodyRange = new Range(examples.getRows().get(1).getLine(), examples.getRows().get(examples.getRows().size() - 1).getLine()); } examplesRange = new Range(examples.getLineRange().getFirst(), tableBodyRange.getLast()); if (filter.evaluate(Collections.<Tag>emptyList(), Collections.<String>emptyList(), Collections.singletonList(tableBodyRange))) { examples.setRows(filter.filterTableBodyRows(examples.getRows())); } examplesEvents = new ArrayList<BasicStatement>(); examplesEvents.add(examples); } FilterFormatter(Formatter formatter, List filters); @Override void uri(String uri); @Override void feature(Feature feature); @Override void background(Background background); @Override void scenario(Scenario scenario); @Override void scenarioOutline(ScenarioOutline scenarioOutline); @Override void examples(Examples examples); @Override void step(Step step); void table(List<Row> table); @Override void eof(); @Override void syntaxError(String state, String event, List<String> legalEvents, String uri, Integer line); @Override void done(); @Override void close(); @Override void startOfScenarioLifeCycle(Scenario scenario); @Override void endOfScenarioLifeCycle(Scenario scenario);  }