Add updateStructureConversionPath

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2022-07-30 04:01:47 +02:00
parent 92b11eabbd
commit 648232c344
1 changed files with 21 additions and 0 deletions

View File

@ -130,6 +130,27 @@ public class TagUpdateTest {
assertNull(handler.getTag(tag2));
}
@Test
public void updateStructureConversionPath() {
record Test(int coin) {
}
var tag1 = Tag.Integer("coin").path("path", "path2");
var tag2 = Tag.Structure("path2", Test.class).path("path");
var handler = TagHandler.newHandler();
handler.setTag(tag1, 5);
assertEquals(5, handler.getTag(tag1));
assertEquals(new Test(5), handler.getTag(tag2));
assertDoesNotThrow(() -> handler.updateTag(tag2, value -> new Test(value.coin + 1)));
assertEquals(6, handler.getTag(tag1));
assertEquals(new Test(6), handler.getTag(tag2));
handler.updateTag(tag2, value -> null);
assertNull(handler.getTag(tag1));
assertNull(handler.getTag(tag2));
}
@Test
public void updateViewConversion() {
record Test(int coin) {