### Question:
DriverRepository implements DriverFactory { @Override public <T> SourceDriver<T> createSource(ProcessScript<T> script) throws IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); } String name = script.getSourceScript().getResourceName(); ResourceMirror resource = resources.get(name); if (resource == null) { WGLOG.error("E04001", script.getName(), name); throw new IOException(MessageFormat.format( "Resource \"{0}\" is not defined (source of \"{1}\")", name, script.getName())); } return resource.createSource(script); } DriverRepository(Iterable<? extends ResourceMirror> resources); @Override SourceDriver<T> createSource(ProcessScript<T> script); @Override DrainDriver<T> createDrain(ProcessScript<T> script);  }### Answer:
@Test public void createSource() throws Exception { DriverRepository repo = new DriverRepository(Arrays.asList(new MockResourceMirror("test1"))); ProcessScript<String> script = new ProcessScript<>( "testing", "simple", String.class, driver("test1"), driver("test2")); SourceDriver<String> source = repo.createSource(script); assertThat(source, is(instanceOf(MockSourceDriver.class))); MockSourceDriver<String> mock = (MockSourceDriver<String>) source; assertThat(mock.name, is("test1")); }
@Test(expected = IOException.class) public void createSource_missing() throws Exception { DriverRepository repo = new DriverRepository(Arrays.asList(new MockResourceMirror("test"))); ProcessScript<String> script = new ProcessScript<>( "testing", "simple", String.class, driver("MISSING"), driver("test")); repo.createSource(script); }