-
-
Notifications
You must be signed in to change notification settings - Fork 470
OBPIH-6300 Add tests for mapping requestor's dashboard statuses #4585
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| package unit.org.pih.warehouse.core | ||
|
|
||
| import org.pih.warehouse.inventory.StockMovementStatusCode | ||
| import org.pih.warehouse.requisition.Requisition | ||
| import org.pih.warehouse.shipping.Shipment | ||
| import org.pih.warehouse.shipping.ShipmentStatusCode | ||
| import spock.lang.Specification | ||
| import spock.lang.Unroll | ||
| import org.pih.warehouse.requisition.RequisitionStatus | ||
| import org.pih.warehouse.api.StockMovement | ||
|
|
||
| @Unroll | ||
| class StockMovementSpec extends Specification { | ||
|
|
||
| void 'StockMovement.getDisplayStatus() should return: #expected for requisition status #status'() { | ||
| when: | ||
| StockMovement stockMovement = new StockMovement() { | ||
| @Override | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice work on these tests! In general I'm not the hugest fan of overriding methods in a test like this. Usually I'd try to Stub out the tagLib but it doesn't look like that'd be easy to do since it's fetched statically in the StockMovement. You could maybe Stub the StockMovemnt instance itself with something like: but that's essentially what you're doing anyways with your override (and I don't even know if the above code would work). I'm okay with your approach here. Yay tests! |
||
| String getTranslatedDisplayStatus(def status) { | ||
| return status.name() | ||
| } | ||
| } | ||
| stockMovement.requisition = new Requisition() | ||
| stockMovement.requisition.status = status | ||
|
|
||
| then: | ||
| stockMovement.getDisplayStatus() == expected.name() | ||
|
|
||
| where: | ||
| status || expected | ||
| RequisitionStatus.APPROVED || StockMovementStatusCode.APPROVED | ||
| RequisitionStatus.REJECTED || StockMovementStatusCode.REJECTED | ||
| RequisitionStatus.PENDING_APPROVAL || StockMovementStatusCode.PENDING_APPROVAL | ||
| RequisitionStatus.VERIFYING || StockMovementStatusCode.IN_PROGRESS | ||
| RequisitionStatus.PICKING || StockMovementStatusCode.IN_PROGRESS | ||
| RequisitionStatus.PICKED || StockMovementStatusCode.IN_PROGRESS | ||
| RequisitionStatus.CHECKING || StockMovementStatusCode.IN_PROGRESS | ||
| } | ||
|
|
||
| void 'StockMovement.getDisplayStatus() should return: #expected for shipment status #status'() { | ||
| when: | ||
| StockMovement stockMovement = new StockMovement() { | ||
| @Override | ||
| String getTranslatedDisplayStatus(def status) { | ||
| return status.name() | ||
| } | ||
| } | ||
| stockMovement.shipment = new Shipment() | ||
| stockMovement.shipment.status.code = status | ||
|
|
||
| then: | ||
| stockMovement.getDisplayStatus() == expected.name() | ||
|
|
||
| where: | ||
| status || expected | ||
| ShipmentStatusCode.CREATED || ShipmentStatusCode.PENDING | ||
| ShipmentStatusCode.PARTIALLY_RECEIVED || ShipmentStatusCode.PENDING | ||
| ShipmentStatusCode.RECEIVED || ShipmentStatusCode.PENDING | ||
| ShipmentStatusCode.SHIPPED || ShipmentStatusCode.PENDING | ||
| } | ||
| } | ||
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 didn't get a chance to review this but could you please change the implementation of this method to be ...
Also why do we need a second method to get the translated display status when the original getDisplayStatus() method already does the localization?
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 am not sure if I understand what you mean, but I moved this to a separate function because I wanted to make the code more clean 🤔