Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-04 23:30:17 +01:00
Simplify publish logic and move to GitHub Actions (#3579)
Co-authored-by: Tim203 <mctim203@gmail.com> Co-authored-by: rtm516 <ryantmilner@hotmail.co.uk>
Dieser Commit ist enthalten in:
Ursprung
50104c95ec
Commit
a72e49527d
53
.github/workflows/build.yml
vendored
Normale Datei
53
.github/workflows/build.yml
vendored
Normale Datei
@ -0,0 +1,53 @@
|
||||
name: Build
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository and submodules
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: 17
|
||||
distribution: temurin
|
||||
cache: gradle
|
||||
|
||||
- name: Build
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
arguments: build
|
||||
|
||||
- name: Publish to Maven Repository
|
||||
if: ${{ job.status == 'success' && github.repository == 'GeyserMC/Geyser' && github.ref_name == 'master' }}
|
||||
uses: gradle/gradle-build-action@v2
|
||||
env:
|
||||
ORG_GRADLE_PROJECT_geysermcUsername: ${{ vars.DEPLOY_USER }}
|
||||
ORG_GRADLE_PROJECT_geysermcPassword: ${{ secrets.DEPLOY_PASS }}
|
||||
with:
|
||||
arguments: publish
|
||||
|
||||
- name: Publish to Downloads API
|
||||
if: ${{ github.ref_name == 'master' && job.status == 'success' && github.repository == 'GeyserMC/Geyser' }}
|
||||
shell: bash
|
||||
run: |
|
||||
# Save the private key to a file
|
||||
echo "$DOWNLOADS_PRIVATE_KEY" > id_ecdsa
|
||||
chmod 600 id_ecdsa
|
||||
# Get the version from gradle.properties
|
||||
version=$(cat gradle.properties | grep -o "version=[0-9\\.]*" | cut -d"=" -f2)
|
||||
# Copy over artifacts
|
||||
scp -B -o StrictHostKeyChecking=no -i id_ecdsa bootstrap/**/build/libs/Geyser-*.jar $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP:~/files/
|
||||
# Run the build script
|
||||
ssh -o StrictHostKeyChecking=no -i id_ecdsa $DOWNLOADS_USERNAME@$DOWNLOADS_SERVER_IP ./handleBuild.sh geyser $version $GITHUB_RUN_ID $GITHUB_SHA
|
||||
|
||||
- name: Notify Discord
|
||||
if: ${{ github.repository == 'GeyserMC/Geyser' }}
|
||||
uses: Tim203/actions-git-discord-webhook@main
|
||||
with:
|
||||
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
status: ${{ job.status }}
|
37
Jenkinsfile
vendored
37
Jenkinsfile
vendored
@ -27,43 +27,6 @@ pipeline {
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
def changeLogSets = currentBuild.changeSets
|
||||
def message = "**Changes:**"
|
||||
|
||||
if (changeLogSets.size() == 0) {
|
||||
message += "\n*No changes.*"
|
||||
} else {
|
||||
def repositoryUrl = scm.userRemoteConfigs[0].url.replace(".git", "")
|
||||
def count = 0;
|
||||
def extra = 0;
|
||||
for (int i = 0; i < changeLogSets.size(); i++) {
|
||||
def entries = changeLogSets[i].items
|
||||
for (int j = 0; j < entries.length; j++) {
|
||||
if (count <= 10) {
|
||||
def entry = entries[j]
|
||||
def commitId = entry.commitId.substring(0, 6)
|
||||
message += "\n - [`${commitId}`](${repositoryUrl}/commit/${entry.commitId}) ${entry.msg}"
|
||||
count++
|
||||
} else {
|
||||
extra++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (extra != 0) {
|
||||
message += "\n - ${extra} more commits"
|
||||
}
|
||||
}
|
||||
|
||||
env.changes = message
|
||||
}
|
||||
deleteDir()
|
||||
withCredentials([string(credentialsId: 'geyser-discord-webhook', variable: 'DISCORD_WEBHOOK')]) {
|
||||
discordSend description: "**Build:** [${currentBuild.id}](${env.BUILD_URL})\n**Status:** [${currentBuild.currentResult}](${env.BUILD_URL})\n${changes}\n\n[**Artifacts on Jenkins**](https://ci.opencollab.dev/job/GeyserMC/job/Geyser)", footer: 'Open Collaboration Jenkins', link: env.BUILD_URL, successful: currentBuild.resultIsBetterOrEqualTo('SUCCESS'), title: "${env.JOB_NAME} #${currentBuild.id}", webhookURL: DISCORD_WEBHOOK
|
||||
}
|
||||
}
|
||||
success {
|
||||
script {
|
||||
if (env.BRANCH_NAME == 'master') {
|
||||
|
@ -1,5 +1,3 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
@ -10,17 +8,10 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("net.kyori", "indra-common", "2.0.6")
|
||||
implementation("org.jfrog.buildinfo", "build-info-extractor-gradle", "4.26.1")
|
||||
implementation("net.kyori", "indra-common", "3.0.1")
|
||||
implementation("com.github.johnrengelman", "shadow", "7.1.3-SNAPSHOT")
|
||||
|
||||
// Within the gradle plugin classpath, there is a version conflict between loom and some other
|
||||
// plugin for databind. This fixes it: minimum 2.13.2 is required by loom.
|
||||
implementation("com.fasterxml.jackson.core:jackson-databind:2.14.0")
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions {
|
||||
jvmTarget = "16"
|
||||
}
|
||||
}
|
||||
|
@ -30,9 +30,6 @@ import org.gradle.api.artifacts.ProjectDependency
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.kotlin.dsl.named
|
||||
|
||||
fun Project.isSnapshot(): Boolean =
|
||||
version.toString().endsWith("-SNAPSHOT")
|
||||
|
||||
fun Project.relocate(pattern: String) {
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
relocate(pattern, "org.geysermc.geyser.shaded.$pattern")
|
||||
|
@ -1,12 +1,25 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
id("net.kyori.indra")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.checkerframework", "checker-qual", "3.19.0")
|
||||
}
|
||||
|
||||
indra {
|
||||
github("GeyserMC", "Geyser") {
|
||||
ci(true)
|
||||
issues(true)
|
||||
scm(true)
|
||||
}
|
||||
mitLicense()
|
||||
|
||||
javaVersions {
|
||||
target(16)
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
processResources {
|
||||
// Spigot, BungeeCord, Velocity, Sponge, Fabric
|
||||
@ -21,14 +34,4 @@ tasks {
|
||||
)
|
||||
}
|
||||
}
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_16
|
||||
targetCompatibility = JavaVersion.VERSION_16
|
||||
|
||||
withSourcesJar()
|
||||
}
|
||||
|
@ -1,33 +1,9 @@
|
||||
plugins {
|
||||
id("geyser.shadow-conventions")
|
||||
id("com.jfrog.artifactory")
|
||||
id("maven-publish")
|
||||
id("net.kyori.indra.publishing")
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("mavenJava") {
|
||||
groupId = project.group as String
|
||||
artifactId = project.name
|
||||
version = project.version as String
|
||||
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
artifactory {
|
||||
setContextUrl("https://repo.opencollab.dev/artifactory")
|
||||
publish {
|
||||
repository {
|
||||
setRepoKey(if (isSnapshot()) "maven-snapshots" else "maven-releases")
|
||||
setMavenCompatible(true)
|
||||
}
|
||||
defaults {
|
||||
publications("mavenJava")
|
||||
setPublishArtifacts(true)
|
||||
setPublishPom(true)
|
||||
setPublishIvy(false)
|
||||
}
|
||||
}
|
||||
indra {
|
||||
publishSnapshotsTo("geysermc", "https://repo.opencollab.dev/maven-snapshots")
|
||||
publishReleasesTo("geysermc", "https://repo.opencollab.dev/maven-releases")
|
||||
}
|
||||
|
@ -27,18 +27,20 @@ package org.geysermc.geyser.network.translators.chat;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.DefaultComponentSerializer;
|
||||
import org.geysermc.geyser.translator.text.MessageTranslator;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class MessageTranslatorTest {
|
||||
|
||||
private Map<String, String> messages = new HashMap<>();
|
||||
|
||||
@Before
|
||||
@BeforeAll
|
||||
public void setUp() throws Exception {
|
||||
messages.put("{\"text\":\"\",\"extra\":[{\"text\":\"DoctorMad9952 joined the game\",\"color\":\"yellow\"}]}",
|
||||
"§r§eDoctorMad9952 joined the game");
|
||||
@ -70,27 +72,27 @@ public class MessageTranslatorTest {
|
||||
public void convertMessage() {
|
||||
for (Map.Entry<String, String> entry : messages.entrySet()) {
|
||||
String bedrockMessage = MessageTranslator.convertMessage(entry.getKey(), "en_US");
|
||||
Assert.assertEquals("Translation of messages is incorrect", entry.getValue(), bedrockMessage);
|
||||
Assertions.assertEquals(entry.getValue(), bedrockMessage, "Translation of messages is incorrect");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertMessageLenient() {
|
||||
Assert.assertEquals("All newline message is not handled properly", "\n\n\n\n", MessageTranslator.convertMessageLenient("\n\n\n\n"));
|
||||
Assert.assertEquals("Empty message is not handled properly", "", MessageTranslator.convertMessageLenient(""));
|
||||
Assert.assertEquals("Reset before message is not handled properly", "§r§eGame Selector", MessageTranslator.convertMessageLenient("§r§eGame Selector"));
|
||||
Assert.assertEquals("Unimplemented formatting chars not stripped", "Bold Underline", MessageTranslator.convertMessageLenient("§m§nBold Underline"));
|
||||
Assertions.assertEquals("\n\n\n\n", MessageTranslator.convertMessageLenient("\n\n\n\n"), "All newline message is not handled properly");
|
||||
Assertions.assertEquals("", MessageTranslator.convertMessageLenient(""), "Empty message is not handled properly");
|
||||
Assertions.assertEquals("§r§eGame Selector", MessageTranslator.convertMessageLenient("§r§eGame Selector"), "Reset before message is not handled properly");
|
||||
Assertions.assertEquals("Bold Underline", MessageTranslator.convertMessageLenient("§m§nBold Underline"), "Unimplemented formatting chars not stripped");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void convertToPlainText() {
|
||||
Assert.assertEquals("JSON message is not handled properly", "Many colors here", MessageTranslator.convertToPlainText("{\"extra\":[{\"color\":\"red\",\"text\":\"M\"},{\"color\":\"gold\",\"text\":\"a\"},{\"color\":\"yellow\",\"text\":\"n\"},{\"color\":\"green\",\"text\":\"y \"},{\"color\":\"aqua\",\"text\":\"c\"},{\"color\":\"dark_purple\",\"text\":\"o\"},{\"color\":\"red\",\"text\":\"l\"},{\"color\":\"gold\",\"text\":\"o\"},{\"color\":\"yellow\",\"text\":\"r\"},{\"color\":\"green\",\"text\":\"s \"},{\"color\":\"aqua\",\"text\":\"h\"},{\"color\":\"dark_purple\",\"text\":\"e\"},{\"color\":\"red\",\"text\":\"r\"},{\"color\":\"gold\",\"text\":\"e\"}],\"text\":\"\"}", "en_US"));
|
||||
Assert.assertEquals("Legacy formatted message is not handled properly (Colors)", "Many colors here", MessageTranslator.convertToPlainText("§cM§6a§en§ay §bc§5o§cl§6o§er§as §bh§5e§cr§6e"));
|
||||
Assert.assertEquals("Legacy formatted message is not handled properly (Colors)", "Many colors here", MessageTranslator.convertToPlainText("§cM§6a§en§ay §bc§5o§cl§6o§er§as §bh§5e§cr§6e", "en_US"));
|
||||
Assert.assertEquals("Legacy formatted message is not handled properly (Style)", "Obf Bold Strikethrough Underline Italic Reset", MessageTranslator.convertToPlainText("§kObf §lBold §mStrikethrough §nUnderline §oItalic §rReset", "en_US"));
|
||||
Assert.assertEquals("Valid lenient JSON is not handled properly", "Strange", MessageTranslator.convertToPlainText("§rStrange", "en_US"));
|
||||
Assert.assertEquals("Empty message is not handled properly", "", MessageTranslator.convertToPlainText("", "en_US"));
|
||||
Assert.assertEquals("Whitespace is not preserved", " ", MessageTranslator.convertToPlainText(" ", "en_US"));
|
||||
Assertions.assertEquals("Many colors here", MessageTranslator.convertToPlainText("{\"extra\":[{\"color\":\"red\",\"text\":\"M\"},{\"color\":\"gold\",\"text\":\"a\"},{\"color\":\"yellow\",\"text\":\"n\"},{\"color\":\"green\",\"text\":\"y \"},{\"color\":\"aqua\",\"text\":\"c\"},{\"color\":\"dark_purple\",\"text\":\"o\"},{\"color\":\"red\",\"text\":\"l\"},{\"color\":\"gold\",\"text\":\"o\"},{\"color\":\"yellow\",\"text\":\"r\"},{\"color\":\"green\",\"text\":\"s \"},{\"color\":\"aqua\",\"text\":\"h\"},{\"color\":\"dark_purple\",\"text\":\"e\"},{\"color\":\"red\",\"text\":\"r\"},{\"color\":\"gold\",\"text\":\"e\"}],\"text\":\"\"}", "en_US"), "JSON message is not handled properly");
|
||||
Assertions.assertEquals("Many colors here", MessageTranslator.convertToPlainText("§cM§6a§en§ay §bc§5o§cl§6o§er§as §bh§5e§cr§6e"), "Legacy formatted message is not handled properly (Colors)");
|
||||
Assertions.assertEquals("Many colors here", MessageTranslator.convertToPlainText("§cM§6a§en§ay §bc§5o§cl§6o§er§as §bh§5e§cr§6e", "en_US"), "Legacy formatted message is not handled properly (Colors)");
|
||||
Assertions.assertEquals("Obf Bold Strikethrough Underline Italic Reset", MessageTranslator.convertToPlainText("§kObf §lBold §mStrikethrough §nUnderline §oItalic §rReset", "en_US"), "Legacy formatted message is not handled properly (Style)");
|
||||
Assertions.assertEquals("Strange", MessageTranslator.convertToPlainText("§rStrange", "en_US"), "Valid lenient JSON is not handled properly");
|
||||
Assertions.assertEquals("", MessageTranslator.convertToPlainText("", "en_US"), "Empty message is not handled properly");
|
||||
Assertions.assertEquals(" ", MessageTranslator.convertToPlainText(" ", "en_US"), "Whitespace is not preserved");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -36,20 +36,22 @@ import org.geysermc.geyser.api.item.custom.CustomItemOptions;
|
||||
import org.geysermc.geyser.api.util.TriState;
|
||||
import org.geysermc.geyser.item.GeyserCustomItemOptions;
|
||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class CustomItemsTest {
|
||||
private ItemMapping testMappingWithDamage;
|
||||
private Object2IntMap<CompoundTag> tagToCustomItemWithDamage;
|
||||
private ItemMapping testMappingWithNoDamage;
|
||||
private Object2IntMap<CompoundTag> tagToCustomItemWithNoDamage;
|
||||
|
||||
@Before
|
||||
@BeforeAll
|
||||
public void setup() {
|
||||
CustomItemOptions a = new GeyserCustomItemOptions(TriState.TRUE, OptionalInt.of(2), OptionalInt.empty());
|
||||
CustomItemOptions b = new GeyserCustomItemOptions(TriState.FALSE, OptionalInt.of(5), OptionalInt.empty());
|
||||
@ -147,12 +149,12 @@ public class CustomItemsTest {
|
||||
public void testCustomItems() {
|
||||
for (Object2IntMap.Entry<CompoundTag> entry : this.tagToCustomItemWithDamage.object2IntEntrySet()) {
|
||||
int id = CustomItemTranslator.getCustomItem(entry.getKey(), this.testMappingWithDamage);
|
||||
Assert.assertEquals(entry.getKey() + " did not produce the correct custom item", entry.getIntValue(), id);
|
||||
Assertions.assertEquals(entry.getIntValue(), id, entry.getKey() + " did not produce the correct custom item");
|
||||
}
|
||||
|
||||
for (Object2IntMap.Entry<CompoundTag> entry : this.tagToCustomItemWithNoDamage.object2IntEntrySet()) {
|
||||
int id = CustomItemTranslator.getCustomItem(entry.getKey(), this.testMappingWithNoDamage);
|
||||
Assert.assertEquals(entry.getKey() + " did not produce the correct custom item", entry.getIntValue(), id);
|
||||
Assertions.assertEquals(entry.getIntValue(), id, entry.getKey() + " did not produce the correct custom item");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,11 @@
|
||||
|
||||
package org.geysermc.geyser.util.collection;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
public class GeyserCollectionsTest {
|
||||
private final byte[] bytes = new byte[] {(byte) 5, (byte) 4, (byte) 3, (byte) 2, (byte) 2, (byte) 1};
|
||||
private final boolean[] booleans = new boolean[] {true, false, false, true};
|
||||
@ -51,35 +53,35 @@ public class GeyserCollectionsTest {
|
||||
int lastKey = index;
|
||||
|
||||
// Easy, understandable out-of-bounds checks
|
||||
Assert.assertFalse("Map contains key bigger by one!", map.containsKey(lastKey));
|
||||
Assert.assertTrue("Map doesn't contain final key!", map.containsKey(lastKey - 1));
|
||||
Assertions.assertFalse(map.containsKey(lastKey), "Map contains key bigger by one!");
|
||||
Assertions.assertTrue(map.containsKey(lastKey - 1), "Map doesn't contain final key!");
|
||||
|
||||
// Ensure the first and last values do not throw an exception on get, and test getOrDefault
|
||||
map.get(start - 1);
|
||||
map.get(lastKey);
|
||||
Assert.assertEquals(map.getOrDefault(start - 1, Byte.MAX_VALUE), Byte.MAX_VALUE);
|
||||
Assert.assertEquals(map.getOrDefault(lastKey, Byte.MAX_VALUE), Byte.MAX_VALUE);
|
||||
Assert.assertEquals(map.getOrDefault(lastKey, Byte.MIN_VALUE), Byte.MIN_VALUE);
|
||||
Assertions.assertEquals(map.getOrDefault(start - 1, Byte.MAX_VALUE), Byte.MAX_VALUE);
|
||||
Assertions.assertEquals(map.getOrDefault(lastKey, Byte.MAX_VALUE), Byte.MAX_VALUE);
|
||||
Assertions.assertEquals(map.getOrDefault(lastKey, Byte.MIN_VALUE), Byte.MIN_VALUE);
|
||||
|
||||
Assert.assertEquals(map.size(), bytes.length);
|
||||
Assertions.assertEquals(map.size(), bytes.length);
|
||||
|
||||
for (int i = start; i < bytes.length; i++) {
|
||||
Assert.assertTrue(map.containsKey(i));
|
||||
Assert.assertEquals(map.get(i), bytes[i - start]);
|
||||
Assertions.assertTrue(map.containsKey(i));
|
||||
Assertions.assertEquals(map.get(i), bytes[i - start]);
|
||||
}
|
||||
|
||||
for (int i = start - 1; i >= (start - 6); i--) {
|
||||
// Lower than expected check
|
||||
Assert.assertFalse(i + " is in a map that starts with " + start, map.containsKey(i));
|
||||
Assertions.assertFalse(map.containsKey(i), i + " is in a map that starts with " + start);
|
||||
}
|
||||
|
||||
for (int i = bytes.length + start; i < bytes.length + 5 + start; i++) {
|
||||
// Higher than expected check
|
||||
Assert.assertFalse(i + " is in a map that ends with " + (start + bytes.length), map.containsKey(i));
|
||||
Assertions.assertFalse(map.containsKey(i), i + " is in a map that ends with " + (start + bytes.length));
|
||||
}
|
||||
|
||||
for (byte b : bytes) {
|
||||
Assert.assertTrue(map.containsValue(b));
|
||||
Assertions.assertTrue(map.containsValue(b));
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,33 +101,33 @@ public class GeyserCollectionsTest {
|
||||
int lastKey = index;
|
||||
|
||||
// Easy, understandable out-of-bounds checks
|
||||
Assert.assertFalse("Map contains key bigger by one!", map.containsKey(lastKey));
|
||||
Assert.assertTrue("Map doesn't contain final key!", map.containsKey(lastKey - 1));
|
||||
Assertions.assertFalse(map.containsKey(lastKey), "Map contains key bigger by one!");
|
||||
Assertions.assertTrue(map.containsKey(lastKey - 1), "Map doesn't contain final key!");
|
||||
|
||||
// Ensure the first and last values do not throw an exception on get
|
||||
map.get(start - 1);
|
||||
map.get(lastKey);
|
||||
Assert.assertTrue(map.getOrDefault(lastKey, true));
|
||||
Assertions.assertTrue(map.getOrDefault(lastKey, true));
|
||||
|
||||
Assert.assertEquals(map.size(), booleans.length);
|
||||
Assertions.assertEquals(map.size(), booleans.length);
|
||||
|
||||
for (int i = start; i < booleans.length; i++) {
|
||||
Assert.assertTrue(map.containsKey(i));
|
||||
Assert.assertEquals(map.get(i), booleans[i - start]);
|
||||
Assertions.assertTrue(map.containsKey(i));
|
||||
Assertions.assertEquals(map.get(i), booleans[i - start]);
|
||||
}
|
||||
|
||||
for (int i = start - 1; i >= (start - 6); i--) {
|
||||
// Lower than expected check
|
||||
Assert.assertFalse(i + " is in a map that starts with " + start, map.containsKey(i));
|
||||
Assertions.assertFalse(map.containsKey(i), i + " is in a map that starts with " + start);
|
||||
}
|
||||
|
||||
for (int i = booleans.length + start; i < booleans.length + start + 5; i++) {
|
||||
// Higher than expected check
|
||||
Assert.assertFalse(i + " is in a map that ends with " + (start + booleans.length), map.containsKey(i));
|
||||
Assertions.assertFalse(map.containsKey(i), i + " is in a map that ends with " + (start + booleans.length));
|
||||
}
|
||||
|
||||
for (boolean b : booleans) {
|
||||
Assert.assertTrue(map.containsValue(b));
|
||||
Assertions.assertTrue(map.containsValue(b));
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,35 +147,35 @@ public class GeyserCollectionsTest {
|
||||
int lastKey = index;
|
||||
|
||||
// Easy, understandable out-of-bounds checks
|
||||
Assert.assertFalse("Map contains key bigger by one!", map.containsKey(lastKey));
|
||||
Assert.assertTrue("Map doesn't contain final key!", map.containsKey(lastKey - 1));
|
||||
Assertions.assertFalse(map.containsKey(lastKey), "Map contains key bigger by one!");
|
||||
Assertions.assertTrue(map.containsKey(lastKey - 1), "Map doesn't contain final key!");
|
||||
|
||||
// Ensure the first and last values do not throw an exception on get, and test getOrDefault
|
||||
map.get(start - 1);
|
||||
map.get(lastKey);
|
||||
Assert.assertEquals(map.getOrDefault(start - 1, Integer.MAX_VALUE), Integer.MAX_VALUE);
|
||||
Assert.assertEquals(map.getOrDefault(lastKey, Integer.MAX_VALUE), Integer.MAX_VALUE);
|
||||
Assert.assertEquals(map.getOrDefault(lastKey, Integer.MIN_VALUE), Integer.MIN_VALUE);
|
||||
Assertions.assertEquals(map.getOrDefault(start - 1, Integer.MAX_VALUE), Integer.MAX_VALUE);
|
||||
Assertions.assertEquals(map.getOrDefault(lastKey, Integer.MAX_VALUE), Integer.MAX_VALUE);
|
||||
Assertions.assertEquals(map.getOrDefault(lastKey, Integer.MIN_VALUE), Integer.MIN_VALUE);
|
||||
|
||||
Assert.assertEquals(map.size(), ints.length);
|
||||
Assertions.assertEquals(map.size(), ints.length);
|
||||
|
||||
for (int i = start; i < ints.length; i++) {
|
||||
Assert.assertTrue(map.containsKey(i));
|
||||
Assert.assertEquals(map.get(i), ints[i - start]);
|
||||
Assertions.assertTrue(map.containsKey(i));
|
||||
Assertions.assertEquals(map.get(i), ints[i - start]);
|
||||
}
|
||||
|
||||
for (int i = start - 1; i >= (start - 6); i--) {
|
||||
// Lower than expected check
|
||||
Assert.assertFalse(i + " is in a map that starts with " + start, map.containsKey(i));
|
||||
Assertions.assertFalse(map.containsKey(i), i + " is in a map that starts with " + start);
|
||||
}
|
||||
|
||||
for (int i = ints.length + start; i < ints.length + 5 + start; i++) {
|
||||
// Higher than expected check
|
||||
Assert.assertFalse(i + " is in a map that ends with " + (start + ints.length), map.containsKey(i));
|
||||
Assertions.assertFalse(map.containsKey(i), i + " is in a map that ends with " + (start + ints.length));
|
||||
}
|
||||
|
||||
for (int i : ints) {
|
||||
Assert.assertTrue(map.containsValue(i));
|
||||
Assertions.assertTrue(map.containsValue(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ mcprotocollib = "1.19.3-20230107.194116-10"
|
||||
packetlib = "3.0.1"
|
||||
adventure = "4.12.0-20220629.025215-9"
|
||||
adventure-platform = "4.1.2"
|
||||
junit = "4.13.1"
|
||||
junit = "5.9.2"
|
||||
checkerframework = "3.19.0"
|
||||
log4j = "2.17.1"
|
||||
jline = "3.21.0"
|
||||
@ -81,7 +81,7 @@ checker-qual = { group = "org.checkerframework", name = "checker-qual", version.
|
||||
commodore = { group = "me.lucko", name = "commodore", version.ref = "commodore" }
|
||||
guava = { group = "com.google.guava", name = "guava", version.ref = "guava" }
|
||||
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
|
||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||
junit = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "junit" }
|
||||
mcauthlib = { group = "com.github.GeyserMC", name = "MCAuthLib", version.ref = "mcauthlib" }
|
||||
mcprotocollib = { group = "com.github.steveice10", name = "mcprotocollib", version.ref = "mcprotocollib" }
|
||||
packetlib = { group = "com.github.steveice10", name = "packetlib", version.ref = "packetlib" }
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren