### Question:
CodeBasePublisherFactoryImpl implements CodeBasePublisherFactory { @Override public CodeBasePublisher create(String name, AgentConfig config) { if (name.equals(NoOpCodeBasePublisherImpl.NAME)) { return new NoOpCodeBasePublisherImpl(config); } if (name.equals(HttpCodeBasePublisherImpl.NAME)) { return new HttpCodeBasePublisherImpl(config); } logger.warning( String.format( "Unrecognized code base publisher name: '%s', will use %s", name, NoOpCodeBasePublisherImpl.NAME)); return new NoOpCodeBasePublisherImpl(config); }  @Override CodeBasePublisher create(String name, AgentConfig config);  }### Answer:
@Test public void should_handle_noop_name() throws Exception { CodeBasePublisher publisher = factory.create(NoOpCodeBasePublisherImpl.NAME, config); assertThat(publisher, instanceOf(NoOpCodeBasePublisherImpl.class)); output.expect(is("")); }
@Test public void should_warn_when_unrecognized_name() throws Exception { CodeBasePublisher publisher = factory.create("foobar", config); assertThat(publisher, instanceOf(NoOpCodeBasePublisherImpl.class)); output.expect(containsString("[WARNING]")); output.expect( containsString("Unrecognized code base publisher name: 'foobar', will use no-op")); }