Skip to content
Permalink
Browse files

Removing NullPointerException handling and fixing test mock objects t…

…hat triggered the NPE
  • Loading branch information...
escowles committed Jul 28, 2014
1 parent 5bc7a40 commit 2feab186e98cc25f05d463bfb2980b3899de4094
@@ -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);
}
@@ -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");
@@ -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,
@@ -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);
@@ -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);

0 comments on commit 2feab18

Please sign in to comment.
You can’t perform that action at this time.