### Question:
NotLocalFolderAndResourceArgumentVoter extends BasicObjectPermissionArgumentVoter { @Override protected boolean isPermitted(Authentication authentication, ObjectPermission objectPermission, Object object) { InternalURI internalURI = new InternalURIDefinition(objectPermission.getURI()); return !(repositoryService.isLocalFolder(null, internalURI.getPath()) || isLocalResource(internalURI)); }  @Override boolean supports(ConfigAttribute attribute);  }### Answer:
@Test public void isPermitted_localFolder_returnFalse() { String localFolderUri = "/f1/f2_files"; when(repositoryService.isLocalFolder(null, localFolderUri)).thenReturn(true); ObjectPermission objectPermission = mock(ObjectPermission.class); when(objectPermission.getURI()).thenReturn("repo:" + localFolderUri); boolean result = notLocalFolderAndResourceArgumentVoter. isPermitted(mock(Authentication.class), objectPermission, mock(Object.class)); assertFalse(result); }
@Test public void isPermitted_localResource_returnFalse() { String parentPath = "/f1/f2_files"; String localResource = "/f1/f2_files/Res"; when(repositoryService.isLocalFolder(null, parentPath)).thenReturn(true); ObjectPermission objectPermission = mock(ObjectPermission.class); when(objectPermission.getURI()).thenReturn("repo:"+ localResource); boolean result = notLocalFolderAndResourceArgumentVoter. isPermitted(mock(Authentication.class), objectPermission, mock(Object.class)); assertFalse(result); }
@Test public void isPermitted_notLocalResourceNorFolder_returnTrue() { String notLocalResourceNorFolder = "/f1/f2"; when(repositoryService.isLocalFolder(null, notLocalResourceNorFolder)).thenReturn(false); ObjectPermission objectPermission = mock(ObjectPermission.class); when(objectPermission.getURI()).thenReturn("repo:" + notLocalResourceNorFolder); boolean result = notLocalFolderAndResourceArgumentVoter. isPermitted(mock(Authentication.class), objectPermission, mock(Object.class)); assertTrue(result); }