Skip to content

Commit

Permalink
More unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Oct 25, 2013
1 parent a623168 commit 6813bdd
Showing 1 changed file with 16 additions and 2 deletions.
Expand Up @@ -2,6 +2,7 @@
package org.fcrepo.kernel.utils.iterators;

import static com.hp.hpl.jena.graph.NodeFactory.createAnon;
import static com.hp.hpl.jena.graph.NodeFactory.createLiteral;
import static com.hp.hpl.jena.graph.Triple.create;
import static com.hp.hpl.jena.rdf.model.ModelFactory.createDefaultModel;
import static com.hp.hpl.jena.vocabulary.RDF.type;
Expand Down Expand Up @@ -52,11 +53,17 @@ public class RdfPersisterTest {
private static final Statement propertyStatement = m
.asStatement(propertyTriple);

private static final Triple badMixinTriple = create(createAnon(),
type.asNode(), createLiteral("mixin:mixin"));

private static final Statement badMixinStatement = m.asStatement(badMixinTriple);

private static final Triple mixinTriple = create(createAnon(),
type.asNode(), createAnon());

private static final Statement mixinStatement = m.asStatement(mixinTriple);


private static final Triple foreignTriple = create(createAnon(),
createAnon(), createAnon());

Expand All @@ -71,8 +78,9 @@ public void setUp() throws RepositoryException {

@Test
public void testConsumeAsync() throws Exception {
when(mockStream.hasNext()).thenReturn(true, true, false);
when(mockStream.next()).thenReturn(propertyTriple, mixinTriple);
when(mockStream.hasNext()).thenReturn(true, true, true, true, false);
when(mockStream.next()).thenReturn(propertyTriple, mixinTriple,
foreignTriple, badMixinTriple);
when(
mockGraphSubjects.getNodeFromGraphSubject(propertyStatement
.getSubject())).thenReturn(mockNode);
Expand All @@ -82,6 +90,9 @@ public void testConsumeAsync() throws Exception {
when(
mockGraphSubjects.getNodeFromGraphSubject(foreignStatement
.getSubject())).thenReturn(mockNode);
when(
mockGraphSubjects.getNodeFromGraphSubject(badMixinStatement
.getSubject())).thenReturn(mockNode);
when(
mockGraphSubjects.isFedoraGraphSubject(propertyStatement
.getSubject())).thenReturn(true);
Expand All @@ -91,6 +102,9 @@ public void testConsumeAsync() throws Exception {
when(
mockGraphSubjects.isFedoraGraphSubject(foreignStatement
.getSubject())).thenReturn(false);
when(
mockGraphSubjects.isFedoraGraphSubject(badMixinStatement
.getSubject())).thenReturn(true);

testPersister =
new RdfPersister(mockGraphSubjects, mockSession, mockStream) {
Expand Down

0 comments on commit 6813bdd

Please sign in to comment.