-
Notifications
You must be signed in to change notification settings - Fork 0
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
SD-1823 Revisit the OVS checks with unit test cases #235
Conversation
CI Failure Feedback 🧐(Checks updated until commit a75e892)
✨ CI feedback usage guide:The CI feedback tool (
In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR:
where Configuration options
See more information about the |
…alse and removed TODO
…ant changes to OvsChecksTest.java
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here. PR Code Suggestions ✨Explore these optional code suggestions:
|
…validation and change the limit to 5.
ovs/src/main/java/org/dcsa/conformance/standards/ovs/party/OvsPublisher.java
Outdated
Show resolved
Hide resolved
sspSupplier, | ||
OvsFilterParameter.FACILITY_SMDG_CODE, | ||
"*/vesselSchedules/*/transportCalls/*/location/facilitySMDGCode"))); | ||
"If present, at least schedule attribute must match the corresponding query parameters", |
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.
Does this mean at least one schedule? I didn't get it from this message string
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.
it should have been "at least one schedule". it corrrect it
ovs/src/main/java/org/dcsa/conformance/standards/ovs/party/OvsFilterParameter.java
Show resolved
Hide resolved
if (RETURN_EMPTY_RESPONSE) { | ||
return request.createResponse( | ||
200, headers, new ConformanceMessageBody(OBJECT_MAPPER.createArrayNode())); | ||
} else if (USE_WRONG_ATTRIBUTE_VALUES) { |
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.
Do we need two different responses for both wrong attributes and dates?
…ded unit test cases.
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.
I've investigated the code locally and I think you can make it easier, with a few adjustments. Let's have a Team call if you think it is not feasible.
ovs/src/main/java/org/dcsa/conformance/standards/ovs/checks/OvsChecks.java
Outdated
Show resolved
Hide resolved
ovs/src/main/java/org/dcsa/conformance/standards/ovs/checks/OvsChecks.java
Show resolved
Hide resolved
ovs/src/test/java/org/dcsa/conformance/standards/ovs/OvsChecksTest.java
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
return Set.of(); | ||
})); | ||
|
||
return JsonAttribute.contentChecks( |
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.
@preetamnpr, I've checked on how you can unit test this without the modifications in JsonAttributeBasedCheck
. I think it is possible if you move each separate check into a package private method, which generates just one check. Or if you don't like that, just have this method return the checks
and make it package private. The checks itself are easy to validate with. And create the wrapper a level higher: JsonAttribute.contentChecks(OvsRole::isPublisher, matched, HttpMessageType.RESPONSE, standardVersion, checks);
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.
The wrapper method works and this doesnt require any core changes in order to build the unit test cases. I have implemented the wrapper method and it works fine with no changs to core.
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.
It was just a suggestion on how you can more easily unit test it. The last sentence on the wrapper is just a side note.. just keep it if it is needed. No worries.
.map(Map.Entry::getKey) | ||
.collect(Collectors.joining(", ")), // Get keys here | ||
attributeValues.size() > 1 ? "" : "es", | ||
parameterValues.size() > 1 ? "s" : "", |
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.
You're doing this very properly..but I think perhaps it is too nice 😉 . You can just safe time and code by doing this: Value(s). If it was on the front page of a site, it is important, but since this is an error code, which is still clear, you can make it yourself easy.
ovs/src/test/java/org/dcsa/conformance/standards/ovs/OvsChecksTest.java
Outdated
Show resolved
Hide resolved
ovs/src/test/java/org/dcsa/conformance/standards/ovs/OvsChecksTest.java
Outdated
Show resolved
Hide resolved
ovs/src/test/java/org/dcsa/conformance/standards/ovs/OvsChecksTest.java
Outdated
Show resolved
Hide resolved
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.
Thanks Preetam. Please wait before merging, on the others. Only put some minor remarks.
"CheckServiceSchedules failed: %s".formatted(validationError))); | ||
if (validationErrors.isEmpty()) { | ||
return Set.of(); | ||
} |
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.
Line 41-43 can be removed, because line 44 does the same (return empty Set, or with entries).
|
||
if (body == null || body.isMissingNode() || body.isNull()) { | ||
return Set.of("Response body is missing or null."); | ||
} else { |
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.
} else { | |
} |
…on to return empty set.
User description
I am enhancing the unit test cases to capture all possible cases. Once its done this PR will be ready for the review
PR Type
Enhancement, Tests
Description
Changes walkthrough 📝
6 files
OvsScenarioListBuilder.java
Update scenario dates for consistency
ovs/src/main/java/org/dcsa/conformance/standards/ovs/OvsScenarioListBuilder.java
OvsChecks.java
Refactor and enhance OVS checks with logging
ovs/src/main/java/org/dcsa/conformance/standards/ovs/checks/OvsChecks.java
@Slf4j
.OvsFilterParameter.java
Enhance OvsFilterParameter with additional attributes
ovs/src/main/java/org/dcsa/conformance/standards/ovs/party/OvsFilterParameter.java
@Getter
annotation.OvsPublisher.java
Add test flags for response scenarios in OvsPublisher
ovs/src/main/java/org/dcsa/conformance/standards/ovs/party/OvsPublisher.java
ovs-300-response.json
Update transport call reference and event date time
ovs/src/main/resources/standards/ovs/messages/ovs-300-response.json
OVS_v3.0.0.yaml
Restrict additional properties in UNLocationLocation schema
ovs/src/main/resources/standards/ovs/schemas/OVS_v3.0.0.yaml
additionalProperties
to false for UNLocationLocation.4 files
OvsChecksTest.java
Add unit tests for OvsChecks validation logic
ovs/src/test/java/org/dcsa/conformance/standards/ovs/OvsChecksTest.java
ovs-300-response-wrong-attribute-values.json
Add test message with incorrect attribute values
ovs/src/main/resources/standards/ovs/messages/ovs-300-response-wrong-attribute-values.json
ovs-300-response-wrong-date-times.json
Add test message with incorrect date formats
ovs/src/main/resources/standards/ovs/messages/ovs-300-response-wrong-date-times.json
ovs-300-response-wrong-structure.json
Add test message with incorrect structure
ovs/src/main/resources/standards/ovs/messages/ovs-300-response-wrong-structure.json
1 files
pom.xml
Add JUnit Jupiter dependency for testing
ovs/pom.xml