WidgetDirectiveBuilder extends AbstractLiveFileBuilder { @Override public void build(Path jsonPath) throws IOException { Widget widget = widgetLoader.get(jsonPath); write( get(valueOf(jsonPath).replace(".json", ".js")), htmlBuilder .with("escapedTemplate", htmlSanitizer.escapeSingleQuotesAndNewLines(widget.getTemplate())) .build(widget).getBytes(StandardCharsets.UTF_8)); } @Inject  WidgetDirectiveBuilder(Watcher watcher, WidgetFileBasedLoader widgetLoader, HtmlSanitizer htmlSanitizer); @Override void build(Path jsonPath); @Override boolean isBuildable(String path);  }
@Test public void should_build_directive_even_if_it_already_exist() throws Exception { writeDirective("pbInput", "previous content".getBytes()); widgetDirectiveBuilder.build(resolve("pbInput/pbInput.json")); assertThat(readDirective("pbInput")).isEqualTo(generateDirective(pbInput)); }