-
-
Notifications
You must be signed in to change notification settings - Fork 21
GH-1228 Litegration #1228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
GH-1228 Litegration #1228
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ out/ | |
| .gradle/ | ||
| .kotlin/ | ||
| run/ | ||
| runTestPaper/ | ||
| build/ | ||
|
|
||
| .DS_Store | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,12 @@ plugins { | |
| `eternalcode-java` | ||
| `eternalcore-repositories` | ||
| `eternalcore-shadow-compiler` | ||
| id("xyz.jpenilla.run-paper") version "3.0.2" | ||
| id("dev.rollczi.litegration.paper") version Versions.LITEGRATION | ||
| id("xyz.jpenilla.run-paper") | ||
| } | ||
|
|
||
| repositories { | ||
| maven("https://repo.eternalcode.pl/releases/") | ||
| } | ||
|
|
||
| eternalShadowCompiler { | ||
|
|
@@ -30,8 +35,23 @@ eternalShadowCompiler { | |
| } | ||
| } | ||
|
|
||
| tasks.testPaper { | ||
| eula = true | ||
| serverVersion = "1.21.7" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The server version For example, you could add |
||
| } | ||
|
|
||
| dependencies { | ||
| implementation("com.spotify:completable-futures:${Versions.SPOTIFY_COMPLETABLE_FUTURES}") | ||
|
|
||
| testPaperImplementation(project(":eternalcore-core")) | ||
| testPaperImplementation(project(":eternalcore-api")) | ||
|
|
||
| testPaperImplementation("dev.rollczi:litegration-client-mcprotocollib:${Versions.LITEGRATION}") | ||
|
|
||
| testPaperImplementation(platform("org.junit:junit-bom:6.0.0")) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| testPaperImplementation("org.spigotmc:spigot-api:${Versions.SPIGOT_API}") | ||
|
|
||
| testPaperImplementation("org.assertj:assertj-core:3.27.6") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the AssertJ framework, we should migrate other tests to it in near future. |
||
| } | ||
|
|
||
| tasks { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||||||||||||||||||
| package com.eternalcode.core; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import dev.rollczi.litegration.Litegration; | ||||||||||||||||||||||
| import dev.rollczi.litegration.client.Client; | ||||||||||||||||||||||
| import dev.rollczi.litegration.client.McProtocolLibClient; | ||||||||||||||||||||||
| import java.util.Objects; | ||||||||||||||||||||||
| import java.util.function.Consumer; | ||||||||||||||||||||||
| import org.bukkit.Bukkit; | ||||||||||||||||||||||
| import org.bukkit.entity.Player; | ||||||||||||||||||||||
| import org.bukkit.plugin.Plugin; | ||||||||||||||||||||||
| import org.bukkit.plugin.java.JavaPlugin; | ||||||||||||||||||||||
| import org.bukkit.scheduler.BukkitScheduler; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| public class IntegrationBaseTest { | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| private final static Plugin plugin = JavaPlugin.getProvidingPlugin(EternalCoreApi.class); | ||||||||||||||||||||||
| private final static BukkitScheduler scheduler = Bukkit.getScheduler(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| protected static void joinPlayer(String name, Consumer<Player> action) { | ||||||||||||||||||||||
| Litegration litegration = Litegration.getCurrent(); | ||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||||||||||||||||||||||
| scheduler.runTaskAsynchronously(plugin, () -> joinPlayer(name, litegration, action)); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| private static void joinPlayer(String name, Litegration litegration, Consumer<Player> action) { | ||||||||||||||||||||||
| Client client = McProtocolLibClient.connected(name, litegration.getAddress(), litegration.getPort()); | ||||||||||||||||||||||
| Player rollczi = Objects.requireNonNull(Bukkit.getPlayer(client.getName())); | ||||||||||||||||||||||
| scheduler.runTask(plugin, () -> { | ||||||||||||||||||||||
| action.accept(rollczi); | ||||||||||||||||||||||
| client.quit(); | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
Comment on lines
+28
to
+32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable
Suggested change
|
||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| } | ||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,38 @@ | ||||||
| package com.eternalcode.core.catboy; | ||||||
|
|
||||||
| import com.eternalcode.core.EternalCoreApi; | ||||||
| import com.eternalcode.core.EternalCoreApiProvider; | ||||||
| import com.eternalcode.core.IntegrationBaseTest; | ||||||
| import com.eternalcode.core.feature.catboy.CatboyService; | ||||||
| import dev.rollczi.litegration.junit.LitegrationTest; | ||||||
| import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; | ||||||
| import org.bukkit.entity.Cat; | ||||||
| import org.junit.jupiter.api.Test; | ||||||
|
|
||||||
| class CatboyServiceIntegrationTest extends IntegrationBaseTest { | ||||||
|
|
||||||
| @LitegrationTest | ||||||
| void shouldMarkAndUnmarkPlayerAsCatboy() { | ||||||
| EternalCoreApi api = EternalCoreApiProvider.provide(); | ||||||
| CatboyService catboyService = api.getCatboyService(); | ||||||
|
|
||||||
| joinPlayer("Rollczi", rollczi -> { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
No need to use player's name as parameter, as |
||||||
| catboyService.markAsCatboy(rollczi, Cat.Type.WHITE); | ||||||
| assertThat(catboyService.isCatboy(rollczi.getUniqueId())).isTrue(); | ||||||
| assertThat(rollczi.getWalkSpeed()).isEqualTo(0.4F); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The walk speed value |
||||||
| assertThat(rollczi.getPassengers()).hasSize(1) | ||||||
| .allMatch(entity -> entity instanceof Cat cat && cat.getCatType() == Cat.Type.WHITE); | ||||||
|
|
||||||
| catboyService.changeCatboyType(rollczi, Cat.Type.BLACK); | ||||||
| assertThat(rollczi.getPassengers()).hasSize(1) | ||||||
| .allMatch(entity -> entity instanceof Cat cat && cat.getCatType() == Cat.Type.BLACK); | ||||||
|
|
||||||
| catboyService.unmarkAsCatboy(rollczi); | ||||||
| assertThat(rollczi.getWalkSpeed()).isEqualTo(0.2F); | ||||||
| assertThat(rollczi.getPassengers()).isEmpty(); | ||||||
|
|
||||||
| assertThat(catboyService.isCatboy(rollczi.getUniqueId())).isFalse(); | ||||||
| }); | ||||||
| } | ||||||
|
|
||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| # https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties | ||
|
|
||
| org.gradle.parallel=true | ||
| org.gradle.parallel=false | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Disabling parallel execution can significantly increase build times. While this might be a necessary workaround for the integration tests to function correctly, the reason for this change should be documented with a comment. This will help other developers understand the limitation and potentially re-enable it in the future if the underlying issue is resolved. The same applies to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Rollczi Can't we toggle this off per-task? |
||
| org.gradle.caching=true | ||
| org.gradle.configuration-cache=true | ||
| org.gradle.configuration-cache.parallel=true | ||
| org.gradle.configuration-cache.parallel=false | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? |
||
| #org.gradle.jvmargs=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
repositoriesblock is redundant. Theeternalcore-repositoriesconvention plugin is applied on line 3, and it already includes thehttps://repo.eternalcode.pl/releases/repository. You can safely remove this block to avoid duplication.