23
23
import be .seeseemelk .mockbukkit .ServerMock ;
24
24
import com .google .common .collect .ImmutableList ;
25
25
import net .william278 .husktowns .audit .Action ;
26
+ import net .william278 .husktowns .audit .Log ;
26
27
import net .william278 .husktowns .claim .*;
27
28
import net .william278 .husktowns .map .MapSquare ;
28
29
import net .william278 .husktowns .town .Town ;
@@ -334,7 +335,7 @@ private static Stream<Arguments> getTownAndMayorParameters() {
334
335
@ Order (5 )
335
336
@ Nested
336
337
@ DisplayName ("Town Schema Update Tests" )
337
- public class TownSchemaUpdateTests {
338
+ public class TownSchemaTests {
338
339
339
340
@ Order (1 )
340
341
@ DisplayName ("Test Town Schema Update" )
@@ -351,6 +352,24 @@ public void testTownSchemaUpdate() {
351
352
);
352
353
}
353
354
355
+ @ Order (2 )
356
+ @ DisplayName ("Test Deserializing Town Log with Duplicate Keys" )
357
+ @ Test
358
+ public void testTownLogSerialization () {
359
+ final String logJson = """
360
+ {
361
+ "actions": {
362
+ "2024-02-04T15:09:34.661609Z": { "action": "CREATE_TOWN" },
363
+ "2024-02-04T15:09:34.661609Z": { "action": "CREATE_TOWN" }
364
+ }
365
+ }""" ;
366
+ final Log log = plugin .getGson ().fromJson (logJson , Log .class );
367
+ Assertions .assertNotNull (log , "Failed to deserialize log with duplicate keys" );
368
+
369
+ final Map <OffsetDateTime , Action > actions = log .getActions ();
370
+ Assertions .assertEquals (1 , actions .size (), "Duplicate keys were not removed on load" );
371
+ }
372
+
354
373
}
355
374
356
375
@ NotNull
0 commit comments