StudioWorkspaceResourceHandler implements WorkspaceResourceHandler { @Override public void preOpen(final Path filePath) throws LockedResourceException, ResourceNotFoundException { try { doPost(filePath, WorkspaceResourceEvent.PRE_OPEN); } catch (Exception e) { if (e instanceof HttpClientErrorException) { if (HttpStatus.LOCKED.equals(((HttpClientErrorException) e).getStatusCode())) { throw new LockedResourceException(filePath.toString(), e); } } handleResourceException(filePath, e); } } @Inject  StudioWorkspaceResourceHandler(RestClient restClient); @Override void preOpen(final Path filePath); @Override void postClose(final Path filePath); @Override void delete(Path filePath); @Override void postDelete(final Path filePath); @Override void postSave(final Path filePath); @Override void preImport(); @Override void postImport(); @Override LockStatus getLockStatus(final Path filePath);  }
@Test public void should_preOpen_post_filePath_to_workspace_rest_api() throws Exception { server.request(by(uri("/workspace/PRE_OPEN"))).response(status(HttpStatus.OK.value())); studioWorkspaceResourceHandler.preOpen(filePath); }
@Test(expected = LockedResourceException.class) public void should_preOpen_throw_a_LockedResourceException_if_status_is_locked() throws Exception { server.request(by(uri("/workspace/PRE_OPEN"))).response(status(HttpStatus.LOCKED.value())); studioWorkspaceResourceHandler.preOpen(filePath); }
@Test(expected = ResourceNotFoundException.class) public void should_preOpen_throw_a_ResourceNotFoundException_if_status_is_NOT_FOUND() throws Exception { server.request(by(uri("/workspace/PRE_OPEN"))).response(status(HttpStatus.NOT_FOUND.value())); studioWorkspaceResourceHandler.preOpen(filePath); }