Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ jobs:
with:
languages: ${{ matrix.language }}

- name: Set up JDK 21
- name: Set up JDK 25
uses: actions/setup-java@v5
with:
java-version: '21'
java-version: '25'
distribution: 'temurin'
cache: gradle

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reusable-gradle-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ on:
gradle-version:
required: false
type: string
default: '8.14.3'
default: '9.4.0'
java-version:
required: false
type: string
default: '21'
default: '25'

jobs:
gradle-build:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/reusable-gradle-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ on:
java-version:
required: false
type: string
default: '21'
default: '25'
gradle-version:
required: false
type: string
default: '8.14.3'
default: '9.4.0'
secrets:
FORGEJO_REGISTRY:
required: true
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
run: docker compose -f docker-compose.test.yml up -d --wait

- name: Test with Gradle
run: gradle test
run: gradle clean test
env:
CAFEBOT_API_URL: 'http://localhost:5000'

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Output
libs/
.claude/

# Node/NPM
/node_modules/
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use an official Gradle image with JDK 21 for building
FROM gradle:jdk21 AS build
FROM gradle:jdk25 AS build

# Set the working directory
WORKDIR /app
Expand Down
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ allprojects {
apply(plugin = "com.gradleup.shadow")

java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
}

repositories {
Expand Down Expand Up @@ -100,6 +100,7 @@ tasks.clean {
dependencies {
implementation(project(":modules:cafeBot-api-wrapper"))
implementation(project(":modules:meme-api-wrapper"))
implementation(project(":modules:i18n"))

implementation("net.dv8tion:JDA:6.4.0") { exclude(module = "opus-java") }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@

public class PollApiTest extends ApiTest {

private Poll poll;
private String user1;

@BeforeEach
public void setup() throws ExecutionException, InterruptedException {
private static Poll setupPoll() throws ExecutionException, InterruptedException {
String guildId = generateSnowflake().toString();
String messageId = generateSnowflake().toString();
String user1 = generateSnowflake().toString();
Expand All @@ -35,32 +31,36 @@ public void setup() throws ExecutionException, InterruptedException {
"Example Title",
"Example Description",
true,
Instant.now().plus(2, ChronoUnit.SECONDS).toString(),
Instant.now().plus(1, ChronoUnit.SECONDS).toString(),
options.toArray(new PartialPollOption[0])
);

this.poll = cafeAPI.getPollApi().createPoll(guildId, messageId, partialPoll).get();
this.poll = cafeAPI.getPollApi().toggleVote(this.poll.getId(), this.poll.getOptions()[0].getId(), user1).get();
Poll poll = cafeAPI.getPollApi().createPoll(guildId, messageId, partialPoll).get();
poll = cafeAPI.getPollApi().toggleVote(poll.getId(), poll.getOptions()[0].getId(), user1).get();

Thread.sleep(Duration.of(1, ChronoUnit.SECONDS).toMillis());

return poll;
}

@Test
@DisplayName("can get all polls")
public void testCanGetAllPolls() throws ExecutionException, InterruptedException {
Thread.sleep(Duration.of(3, ChronoUnit.SECONDS).toMillis());
Poll originalPoll = setupPoll();

Map<String, List<Poll>> polls = cafeAPI.getPollApi().getPolls().get();

Assertions.assertNotNull(polls.get(this.poll.getGuildId()));
Assertions.assertEquals(1, polls.get(this.poll.getGuildId()).size());
Assertions.assertNotNull(polls.get(this.poll.getGuildId()).getFirst());
Assertions.assertNotNull(polls.get(originalPoll.getGuildId()));
Assertions.assertEquals(1, polls.get(originalPoll.getGuildId()).size());
Assertions.assertNotNull(polls.get(originalPoll.getGuildId()).getFirst());
}

@Test
@DisplayName("can get polls for guild")
public void testCanGetSpecificPoll() throws ExecutionException, InterruptedException {
Thread.sleep(Duration.of(3, ChronoUnit.SECONDS).toMillis());
Poll originalPoll = setupPoll();

List<Poll> polls = cafeAPI.getPollApi().getPolls(this.poll.getGuildId()).get();
List<Poll> polls = cafeAPI.getPollApi().getPolls(originalPoll.getGuildId()).get();

Assertions.assertEquals(1, polls.size());
Assertions.assertNotNull(polls.getFirst());
Expand Down Expand Up @@ -98,7 +98,7 @@ public void testCanCreatePoll() throws ExecutionException, InterruptedException
Assertions.assertTrue(poll.getDescription().isPresent());
Assertions.assertEquals("Example Description", poll.getDescription().get());

Assertions.assertEquals(2, poll.getOptions()[0].getEmoji().get().length());
Assertions.assertEquals("🥺".length(), poll.getOptions()[0].getEmoji().get().length());
Assertions.assertEquals("🥺", poll.getOptions()[0].getEmoji().get());
Assertions.assertEquals("Poll Option #1", poll.getOptions()[0].getTitle());
Assertions.assertTrue(poll.getOptions()[0].getDescription().isPresent());
Expand All @@ -112,9 +112,10 @@ public void testCanCreatePoll() throws ExecutionException, InterruptedException
@Test
@DisplayName("can vote for poll")
public void testCanVoteForPoll() throws ExecutionException, InterruptedException {
Poll originalPoll = setupPoll();
String user = generateSnowflake().toString();

Poll poll = cafeAPI.getPollApi().toggleVote(this.poll.getId(), this.poll.getOptions()[1].getId(), user).get();
Poll poll = cafeAPI.getPollApi().toggleVote(originalPoll.getId(), originalPoll.getOptions()[1].getId(), user).get();

Assertions.assertNotNull(poll);
Assertions.assertTrue(Arrays.stream(poll.getOptions()[1].getVoters()).anyMatch((voters) -> voters.equalsIgnoreCase(user)));
Expand All @@ -123,9 +124,9 @@ public void testCanVoteForPoll() throws ExecutionException, InterruptedException
@Test
@DisplayName("can close poll")
public void testCanClosePoll() throws ExecutionException, InterruptedException {
Thread.sleep(Duration.of(3, ChronoUnit.SECONDS).toMillis());
Poll originalPoll = setupPoll();

Poll poll = cafeAPI.getPollApi().closePoll(this.poll.getId()).get();
Poll poll = cafeAPI.getPollApi().closePoll(originalPoll.getId()).get();

Assertions.assertNotNull(poll);
Assertions.assertFalse(poll.isActive());
Expand All @@ -135,44 +136,49 @@ public void testCanClosePoll() throws ExecutionException, InterruptedException {
@Test
@DisplayName("can delete poll")
public void testCanDeletePoll() throws ExecutionException, InterruptedException {
List<Poll> polls = cafeAPI.getPollApi().getPolls(this.poll.getGuildId(), true, false).get();
Poll originalPoll = setupPoll();

List<Poll> polls = cafeAPI.getPollApi().getPolls(originalPoll.getGuildId(), true, false).get();
Assertions.assertEquals(1, polls.size());

cafeAPI.getPollApi().deletePoll(this.poll.getId()).join();
cafeAPI.getPollApi().deletePoll(originalPoll.getId()).join();

polls = cafeAPI.getPollApi().getPolls(this.poll.getGuildId()).get();
polls = cafeAPI.getPollApi().getPolls(originalPoll.getGuildId()).get();
Assertions.assertEquals(0, polls.size());
}

@Test
@DisplayName("can get poll by message id")
public void testCanGetPollById() throws ExecutionException, InterruptedException {
Poll poll = cafeAPI.getPollApi().getPoll(this.poll.getGuildId(), this.poll.getMessageId()).get();
Poll originalPoll = setupPoll();
Poll poll = cafeAPI.getPollApi().getPoll(originalPoll.getGuildId(), originalPoll.getMessageId()).get();

Assertions.assertNotNull(poll);
Assertions.assertEquals(poll.getId(), this.poll.getId());
Assertions.assertEquals(poll.getTitle(), this.poll.getTitle());
Assertions.assertEquals(poll.getDescription(), this.poll.getDescription());
Assertions.assertEquals(poll.getId(), originalPoll.getId());
Assertions.assertEquals(poll.getTitle(), originalPoll.getTitle());
Assertions.assertEquals(poll.getDescription(), originalPoll.getDescription());
}

@Test
@DisplayName("can manually set poll submission to false")
public void testCanSetPollSubmissionToFalse() throws ExecutionException, InterruptedException {
int originalVotes = poll.getOptions()[0].getVoters().length;
Poll originalPoll = setupPoll();
int originalVotes = originalPoll.getOptions()[0].getVoters().length;

String user = generateSnowflake().toString();
Poll poll = cafeAPI.getPollApi().setVote(this.poll.getId(), this.poll.getOptions()[0].getId(), user, true).get();
Poll poll = cafeAPI.getPollApi().setVote(originalPoll.getId(), originalPoll.getOptions()[0].getId(), user, true).get();

Assertions.assertEquals(originalVotes + 1, poll.getOptions()[0].getVoters().length);
}

@Test
@DisplayName("can manually set poll submission to true")
public void testCanSetPollSubmissionToTrue() throws ExecutionException, InterruptedException {
int originalVotes = poll.getOptions()[0].getVoters().length;
Poll originalPoll = setupPoll();
int originalVotes = originalPoll.getOptions()[0].getVoters().length;

String user = generateSnowflake().toString();
Poll poll = cafeAPI.getPollApi().setVote(this.poll.getId(), this.poll.getOptions()[0].getId(), user, false).get();
Poll poll = cafeAPI.getPollApi().setVote(originalPoll.getId(), originalPoll.getOptions()[0].getId(), user, false).get();

Assertions.assertEquals(originalVotes, poll.getOptions()[0].getVoters().length);
}
Expand Down
9 changes: 9 additions & 0 deletions modules/i18n/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

version = "0.0.0"

dependencies {
implementation("org.yaml:snakeyaml:2.5") // https://mvnrepository.com/artifact/org.yaml/snakeyaml
}

tasks.withType<ShadowJar> { }
Loading
Loading