From 1ad8b8f9672463f6a58b64a687d3d9939d7b6a7d Mon Sep 17 00:00:00 2001 From: Szymon Radziszewski <117299684+sradziszewski@users.noreply.github.com> Date: Thu, 13 Jun 2024 18:40:52 +0200 Subject: [PATCH] OAM-48: Added event validation and assignments filter for Wards/Services (#51) * OAM-48: Added event validation for Wards/Services * OAM-48: Added destination/source filter for Wards/Services * OAM-48: Removed unnecessary lines --- .../StockEventsControllerIntegrationTest.java | 2 +- .../stockmanagement/i18n/MessageKeys.java | 7 +- .../service/SourceDestinationBaseService.java | 15 ++ .../service/StockEventValidationsService.java | 5 + .../validators/FacilityValidator.java | 76 ++++++ src/main/resources/api-definition.yaml | 2 + src/main/resources/messages_en.properties | 3 + .../SourceDestinationBaseServiceTest.java | 1 + .../StockEventValidationsServiceTest.java | 7 +- .../validators/FacilityValidatorTest.java | 228 ++++++++++++++++++ .../validators/QuantityValidatorTest.java | 2 +- ...rceDestinationAssignmentValidatorTest.java | 4 +- 12 files changed, 346 insertions(+), 6 deletions(-) create mode 100644 src/main/java/org/openlmis/stockmanagement/validators/FacilityValidator.java create mode 100644 src/test/java/org/openlmis/stockmanagement/validators/FacilityValidatorTest.java diff --git a/src/integration-test/java/org/openlmis/stockmanagement/web/StockEventsControllerIntegrationTest.java b/src/integration-test/java/org/openlmis/stockmanagement/web/StockEventsControllerIntegrationTest.java index 9fe18ef5..d167278c 100644 --- a/src/integration-test/java/org/openlmis/stockmanagement/web/StockEventsControllerIntegrationTest.java +++ b/src/integration-test/java/org/openlmis/stockmanagement/web/StockEventsControllerIntegrationTest.java @@ -17,7 +17,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.when; import static org.openlmis.stockmanagement.i18n.MessageKeys.ERROR_REASON_ASSIGNMENT_NOT_FOUND; diff --git a/src/main/java/org/openlmis/stockmanagement/i18n/MessageKeys.java b/src/main/java/org/openlmis/stockmanagement/i18n/MessageKeys.java index 2e49e9ec..da751313 100644 --- a/src/main/java/org/openlmis/stockmanagement/i18n/MessageKeys.java +++ b/src/main/java/org/openlmis/stockmanagement/i18n/MessageKeys.java @@ -161,6 +161,8 @@ public abstract class MessageKeys { EVENT_ERROR_PREFIX + ".reasonFreeText.notAllowed"; public static final String ERROR_STOCK_EVENT_ORDERABLE_DISABLED_VVM = EVENT_ERROR_PREFIX + ".orderable.disabled.vvm"; + public static final String ERROR_DESTINATION_MUST_BE_WARD_SERVICE_OF_FACILITY = + EVENT_ERROR_PREFIX + ".destination.must.be.wardService.of.facility"; //stock events creation: mandatory fields public static final String ERROR_EVENT_OCCURRED_DATE_INVALID = EVENT_ERROR_PREFIX + ".occurredDate.invalid"; @@ -249,7 +251,10 @@ public abstract class MessageKeys { PHYSICAL_INVENTORY_ERROR_PREFIX + ".draft.exists"; public static final String ERROR_PHYSICAL_INVENTORY_DRAFT_SUBMIT = PHYSICAL_INVENTORY_ERROR_PREFIX + ".draft.submit"; - + private static final String NODE_ERROR_PREFIX = ERROR_PREFIX + ".node"; + //node + public static final String ERROR_NODE_NOT_FOUND = + NODE_ERROR_PREFIX + ".notFound"; public static final String ERROR_SIZE_NULL = ERROR_PREFIX + ".pageable.size.null"; public static final String ERROR_SIZE_NOT_POSITIVE diff --git a/src/main/java/org/openlmis/stockmanagement/service/SourceDestinationBaseService.java b/src/main/java/org/openlmis/stockmanagement/service/SourceDestinationBaseService.java index a40db8bc..5a9e0056 100644 --- a/src/main/java/org/openlmis/stockmanagement/service/SourceDestinationBaseService.java +++ b/src/main/java/org/openlmis/stockmanagement/service/SourceDestinationBaseService.java @@ -332,6 +332,21 @@ private List createAssignmentDto( return true; } }) + .filter(assignment -> { + // check if assignment facility is type Ward/Service AND is in the same zone as facility + if (assignment.getNode().isRefDataFacility()) { + FacilityDto assignmentFacility = + facilitiesById.get(assignment.getNode().getReferenceId()); + if (assignmentFacility.getType().getCode().equals("WS")) { + return assignmentFacility.getGeographicZone().getId() + .equals(facility.getGeographicZone().getId()); + } else { + return true; + } + } else { + return true; + } + }) .filter(assignment -> !assignment.getNode().isRefDataFacility() || hasGeoAffinity(assignment, facility, facilitiesById)) .collect(Collectors.toList()); diff --git a/src/main/java/org/openlmis/stockmanagement/service/StockEventValidationsService.java b/src/main/java/org/openlmis/stockmanagement/service/StockEventValidationsService.java index 24cef6f3..4fd7efef 100644 --- a/src/main/java/org/openlmis/stockmanagement/service/StockEventValidationsService.java +++ b/src/main/java/org/openlmis/stockmanagement/service/StockEventValidationsService.java @@ -22,6 +22,7 @@ import org.openlmis.stockmanagement.extension.point.FreeTextValidator; import org.openlmis.stockmanagement.extension.point.UnpackKitValidator; import org.openlmis.stockmanagement.validators.ApprovedOrderableValidator; +import org.openlmis.stockmanagement.validators.FacilityValidator; import org.openlmis.stockmanagement.validators.LotValidator; import org.openlmis.stockmanagement.validators.MandatoryFieldsValidator; import org.openlmis.stockmanagement.validators.OrderableLotUnitDuplicationValidator; @@ -83,6 +84,9 @@ public class StockEventValidationsService { @Autowired private UnitOfOrderableValidator unitOfOrderableValidator; + @Autowired + private FacilityValidator facilityValidator; + /** * Validate stock event with permission service and all validators. * @@ -101,6 +105,7 @@ public void validate(StockEventDto stockEventDto) { destinationGeoLevelAffinityValidator.validate(stockEventDto); stockEventVvmValidator.validate(stockEventDto); unitOfOrderableValidator.validate(stockEventDto); + facilityValidator.validate(stockEventDto); AdjustmentReasonValidator adjustmentReasonValidator = extensionManager.getExtension( ExtensionPointId.ADJUSTMENT_REASON_POINT_ID, AdjustmentReasonValidator.class); diff --git a/src/main/java/org/openlmis/stockmanagement/validators/FacilityValidator.java b/src/main/java/org/openlmis/stockmanagement/validators/FacilityValidator.java new file mode 100644 index 00000000..b2369671 --- /dev/null +++ b/src/main/java/org/openlmis/stockmanagement/validators/FacilityValidator.java @@ -0,0 +1,76 @@ +/* + * This program is part of the OpenLMIS logistics management information system platform software. + * Copyright © 2017 VillageReach + * + * This program is free software: you can redistribute it and/or modify it under the terms + * of the GNU Affero General Public License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Affero General Public License for more details. You should have received a copy of + * the GNU Affero General Public License along with this program. If not, see + * http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org. + */ + +package org.openlmis.stockmanagement.validators; + +import static org.openlmis.stockmanagement.i18n.MessageKeys.ERROR_DESTINATION_MUST_BE_WARD_SERVICE_OF_FACILITY; +import static org.openlmis.stockmanagement.i18n.MessageKeys.ERROR_NODE_NOT_FOUND; + +import org.openlmis.stockmanagement.domain.sourcedestination.Node; +import org.openlmis.stockmanagement.dto.StockEventDto; +import org.openlmis.stockmanagement.dto.StockEventLineItemDto; +import org.openlmis.stockmanagement.dto.referencedata.FacilityDto; +import org.openlmis.stockmanagement.exception.ResourceNotFoundException; +import org.openlmis.stockmanagement.exception.ValidationMessageException; +import org.openlmis.stockmanagement.repository.NodeRepository; +import org.openlmis.stockmanagement.service.referencedata.FacilityReferenceDataService; +import org.openlmis.stockmanagement.util.Message; +import org.slf4j.profiler.Profiler; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component(value = "FacilityValidator") +public class FacilityValidator implements StockEventValidator { + + @Autowired + private FacilityReferenceDataService facilityService; + + @Autowired + private NodeRepository nodeRepository; + + @Override + public void validate(StockEventDto stockEventDto) { + XLOGGER.entry(stockEventDto); + + Profiler profiler = new Profiler("FACILITY_VALIDATOR"); + profiler.setLogger(XLOGGER); + + if (stockEventDto.isPhysicalInventory() || stockEventDto.getLineItems().isEmpty()) { + return; + } + + FacilityDto facility = facilityService.findOne(stockEventDto.getFacilityId()); + for (StockEventLineItemDto lineItem : stockEventDto.getLineItems()) { + if (lineItem.getDestinationId() != null) { + Node node = nodeRepository.findById(lineItem.getDestinationId()) + .orElseThrow(() -> new ResourceNotFoundException( + new Message(ERROR_NODE_NOT_FOUND, lineItem.getDestinationId()))); + if (node.isRefDataFacility()) { + FacilityDto destinationFacility = facilityService.findOne(node.getReferenceId()); + if (destinationFacility.getType().getCode().equals("WS") + && !destinationFacility.getGeographicZone().getId() + .equals(facility.getGeographicZone().getId())) { + throw new ValidationMessageException( + new Message(ERROR_DESTINATION_MUST_BE_WARD_SERVICE_OF_FACILITY)); + } + } + } + } + + profiler.stop().log(); + XLOGGER.exit(stockEventDto); + } + +} diff --git a/src/main/resources/api-definition.yaml b/src/main/resources/api-definition.yaml index fe822097..b637efa9 100644 --- a/src/main/resources/api-definition.yaml +++ b/src/main/resources/api-definition.yaml @@ -265,6 +265,8 @@ traits: 403: description: User does not have permission to create stock events for given facility and program. + headers: + Keep-Alive: body: application/json: schema: localizedMessage diff --git a/src/main/resources/messages_en.properties b/src/main/resources/messages_en.properties index 39a225cf..63d45681 100644 --- a/src/main/resources/messages_en.properties +++ b/src/main/resources/messages_en.properties @@ -25,6 +25,7 @@ stockmanagement.error.event.no.lineItems=No line items were provided. {0} stockmanagement.error.event.sourceAndDestination.bothPresent=Source {0} and destination {1} should not both be present. stockmanagement.error.event.source.not.in.validList=Source {0} is not in the valid sources list. stockmanagement.error.event.destination.not.in.validList=Destination {0} is not in the valid destinations list. +stockmanagement.error.event.destination.must.be.wardService.of.facility=Products can only be issued between wards/services of a given facility. #stock event creation: adjustment reason stockmanagement.error.event.adjustment.quantity.invalid=Stock Adjustment quantity must not be negative. stockmanagement.error.event.adjustment.reason.type.invalid=Reason type {0} is not valid for this adjustment event. @@ -121,6 +122,8 @@ stockmanagement.error.reporting.file.empty=Empty file stockmanagement.reason.physicalInventory.credit=Overstock stockmanagement.reason.physicalInventory.debit=Understock stockmanagement.reason.physicalInventory.balance_adjustment=Balance adjustment +#node +stockmanagement.error.node.notFound=Node not found for id: {0} #notification stockmanagement.email.stockout.subject=STOCKOUT Action Required: ${facilityName}, ${orderableName} stockmanagement.email.stockout.content=Dear ${username}:\n\ diff --git a/src/test/java/org/openlmis/stockmanagement/service/SourceDestinationBaseServiceTest.java b/src/test/java/org/openlmis/stockmanagement/service/SourceDestinationBaseServiceTest.java index a73136b0..f38a152a 100644 --- a/src/test/java/org/openlmis/stockmanagement/service/SourceDestinationBaseServiceTest.java +++ b/src/test/java/org/openlmis/stockmanagement/service/SourceDestinationBaseServiceTest.java @@ -780,6 +780,7 @@ private GeographicZoneDto generateGeographicZone(UUID districtLevelId, UUID regi private FacilityDto createFacilityDtoWithFacilityType(UUID facilityId, UUID facilityTypeId) { FacilityTypeDto facilityDto = new FacilityTypeDto(); facilityDto.setId(facilityTypeId); + facilityDto.setCode("TEST"); return FacilityDto.builder() .id(facilityId) .type(facilityDto) diff --git a/src/test/java/org/openlmis/stockmanagement/service/StockEventValidationsServiceTest.java b/src/test/java/org/openlmis/stockmanagement/service/StockEventValidationsServiceTest.java index b70330db..04e94d0d 100644 --- a/src/test/java/org/openlmis/stockmanagement/service/StockEventValidationsServiceTest.java +++ b/src/test/java/org/openlmis/stockmanagement/service/StockEventValidationsServiceTest.java @@ -42,6 +42,7 @@ import org.openlmis.stockmanagement.validators.DefaultAdjustmentReasonValidator; import org.openlmis.stockmanagement.validators.DefaultFreeTextValidator; import org.openlmis.stockmanagement.validators.DefaultUnpackKitValidator; +import org.openlmis.stockmanagement.validators.FacilityValidator; import org.openlmis.stockmanagement.validators.LotValidator; import org.openlmis.stockmanagement.validators.MandatoryFieldsValidator; import org.openlmis.stockmanagement.validators.OrderableLotUnitDuplicationValidator; @@ -108,6 +109,9 @@ public class StockEventValidationsServiceTest { @Mock private UnitOfOrderableValidator unitOfOrderableValidator; + @Mock + private FacilityValidator facilityValidator; + @Before public void setUp() throws Exception { //make real validators do nothing because @@ -127,6 +131,7 @@ public void setUp() throws Exception { doNothing().when(physicalInventoryReasonsValidator).validate(any(StockEventDto.class)); doNothing().when(unpackKitValidator).validate(any(StockEventDto.class)); doNothing().when(unitOfOrderableValidator).validate(any(StockEventDto.class)); + doNothing().when(facilityValidator).validate(any(StockEventDto.class)); when(extensionManager .getExtension(ExtensionPointId.ADJUSTMENT_REASON_POINT_ID, AdjustmentReasonValidator.class)) .thenReturn(adjustmentReasonValidator); @@ -182,4 +187,4 @@ public void shouldNotRunNextValidatorIfPreviousValidatorFailed() throws Exceptio } } -} \ No newline at end of file +} diff --git a/src/test/java/org/openlmis/stockmanagement/validators/FacilityValidatorTest.java b/src/test/java/org/openlmis/stockmanagement/validators/FacilityValidatorTest.java new file mode 100644 index 00000000..a17e3778 --- /dev/null +++ b/src/test/java/org/openlmis/stockmanagement/validators/FacilityValidatorTest.java @@ -0,0 +1,228 @@ +/* + * This program is part of the OpenLMIS logistics management information system platform software. + * Copyright © 2017 VillageReach + * + * This program is free software: you can redistribute it and/or modify it under the terms + * of the GNU Affero General Public License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Affero General Public License for more details. You should have received a copy of + * the GNU Affero General Public License along with this program. If not, see + * http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org. + */ + +package org.openlmis.stockmanagement.validators; + +import static java.util.Collections.emptyList; +import static java.util.Collections.singletonList; +import static org.hamcrest.core.StringContains.containsString; +import static org.junit.rules.ExpectedException.none; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.openlmis.stockmanagement.i18n.MessageKeys.ERROR_DESTINATION_MUST_BE_WARD_SERVICE_OF_FACILITY; +import static org.openlmis.stockmanagement.i18n.MessageKeys.ERROR_NODE_NOT_FOUND; +import static org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventDto; +import static org.openlmis.stockmanagement.testutils.StockEventDtoDataBuilder.createStockEventLineItem; + +import java.util.Optional; +import java.util.UUID; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.openlmis.stockmanagement.domain.sourcedestination.Node; +import org.openlmis.stockmanagement.dto.StockEventDto; +import org.openlmis.stockmanagement.dto.StockEventLineItemDto; +import org.openlmis.stockmanagement.dto.referencedata.FacilityDto; +import org.openlmis.stockmanagement.dto.referencedata.FacilityTypeDto; +import org.openlmis.stockmanagement.dto.referencedata.GeographicZoneDto; +import org.openlmis.stockmanagement.exception.ResourceNotFoundException; +import org.openlmis.stockmanagement.exception.ValidationMessageException; +import org.openlmis.stockmanagement.testutils.GeographicZoneDtoDataBuilder; + +@RunWith(MockitoJUnitRunner.class) +public class FacilityValidatorTest extends BaseValidatorTest { + + public static final String FACILITY_TYPE_CODE = "TEST"; + public static final String WARD_SERVICE_TYPE_CODE = "WS"; + + @Rule + public ExpectedException expectedException = none(); + + @Mock + private Node node; + + @InjectMocks + private FacilityValidator facilityValidator; + + private GeographicZoneDto geographicZone; + + @Before + public void setUp() throws Exception { + super.setUp(); + when(node.getReferenceId()).thenReturn(UUID.randomUUID()); + when(node.isRefDataFacility()).thenReturn(true); + + geographicZone = new GeographicZoneDtoDataBuilder().withId(UUID.randomUUID()).build(); + } + + @Test + public void shouldPassIfEventLineItemsListIsEmpty() { + //given + StockEventDto eventDto = createStockEventDto(); + eventDto.setLineItems(emptyList()); + + //when + facilityValidator.validate(eventDto); + + //then: no error + } + + @Test + public void shouldPassIfEventIsPhysicalInventory() { + //given + StockEventDto eventDto = mock(StockEventDto.class); + when(eventDto.isPhysicalInventory()).thenReturn(true); + + //when + facilityValidator.validate(eventDto); + + //then: no error + } + + @Test + public void shouldPassIfEventLineItemDestinationIsNotWardServiceType() { + //given + StockEventDto eventDto = createStockEventDto(); + FacilityDto eventFacility = generateFacility(eventDto, FACILITY_TYPE_CODE, geographicZone); + + when(facilityService.findOne(eventDto.getFacilityId())).thenReturn(eventFacility); + when(nodeRepository.findById(eventDto.getLineItems().get(0).getDestinationId())) + .thenReturn(Optional.of(node)); + + FacilityDto destinationFacility = + generateFacility(eventDto, FACILITY_TYPE_CODE, geographicZone); + when(facilityService.findOne(node.getReferenceId())).thenReturn(destinationFacility); + + //when + facilityValidator.validate(eventDto); + + //then: no error + } + + @Test + public void shouldNotPassIfEventLineItemDestinationIsWardServiceType() { + //given + StockEventDto eventDto = createStockEventDto(); + FacilityDto eventFacility = generateFacility(eventDto, FACILITY_TYPE_CODE, geographicZone); + + when(facilityService.findOne(eventDto.getFacilityId())).thenReturn(eventFacility); + when(nodeRepository.findById(eventDto.getLineItems().get(0).getDestinationId())) + .thenReturn(Optional.of(node)); + + GeographicZoneDto geographicZone2 = new GeographicZoneDtoDataBuilder() + .withId(UUID.randomUUID()) + .build(); + FacilityDto destinationFacility = + generateFacility(eventDto, WARD_SERVICE_TYPE_CODE, geographicZone2); + when(facilityService.findOne(node.getReferenceId())).thenReturn(destinationFacility); + + expectedException.expect(ValidationMessageException.class); + expectedException.expectMessage( + containsString(ERROR_DESTINATION_MUST_BE_WARD_SERVICE_OF_FACILITY)); + + //when + facilityValidator.validate(eventDto); + } + + @Test + public void shouldPassIfEventLineItemDestinationIsWardServiceTypeInSameZoneAsEventFacility() { + //given + StockEventDto eventDto = createStockEventDto(); + FacilityDto eventFacility = generateFacility(eventDto, FACILITY_TYPE_CODE, geographicZone); + + when(facilityService.findOne(eventDto.getFacilityId())).thenReturn(eventFacility); + when(nodeRepository.findById(eventDto.getLineItems().get(0).getDestinationId())) + .thenReturn(Optional.of(node)); + + FacilityDto destinationFacility = + generateFacility(eventDto, WARD_SERVICE_TYPE_CODE, geographicZone); + when(facilityService.findOne(node.getReferenceId())).thenReturn(destinationFacility); + + //when + facilityValidator.validate(eventDto); + + //then: no error + } + + @Test + public void shouldPassIfEventLineItemDestinationIsNull() { + //given + StockEventDto eventDto = createStockEventDto(); + FacilityDto eventFacility = generateFacility(eventDto, FACILITY_TYPE_CODE, geographicZone); + + when(facilityService.findOne(eventDto.getFacilityId())).thenReturn(eventFacility); + when(nodeRepository.findById(eventDto.getLineItems().get(0).getDestinationId())) + .thenReturn(Optional.of(node)); + when(node.isRefDataFacility()).thenReturn(false); + + //when + facilityValidator.validate(eventDto); + + //then: no error + } + + @Test + public void shouldPassIfNodeRefDataIsNotFacility() { + //given + StockEventDto eventDto = createStockEventDto(); + StockEventLineItemDto lineItem = createStockEventLineItem(); + lineItem.setDestinationId(null); + eventDto.setLineItems(singletonList(lineItem)); + FacilityDto eventFacility = generateFacility(eventDto, FACILITY_TYPE_CODE, geographicZone); + when(facilityService.findOne(eventDto.getFacilityId())).thenReturn(eventFacility); + + //when + facilityValidator.validate(eventDto); + + //then: no error + } + + @Test + public void shouldNotPassIfNodeNotFound() { + //given + StockEventDto eventDto = createStockEventDto(); + FacilityDto eventFacility = generateFacility(eventDto, FACILITY_TYPE_CODE, geographicZone); + + when(facilityService.findOne(eventDto.getFacilityId())).thenReturn(eventFacility); + when(nodeRepository.findById(eventDto.getLineItems().get(0).getDestinationId())) + .thenReturn(Optional.empty()); + + expectedException.expect(ResourceNotFoundException.class); + expectedException.expectMessage(containsString(ERROR_NODE_NOT_FOUND)); + + //when + facilityValidator.validate(eventDto); + } + + private FacilityDto generateFacility(StockEventDto eventDto, String facilityTypeCode, + GeographicZoneDto geographicZone) { + FacilityTypeDto facilityTypeDto = new FacilityTypeDto(); + facilityTypeDto.setId(UUID.randomUUID()); + facilityTypeDto.setCode(facilityTypeCode); + FacilityDto facility = new FacilityDto(); + facility.setId(eventDto.getFacilityId()); + facility.setType(facilityTypeDto); + facility.setGeographicZone(geographicZone); + + setContext(eventDto); + return facility; + } + +} diff --git a/src/test/java/org/openlmis/stockmanagement/validators/QuantityValidatorTest.java b/src/test/java/org/openlmis/stockmanagement/validators/QuantityValidatorTest.java index 5ee182be..9dabc671 100644 --- a/src/test/java/org/openlmis/stockmanagement/validators/QuantityValidatorTest.java +++ b/src/test/java/org/openlmis/stockmanagement/validators/QuantityValidatorTest.java @@ -36,7 +36,7 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.InjectMocks; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.openlmis.stockmanagement.domain.card.StockCard; import org.openlmis.stockmanagement.domain.card.StockCardLineItem; import org.openlmis.stockmanagement.domain.reason.StockCardLineItemReason; diff --git a/src/test/java/org/openlmis/stockmanagement/validators/SourceDestinationAssignmentValidatorTest.java b/src/test/java/org/openlmis/stockmanagement/validators/SourceDestinationAssignmentValidatorTest.java index ac1dcff3..6c03dca6 100644 --- a/src/test/java/org/openlmis/stockmanagement/validators/SourceDestinationAssignmentValidatorTest.java +++ b/src/test/java/org/openlmis/stockmanagement/validators/SourceDestinationAssignmentValidatorTest.java @@ -17,7 +17,7 @@ import static java.util.Collections.singletonList; import static org.hamcrest.core.StringContains.containsString; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.when; import static org.openlmis.stockmanagement.i18n.MessageKeys.ERROR_DESTINATION_NOT_FOUND; @@ -34,7 +34,7 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.openlmis.stockmanagement.domain.sourcedestination.Node; import org.openlmis.stockmanagement.domain.sourcedestination.ValidDestinationAssignment; import org.openlmis.stockmanagement.domain.sourcedestination.ValidSourceAssignment;