Skip to content

Commit

Permalink
fix flakyness
Browse files Browse the repository at this point in the history
refs: #17813
  • Loading branch information
cp-ps committed Apr 10, 2024
1 parent 9b3714a commit 932893f
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import de.metas.cucumber.stepdefs.DataTableRow;
import de.metas.cucumber.stepdefs.DataTableRows;
import de.metas.cucumber.stepdefs.StepDefDataIdentifier;
import de.metas.cucumber.stepdefs.StepDefUtil;
import de.metas.picking.api.IPickingSlotDAO;
import de.metas.picking.model.I_M_PickingSlot;
import de.metas.util.Services;
Expand Down Expand Up @@ -37,42 +38,21 @@ public void createPickingSlots(@NonNull final DataTable dataTable)
DataTableRows.of(dataTable).forEach(this::createPickingSlot);
}

@Then("validate M_PickingSlot:")
public void validatePickingSlot(@NonNull final DataTable dataTable)
@Then("^after not more than (.*)s, validate M_PickingSlot:$")
public void validateAndWaitPickingSlotStep(final int timeoutSec, @NonNull final DataTable dataTable) throws InterruptedException
{
DataTableRows.of(dataTable).forEach((tableRow) -> {
final I_M_PickingSlot pickingSlot = tableRow
.getAsIdentifier(I_M_PickingSlot.COLUMNNAME_M_PickingSlot_ID)
.lookupIn(pickingSlotsTable);

final SoftAssertions softAssertions = new SoftAssertions();

tableRow.getAsOptionalIdentifier(I_M_PickingSlot.COLUMNNAME_C_BPartner_ID)
.map(identifier -> identifier.lookupIn(bpartnerTable))
.map(I_C_BPartner::getC_BPartner_ID)
.ifPresent(bpartnerId -> softAssertions.assertThat(pickingSlot.getC_BPartner_ID()).isEqualTo(bpartnerId));

tableRow.getAsOptionalIdentifier(I_M_PickingSlot.COLUMNNAME_C_BPartner_Location_ID)
.map(identifier -> identifier.lookupIn(bpartnerLocationTable))
.map(I_C_BPartner_Location::getC_BPartner_Location_ID)
.ifPresent(bpartnerLocationId -> softAssertions.assertThat(pickingSlot.getC_BPartner_Location_ID()).isEqualTo(bpartnerLocationId));

tableRow.getAsOptionalBoolean("IsAllocated")
.ifPresent(isAllocated -> {
if (isAllocated)
{
softAssertions.assertThat(pickingSlot.getC_BPartner_ID()).isGreaterThan(0);
softAssertions.assertThat(pickingSlot.getC_BPartner_Location_ID()).isGreaterThan(0);
}
else
{
softAssertions.assertThat(pickingSlot.getC_BPartner_ID()).isEqualTo(0);
softAssertions.assertThat(pickingSlot.getC_BPartner_Location_ID()).isEqualTo(0);
}
});
StepDefUtil.tryAndWait(timeoutSec, 1000,
() -> {
final SoftAssertions softAssertions = checkPickingSlot(dataTable);
return softAssertions.assertionErrorsCollected().isEmpty();
},
() -> checkPickingSlot(dataTable).assertAll());
}

softAssertions.assertAll();
});
@Then("validate M_PickingSlot:")
public void validatePickingSlotStep(@NonNull final DataTable dataTable)
{
checkPickingSlot(dataTable).assertAll();
}

private void createPickingSlot(@NonNull final DataTableRow row)
Expand Down Expand Up @@ -110,4 +90,42 @@ private LocatorId getMainLocatorId()
{
return warehouseBL.getDefaultLocatorId(WarehouseId.MAIN);
}

@NonNull
private SoftAssertions checkPickingSlot(@NonNull final DataTable dataTable)
{
final SoftAssertions softAssertions = new SoftAssertions();

DataTableRows.of(dataTable).forEach((tableRow) -> {
final I_M_PickingSlot pickingSlot = tableRow
.getAsIdentifier(I_M_PickingSlot.COLUMNNAME_M_PickingSlot_ID)
.lookupIn(pickingSlotsTable);

tableRow.getAsOptionalIdentifier(I_M_PickingSlot.COLUMNNAME_C_BPartner_ID)
.map(identifier -> identifier.lookupIn(bpartnerTable))
.map(I_C_BPartner::getC_BPartner_ID)
.ifPresent(bpartnerId -> softAssertions.assertThat(pickingSlot.getC_BPartner_ID()).isEqualTo(bpartnerId));

tableRow.getAsOptionalIdentifier(I_M_PickingSlot.COLUMNNAME_C_BPartner_Location_ID)
.map(identifier -> identifier.lookupIn(bpartnerLocationTable))
.map(I_C_BPartner_Location::getC_BPartner_Location_ID)
.ifPresent(bpartnerLocationId -> softAssertions.assertThat(pickingSlot.getC_BPartner_Location_ID()).isEqualTo(bpartnerLocationId));

tableRow.getAsOptionalBoolean("IsAllocated")
.ifPresent(isAllocated -> {
if (isAllocated)
{
softAssertions.assertThat(pickingSlot.getC_BPartner_ID()).isGreaterThan(0);
softAssertions.assertThat(pickingSlot.getC_BPartner_Location_ID()).isGreaterThan(0);
}
else
{
softAssertions.assertThat(pickingSlot.getC_BPartner_ID()).isEqualTo(0);
softAssertions.assertThat(pickingSlot.getC_BPartner_Location_ID()).isEqualTo(0);
}
});
});

return softAssertions;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,21 @@ Feature: Picking workflow - abort not started picking jobs after shipment
Given start picking job for sales order identified by salesOrder_17813
And metasfresh contains M_PickingSlot:
| Identifier | PickingSlot | IsDynamic |
| 170.0 | 170.0 | Y |
And scan picking slot identified by 170.0
| 180.0 | 180.0 | Y |
And scan picking slot identified by 180.0
And validate M_PickingSlot:
| M_PickingSlot_ID.Identifier | C_BPartner_ID.Identifier | C_BPartner_Location_ID.Identifier |
| 170.0 | pickingCustomer_17813 | pickingCustomer_17813Location |
| 180.0 | pickingCustomer_17813 | pickingCustomer_17813Location |
When 'generate shipments' process is invoked
| M_ShipmentSchedule_ID.Identifier | QuantityType | IsCompleteShipments | IsShipToday |
| pickingShipmentSchedule | D | true | false |
And after not more than 60s, M_InOut is found:
| M_ShipmentSchedule_ID.Identifier | M_InOut_ID.Identifier |
| pickingShipmentSchedule | s_1 |
Then validate M_PickingSlot:
And validate single M_ShipmentSchedule_QtyPicked record created for shipment schedule
| M_ShipmentSchedule_ID.Identifier | QtyPicked | Processed | IsAnonymousHuPickedOnTheFly | OPT.VHU_ID.Identifier |
| pickingShipmentSchedule | 10 | true | false | null |
Then after not more than 15s, validate M_PickingSlot:
| M_PickingSlot_ID.Identifier | IsAllocated |
| 170.0 | N |
| 180.0 | N |

0 comments on commit 932893f

Please sign in to comment.