CapabilityProcessorFactory { public CapabilityProcessor getProcessor(JsonCapabilities caps) { return processors.stream() .filter(p -> p.accept(caps)) .findFirst() .orElse(new DummyCapabilityProcessor()); }  CapabilityProcessor getProcessor(JsonCapabilities caps);  }
@Test public void testGetIEProcessor() throws Exception { JsonCapabilities ieCaps = buildJsonCapabilities(internetExplorer()); assertThat(factory.getProcessor(ieCaps), is(instanceOf(IECapabilityProcessor.class))); }
@Test public void testGetDummyProcessor() throws Exception { JsonCapabilities firefoxCaps = buildJsonCapabilities(firefox()); assertThat(factory.getProcessor(firefoxCaps), is(instanceOf(DummyCapabilityProcessor.class))); }