ApplicationGenerator { public GeneratedFile generateApplicationDescriptor() { List<String> sections = generators.stream() .map(Generator::section) .filter(Objects::nonNull) .map(ApplicationSection::sectionClassName) .collect(Collectors.toList()); applicationMainGenerator.withSections(sections); CompilationUnit compilationUnit = applicationMainGenerator.getCompilationUnitOrThrow(); return new GeneratedFile(GeneratedFile.Type.APPLICATION, applicationMainGenerator.generatedFilePath(), log(compilationUnit.toString()).getBytes(StandardCharsets.UTF_8)); } ApplicationGenerator(String packageName, File targetDirectory); String targetCanonicalName(); ApplicationGenerator withDependencyInjection(DependencyInjectionAnnotator annotator); ApplicationGenerator withGeneratorContext(GeneratorContext context); ApplicationGenerator withRuleUnits(boolean hasRuleUnits); ApplicationGenerator withAddons(AddonsConfig addonsConfig); Collection<GeneratedFile> generate(); List<GeneratedFile> generateComponents(); GeneratedFile generateApplicationDescriptor(); G withGenerator(G generator); static String log(String source); static void log(byte[] source); ApplicationGenerator withClassLoader(ClassLoader classLoader); static final Logger logger; static final String DEFAULT_GROUP_ID; static final String DEFAULT_PACKAGE_NAME; static final String APPLICATION_CLASS_NAME; }
@Test public void generatedFilePath() { final ApplicationGenerator appGenerator = new ApplicationGenerator(PACKAGE_NAME, new File("")); String path = appGenerator.generateApplicationDescriptor().relativePath(); assertThat(path).isNotNull(); assertThat(path).isEqualTo(EXPECTED_APPLICATION_NAME.replace(".", "/") + ".java"); }