Search in sources :

Example 1 with PatchOrderLineRequest

use of org.folio.rest.jaxrs.model.PatchOrderLineRequest in project mod-orders by folio-org.

the class OrderLineUpdateInstanceHandlerTest method shouldThrowNotImplementedExceptionForPhysicalOrderFormat.

@Test
public void shouldThrowNotImplementedExceptionForPhysicalOrderFormat() {
    String orderLineId = UUID.randomUUID().toString();
    PoLine poLine = new PoLine().withId(orderLineId).withOrderFormat(PoLine.OrderFormat.PHYSICAL_RESOURCE).withPhysical(new Physical().withCreateInventory(Physical.CreateInventory.INSTANCE_HOLDING));
    PatchOrderLineRequest patchOrderLineRequest = new PatchOrderLineRequest();
    patchOrderLineRequest.withOperation(PatchOrderLineRequest.Operation.REPLACE_INSTANCE_REF);
    OrderLineUpdateInstanceHolder orderLineUpdateInstanceHolder = new OrderLineUpdateInstanceHolder().withStoragePoLine(poLine).withPathOrderLineRequest(patchOrderLineRequest);
    assertThrows(NotImplementedException.class, () -> orderLineUpdateInstanceHandler.handle(orderLineUpdateInstanceHolder, requestContext));
}
Also used : Physical(org.folio.rest.jaxrs.model.Physical) PatchOrderLineRequest(org.folio.rest.jaxrs.model.PatchOrderLineRequest) PoLine(org.folio.rest.jaxrs.model.PoLine) Test(org.junit.jupiter.api.Test)

Example 2 with PatchOrderLineRequest

use of org.folio.rest.jaxrs.model.PatchOrderLineRequest in project mod-orders by folio-org.

the class OrderLineUpdateInstanceHandlerTest method shouldThrowNotImplementedExceptionForOtherOrderFormat.

@Test
public void shouldThrowNotImplementedExceptionForOtherOrderFormat() {
    String orderLineId = UUID.randomUUID().toString();
    PoLine poLine = new PoLine().withId(orderLineId).withOrderFormat(PoLine.OrderFormat.OTHER).withPhysical(new Physical().withCreateInventory(Physical.CreateInventory.INSTANCE_HOLDING));
    PatchOrderLineRequest patchOrderLineRequest = new PatchOrderLineRequest();
    patchOrderLineRequest.withOperation(PatchOrderLineRequest.Operation.REPLACE_INSTANCE_REF);
    OrderLineUpdateInstanceHolder orderLineUpdateInstanceHolder = new OrderLineUpdateInstanceHolder().withStoragePoLine(poLine).withPathOrderLineRequest(patchOrderLineRequest);
    assertThrows(NotImplementedException.class, () -> orderLineUpdateInstanceHandler.handle(orderLineUpdateInstanceHolder, requestContext));
}
Also used : Physical(org.folio.rest.jaxrs.model.Physical) PatchOrderLineRequest(org.folio.rest.jaxrs.model.PatchOrderLineRequest) PoLine(org.folio.rest.jaxrs.model.PoLine) Test(org.junit.jupiter.api.Test)

Example 3 with PatchOrderLineRequest

use of org.folio.rest.jaxrs.model.PatchOrderLineRequest in project mod-orders by folio-org.

the class OrderLineUpdateInstanceHandlerTest method shouldThrowNotImplementedExceptionForMIXOrderFormat.

@Test
public void shouldThrowNotImplementedExceptionForMIXOrderFormat() {
    String orderLineId = UUID.randomUUID().toString();
    PoLine poLine = new PoLine().withId(orderLineId).withOrderFormat(PoLine.OrderFormat.P_E_MIX).withPhysical(new Physical().withCreateInventory(Physical.CreateInventory.INSTANCE_HOLDING)).withEresource(new Eresource().withCreateInventory(Eresource.CreateInventory.INSTANCE));
    PatchOrderLineRequest patchOrderLineRequest = new PatchOrderLineRequest();
    patchOrderLineRequest.withOperation(PatchOrderLineRequest.Operation.REPLACE_INSTANCE_REF);
    OrderLineUpdateInstanceHolder orderLineUpdateInstanceHolder = new OrderLineUpdateInstanceHolder().withStoragePoLine(poLine).withPathOrderLineRequest(patchOrderLineRequest);
    assertThrows(NotImplementedException.class, () -> orderLineUpdateInstanceHandler.handle(orderLineUpdateInstanceHolder, requestContext));
}
Also used : Physical(org.folio.rest.jaxrs.model.Physical) PatchOrderLineRequest(org.folio.rest.jaxrs.model.PatchOrderLineRequest) PoLine(org.folio.rest.jaxrs.model.PoLine) Eresource(org.folio.rest.jaxrs.model.Eresource) Test(org.junit.jupiter.api.Test)

Example 4 with PatchOrderLineRequest

use of org.folio.rest.jaxrs.model.PatchOrderLineRequest in project mod-orders by folio-org.

the class CompositePoLineAPI method patchOrdersOrderLinesById.

@Override
@Validate
public void patchOrdersOrderLinesById(String lineId, PatchOrderLineRequest request, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
    RequestContext requestContext = new RequestContext(vertxContext, okapiHeaders);
    orderLinePatchOperationService.patch(lineId, request, requestContext).thenAccept(v -> asyncResultHandler.handle(succeededFuture(buildNoContentResponse()))).exceptionally(t -> handleErrorResponse(asyncResultHandler, t));
}
Also used : Future.succeededFuture(io.vertx.core.Future.succeededFuture) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) Context(io.vertx.core.Context) OrdersOrderLines(org.folio.rest.jaxrs.resource.OrdersOrderLines) SpringContextUtil(org.folio.spring.SpringContextUtil) ArrayList(java.util.ArrayList) Map(java.util.Map) RequestContext(org.folio.rest.core.models.RequestContext) JsonObject(io.vertx.core.json.JsonObject) OKAPI_URL(org.folio.rest.RestConstants.OKAPI_URL) AsyncResult(io.vertx.core.AsyncResult) ORDER_CONFIG_MODULE_NAME(org.folio.orders.utils.HelperUtils.ORDER_CONFIG_MODULE_NAME) Errors(org.folio.rest.jaxrs.model.Errors) OrderLinePatchOperationService(org.folio.service.orders.lines.update.OrderLinePatchOperationService) PO_LINES_BUSINESS(org.folio.orders.utils.ResourcePathResolver.PO_LINES_BUSINESS) Vertx(io.vertx.core.Vertx) ErrorCodes(org.folio.rest.core.exceptions.ErrorCodes) Validate(org.folio.rest.annotations.Validate) ConfigurationEntriesService(org.folio.service.configuration.ConfigurationEntriesService) Error(org.folio.rest.jaxrs.model.Error) List(java.util.List) ResourcePathResolver.resourceByIdPath(org.folio.orders.utils.ResourcePathResolver.resourceByIdPath) Logger(org.apache.logging.log4j.Logger) Response(javax.ws.rs.core.Response) CompositePoLineValidationService(org.folio.service.orders.CompositePoLineValidationService) PurchaseOrderLineHelper(org.folio.helper.PurchaseOrderLineHelper) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) PurchaseOrderLineService(org.folio.service.orders.PurchaseOrderLineService) PatchOrderLineRequest(org.folio.rest.jaxrs.model.PatchOrderLineRequest) Handler(io.vertx.core.Handler) LogManager(org.apache.logging.log4j.LogManager) RequestContext(org.folio.rest.core.models.RequestContext) Validate(org.folio.rest.annotations.Validate)

Example 5 with PatchOrderLineRequest

use of org.folio.rest.jaxrs.model.PatchOrderLineRequest in project mod-orders by folio-org.

the class OrderLineUpdateInstanceHandlerTest method shouldThrowNotImplementedExceptionForEresourceOrderFormat.

@Test
public void shouldThrowNotImplementedExceptionForEresourceOrderFormat() {
    String orderLineId = UUID.randomUUID().toString();
    PoLine poLine = new PoLine().withId(orderLineId).withOrderFormat(PoLine.OrderFormat.ELECTRONIC_RESOURCE).withEresource(new Eresource().withCreateInventory(Eresource.CreateInventory.INSTANCE));
    PatchOrderLineRequest patchOrderLineRequest = new PatchOrderLineRequest();
    patchOrderLineRequest.withOperation(PatchOrderLineRequest.Operation.REPLACE_INSTANCE_REF);
    OrderLineUpdateInstanceHolder orderLineUpdateInstanceHolder = new OrderLineUpdateInstanceHolder().withStoragePoLine(poLine).withPathOrderLineRequest(patchOrderLineRequest);
    assertThrows(NotImplementedException.class, () -> orderLineUpdateInstanceHandler.handle(orderLineUpdateInstanceHolder, requestContext));
}
Also used : PatchOrderLineRequest(org.folio.rest.jaxrs.model.PatchOrderLineRequest) PoLine(org.folio.rest.jaxrs.model.PoLine) Eresource(org.folio.rest.jaxrs.model.Eresource) Test(org.junit.jupiter.api.Test)

Aggregations

PatchOrderLineRequest (org.folio.rest.jaxrs.model.PatchOrderLineRequest)5 PoLine (org.folio.rest.jaxrs.model.PoLine)4 Test (org.junit.jupiter.api.Test)4 Physical (org.folio.rest.jaxrs.model.Physical)3 Eresource (org.folio.rest.jaxrs.model.Eresource)2 AsyncResult (io.vertx.core.AsyncResult)1 Context (io.vertx.core.Context)1 Future.succeededFuture (io.vertx.core.Future.succeededFuture)1 Handler (io.vertx.core.Handler)1 Vertx (io.vertx.core.Vertx)1 JsonObject (io.vertx.core.json.JsonObject)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Response (javax.ws.rs.core.Response)1 StringUtils (org.apache.commons.lang3.StringUtils)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 PurchaseOrderLineHelper (org.folio.helper.PurchaseOrderLineHelper)1 ORDER_CONFIG_MODULE_NAME (org.folio.orders.utils.HelperUtils.ORDER_CONFIG_MODULE_NAME)1