@Test public void shouldGetDeliveryZoneById() throws Exception { DeliveryZone zone = new DeliveryZone(); when(service.getById(1l)).thenReturn(zone); when(permissionService.hasPermissionOnZone(USER_ID, 1l)).thenReturn(true); ResponseEntity<OpenLmisResponse> response = controller.get(1l); verify(service).getById(1l); assertThat((DeliveryZone) response.getBody().getData().get("zone"), is(zone)); }
@RequestMapping(value = "deliveryZones/{id}", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DISTRIBUTION')") public ResponseEntity<OpenLmisResponse> get(@PathVariable Long id) { return response("zone", service.getById(id)); }
DeliveryZoneController extends BaseController { @RequestMapping(value = "deliveryZones/{id}", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DISTRIBUTION')") public ResponseEntity<OpenLmisResponse> get(@PathVariable Long id) { return response("zone", service.getById(id)); } }
DeliveryZoneController extends BaseController { @RequestMapping(value = "deliveryZones/{id}", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DISTRIBUTION')") public ResponseEntity<OpenLmisResponse> get(@PathVariable Long id) { return response("zone", service.getById(id)); }  }
DeliveryZoneController extends BaseController { @RequestMapping(value = "deliveryZones/{id}", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DISTRIBUTION')") public ResponseEntity<OpenLmisResponse> get(@PathVariable Long id) { return response("zone", service.getById(id)); }  @RequestMapping(value = "user/deliveryZones", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DISTRIBUTION')") ResponseEntity<OpenLmisResponse> getDeliveryZonesForInitiatingAllocation(HttpServletRequest request); @RequestMapping(value = "deliveryZones/{id}/activePrograms", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DISTRIBUTION')") ResponseEntity<OpenLmisResponse> getActiveProgramsForDeliveryZone(@PathVariable Long id); @RequestMapping(value = "deliveryZones/{id}/programs", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_USER')") ResponseEntity<OpenLmisResponse> getAllProgramsForDeliveryZone(@PathVariable Long id); @RequestMapping(value = "deliveryZones/{id}", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DISTRIBUTION')") ResponseEntity<OpenLmisResponse> get(@PathVariable Long id); @RequestMapping(value = "deliveryZones", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_USER')") ResponseEntity<OpenLmisResponse> getAll(); }
DeliveryZoneController extends BaseController { @RequestMapping(value = "deliveryZones/{id}", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DISTRIBUTION')") public ResponseEntity<OpenLmisResponse> get(@PathVariable Long id) { return response("zone", service.getById(id)); }  @RequestMapping(value = "user/deliveryZones", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DISTRIBUTION')") ResponseEntity<OpenLmisResponse> getDeliveryZonesForInitiatingAllocation(HttpServletRequest request); @RequestMapping(value = "deliveryZones/{id}/activePrograms", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DISTRIBUTION')") ResponseEntity<OpenLmisResponse> getActiveProgramsForDeliveryZone(@PathVariable Long id); @RequestMapping(value = "deliveryZones/{id}/programs", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_USER')") ResponseEntity<OpenLmisResponse> getAllProgramsForDeliveryZone(@PathVariable Long id); @RequestMapping(value = "deliveryZones/{id}", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_DISTRIBUTION')") ResponseEntity<OpenLmisResponse> get(@PathVariable Long id); @RequestMapping(value = "deliveryZones", method = GET, headers = ACCEPT_JSON) @PreAuthorize("@permissionEvaluator.hasPermission(principal,'MANAGE_USER')") ResponseEntity<OpenLmisResponse> getAll(); static final String DELIVERY_ZONE_PROGRAMS; }