### Question:
EventProcessorMapping implements BiFunction<String, Collection<ClientProcessor>, EventProcessor> { @Override public EventProcessor apply(String name, Collection<ClientProcessor> clientProcessors) { String mode = modeOf(clientProcessors); if ("Tracking".equals(mode)) { return new TrackingProcessor(name, mode, clientProcessors); } else { return new GenericProcessor(name, mode, clientProcessors); } }  @Override EventProcessor apply(String name, Collection<ClientProcessor> clientProcessors);  }### Answer:
@Test public void testTracking(){ ClientProcessor clientProcessor = new FakeClientProcessor("clientId", true, EventProcessorInfo.newBuilder().setMode("Tracking") .build()); EventProcessor processor = processorMapping.apply("processorName", asList(clientProcessor, clientProcessor)); assertTrue(processor instanceof TrackingProcessor); }
@Test public void testGeneric() { ClientProcessor clientProcessor = new FakeClientProcessor("clientId", true, EventProcessorInfo.newBuilder().setMode("Subscribing") .build()); EventProcessor processor = processorMapping.apply("processorName", asList(clientProcessor, clientProcessor)); assertTrue(processor instanceof GenericProcessor); assertEquals("Subscribing", processor.mode()); }
@Test public void testMixed() { ClientProcessor tracking = new FakeClientProcessor("clientId", true, EventProcessorInfo.newBuilder().setMode("Tracking").build()); ClientProcessor subscribing = new FakeClientProcessor("clientId", true, EventProcessorInfo.newBuilder().setMode("Subscribing") .build()); EventProcessor processor = processorMapping.apply("processorName", asList(tracking, subscribing)); assertTrue(processor instanceof GenericProcessor); assertNotEquals("Tracking", processor.mode()); assertNotEquals("Subscribing", processor.mode()); }