@Test public void shouldReturnTrueIfUserHasPermissionOnZone() throws Exception { List<DeliveryZone> zones = new ArrayList<DeliveryZone>() {{ add(new DeliveryZone(2l)); }}; when(zoneService.getByUserForRight(1l, MANAGE_DISTRIBUTION)).thenReturn(zones); assertTrue(permissionService.hasPermissionOnZone(1l, 2l)); }
public boolean hasPermissionOnZone(Long userId, final long zoneId) { List<DeliveryZone> zones = zoneService.getByUserForRight(userId, MANAGE_DISTRIBUTION); return exists(zones, new Predicate() { @Override public boolean evaluate(Object o) { DeliveryZone zone = (DeliveryZone) o; return zone.getId() == zoneId; } }); }
AllocationPermissionService { public boolean hasPermissionOnZone(Long userId, final long zoneId) { List<DeliveryZone> zones = zoneService.getByUserForRight(userId, MANAGE_DISTRIBUTION); return exists(zones, new Predicate() { @Override public boolean evaluate(Object o) { DeliveryZone zone = (DeliveryZone) o; return zone.getId() == zoneId; } }); } }
AllocationPermissionService { public boolean hasPermissionOnZone(Long userId, final long zoneId) { List<DeliveryZone> zones = zoneService.getByUserForRight(userId, MANAGE_DISTRIBUTION); return exists(zones, new Predicate() { @Override public boolean evaluate(Object o) { DeliveryZone zone = (DeliveryZone) o; return zone.getId() == zoneId; } }); }  }
AllocationPermissionService { public boolean hasPermissionOnZone(Long userId, final long zoneId) { List<DeliveryZone> zones = zoneService.getByUserForRight(userId, MANAGE_DISTRIBUTION); return exists(zones, new Predicate() { @Override public boolean evaluate(Object o) { DeliveryZone zone = (DeliveryZone) o; return zone.getId() == zoneId; } }); }  boolean hasPermissionOnZone(Long userId, final long zoneId); }
AllocationPermissionService { public boolean hasPermissionOnZone(Long userId, final long zoneId) { List<DeliveryZone> zones = zoneService.getByUserForRight(userId, MANAGE_DISTRIBUTION); return exists(zones, new Predicate() { @Override public boolean evaluate(Object o) { DeliveryZone zone = (DeliveryZone) o; return zone.getId() == zoneId; } }); }  boolean hasPermissionOnZone(Long userId, final long zoneId);  }