Fix #113 by fixing initialization of RestServiceForDelivery.
This commit is contained in:
		| @ -4,10 +4,13 @@ import org.hso.ecommerce.api.RestServiceForDelivery; | ||||
| import org.hso.ecommerce.entities.shop.CustomerOrder; | ||||
| import org.springframework.web.client.ResourceAccessException; | ||||
|  | ||||
| import java.sql.Timestamp; | ||||
| import java.util.Date; | ||||
|  | ||||
| public class EnableTrackingAction { | ||||
|  | ||||
|     public static void addTrackingInfo(CustomerOrder customerOrder) throws ResourceAccessException { | ||||
|  | ||||
|         customerOrder.trackingId = new RestServiceForDelivery().getDeliveryID(customerOrder); | ||||
|     public static void addTrackingInfo(RestServiceForDelivery deliveryService, CustomerOrder customerOrder) throws ResourceAccessException { | ||||
|         customerOrder.inDeliverySince = new Timestamp(new Date().getTime()); | ||||
|         customerOrder.trackingId = deliveryService.getDeliveryID(customerOrder); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| package org.hso.ecommerce.controller.intern.warehouse; | ||||
|  | ||||
| import org.hso.ecommerce.action.shop.EnableTrackingAction; | ||||
| import org.hso.ecommerce.api.RestServiceForDelivery; | ||||
| import org.hso.ecommerce.entities.warehouse.WarehouseBooking; | ||||
| import org.hso.ecommerce.repos.warehouse.WarehouseBookingRepository; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| @ -23,6 +24,9 @@ public class TodoController { | ||||
|     @Autowired | ||||
|     private final WarehouseBookingRepository warehouseBookingRepository = null; | ||||
|  | ||||
|     @Autowired | ||||
|     private final RestServiceForDelivery deliveryService = null; | ||||
|  | ||||
|     @GetMapping("todo") | ||||
|     public String accountingWarehouseTodo( | ||||
|             Model model | ||||
| @ -77,7 +81,7 @@ public class TodoController { | ||||
|         // Update Delivery Date | ||||
|         if (booking.get().reason.customerOrder != null) { | ||||
|             try{ | ||||
|                 EnableTrackingAction.addTrackingInfo(booking.get().reason.customerOrder); | ||||
|                 EnableTrackingAction.addTrackingInfo(deliveryService, booking.get().reason.customerOrder); | ||||
|             } | ||||
|             catch(ResourceAccessException e) | ||||
|             { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user