use of javax.jcr.version.VersionIterator in project jackrabbit-oak by apache.
the class ReadVersionContentTest method testGetAllVersions.
/**
* @since oak
*/
@Test
public void testGetAllVersions() throws Exception {
// accessing the version history must be allowed if the versionable node
// is readable to the editing test session.
Node testNode = testSession.getNode(versionablePath);
VersionHistory vh = testNode.getVersionHistory();
VersionIterator versionIterator = vh.getAllVersions();
}
use of javax.jcr.version.VersionIterator in project jackrabbit-oak by apache.
the class ReadVersionContentTest method testGetAllLinearVersions.
/**
* @since oak
*/
@Test
public void testGetAllLinearVersions() throws Exception {
// accessing the version history must be allowed if the versionable node
// is readable to the editing test session.
Node testNode = testSession.getNode(versionablePath);
VersionHistory vh = testNode.getVersionHistory();
VersionIterator versionIterator = vh.getAllLinearVersions();
}
use of javax.jcr.version.VersionIterator in project acs-aem-commons by Adobe-Consulting-Services.
the class ReplicateVersionImplTest method testReplicate.
@Test
public final void testReplicate() throws Exception {
final String[] agents = new String[] { "agent1" };
final String[] rootPaths = new String[] { "/content/geometrixx/en" };
final Date date = getDate("2013-12-21T00:00:00");
final Date vDate = getDate("2013-12-01T00:00:00");
final Date vDate1 = getDate("2013-12-22T00:00:00");
final Calendar cal = GregorianCalendar.getInstance();
cal.setTime(vDate);
final Calendar cal1 = GregorianCalendar.getInstance();
cal1.setTime(vDate1);
final ResourceResolver resourceResolver = mock(ResourceResolver.class);
final Session session = mock(Session.class);
final Workspace wk = mock(Workspace.class);
final VersionManager vm = mock(VersionManager.class);
final VersionHistory vh = mock(VersionHistory.class);
final VersionIterator vi = mock(VersionIterator.class);
final Version v = mock(Version.class);
final Version v1 = mock(Version.class);
when(v.getCreated()).thenReturn(cal);
when(v1.getCreated()).thenReturn(cal1);
when(v.getName()).thenReturn("version1");
when(vi.nextVersion()).thenReturn(v, v1);
when(vi.hasNext()).thenReturn(true, true, false);
when(session.getWorkspace()).thenReturn(wk);
when(wk.getVersionManager()).thenReturn(vm);
when(resourceResolver.adaptTo(Session.class)).thenReturn(session);
when(vm.getVersionHistory(rootPaths[0])).thenReturn(vh);
when(vh.getAllVersions()).thenReturn(vi);
final Resource res = mock(Resource.class);
when(res.getPath()).thenReturn(rootPaths[0]);
final Node node = mock(Node.class);
when(resourceResolver.getResource(rootPaths[0])).thenReturn(res);
when(res.adaptTo(Node.class)).thenReturn(node);
when(session.getNode(rootPaths[0])).thenReturn(node);
when(node.hasNode(NameConstants.NN_CONTENT)).thenReturn(true);
final Node node1 = mock(Node.class);
when(node1.getPath()).thenReturn(rootPaths[0]);
when(node.getNode(NameConstants.NN_CONTENT)).thenReturn(node1);
when(node1.isNodeType(JcrConstants.MIX_VERSIONABLE)).thenReturn(true);
when(node.isNodeType("nt:hierarchyNode")).thenReturn(true);
final Resource res1 = mock(Resource.class);
final Resource res2 = mock(Resource.class);
@SuppressWarnings("unchecked") final Iterator<Resource> itr = mock(Iterator.class);
when(resourceResolver.listChildren(res)).thenReturn(itr);
when(itr.hasNext()).thenReturn(true, true, false);
when(itr.next()).thenReturn(res1, res2);
when(res1.adaptTo(Node.class)).thenReturn(node1);
when(res2.adaptTo(Node.class)).thenReturn(node1);
when(node1.isNodeType("nt:hierarchyNode")).thenReturn(false);
List<ReplicationResult> list = rpvs.replicate(resourceResolver, rootPaths, agents, date);
Assert.assertEquals("/content/geometrixx/en", list.get(0).getPath());
Assert.assertEquals(Status.replicated, list.get(0).getStatus());
Assert.assertEquals("version1", list.get(0).getVersion());
}
use of javax.jcr.version.VersionIterator in project acs-aem-commons by Adobe-Consulting-Services.
the class VersionServiceImplTest method lastVersion_oneVersion_returnVersion.
@Test
public void lastVersion_oneVersion_returnVersion() throws Exception {
// given
VersionIterator versionIterator = mock(VersionIterator.class, withSettings().extraInterfaces(Iterator.class));
when(versionIterator.hasNext()).thenReturn(true, false);
Version last = mock(Version.class);
when(versionIterator.next()).thenReturn(last);
Resource resource = mockResource(versionIterator);
// when
Version result = underTest.lastVersion(resource);
// then
assertThat(result, is(last));
}
use of javax.jcr.version.VersionIterator in project acs-aem-commons by Adobe-Consulting-Services.
the class VersionServiceImplTest method lastVersion_error_returnNull.
@Test
public void lastVersion_error_returnNull() throws Exception {
// given
VersionIterator versionIterator = mock(VersionIterator.class, withSettings().extraInterfaces(Iterator.class));
when(versionIterator.hasNext()).thenThrow(RepositoryException.class);
Resource resource = mockResource(versionIterator);
// when
Version result = underTest.lastVersion(resource);
// then
assertNull(result);
}
Aggregations