### Question:
FileResourceMirror extends ResourceMirror { @Override public void prepare(GateScript script) throws IOException { if (script == null) { throw new IllegalArgumentException("script must not be null"); } LOG.debug("Preparing file resource: {}", getName()); for (ProcessScript<?> process : script.getProcesses()) { if (process.getSourceScript().getResourceName().equals(getName())) { FileResourceUtil.getPath(profile, process, arguments, DriverScript.Kind.SOURCE); FileResourceUtil.loadSupport(profile, process, DriverScript.Kind.SOURCE); ProcessUtil.newDataModel(profile.getResourceName(), process); } if (process.getDrainScript().getResourceName().equals(getName())) { FileResourceUtil.getPath(profile, process, arguments, DriverScript.Kind.DRAIN); FileResourceUtil.loadSupport(profile, process, DriverScript.Kind.DRAIN); } } } FileResourceMirror(FileProfile profile, ParameterList arguments); @Override String getName(); @Override void prepare(GateScript script); @Override SourceDriver<T> createSource(ProcessScript<T> script); @Override DrainDriver<T> createDrain(ProcessScript<T> script); @Override void close();  }### Answer:
@Test public void prepare() throws Exception { try (FileResourceMirror resource = new FileResourceMirror(profile(), new ParameterList())) { ProcessScript<StringBuilder> a = process("a", driver("source"), dummy()); ProcessScript<StringBuilder> b = process("b", dummy(), driver("drain")); GateScript gate = script(a, b); resource.prepare(gate); } }
@Test(expected = IOException.class) public void prepare_invalid_variable() throws Exception { try (FileResourceMirror resource = new FileResourceMirror(profile(), new ParameterList())) { ProcessScript<StringBuilder> a = process("a", driver("${invalid_var}"), dummy()); ProcessScript<StringBuilder> b = process("b", dummy(), driver("drain")); GateScript gate = script(a, b); resource.prepare(gate); fail(); } }
@Test(expected = IOException.class) public void prepare_invalid_source() throws Exception { Map<String, String> conf = new HashMap<>(); DriverScript driverScript = new DriverScript("file", conf); try (FileResourceMirror resource = new FileResourceMirror(profile(), new ParameterList())) { ProcessScript<StringBuilder> a = process("a", driverScript, dummy()); ProcessScript<StringBuilder> b = process("b", dummy(), driver("drain")); GateScript gate = script(a, b); resource.prepare(gate); fail(); } }
@Test(expected = IOException.class) public void prepare_invalid_drain() throws Exception { Map<String, String> conf = new HashMap<>(); DriverScript driverScript = new DriverScript("file", conf); try (FileResourceMirror resource = new FileResourceMirror(profile(), new ParameterList())) { ProcessScript<StringBuilder> a = process("a", driver("source"), dummy()); ProcessScript<StringBuilder> b = process("b", dummy(), driverScript); GateScript gate = script(a, b); resource.prepare(gate); fail(); } }