@Test public void testVisit() { final ProjectFile projectFile = new ProjectFile(); projectFile.setName("test/test"); projectFile.setSource("source.lua"); projectFile.setTarget("target.lua"); final Project project = new Project(".", projectFile); final String base = "/" + getClass().getName().replace('.', '/') + "/case1/"; final ResourceManager resourceManager = new ResourceManagerMock( project, dir( ".", file("aergo.json", () -> open(base + "aergo.json")), file("source.lua", () -> open(base + "source.lua")), dir("subdir", file("ref1.lua", () -> open(base + "subdir/ref1.lua")), file("ref2.lua", () -> open(base + "subdir/ref2.lua")) ) ) ); final Concatenator concatenator = new Concatenator(resourceManager); final BuildDetails buildDetails = concatenator.visit(new BuildResource(project, "target.lua")); logger.debug("Build result: {}", buildDetails.getResult()); final String result = buildDetails.getResult(); final String fingerprint1 = "ref1fingerprint"; final String fingerprint2 = "ref2fingerprint"; assertEquals(1, (result.length() - result.replace(fingerprint1, "").length()) / fingerprint1.length()); assertEquals(1, (result.length() - result.replace(fingerprint2, "").length()) / fingerprint2.length()); assertTrue(result.contains("world")); }
protected String visit(final Source source) { if (visitedResources.contains(source)) { return null; } try { return source.getBody().get(); } catch (final BuildException e) { throw e; } catch (final FileNotFoundException | NoSuchFileException ex) { throw new BuildException("<green>" + getCanonicalForm(source.getPath().toFile().getAbsolutePath()) + "</green> not found"); } catch (final Throwable e) { throw new BuildException(e); } }
Concatenator { protected String visit(final Source source) { if (visitedResources.contains(source)) { return null; } try { return source.getBody().get(); } catch (final BuildException e) { throw e; } catch (final FileNotFoundException | NoSuchFileException ex) { throw new BuildException("<green>" + getCanonicalForm(source.getPath().toFile().getAbsolutePath()) + "</green> not found"); } catch (final Throwable e) { throw new BuildException(e); } } }
Concatenator { protected String visit(final Source source) { if (visitedResources.contains(source)) { return null; } try { return source.getBody().get(); } catch (final BuildException e) { throw e; } catch (final FileNotFoundException | NoSuchFileException ex) { throw new BuildException("<green>" + getCanonicalForm(source.getPath().toFile().getAbsolutePath()) + "</green> not found"); } catch (final Throwable e) { throw new BuildException(e); } } Concatenator(final ResourceManager resourceManager); }
Concatenator { protected String visit(final Source source) { if (visitedResources.contains(source)) { return null; } try { return source.getBody().get(); } catch (final BuildException e) { throw e; } catch (final FileNotFoundException | NoSuchFileException ex) { throw new BuildException("<green>" + getCanonicalForm(source.getPath().toFile().getAbsolutePath()) + "</green> not found"); } catch (final Throwable e) { throw new BuildException(e); } } Concatenator(final ResourceManager resourceManager); BuildDetails visit(final Resource resource); String visit(final Resource resource, final BuildDependency resourceDependency); }
Concatenator { protected String visit(final Source source) { if (visitedResources.contains(source)) { return null; } try { return source.getBody().get(); } catch (final BuildException e) { throw e; } catch (final FileNotFoundException | NoSuchFileException ex) { throw new BuildException("<green>" + getCanonicalForm(source.getPath().toFile().getAbsolutePath()) + "</green> not found"); } catch (final Throwable e) { throw new BuildException(e); } } Concatenator(final ResourceManager resourceManager); BuildDetails visit(final Resource resource); String visit(final Resource resource, final BuildDependency resourceDependency);  }