DefaultNetworkResponseParserFactory { public static void addSimpleXmlParserIfPresent(IntegratedNetworkResponseParser.Builder builder) { if(ClassUtils.isPresent(SIMPLE_XML_CLASS_NAME)) { builder.addParser(new SimpleXmlNetworkResponseParser()); } }  static NetworkResponseParser create(); static void addJacksonParserIfPresent(IntegratedNetworkResponseParser.Builder builder); static void addSimpleXmlParserIfPresent(IntegratedNetworkResponseParser.Builder builder);  }
@Test public void shouldAddSimpleXmlNetworkResponseParserIfPresent() { given(ClassUtils.isPresent(SIMPLE_XML_CLASS_NAME)).willReturn(true); Matcher<TypedNetworkResponseParser> matcher = argMatcher(new PlainMatcher(){ @Override public boolean matches(Object item) { if (item instanceof SimpleXmlNetworkResponseParser) { return true; } return false; }}); DefaultNetworkResponseParserFactory.addSimpleXmlParserIfPresent(builder); verify(builder).addParser(Matchers.argThat(matcher)); }
@Test public void shouldNotAddSimpleXmlNetworkResponseParserIfNotPresent() { given(ClassUtils.isPresent(SIMPLE_XML_CLASS_NAME)).willReturn(false); Matcher<TypedNetworkResponseParser> matcher = argMatcher(new PlainMatcher(){ @Override public boolean matches(Object item) { if (item instanceof SimpleXmlNetworkResponseParser) { return true; } return false; }}); DefaultNetworkResponseParserFactory.addSimpleXmlParserIfPresent(builder); verify(builder, never()).addParser(Matchers.argThat(matcher)); }