Skip to content

Commit

Permalink
OAM-20: Yet another test corrected.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsznaj committed Jun 17, 2024
1 parent 0a8b49d commit bbe5d18
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.openlmis.fulfillment.domain.Order;
import org.openlmis.fulfillment.domain.OrderStatus;
import org.openlmis.fulfillment.repository.custom.OrderRepositoryCustom;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

Expand All @@ -32,5 +34,7 @@ public interface OrderRepository extends PagingAndSortingRepository<Order, UUID>

Long countByFacilityIdAndStatus(UUID facilityId, OrderStatus status);

Iterable<Order> findAllByIdAndStatus(List<UUID> ids, String creating);
@Modifying
@Query("select o from Order o where id in ")
Iterable<Order> findByIdInAndStatus(List<UUID> ids, String status);
}
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ public void deleteMultipleOrders(@RequestParam(name = "ids") List<UUID> ids) {
XLOGGER.info("Nothing to delete");
return;
}
Iterable<Order> orders = orderRepository.findAllByIdAndStatus(ids, OrderStatus.CREATING.name());
Iterable<Order> orders = orderRepository.findByIdInAndStatus(ids, OrderStatus.CREATING.name());
List<UUID> receivingIds = new ArrayList<>();
List<UUID> ordersToDeleteIds = new ArrayList<>();
orders.forEach(order -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void shouldDeleteMultipleOrders() {

List<Order> orders = new ArrayList();
orders.add(orderTwo);
when(orderRepository.findAllByIdAndStatus(ids, OrderStatus.CREATING.name())).thenReturn(orders);
when(orderRepository.findByIdInAndStatus(ids, OrderStatus.CREATING.name())).thenReturn(orders);

List<UUID> receivingIds = new ArrayList<>();
receivingIds.add(orderTwo.getReceivingFacilityId());
Expand All @@ -197,7 +197,7 @@ public void shouldDeleteMultipleOrders() {
orderController.deleteMultipleOrders(ids);

//then
verify(orderRepository).findAllByIdAndStatus(ids, OrderStatus.CREATING.name());
verify(orderRepository).findByIdInAndStatus(ids, OrderStatus.CREATING.name());
verify(permissionService).canDeleteOrders(receivingIds);
verify(orderRepository).deleteById(orderTwo.getId());
}
Expand Down

0 comments on commit bbe5d18

Please sign in to comment.