DefaultWorldpayOrderModificationCleanUpStrategy implements WorldpayOrderModificationCleanUpStrategy { @Override public void doCleanUp(int days) { List<WorldpayOrderModificationModel> processedOrderModificationsBeforeDate = getOrderModificationDao().findProcessedOrderModificationsBeforeDate(WorldpayUtil.createDateInPast(days)); processedOrderModificationsBeforeDate.forEach(orderModificationModel -> { LOG.info(MessageFormat.format("Deleting Order Modification Model with Worldpay Order code: {0}", orderModificationModel.getWorldpayOrderCode())); getModelService().remove(orderModificationModel); }); }  @Override void doCleanUp(int days); ModelService getModelService(); @Required void setModelService(ModelService modelService); OrderModificationDao getOrderModificationDao(); @Required void setOrderModificationDao(OrderModificationDao orderModificationDao);  }
@Test public void removeProcessOrderModificationsIfAnyAreFound() { when(orderModificationDaoMock.findProcessedOrderModificationsBeforeDate(any(Date.class))).thenReturn(Collections.singletonList(orderModificationMock)); testObj.doCleanUp(5); verify(modelServiceMock).remove(orderModificationMock); }
@Test public void doNothingIfNoProcessOrderModificationsAreFound() { when(orderModificationDaoMock.findProcessedOrderModificationsBeforeDate(any(Date.class))).thenReturn(Collections.emptyList()); testObj.doCleanUp(5); verify(modelServiceMock, never()).remove(any(WorldpayOrderModificationModel.class)); }