@Test
  public void testChildren() throws RepositoryException {
    when(mockRes1.getPath()).thenReturn(RDF_PATH + "/res1");
    when(mockRes2.getPath()).thenReturn(RDF_PATH + "/res2");
    when(mockRes3.getPath()).thenReturn(RDF_PATH + "/res3");
    when(mockResourceNode.hasNodes()).thenReturn(true);
    final Stream<FedoraResource> first = of(mockRes1, mockRes2, mockRes3);
    final Stream<FedoraResource> second = of(mockRes1, mockRes2, mockRes3);
    when(mockResource.getChildren()).thenReturn(first).thenReturn(second);

    try (final ChildrenRdfContext context = new ChildrenRdfContext(mockResource, idTranslator)) {
      final Model results = context.collect(toModel());
      final Resource subject = idTranslator.reverse().convert(mockResource);

      final StmtIterator stmts =
          results.listStatements(subject, RdfLexicon.HAS_CHILD_COUNT, (RDFNode) null);

      assertTrue("There should have been a statement!", stmts.hasNext());
      final Statement stmt = stmts.nextStatement();
      assertTrue("Object should be a literal! " + stmt.getObject(), stmt.getObject().isLiteral());
      assertEquals(3, stmt.getInt());

      assertFalse("There should not have been a second statement!", stmts.hasNext());
    }
  }
  @Test
  public void testNoChildren() throws RepositoryException {
    when(mockResourceNode.hasNodes()).thenReturn(false);

    try (final ChildrenRdfContext childrenRdfContext =
        new ChildrenRdfContext(mockResource, idTranslator)) {
      final Model results = childrenRdfContext.collect(toModel());
      final Resource subject = idTranslator.reverse().convert(mockResource);

      final StmtIterator stmts =
          results.listStatements(subject, RdfLexicon.HAS_CHILD_COUNT, (RDFNode) null);

      assertTrue("There should have been a statement!", stmts.hasNext());
      final Statement stmt = stmts.nextStatement();
      assertTrue("Object should be a literal! " + stmt.getObject(), stmt.getObject().isLiteral());
      assertEquals(0, stmt.getInt());

      assertFalse("There should not have been a second statement!", stmts.hasNext());
    }
  }