Generate versioned Model metadata and consume it in shared binding discovery

This commit is contained in:
2026-11-13 19:08:30 +01:00
parent 9bc4569407
commit adf432b98b
20 changed files with 700 additions and 15 deletions
@@ -0,0 +1,35 @@
package de.neitzel.fxdesigner.protocol;
import static org.junit.jupiter.api.Assertions.*;
import java.io.*;
import java.util.*;
import org.junit.jupiter.api.Test;
class ModelMetadataTest {
@Test
void deterministicRoundTripAndSchemaValidation() throws Exception {
var m =
new ModelMetadata(
"app.Person",
List.of(
new ModelMetadata.Property("name", "java.lang.String", "", "getName", "setName")));
assertEquals(m, ModelMetadata.read(new ByteArrayInputStream(m.encode())));
assertThrows(
IOException.class,
() ->
ModelMetadata.read(
new ByteArrayInputStream(
new String(m.encode(), java.nio.charset.StandardCharsets.UTF_8)
.replace("schemaVersion=1.0", "schemaVersion=9.0")
.getBytes(java.nio.charset.StandardCharsets.UTF_8))));
assertThrows(
IOException.class,
() -> ModelMetadata.read(new ByteArrayInputStream(new byte[ModelMetadata.LIMIT + 1])));
assertThrows(
IllegalArgumentException.class,
() ->
new ModelMetadata(
"app.Person", List.of(m.properties().getFirst(), m.properties().getFirst())));
}
}