protected static DateTime computeExpirationTime( CacheableRequest request ) { CachePolicy policy = request.getCachePolicy(); return policy == null ? null : request.getTimeLoaded().plus(policy.getTimeToLive(), TimeUnit.MILLISECONDS); }
@Test public void shouldIncludeTimeLoadedInReadNextBlockOfChildrenRequests() { // Get the first child ... String workspaceName = graph.getCurrentWorkspaceName(); Location firstChild = graph.getChildren().of("/").get(0); // Don't use the graph so that we can obtain and interrogate the request ... CacheableRequest request = new ReadNextBlockOfChildrenRequest(firstChild, workspaceName, 100); execute(request); assertThat(request.getTimeLoaded(), is(notNullValue())); }
@Test public void shouldIncludeTimeLoadedInReadNodeRequests() { String workspaceName = graph.getCurrentWorkspaceName(); // Don't use the graph so that we can obtain and interrogate the request ... CacheableRequest request = new ReadNodeRequest(location("/"), workspaceName); execute(request); assertThat(request.getTimeLoaded(), is(notNullValue())); }
@Test public void shouldIncludeTimeLoadedInReadBranchRequests() { String workspaceName = graph.getCurrentWorkspaceName(); // Don't use the graph so that we can obtain and interrogate the request ... CacheableRequest request = new ReadBranchRequest(location("/"), workspaceName, 2); execute(request); assertThat(request.getTimeLoaded(), is(notNullValue())); }
@Test public void shouldIncludeTimeLoadedInReadAllPropertiesRequests() { String workspaceName = graph.getCurrentWorkspaceName(); // Don't use the graph so that we can obtain and interrogate the request ... CacheableRequest request = new ReadAllPropertiesRequest(location("/"), workspaceName); execute(request); assertThat(request.getTimeLoaded(), is(notNullValue())); }
@Test public void shouldIncludeTimeLoadedInReadAllChildrenRequests() { String workspaceName = graph.getCurrentWorkspaceName(); // Don't use the graph so that we can obtain and interrogate the request ... CacheableRequest request = new ReadAllChildrenRequest(location("/"), workspaceName); execute(request); assertThat(request.getTimeLoaded(), is(notNullValue())); }
@Test public void shouldIncludeTimeLoadedInReadBlockOfChildrenRequests() { String workspaceName = graph.getCurrentWorkspaceName(); // Don't use the graph so that we can obtain and interrogate the request ... CacheableRequest request = new ReadBlockOfChildrenRequest(location("/"), workspaceName, 0, 100); execute(request); assertThat(request.getTimeLoaded(), is(notNullValue())); }
@Test public void shouldIncludeTimeLoadedInReadPropertyRequests() { // Get each of the properties on the first child ... String workspaceName = graph.getCurrentWorkspaceName(); Location firstChildLocation = graph.getChildren().of("/").get(0); Node firstChild = graph.getNodeAt(firstChildLocation); // Don't use the graph so that we can obtain and interrogate the request ... for (Property property : firstChild.getProperties()) { CacheableRequest request = new ReadPropertyRequest(firstChildLocation, workspaceName, property.getName()); execute(request); assertThat(request.getTimeLoaded(), is(notNullValue())); } }