-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AAS Part 2 / API Model Classes #161
Add AAS Part 2 / API Model Classes #161
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are getting closer to merging this PR, however there are still some issues with the tests. Main issues are
-
JSON-realted tests should use static JSON/value pairs (use
ExampleData<T>
class) instead of generating in-/output on the fly via counterpart (i.e.JsonSerializerTest
should not useJsonDeserializer
and the other way around). The PR introduced some duplicate structures on how to store static test data viaTestDataHelper
-
tests for custom subclasses (e.g. of
Property
orDataSpecification
) missing, incomplete, and/or not properly separated (e.g.JsonSerializerTest.testSerializeCustomDataSpecification()
tests also deserialization but should only test serialization)
...-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSerializerTest.java
Outdated
Show resolved
Hide resolved
...-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSerializerTest.java
Outdated
Show resolved
Hide resolved
...-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSerializerTest.java
Outdated
Show resolved
Hide resolved
...-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSerializerTest.java
Outdated
Show resolved
Hide resolved
...-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonSerializerTest.java
Outdated
Show resolved
Hide resolved
...son/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java
Outdated
Show resolved
Hide resolved
...son/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java
Outdated
Show resolved
Hide resolved
...son/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java
Outdated
Show resolved
Hide resolved
...son/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java
Outdated
Show resolved
Hide resolved
...son/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java
Outdated
Show resolved
Hide resolved
@mjacoby, @sebbader-sap, @FrankSchnicke, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only slight changes required wrt de-/serializing custom data specifications as ReflectionHelper.SUBTYPES
should never be modified. When specific type resolution is needed use JsonDeserializer.useImplementation(...)
.
Once these changes are made we can merge the PR.
Environment expected = Examples.EXAMPLE_FULL.getModel(); | ||
Environment actual = new JsonDeserializer().read(Examples.EXAMPLE_FULL.fileContentStream()); | ||
Assert.assertEquals(expected, actual); | ||
public void testReadCustomDataSpecification() throws DeserializationException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReflectionHelper values should never be modified! Use this code instead
JsonDeserializer deserializer = new JsonDeserializer();
deserializer.useImplementation(DataSpecificationContent.class, DefaultDummyDataSpecification.class);
Environment env = deserializer.read(Examples.ENVIRONMENT_CUSTOM_DATA.fileContentStream(), Environment.class);
assertEquals(Examples.ENVIRONMENT_CUSTOM_DATA.getModel(), env);`
JsonSerializer serializer = new JsonSerializer(); | ||
JsonDeserializer deserializer = new JsonDeserializer(); | ||
|
||
public void testWriteCustomDataSpecification() { | ||
// This is the only way to make the serialization to work. | ||
Set<Class<?>> subtypes = ReflectionHelper.SUBTYPES.get(DataSpecificationContent.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line as it is not needed for serialization
JsonSerializer serializer = new JsonSerializer(); | ||
JsonDeserializer deserializer = new JsonDeserializer(); | ||
|
||
public void testWriteCustomDataSpecification() { | ||
// This is the only way to make the serialization to work. | ||
Set<Class<?>> subtypes = ReflectionHelper.SUBTYPES.get(DataSpecificationContent.class); | ||
subtypes.add(DefaultDummyDataSpecification.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line as it is not needed for serialization
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove JavaDoc for test methods
List<Referable> emptyList = Collections.emptyList(); | ||
String serialized = new JsonSerializer().write(emptyList); | ||
assertEquals("[]", serialized); | ||
} | ||
|
||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove JavaDoc for tests
@emildinchev just letting you know that I finished review |
@mjacoby Ready |
Solves #15