### Question:
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);  }### Answer:
@Test public void testAuthorizedOrg() 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.eq("state-local"))).thenReturn(Boolean.TRUE); Assert.assertNotNull(processor.process(item)); }
@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); }
@Test public void testAuthorizedOrgTwice() 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.eq("state-local"))).thenReturn(Boolean.TRUE); Assert.assertNotNull(processor.process(item)); Assert.assertNotNull(processor.process(item)); }