Skip to content

EBL Transportdoctype code swb validation#513

Merged
palatsangeetha merged 3 commits into
devfrom
SD-2427-transportdoctypecode-validation
May 4, 2026
Merged

EBL Transportdoctype code swb validation#513
palatsangeetha merged 3 commits into
devfrom
SD-2427-transportdoctypecode-validation

Conversation

@palatsangeetha
Copy link
Copy Markdown
Collaborator

No description provided.

@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Add SWB negotiability validation and test coverage

✨ Enhancement 🧪 Tests

Grey Divider

Walkthroughs

Description
• Add validation to prevent SWB transport documents from being negotiable
• Implement custom validator checking isToOrder flag for SWBs
• Register new validation check in static TD checks list
• Add comprehensive test coverage for SWB negotiability validation
Diagram
flowchart LR
  A["SWB Document"] -->|transportDocumentTypeCode check| B["SWBS_CANNOT_BE_NEGOTIABLE"]
  B -->|isToOrder validation| C["Custom Validator"]
  C -->|true| D["Validation Fails"]
  C -->|false/absent| E["Validation Passes"]
  B -->|registered in| F["STATIC_TD_CHECKS"]
  B -->|registered in| G["allDg checks"]
Loading

Grey Divider

File Changes

1. ebl/src/main/java/org/dcsa/conformance/standards/ebl/checks/EblChecks.java ✨ Enhancement +23/-0

Add SWB negotiability validation check

• Added new static SWBS_CANNOT_BE_NEGOTIABLE validation check using JsonAttribute.ifThen()
• Implements custom validator that ensures isToOrder is false or absent for SWB documents
• Registered the new check in both allDg() and STATIC_TD_CHECKS lists
• Provides descriptive error message when SWB has isToOrder set to true

ebl/src/main/java/org/dcsa/conformance/standards/ebl/checks/EblChecks.java


2. ebl/src/test/java/org/dcsa/conformance/standards/ebl/checks/EblChecksTest.java 🧪 Tests +38/-0

Add SWB negotiability validation test cases

• Added import for SWBS_CANNOT_BE_NEGOTIABLE check
• Implemented comprehensive testSWBsCannotBeNegotiable() test method
• Tests SWB with isToOrder=false passes validation
• Tests SWB with isToOrder=true fails validation
• Tests SWB without isToOrder field passes (defaults to false)
• Tests non-SWB documents (BOL) are marked as irrelevant

ebl/src/test/java/org/dcsa/conformance/standards/ebl/checks/EblChecksTest.java


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Apr 23, 2026

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (1)

Grey Divider


Action required

1. BOL isToOrder=false allowed 📎 Requirement gap ≡ Correctness
Description
The new validation explicitly rejects SWB with isToOrder=true but still does not enforce that
BOL requires isToOrder=true, so BOL with isToOrder=false can still pass validation. The
added unit test also asserts BOL + isToOrder=false is irrelevant instead of invalid,
contradicting the required rule.
Code

ebl/src/test/java/org/dcsa/conformance/standards/ebl/checks/EblChecksTest.java[R521-538]

+    // BOL with isToOrder = true should be irrelevant (not an SWB)
+    rootNode.removeAll();
+    rootNode.put("transportDocumentTypeCode", "BOL");
+    rootNode.put("isToOrder", true);
+    ConformanceCheckResult.ErrorsWithRelevance irrelevantResult =
+        (ConformanceCheckResult.ErrorsWithRelevance)
+            SWBS_CANNOT_BE_NEGOTIABLE.validate(rootNode);
+    assertEquals(1, irrelevantResult.errors().size());
+    assertFalse(irrelevantResult.isRelevant());
+
+    // BOL with isToOrder = false should also be irrelevant
+    rootNode.put("transportDocumentTypeCode", "BOL");
+    rootNode.put("isToOrder", false);
+    irrelevantResult =
+        (ConformanceCheckResult.ErrorsWithRelevance)
+            SWBS_CANNOT_BE_NEGOTIABLE.validate(rootNode);
+    assertEquals(1, irrelevantResult.errors().size());
+    assertFalse(irrelevantResult.isRelevant());
Evidence
PR Compliance ID 1 requires explicitly rejecting transportDocumentTypeCode=BOL when
isToOrder=false. The added check SWBS_CANNOT_BE_NEGOTIABLE only applies when
transportDocumentTypeCode is SWB, and the new test explicitly treats both BOL +
isToOrder=true and BOL + isToOrder=false as irrelevant rather than invalid.

Validate SWB requires isToOrder=false (and BOL requires isToOrder=true) for transportDocumentTypeCode/isToOrder combinations
ebl/src/main/java/org/dcsa/conformance/standards/ebl/checks/EblChecks.java[319-338]
ebl/src/test/java/org/dcsa/conformance/standards/ebl/checks/EblChecksTest.java[521-538]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Validation is missing the required explicit rule that when `transportDocumentTypeCode` is `BOL`, `isToOrder` must be `true` (reject when `false` or absent).

## Issue Context
The PR adds `SWBS_CANNOT_BE_NEGOTIABLE`, but it only validates the `SWB` side of the rule. The added unit test currently expects `BOL` + `isToOrder=false` to be irrelevant, which contradicts the compliance requirement.

## Fix Focus Areas
- ebl/src/main/java/org/dcsa/conformance/standards/ebl/checks/EblChecks.java[312-338]
- ebl/src/test/java/org/dcsa/conformance/standards/ebl/checks/EblChecksTest.java[521-538]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Duplicate negotiable SWB errors 🐞 Bug ⚙ Maintainability
Description
For payloads where transportDocumentTypeCode='SWB' and isToOrder=true, BOTH
ONLY_EBLS_CAN_BE_NEGOTIABLE and SWBS_CANNOT_BE_NEGOTIABLE will fail, producing two separate error
messages for the same invalid condition. This can unnecessarily bloat conformance reports and
potentially break consumers/tests that assume a single error for this violation.
Code

ebl/src/main/java/org/dcsa/conformance/standards/ebl/checks/EblChecks.java[R1165-1169]

          VALID_PARTY_FUNCTION,
          VALID_PARTY_FUNCTION_HBL,
          ONLY_EBLS_CAN_BE_NEGOTIABLE,
+          SWBS_CANNOT_BE_NEGOTIABLE,
          EBL_AT_MOST_ONE_ORIGINAL_TOTAL,
Evidence
The PR adds SWBS_CANNOT_BE_NEGOTIABLE right after ONLY_EBLS_CAN_BE_NEGOTIABLE in the same check
lists, so both checks run for the same payload. ONLY_EBLS_CAN_BE_NEGOTIABLE triggers on
isToOrder=true and fails when transportDocumentTypeCode != 'BOL' (so it fails for SWB).
SWBS_CANNOT_BE_NEGOTIABLE independently triggers on transportDocumentTypeCode='SWB' and fails when
isToOrder=true. Both failures are surfaced as distinct error messages because mustEqual produces a
SimpleErrors error set on mismatch and conformance reports aggregate errors from each sub-check.

ebl/src/main/java/org/dcsa/conformance/standards/ebl/checks/EblChecks.java[312-338]
ebl/src/main/java/org/dcsa/conformance/standards/ebl/checks/EblChecks.java[1148-1203]
core/src/main/java/org/dcsa/conformance/core/check/JsonAttribute.java[474-502]
core/src/main/java/org/dcsa/conformance/core/check/ConformanceResult.java[20-22]
core/src/main/java/org/dcsa/conformance/core/report/ConformanceReport.java[31-41]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
When `transportDocumentTypeCode='SWB'` and `isToOrder=true`, two separate validations fail:
- `ONLY_EBLS_CAN_BE_NEGOTIABLE` (because `isToOrder=true` implies `transportDocumentTypeCode` must be `BOL`)
- `SWBS_CANNOT_BE_NEGOTIABLE` (because `SWB` cannot be negotiable)

This yields duplicate error messages for the same underlying rule violation.

### Issue Context
Both checks are included in the same validation lists for SI and TD payload validation, so they will run in the same conformance evaluation.

### Fix Focus Areas
- ebl/src/main/java/org/dcsa/conformance/standards/ebl/checks/EblChecks.java[312-318]
- ebl/src/main/java/org/dcsa/conformance/standards/ebl/checks/EblChecks.java[1148-1203]

### Suggested fix
Update `ONLY_EBLS_CAN_BE_NEGOTIABLE` so it does not also fire for SWB (letting the new SWB-specific check be the single source of truth for SWB negotiability). For example:
- Change the `when` predicate from `isToOrder==true` to `isToOrder==true AND transportDocumentTypeCode != 'SWB'`.

Optionally add/adjust a unit test to assert that `ONLY_EBLS_CAN_BE_NEGOTIABLE` becomes irrelevant for `SWB + isToOrder=true` (and that `SWBS_CANNOT_BE_NEGOTIABLE` still fails).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a dedicated conformance rule to ensure Sea Waybills (SWB) are never marked negotiable (isToOrder=true), aligning validation with SWB business rules.

Changes:

  • Introduces SWBS_CANNOT_BE_NEGOTIABLE validation in EblChecks.
  • Registers the new validation in both static Shipping Instructions and Transport Document check lists.
  • Adds unit tests covering pass/fail/irrelevant scenarios for the new validation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
ebl/src/main/java/org/dcsa/conformance/standards/ebl/checks/EblChecks.java Adds and wires a new SWB negotiability validation into the standard check sets.
ebl/src/test/java/org/dcsa/conformance/standards/ebl/checks/EblChecksTest.java Adds unit coverage for the new SWB negotiability rule.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Collaborator

@pedrocarvalhodcsa pedrocarvalhodcsa left a comment

Choose a reason for hiding this comment

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

Seems good to me, I don't really understand the comment from copilot

@palatsangeetha palatsangeetha merged commit 0a8e3cd into dev May 4, 2026
1 check passed
@palatsangeetha palatsangeetha deleted the SD-2427-transportdoctypecode-validation branch May 4, 2026 07:15
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.

3 participants