use of org.apache.sling.commons.testing.jcr.MockProperty in project acs-aem-commons by Adobe-Consulting-Services.
the class RootNodeMockFactory method mockEntryNode.
private Node mockEntryNode(Node parentNode, int i, boolean isExpired) throws RepositoryException, IOException {
final String nodeName = (isExpired) ? "expired-entrynode-" : "entrynode-";
final Node entryNode = mockStandardNode(nodeName + (i + 1));
if (settings.enableCacheEntryBinaryContent) {
mockEntryContentNode(entryNode);
}
when(entryNode.hasProperty(JCRHttpCacheStoreConstants.PN_ISCACHEENTRYNODE)).thenReturn(true);
when(entryNode.hasProperty(JCRHttpCacheStoreConstants.PN_ISBUCKETNODE)).thenReturn(false);
when(entryNode.hasProperty(JCRHttpCacheStoreConstants.PN_EXPIRES_ON)).thenReturn(true);
when(entryNode.getNodes()).thenReturn(new MockNodeIterator());
when(entryNode.getProperties()).thenReturn(new MockPropertyIterator(IteratorUtils.EMPTY_ITERATOR));
when(entryNode.getParent()).thenReturn(parentNode);
final MockProperty expiresMockProperty = new MockProperty(JCRHttpCacheStoreConstants.PN_EXPIRES_ON);
int seconds;
if (isExpired) {
seconds = -9000;
} else {
seconds = 9000;
}
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.SECOND, seconds);
expiresMockProperty.setValue(calendar);
when(entryNode.getProperty(JCRHttpCacheStoreConstants.PN_EXPIRES_ON)).thenReturn(expiresMockProperty);
return entryNode;
}
Aggregations