Skip to content

Commit

Permalink
MALAWISUP-5622: Added required service references as parameters (#103)
Browse files Browse the repository at this point in the history
* MALAWISUP-5622: Added required service references as parameters

Added processing period ID and facility ID setters calls

* MALAWISUP-5622: Removed comments
  • Loading branch information
sradziszewski authored Sep 3, 2024
1 parent 133e86c commit af92f7b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ ETagResource<RequisitionDto> doUpdate(Requisition requisitionToUpdate, Requisiti
Map<VersionIdentityDto, ApprovedProductDto> approvedProducts = findApprovedProducts(
requisitionToUpdate::getAllApprovedProductIdentities, profiler);

if (Boolean.FALSE.equals(requisitionToUpdate.getEmergency())) {
requisition.setProcessingPeriodId(requisitionToUpdate.getProcessingPeriodId());
requisition.setFacilityId(requisitionToUpdate.getFacilityId());
}

UpdateParams params = new UpdateParams(requisitionToUpdate, requisition, orderables,
facility, program, null, approvedProducts);

Expand Down Expand Up @@ -703,7 +708,8 @@ class UpdateParams {
void updateAndSave(Profiler profiler) {
profiler.start("UPDATE");
toUpdate.updateFrom(requisition, orderables, approvedProducts,
datePhysicalStockCountCompletedEnabledPredicate.exec(program), null, null);
datePhysicalStockCountCompletedEnabledPredicate.exec(program),
requisitionService, periodService);

profiler.start("SAVE");
toUpdate = requisitionRepository.save(toUpdate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.isNotNull;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
Expand Down Expand Up @@ -605,7 +606,7 @@ public void shouldUpdateRequisition() {

assertEquals(template, initiatedRequsition.getTemplate());
verify(initiatedRequsition).updateFrom(
any(Requisition.class), anyMap(), anyMap(), eq(true), isNull(), isNull());
any(Requisition.class), anyMap(), anyMap(), eq(true), isNotNull(), isNotNull());
verify(requisitionRepository).save(initiatedRequsition);
verify(requisitionVersionValidator).validateEtagVersionIfPresent(
any(HttpServletRequest.class), eq(initiatedRequsition));
Expand Down Expand Up @@ -651,7 +652,7 @@ public void shouldUpdateStockBasedRequisition() {

assertEquals(template, initiatedRequsition.getTemplate());
verify(initiatedRequsition).updateFrom(
any(Requisition.class), anyMap(), anyMap(), eq(true), isNull(), isNull());
any(Requisition.class), anyMap(), anyMap(), eq(true), isNotNull(), isNotNull());
verify(requisitionRepository).save(initiatedRequsition);
verify(requisitionVersionValidator).validateEtagVersionIfPresent(
any(HttpServletRequest.class), eq(initiatedRequsition));
Expand Down

0 comments on commit af92f7b

Please sign in to comment.