Generate versioned Model metadata and consume it in shared binding discovery
This commit is contained in:
+35
@@ -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())));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user