@Test(expected = ValidationServiceException.class) public void testNotAuthorizedOrg() throws Exception { DeviceData item = new DeviceData(); item.getDevice().getOrg().setLocalCode("local"); item.setStateCode("state"); Mockito.when( processor.userService.hasAccessToOrgByCode(Matchers.<ServiceContext> any(), Matchers.<Long> any(), Matchers.anyString())).thenReturn(Boolean.FALSE); processor.process(item); }
@Override public DeviceData process(DeviceData item) throws Exception { if (userService.hasAccessToOrgByCode(getServiceContext(), getUserId(), item.getCombinedCode())) { log.debug("Granting delete access to org: {}", item.getCombinedCode()); return item; } log.debug("Denying delete access to org: {}", item.getCombinedCode()); List<ValidationError> errors = Lists.newArrayList(); addNotAllowedError(errors, item.getCombinedCode(), "delete"); throwIfErrors(errors); return null; }
OrgFilterProcessor extends AbstractDeviceStep implements ItemProcessor<DeviceData, DeviceData> { @Override public DeviceData process(DeviceData item) throws Exception { if (userService.hasAccessToOrgByCode(getServiceContext(), getUserId(), item.getCombinedCode())) { log.debug("Granting delete access to org: {}", item.getCombinedCode()); return item; } log.debug("Denying delete access to org: {}", item.getCombinedCode()); List<ValidationError> errors = Lists.newArrayList(); addNotAllowedError(errors, item.getCombinedCode(), "delete"); throwIfErrors(errors); return null; } }
OrgFilterProcessor extends AbstractDeviceStep implements ItemProcessor<DeviceData, DeviceData> { @Override public DeviceData process(DeviceData item) throws Exception { if (userService.hasAccessToOrgByCode(getServiceContext(), getUserId(), item.getCombinedCode())) { log.debug("Granting delete access to org: {}", item.getCombinedCode()); return item; } log.debug("Denying delete access to org: {}", item.getCombinedCode()); List<ValidationError> errors = Lists.newArrayList(); addNotAllowedError(errors, item.getCombinedCode(), "delete"); throwIfErrors(errors); return null; }  }
OrgFilterProcessor extends AbstractDeviceStep implements ItemProcessor<DeviceData, DeviceData> { @Override public DeviceData process(DeviceData item) throws Exception { if (userService.hasAccessToOrgByCode(getServiceContext(), getUserId(), item.getCombinedCode())) { log.debug("Granting delete access to org: {}", item.getCombinedCode()); return item; } log.debug("Denying delete access to org: {}", item.getCombinedCode()); List<ValidationError> errors = Lists.newArrayList(); addNotAllowedError(errors, item.getCombinedCode(), "delete"); throwIfErrors(errors); return null; }  @Override DeviceData process(DeviceData item); }
OrgFilterProcessor extends AbstractDeviceStep implements ItemProcessor<DeviceData, DeviceData> { @Override public DeviceData process(DeviceData item) throws Exception { if (userService.hasAccessToOrgByCode(getServiceContext(), getUserId(), item.getCombinedCode())) { log.debug("Granting delete access to org: {}", item.getCombinedCode()); return item; } log.debug("Denying delete access to org: {}", item.getCombinedCode()); List<ValidationError> errors = Lists.newArrayList(); addNotAllowedError(errors, item.getCombinedCode(), "delete"); throwIfErrors(errors); return null; }  @Override DeviceData process(DeviceData item);  }