Skip to content
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

Merged
merged 103 commits into from
Feb 5, 2024

Conversation

sebbader-sap
Copy link
Contributor

@sebbader-sap sebbader-sap commented Aug 21, 2023

Solves #15

@sebbader-sap sebbader-sap requested a review from mjacoby January 29, 2024 09:42
Copy link
Contributor

@mjacoby mjacoby left a 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 use JsonDeserializer and the other way around). The PR introduced some duplicate structures on how to store static test data via TestDataHelper

  • tests for custom subclasses (e.g. of Property or DataSpecification) missing, incomplete, and/or not properly separated (e.g. JsonSerializerTest.testSerializeCustomDataSpecification() tests also deserialization but should only test serialization)

@emildinchev
Copy link
Contributor

@mjacoby, @sebbader-sap, @FrankSchnicke,
The PR is ready for a new review.

Copy link
Contributor

@mjacoby mjacoby left a 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 {
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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

}

/**
Copy link
Contributor

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);
}

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove JavaDoc for tests

@mjacoby
Copy link
Contributor

mjacoby commented Feb 5, 2024

@emildinchev just letting you know that I finished review

@emildinchev
Copy link
Contributor

@mjacoby Ready

@mjacoby mjacoby merged commit 8c516b5 into eclipse-aas4j:main Feb 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V.1.0.0 Final Release V.1.0.0 following EF processes
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants