Skip to content

Commit

Permalink
Removing NullPointerException handling and fixing test mock objects t…
Browse files Browse the repository at this point in the history
…hat triggered the NPE
  • Loading branch information
escowles committed Jul 28, 2014
1 parent 5bc7a40 commit 2feab18
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Expand Up @@ -131,9 +131,6 @@ public void addedStatement(final Statement s) {
} catch ( UnsupportedEncodingException ex ) {
LOGGER.warn("Required encoding (UTF-8) not supported, trying undecoded path",ex);
path = subjects.getPathFromSubject(subject);
} catch ( NullPointerException ex ) {
LOGGER.debug("Looking up null path",ex);
path = null;
}
subjectNode = session.getNode(path);
}
Expand Down
Expand Up @@ -142,8 +142,9 @@ public void testAddedIrrelevantStatement() {
public void testAddedProhibitedStatement() throws RepositoryException {
mockStatic(JcrRdfTools.class);
when(mockSubjects.isFedoraGraphSubject(mockSubject)).thenReturn(true);
when(mockSession.getNode(mockSubjects.getPathFromSubject(mockSubject)))
.thenReturn(mockSubjectNode);
//when(mockSession.getNode(mockSubjects.getPathFromSubject(mockSubject))).thenReturn(mockSubjectNode);
when(mockSubjects.getPathFromSubject(mockSubject)).thenReturn("/some/path");
when(mockSession.getNode("/some/path")).thenReturn(mockSubjectNode);
when(mockJcrRdfTools.isInternalProperty(mockSubjectNode, mockPredicate)).thenReturn(true);

when(mockPredicate.getURI()).thenReturn("x");
Expand All @@ -155,7 +156,8 @@ public void testAddedProhibitedStatement() throws RepositoryException {
public void testAddedStatement() throws RepositoryException {
mockStatic(JcrRdfTools.class);
when(mockSubjects.isFedoraGraphSubject(mockSubject)).thenReturn(true);
when(mockSession.getNode(mockSubjects.getPathFromSubject(mockSubject))).thenReturn(mockSubjectNode);
when(mockSubjects.getPathFromSubject(mockSubject)).thenReturn("/some/path");
when(mockSession.getNode("/some/path")).thenReturn(mockSubjectNode);
final String mockPropertyName = "mock:property";
when(
mockJcrRdfTools.getPropertyNameFromPredicate(mockSubjectNode,
Expand Down Expand Up @@ -241,7 +243,9 @@ public void testAddRdfType() throws RepositoryException {

final Resource resource = createResource("xyz");
when(mockSubjects.isFedoraGraphSubject(resource)).thenReturn(true);
when(mockSession.getNode(mockSubjects.getPathFromSubject(resource))).thenReturn(mockSubjectNode);
//when(mockSession.getNode(mockSubjects.getPathFromSubject(resource))).thenReturn(mockSubjectNode);
when(mockSubjects.getPathFromSubject(resource)).thenReturn("/xyz");
when(mockSession.getNode("/xyz")).thenReturn(mockSubjectNode);

when(mockSubjectNode.getSession()).thenReturn(mockSession);
when(mockSession.getWorkspace()).thenReturn(mockWorkspace);
Expand Down Expand Up @@ -282,7 +286,8 @@ public void testAddRdfTypeForNonMixin() throws RepositoryException {

final Resource resource = createResource("xyz");
when(mockSubjects.isFedoraGraphSubject(resource)).thenReturn(true);
when(mockSession.getNode(mockSubjects.getPathFromSubject(resource))).thenReturn(mockSubjectNode);
when(mockSubjects.getPathFromSubject(resource)).thenReturn("/xyz");
when(mockSession.getNode("/xyz")).thenReturn(mockSubjectNode);

when(mockSubjectNode.getSession()).thenReturn(mockSession);
when(mockSession.getWorkspace()).thenReturn(mockWorkspace);
Expand Down

0 comments on commit 2feab18

Please sign in to comment.