@Test void verifyBasicGenerationCase() { final String sourceCode = new CloudEventsResourceGenerator(Collections.emptyList()).generate(); assertNotNull(sourceCode); final CompilationUnit clazz = StaticJavaParser.parse(sourceCode); assertNotNull(clazz); assertThat(clazz.getChildNodes()).isNotEmpty(); assertThat(clazz.getImports()).contains( new ImportDeclaration("org.kie.kogito.events.knative.ce.Printer", false, false)); }
public String generate() { final CompilationUnit clazz = this.parseTemplate(); final ClassOrInterfaceDeclaration template = clazz .findFirst(ClassOrInterfaceDeclaration.class) .orElseThrow(() -> new NoSuchElementException("Compilation unit doesn't contain a class or interface declaration!")); template.setName(CLASS_NAME); this.addChannels(template); this.addInjection(template); template.getMembers().sort(new BodyDeclarationComparator()); return clazz.toString(); }
CloudEventsResourceGenerator { public String generate() { final CompilationUnit clazz = this.parseTemplate(); final ClassOrInterfaceDeclaration template = clazz .findFirst(ClassOrInterfaceDeclaration.class) .orElseThrow(() -> new NoSuchElementException("Compilation unit doesn't contain a class or interface declaration!")); template.setName(CLASS_NAME); this.addChannels(template); this.addInjection(template); template.getMembers().sort(new BodyDeclarationComparator()); return clazz.toString(); } }
CloudEventsResourceGenerator { public String generate() { final CompilationUnit clazz = this.parseTemplate(); final ClassOrInterfaceDeclaration template = clazz .findFirst(ClassOrInterfaceDeclaration.class) .orElseThrow(() -> new NoSuchElementException("Compilation unit doesn't contain a class or interface declaration!")); template.setName(CLASS_NAME); this.addChannels(template); this.addInjection(template); template.getMembers().sort(new BodyDeclarationComparator()); return clazz.toString(); } CloudEventsResourceGenerator(final List<ProcessExecutableModelGenerator> generators, final DependencyInjectionAnnotator annotator);   CloudEventsResourceGenerator(final List<ProcessExecutableModelGenerator> generators); }
CloudEventsResourceGenerator { public String generate() { final CompilationUnit clazz = this.parseTemplate(); final ClassOrInterfaceDeclaration template = clazz .findFirst(ClassOrInterfaceDeclaration.class) .orElseThrow(() -> new NoSuchElementException("Compilation unit doesn't contain a class or interface declaration!")); template.setName(CLASS_NAME); this.addChannels(template); this.addInjection(template); template.getMembers().sort(new BodyDeclarationComparator()); return clazz.toString(); } CloudEventsResourceGenerator(final List<ProcessExecutableModelGenerator> generators, final DependencyInjectionAnnotator annotator);   CloudEventsResourceGenerator(final List<ProcessExecutableModelGenerator> generators); String generatedFilePath(); String generate(); }
CloudEventsResourceGenerator { public String generate() { final CompilationUnit clazz = this.parseTemplate(); final ClassOrInterfaceDeclaration template = clazz .findFirst(ClassOrInterfaceDeclaration.class) .orElseThrow(() -> new NoSuchElementException("Compilation unit doesn't contain a class or interface declaration!")); template.setName(CLASS_NAME); this.addChannels(template); this.addInjection(template); template.getMembers().sort(new BodyDeclarationComparator()); return clazz.toString(); } CloudEventsResourceGenerator(final List<ProcessExecutableModelGenerator> generators, final DependencyInjectionAnnotator annotator);   CloudEventsResourceGenerator(final List<ProcessExecutableModelGenerator> generators); String generatedFilePath(); String generate();  }