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

fix/check_obligations_and_prohibitions #509

Conversation

eschrewe
Copy link
Contributor

Description

  • the policy check method of the EdcAdapterService class did not check for any possible contents of the rule type "prohibition" or "obligation" when testing whether a partner's policy in a contract offer was acceptable
  • added some code to the "testContractPolicyConstraints" method to fix this
  • added unit tests for these cases

Pre-review checks

Please ensure to do as many of the following checks as possible, before asking for committer review:

  • DEPENDENCIES are up-to-date. Dash license tool. Committers can open IP issues for restricted libs.
  • Copyright and license header are present on all affected files
  • If helm chart has been changed, the chart version has been bumped to either next major, minor or patch level (compared to released chart).

Copy link
Contributor

@tom-rm-meyer-ISST tom-rm-meyer-ISST left a comment

Choose a reason for hiding this comment

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

Thanks a lot and great catch :) only had small findings and one point for discussion :)

JsonNode validJsonNode = objectMapper.readTree(validJson);
JsonLdUtils jsonLdUtils = new JsonLdUtils();
validJsonNode = jsonLdUtils.expand(validJsonNode);
System.out.println(validJsonNode.toPrettyString());
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove print line and duplicate blank line.

@Test
public void wrongProhibition_testContractPolicyConstraints_fails() throws JsonProcessingException {
// given
String validJson = "{\n" +
Copy link
Contributor

Choose a reason for hiding this comment

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

Checked for other method: let's make the validJson and invalidJson.

* @throws JsonProcessingException if json is invalid
*/
@Test
public void wrongProhibition_testContractPolicyConstraints_fails() throws JsonProcessingException {
Copy link
Contributor

Choose a reason for hiding this comment

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

I was wondering if it makes sense to summarize the two tests into one parametrized test like in mad for the pattern checks.
Then I would propose to make the jsons constants with names like CATALOG_PROHIBITION_SET_NOT_ALLOWED and a comment. That would keep some readability.

Being honest: I also like the test name stating directly wrongProhibition and wrongObligation directly in the beginning. So this is not a neccessary change but an idea - only adapt if you like it better, because I'm not sure what's easier to maintain :)

Copy link
Contributor

@tom-rm-meyer-ISST tom-rm-meyer-ISST left a comment

Choose a reason for hiding this comment

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

LGTM, thanks a lot!

@tom-rm-meyer-ISST tom-rm-meyer-ISST merged commit 1213c58 into eclipse-tractusx:main Jul 24, 2024
12 checks passed
@tom-rm-meyer-ISST tom-rm-meyer-ISST deleted the fix/check_obligations_and_prohibitions branch July 24, 2024 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants