use of io.automatiko.engine.codegen.GeneratedFile in project automatiko-engine by automatiko-io.
the class PersistenceGenerator method dbBasedPersistence.
protected void dbBasedPersistence(List<GeneratedFile> generatedFiles) {
ClassOrInterfaceDeclaration persistenceProviderClazz = new ClassOrInterfaceDeclaration().setName("ProcessInstancesFactoryImpl").setModifiers(Modifier.Keyword.PUBLIC).addExtendedType("io.automatiko.engine.addons.persistence.AbstractProcessInstancesFactory");
CompilationUnit compilationUnit = new CompilationUnit("io.automatiko.engine.addons.persistence.impl");
compilationUnit.getTypes().add(persistenceProviderClazz);
if (useInjection()) {
annotator.withApplicationComponent(persistenceProviderClazz);
addCodecComponents(persistenceProviderClazz);
}
String packageName = compilationUnit.getPackageDeclaration().map(pd -> pd.getName().toString()).orElse("");
String clazzName = packageName + "." + persistenceProviderClazz.findFirst(ClassOrInterfaceDeclaration.class).map(c -> c.getName().toString()).get();
generatedFiles.add(new GeneratedFile(GeneratedFile.Type.CLASS, clazzName.replace('.', '/') + ".java", compilationUnit.toString().getBytes(StandardCharsets.UTF_8)));
persistenceProviderClazz.getMembers().sort(new BodyDeclarationComparator());
}
use of io.automatiko.engine.codegen.GeneratedFile in project automatiko-engine by automatiko-io.
the class JsonSchemaGeneratorTest method testJsonSchemaGenerator.
@Test
public void testJsonSchemaGenerator() throws IOException {
Collection<GeneratedFile> files = new JsonSchemaGenerator.Builder(Stream.of(PersonInputParams.class, PersonOutputParams.class, IgnoredClass.class)).build().generate();
assertEquals(1, files.size());
GeneratedFile file = files.iterator().next();
assertEquals("test_test.json", file.relativePath());
assertSchema(file, SchemaVersion.DRAFT_7);
}
Aggregations