Skip to content

Commit

Permalink
create DatastreamService#getDatastream(String path)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Apr 26, 2013
1 parent 78402ce commit ae15a07
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Expand Up @@ -122,6 +122,17 @@ public Datastream getDatastream(final String pid, final String dsId)
return new Datastream(readOnlySession, pid, dsId);
}

/**
* Retrieve a Datastream instance by pid and dsid
* @param path jcr path to the datastream
* @return
* @throws RepositoryException
*/
public Datastream getDatastream(final String path)
throws RepositoryException {
return new Datastream(readOnlySession, path);
}

/**
* Delete a Datastream
* @param session jcr session
Expand Down
Expand Up @@ -104,6 +104,21 @@ public void testGetDatastream() throws Exception {
verifyNew(Datastream.class).withArguments(mockSession, "foo", "bar");
}


@Test
public void testGetDatastreamFromPath() throws Exception {
final Session mockSession = mock(Session.class);
final Node mockNode = mock(Node.class);
final Datastream mockWrapper = mock(Datastream.class);
when(mockWrapper.getNode()).thenReturn(mockNode);
whenNew(Datastream.class).withArguments(mockSession, "/foo/bar")
.thenReturn(mockWrapper);
final DatastreamService testObj = new DatastreamService();
testObj.readOnlySession = mockSession;
testObj.getDatastream("/foo/bar");
verifyNew(Datastream.class).withArguments(mockSession, "/foo/bar");
}

@Test
public void testPurgeDatastream() throws Exception {
final Session mockSession = mock(Session.class);
Expand Down

0 comments on commit ae15a07

Please sign in to comment.