Skip to content

Commit cf9681e

Browse files
authored
Merge pull request #835 from janpk/feature/kotlin-code-starter
Add Kotlin code starters
2 parents 367b77c + 67efc3a commit cf9681e

File tree

8 files changed

+177
-0
lines changed

8 files changed

+177
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package org.acme
2+
3+
import com.github.rvesse.airline.annotations.Arguments
4+
import com.github.rvesse.airline.annotations.Cli
5+
import com.github.rvesse.airline.annotations.Command
6+
import io.quarkiverse.githubapp.command.airline.AbstractHelpCommand
7+
import java.io.IOException
8+
import org.kohsuke.github.GHEventPayload
9+
10+
// TODO: make sure you adjust the name as @bot is an actual GitHub user
11+
@Cli(
12+
name = "@bot",
13+
commands = [MyGitHubBot.SayHello::class, MyGitHubBot.Help::class],
14+
description = "A friendly bot",
15+
)
16+
class MyGitHubBot {
17+
18+
interface Commands {
19+
@Throws(IOException::class)
20+
fun run(issueCommentPayload: GHEventPayload.IssueComment)
21+
}
22+
23+
@Command(name = "say-hello", description = "Says hello")
24+
class SayHello : Commands {
25+
26+
@Arguments var arguments: MutableList<String> = arrayListOf()
27+
28+
@Throws(IOException::class)
29+
override fun run(issueCommentPayload: GHEventPayload.IssueComment) {
30+
issueCommentPayload.issue.comment(":wave: Hello " + arguments.joinToString(" "))
31+
}
32+
}
33+
34+
@Command(name = "help", description = "Displays help")
35+
class Help : AbstractHelpCommand(), Commands {
36+
@Throws(IOException::class)
37+
override fun run(issueCommentPayload: GHEventPayload.IssueComment) {
38+
super.run(issueCommentPayload)
39+
}
40+
}
41+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package io.quarkiverse.githubapp.it.app;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.junit.jupiter.api.extension.RegisterExtension;
5+
6+
import io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog.Language;
7+
import io.quarkus.devtools.commands.CreateProject.CreateProjectKey;
8+
import io.quarkus.devtools.testing.codestarts.QuarkusCodestartTest;
9+
10+
public class CodestartKotlinTest {
11+
@RegisterExtension
12+
public static QuarkusCodestartTest codestartKotlinTest = QuarkusCodestartTest.builder()
13+
.languages(Language.KOTLIN)
14+
.setupStandaloneExtensionTest("io.quarkiverse.githubapp:quarkus-github-app")
15+
.putData(CreateProjectKey.PROJECT_NAME, "My GitHub App")
16+
.putData(CreateProjectKey.PROJECT_DESCRIPTION, "My GitHub App description")
17+
.build();
18+
19+
@Test
20+
void testContent() throws Throwable {
21+
codestartKotlinTest.checkGeneratedSource("org.acme.MyGitHubApp");
22+
codestartKotlinTest.assertThatGeneratedFile(Language.KOTLIN, "pom.xml").exists();
23+
codestartKotlinTest.assertThatGeneratedFileMatchSnapshot(Language.KOTLIN, "README.md");
24+
}
25+
26+
@Test
27+
void buildAllProjects() throws Throwable {
28+
codestartKotlinTest.buildAllProjects();
29+
}
30+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# My GitHub App
3+
4+
> My GitHub App description
5+
6+
This repository contains a GitHub App powered by [Quarkus GitHub App](https://github.com/quarkiverse/quarkus-github-app).
7+
8+
Have a look at the [documentation](https://quarkiverse.github.io/quarkiverse-docs/quarkus-github-app/dev/index.html) to get started.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package ilove.quark.us
2+
3+
import java.io.IOException
4+
import org.kohsuke.github.GHEventPayload
5+
import io.quarkiverse.githubapp.event.Issue
6+
7+
open class MyGitHubApp {
8+
9+
@Throws(IOException::class)
10+
fun onOpen(@Issue.Opened issuePayload: GHEventPayload.Issue) {
11+
issuePayload.issue.comment(":wave: Hello from my GitHub App")
12+
}
13+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package io.quarkiverse.githubapp.it.command.airline;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.junit.jupiter.api.extension.RegisterExtension;
5+
6+
import io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog.Language;
7+
import io.quarkus.devtools.commands.CreateProject.CreateProjectKey;
8+
import io.quarkus.devtools.testing.codestarts.QuarkusCodestartTest;
9+
10+
public class CodestartKotlinTest {
11+
@RegisterExtension
12+
public static QuarkusCodestartTest codestartKotlinTest = QuarkusCodestartTest.builder()
13+
.languages(Language.KOTLIN)
14+
.setupStandaloneExtensionTest("io.quarkiverse.githubapp:quarkus-github-app-command-airline")
15+
.putData(CreateProjectKey.PROJECT_NAME, "My GitHub Bot")
16+
.putData(CreateProjectKey.PROJECT_DESCRIPTION, "My GitHub Bot description")
17+
.build();
18+
19+
@Test
20+
void testContent() throws Throwable {
21+
codestartKotlinTest.checkGeneratedSource("org.acme.MyGitHubBot");
22+
codestartKotlinTest.assertThatGeneratedFile(Language.KOTLIN, "pom.xml").exists();
23+
codestartKotlinTest.assertThatGeneratedFileMatchSnapshot(Language.KOTLIN, "README.md");
24+
}
25+
26+
@Test
27+
void buildAllProjects() throws Throwable {
28+
codestartKotlinTest.buildAllProjects();
29+
30+
}
31+
}

integration-tests/command-airline/src/test/resources/__snapshots__/CodestartKotlinTest/testContent/README.md

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package ilove.quark.us
2+
3+
import com.github.rvesse.airline.annotations.Arguments
4+
import com.github.rvesse.airline.annotations.Cli
5+
import com.github.rvesse.airline.annotations.Command
6+
import io.quarkiverse.githubapp.command.airline.AbstractHelpCommand
7+
import java.io.IOException
8+
import org.kohsuke.github.GHEventPayload
9+
10+
// TODO: make sure you adjust the name as @bot is an actual GitHub user
11+
@Cli(
12+
name = "@bot",
13+
commands = [MyGitHubBot.SayHello::class, MyGitHubBot.Help::class],
14+
description = "A friendly bot",
15+
)
16+
class MyGitHubBot {
17+
18+
interface Commands {
19+
@Throws(IOException::class)
20+
fun run(issueCommentPayload: GHEventPayload.IssueComment)
21+
}
22+
23+
@Command(name = "say-hello", description = "Says hello")
24+
class SayHello : Commands {
25+
26+
@Arguments var arguments: MutableList<String> = arrayListOf()
27+
28+
@Throws(IOException::class)
29+
override fun run(issueCommentPayload: GHEventPayload.IssueComment) {
30+
issueCommentPayload.issue.comment(":wave: Hello " + arguments.joinToString(" "))
31+
}
32+
}
33+
34+
@Command(name = "help", description = "Displays help")
35+
class Help : AbstractHelpCommand(), Commands {
36+
@Throws(IOException::class)
37+
override fun run(issueCommentPayload: GHEventPayload.IssueComment) {
38+
super.run(issueCommentPayload)
39+
}
40+
}
41+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.acme
2+
3+
import java.io.IOException
4+
import org.kohsuke.github.GHEventPayload
5+
import io.quarkiverse.githubapp.event.Issue
6+
7+
open class MyGitHubApp {
8+
9+
@Throws(IOException::class)
10+
fun onOpen(@Issue.Opened issuePayload: GHEventPayload.Issue) {
11+
issuePayload.issue.comment(":wave: Hello from my GitHub App")
12+
}
13+
}

0 commit comments

Comments
 (0)