Builder { public BuildDetails build(final String resourcePath) { final Resource resource = resourceManager.getResource(resourcePath); logger.trace("{}: {}", resourcePath, resource); final Concatenator concatenator = new Concatenator(resourceManager); final Optional<BuildResource> buildResource = ofNullable(resource.adapt(BuildResource.class)); final Optional<TestResource> testResource = ofNullable(resource.adapt(TestResource.class)); if (buildResource.isPresent()) { logger.trace("Build to target"); return concatenator.visit(buildResource.get()); } else if (testResource.isPresent()) { logger.trace("Build to test"); return concatenator.visit(testResource.get()); } return new BuildDetails(); } Builder(final ResourceManager resourceManager); BuildDetails build(final String resourcePath);  }
@Test public void testBuild() { final String resourcePath = randomUUID().toString(); when(resourceManager.getResource(resourcePath)).thenReturn(resource); final Builder builder = new Builder(resourceManager); builder.build(resourcePath); }