@Test public void shouldReturnTrueIfUserHasPermissionOnADeliveryZone() { Long userId = 1L; Long distributionId = 2L; DeliveryZone deliveryZone = new DeliveryZone(); deliveryZone.setCode("DZ"); Distribution distribution = new Distribution(); distribution.setDeliveryZone(deliveryZone); when(deliveryZoneService.getByUserForRight(userId, MANAGE_DISTRIBUTION)).thenReturn(asList(deliveryZone)); when(distributionService.getBy(distributionId)).thenReturn(distribution); assertThat(distributionPermissionService.hasPermission(userId, "MANAGE_DISTRIBUTION", distributionId), is(true)); }
public Boolean hasPermission(Long userId, String permission, final Distribution distribution) { return hasPermissionForDeliveryZone(userId, permission, distribution); }
DistributionPermissionService { public Boolean hasPermission(Long userId, String permission, final Distribution distribution) { return hasPermissionForDeliveryZone(userId, permission, distribution); } }
DistributionPermissionService { public Boolean hasPermission(Long userId, String permission, final Distribution distribution) { return hasPermissionForDeliveryZone(userId, permission, distribution); }  }
DistributionPermissionService { public Boolean hasPermission(Long userId, String permission, final Distribution distribution) { return hasPermissionForDeliveryZone(userId, permission, distribution); }  Boolean hasPermission(Long userId, String permission, final Distribution distribution); Boolean hasPermission(Long userId, String permission, final Long distributionId); }
DistributionPermissionService { public Boolean hasPermission(Long userId, String permission, final Distribution distribution) { return hasPermissionForDeliveryZone(userId, permission, distribution); }  Boolean hasPermission(Long userId, String permission, final Distribution distribution); Boolean hasPermission(Long userId, String permission, final Long distributionId);  }