From b3a95dcbc86b0e2e48fd0b51b8b41a40800a648a Mon Sep 17 00:00:00 2001 From: "(Jip) Willem Wijnia" Date: Mon, 3 Jun 2024 12:58:15 +0200 Subject: [PATCH] Add tests --- .../commons/replay/LoadReplayLoaderTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/faf-commons-data/src/test/java/com/faforever/commons/replay/LoadReplayLoaderTest.java b/faf-commons-data/src/test/java/com/faforever/commons/replay/LoadReplayLoaderTest.java index 7a06f849..a89b4388 100644 --- a/faf-commons-data/src/test/java/com/faforever/commons/replay/LoadReplayLoaderTest.java +++ b/faf-commons-data/src/test/java/com/faforever/commons/replay/LoadReplayLoaderTest.java @@ -10,11 +10,13 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; import java.util.List; import java.util.Objects; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; class LoadReplayLoaderTest { @@ -41,6 +43,7 @@ public void parseBinary01() throws CompressorException, IOException { assertNoUnprocessedTokens(fafReplayContainer); assertNoErrorTokens(fafReplayContainer); + assertEquals("neroxis_map_generator_1.11.0_wvmzfgnlgiebu_bqgaeb3bgzldwstbaa", ReplaySemantics.getMapFolder(fafReplayContainer)); List chatMessages = ReplaySemantics.getChatMessages(fafReplayContainer.header().sources(), fafReplayContainer.registeredEvents()); assertEquals(106, chatMessages.size()); @@ -58,6 +61,7 @@ public void parseBinary02() throws CompressorException, IOException { assertNoUnprocessedTokens(fafReplayContainer); assertNoErrorTokens(fafReplayContainer); + assertEquals("SCMP_039", ReplaySemantics.getMapFolder(fafReplayContainer)); List chatMessages = ReplaySemantics.getChatMessages(fafReplayContainer.header().sources(), fafReplayContainer.registeredEvents()); assertEquals(2, chatMessages.size()); @@ -75,6 +79,7 @@ public void parseBinary03() throws CompressorException, IOException { assertNoUnprocessedTokens(fafReplayContainer); assertNoErrorTokens(fafReplayContainer); + assertEquals("dualgap_fix_adaptive.v0007", ReplaySemantics.getMapFolder(fafReplayContainer)); List chatMessages = ReplaySemantics.getChatMessages(fafReplayContainer.header().sources(), fafReplayContainer.registeredEvents()); assertEquals(1, chatMessages.size()); @@ -92,6 +97,7 @@ public void parseBinary04() throws CompressorException, IOException { assertNoUnprocessedTokens(fafReplayContainer); assertNoErrorTokens(fafReplayContainer); + assertEquals("SCMP_009", ReplaySemantics.getMapFolder(fafReplayContainer)); List chatMessages = ReplaySemantics.getChatMessages(fafReplayContainer.header().sources(), fafReplayContainer.registeredEvents()); assertEquals(7, chatMessages.size()); @@ -109,6 +115,7 @@ public void parseBinary05() throws CompressorException, IOException { assertNoUnprocessedTokens(fafReplayContainer); assertNoErrorTokens(fafReplayContainer); + assertEquals("SCMP_026", ReplaySemantics.getMapFolder(fafReplayContainer)); List chatMessages = ReplaySemantics.getChatMessages(fafReplayContainer.header().sources(), fafReplayContainer.registeredEvents()); assertEquals(0, chatMessages.size()); @@ -126,6 +133,7 @@ public void parseBinary06() throws CompressorException, IOException { assertNoUnprocessedTokens(fafReplayContainer); assertNoErrorTokens(fafReplayContainer); + assertEquals("SCMP_026", ReplaySemantics.getMapFolder(fafReplayContainer)); List chatMessages = ReplaySemantics.getChatMessages(fafReplayContainer.header().sources(), fafReplayContainer.registeredEvents()); assertEquals(0, chatMessages.size()); @@ -143,6 +151,7 @@ public void parseBinary07() throws CompressorException, IOException { assertNoUnprocessedTokens(fafReplayContainer); assertNoErrorTokens(fafReplayContainer); + assertEquals("SCMP_026", ReplaySemantics.getMapFolder(fafReplayContainer)); List chatMessages = ReplaySemantics.getChatMessages(fafReplayContainer.header().sources(), fafReplayContainer.registeredEvents()); assertEquals(3, chatMessages.size()); @@ -159,9 +168,14 @@ public void parseBinary08() throws CompressorException, IOException { ReplayContainer fafReplayContainer = ReplayLoader.loadFAFReplayFromDisk(fafReplayFile); assertEquals(2, fafReplayContainer.header().mods().size()); + List modUIDs = new ArrayList<>(); + modUIDs.add("fnewm028-v096-55b4-92b6-64398e7ge43f"); + modUIDs.add("d883189d-c556-4d68-b1c8-6ad201b3f7ad"); + assertLinesMatch(modUIDs , ReplaySemantics.getModUIDs(fafReplayContainer)); assertNoUnprocessedTokens(fafReplayContainer); assertNoErrorTokens(fafReplayContainer); + assertEquals("project_tumulus.v0004", ReplaySemantics.getMapFolder(fafReplayContainer)); List chatMessages = ReplaySemantics.getChatMessages(fafReplayContainer.header().sources(), fafReplayContainer.registeredEvents()); assertEquals(0, chatMessages.size()); @@ -180,10 +194,12 @@ public void compareBinary01() throws CompressorException, IOException { ReplayContainer fafReplayContainer = ReplayLoader.loadFAFReplayFromDisk(fafReplayFile); assertNoUnprocessedTokens(fafReplayContainer); assertNoErrorTokens(fafReplayContainer); + assertEquals("SCMP_026", ReplaySemantics.getMapFolder(fafReplayContainer)); ReplayContainer scfaReplayContainer = ReplayLoader.loadSCFAReplayFromDisk(scfaReplayFile); assertNoUnprocessedTokens(scfaReplayContainer); assertNoErrorTokens(scfaReplayContainer); + assertEquals("SCMP_026", ReplaySemantics.getMapFolder(fafReplayContainer)); assertEquals(scfaReplayContainer.registeredEvents().size(), fafReplayContainer.registeredEvents().size()); assertArrayEquals( scfaReplayContainer.registeredEvents().toArray(), fafReplayContainer.registeredEvents().toArray()); @@ -200,10 +216,12 @@ public void compareBinary02() throws CompressorException, IOException { ReplayContainer fafReplayContainer = ReplayLoader.loadFAFReplayFromDisk(fafReplayFile); assertNoUnprocessedTokens(fafReplayContainer); assertNoErrorTokens(fafReplayContainer); + assertEquals("open_palms_-_faf_version.v0002", ReplaySemantics.getMapFolder(fafReplayContainer)); ReplayContainer scfaReplayContainer = ReplayLoader.loadSCFAReplayFromDisk(scfaReplayFile); assertNoUnprocessedTokens(scfaReplayContainer); assertNoErrorTokens(scfaReplayContainer); + assertEquals("open_palms_-_faf_version.v0002", ReplaySemantics.getMapFolder(fafReplayContainer)); assertEquals(scfaReplayContainer.registeredEvents().size(), fafReplayContainer.registeredEvents().size()); assertArrayEquals( scfaReplayContainer.registeredEvents().toArray(), fafReplayContainer.registeredEvents().toArray()); @@ -221,10 +239,12 @@ public void compareBinary03() throws CompressorException, IOException { ReplayContainer fafReplayContainer = ReplayLoader.loadFAFReplayFromDisk(fafReplayFile); assertNoUnprocessedTokens(fafReplayContainer); assertNoErrorTokens(fafReplayContainer); + assertEquals("SCMP_026", ReplaySemantics.getMapFolder(fafReplayContainer)); ReplayContainer scfaReplayContainer = ReplayLoader.loadSCFAReplayFromDisk(scfaReplayFile); assertNoUnprocessedTokens(scfaReplayContainer); assertNoErrorTokens(scfaReplayContainer); + assertEquals("SCMP_026", ReplaySemantics.getMapFolder(fafReplayContainer)); assertEquals(scfaReplayContainer.registeredEvents().size(), fafReplayContainer.registeredEvents().size()); assertArrayEquals( scfaReplayContainer.registeredEvents().toArray(), fafReplayContainer.registeredEvents().toArray());