SvgTagProcessor implements XmlEventProcessor { @Override public ImmutableList<XMLEvent> process(String id, XMLEvent event) { Preconditions.checkNotNull(id); if (event.isStartElement()) { return ImmutableList.of(embeddedSvgStartElement(id)); } else if (event.isEndElement()) { return ImmutableList.of(embeddedSvgEndElement()); } else { throw new IllegalArgumentException("Event must be start or end element."); } }  @Override boolean accepts(XMLEvent event); @Override ImmutableList<XMLEvent> process(String id, XMLEvent event);  }
@Test public void processesStartElement() { test.given(eventIsStartElement("svg")) .when(process()) .then(resultContainsSvgStartElement()); }
@Test public void processEndElement() { test.given(eventIsEndElement("svg")) .when(process()) .then(resultContainsSvgEndElement()); }
@Test(expected = IllegalArgumentException.class) public void failsToProcessNonStartOrEndElement() { test.given(eventIsNotStartElement()) .given(eventIsNotEndElement()) .when(process()); }