RequirementProcessor { public static void handle( BackendRdfSource definition, String graph, ResourceManager resourceManager) throws LpException { List<Map<String, String>> working; List<Map<String, String>> input; try { working = RdfUtils.sparqlSelect(definition, getWorkingDirectoryQuery(graph)); input = RdfUtils.sparqlSelect(definition, getInputDirectoryQuery(graph)); } catch (RdfUtilsException ex) { throw new LpException("Can't query requirements.", ex); } try { RdfBuilder builder = RdfBuilder.create(definition, graph); for (Map<String, String> entry : working) { String iri = entry.get("s"); String id = iri.substring(iri.lastIndexOf("/") + 1) .toLowerCase(); File file = resourceManager.getWorkingDirectory("working-" + id); builder.entity(iri).iri(LP_EXEC.HAS_WORKING_DIRECTORY, file.toURI().toString()); } File inputDirectory = resourceManager.getInputDirectory(); for (Map<String, String> entry : input) { final String iri = entry.get("s"); builder.entity(iri).iri(LP_EXEC.HAS_INPUT_DIRECTORY, inputDirectory.toURI().toString()); } builder.commit(); } catch (RdfUtilsException ex) { throw new LpException("Can't create save RDF.", ex); } } private  RequirementProcessor(); static void handle(
            BackendRdfSource definition, String graph,
            ResourceManager resourceManager);  }
@Test public void workingAndInputDirectory() throws Exception { ClosableRdfSource source = Rdf4jSource.createInMemory(); RdfBuilder builder = RdfBuilder.create( source, "http: ResourceManager manager = Mockito.mock(ResourceManager.class); File workingFile = File.createTempFile("lp-test", ""); File inputFile = File.createTempFile("lp-test", ""); Mockito.when(manager.getInputDirectory()).thenReturn(inputFile); Mockito.when(manager.getWorkingDirectory(Mockito.anyString())) .thenReturn(workingFile); builder.entity("http: LP_PIPELINE.WORKING_DIRECTORY); builder.entity("http: LP_PIPELINE.INPUT_DIRECTORY); builder.commit(); RequirementProcessor.handle(source, "http: String working = RdfUtils.sparqlSelectSingle(source, "SELECT ?v WHERE { GRAPH <http: + " ?s <" + LP_EXEC.HAS_WORKING_DIRECTORY + "> ?v " + " }}", "v"); Assert.assertEquals(workingFile, new File(URI.create(working))); String input = RdfUtils.sparqlSelectSingle(source, "SELECT ?v WHERE { GRAPH <http: + " ?s <" + LP_EXEC.HAS_INPUT_DIRECTORY + "> ?v " + " }}", "v"); Assert.assertEquals(inputFile, new File(URI.create(input))); source.close(); }