StudioWorkspaceResourceHandler implements WorkspaceResourceHandler { protected ResponseEntity<String> doPost(final Path filePath, WorkspaceResourceEvent actionEvent) { if (actionEvent == null) { throw new IllegalArgumentException("actionEvent is null"); } if (restClient.isConfigured()) { final String url = createPostURL(actionEvent); RestTemplate restTemplate = restClient.getRestTemplate(); return restTemplate.postForEntity(URI.create(url), filePath != null ? filePath.toString() : null, String.class); } return new ResponseEntity<>(HttpStatus.SERVICE_UNAVAILABLE); } @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_doPost_doNothing_if_rest_client_is_not_configured() throws Exception { when(env.getProperty(RestClientProperties.WORKSPACE_API_REST_URL)).thenReturn(null); studioWorkspaceResourceHandler.doPost(filePath, WorkspaceResourceEvent.POST_CLOSE); }
@Test(expected = IllegalArgumentException.class) public void should_doPost_throw_an_IllegalArgumentException_if_actionEvent_is_null() throws Exception { Path filePath = Paths.get("path", "to", "file"); studioWorkspaceResourceHandler.doPost(filePath, null); }