Ejemplo n.º 1
0
 @Test
 public void testGetRowNumberAfterGettingNext() throws Exception {
   testObj.next();
   testObj.next();
   testObj.next();
   testObj.next();
   testObj.next();
   assertEquals(5, testObj.getRowNumber());
 }
Ejemplo n.º 2
0
  @Test
  public void testEmptyBinding() throws Exception {

    when(mockQueryResult.getColumnNames()).thenReturn(new String[] {});
    final Binding binding = testObj.nextBinding();
    assertTrue(binding.isEmpty());
  }
Ejemplo n.º 3
0
  @Test
  public void testSolutionVars() throws Exception {
    final QuerySolution solution = testObj.nextSolution();
    final List<String> vars = ImmutableList.copyOf(solution.varNames());

    assertArrayEquals(columnNames, vars.toArray());
  }
Ejemplo n.º 4
0
  @Test
  public void testNextWithURI() throws Exception {
    when(mockValue.getType()).thenReturn(PropertyType.URI);
    when(mockValue.getString()).thenReturn("info:xyz");
    final QuerySolution solution = testObj.next();

    assertEquals("info:xyz", solution.get("a").asResource().getURI());
  }
Ejemplo n.º 5
0
  @Test
  public void testNextWithLiteralBoolean() throws Exception {
    when(mockValue.getType()).thenReturn(PropertyType.BOOLEAN);
    when(mockValue.getString()).thenReturn("true");
    final QuerySolution solution = testObj.next();

    assertEquals("true", solution.get("a").asLiteral().getLexicalForm());
  }
Ejemplo n.º 6
0
  @Test
  public void testNextWithLiteralLong() throws Exception {
    when(mockValue.getType()).thenReturn(PropertyType.LONG);
    when(mockValue.getLong()).thenReturn(1L);
    final QuerySolution solution = testObj.next();

    assertEquals(1L, solution.get("a").asLiteral().getLong());
  }
Ejemplo n.º 7
0
  @Test
  public void testNextWithLiteralDouble() throws Exception {
    when(mockValue.getType()).thenReturn(PropertyType.DOUBLE);
    when(mockValue.getDouble()).thenReturn(1.0);
    final QuerySolution solution = testObj.next();

    assertEquals(1.0, solution.get("a").asLiteral().getDouble(), 0.1);
  }
Ejemplo n.º 8
0
  @Test
  public void testNextBinding() throws Exception {
    when(mockValue.getString()).thenReturn("x");
    final Binding binding = testObj.nextBinding();

    assertTrue(binding.contains(Var.alloc("a")));
    final Node a = binding.get(Var.alloc("a"));
    assertEquals("x", a.getLiteralLexicalForm());
  }
Ejemplo n.º 9
0
  @Test
  public void testNextWithLiteral() throws Exception {
    when(mockValue.getString()).thenReturn("x");
    final QuerySolution solution = testObj.next();

    assertTrue(solution.contains("a"));
    assertEquals("x", solution.get("a").asLiteral().getLexicalForm());
    assertEquals(solution.get("a"), solution.getLiteral("a"));
  }
Ejemplo n.º 10
0
  @Test
  public void testNextWithLiteralDate() throws Exception {
    when(mockValue.getType()).thenReturn(PropertyType.DATE);
    final Calendar date = Calendar.getInstance();
    when(mockValue.getDate()).thenReturn(date);
    final QuerySolution solution = testObj.next();

    assertNotNull(solution.get("a").asLiteral());
    assertEquals(XSDDatatype.XSDdateTime.getURI(), solution.get("a").asLiteral().getDatatypeURI());
  }
Ejemplo n.º 11
0
  @Test
  public void testNextWithResource() throws Exception {
    when(mockValue.getType()).thenReturn(PropertyType.PATH);
    when(mockValue.getString()).thenReturn("/x");
    when(mockGraphSubjects.getSubject("/x")).thenReturn(ResourceFactory.createResource("info:x"));
    final QuerySolution solution = testObj.next();

    assertTrue(solution.contains("a"));
    assertEquals("info:x", solution.get("a").asResource().getURI());
    assertEquals(solution.get("a"), solution.getResource("a"));
  }
Ejemplo n.º 12
0
  @Test
  public void testNextWithReference() throws Exception {
    when(mockValue.getType()).thenReturn(PropertyType.REFERENCE);
    when(mockValue.getString()).thenReturn("uuid");
    when(mockSession.getNodeByIdentifier("uuid")).thenReturn(mockNode);
    when(mockGraphSubjects.getSubject(mockNode.getPath()))
        .thenReturn(ResourceFactory.createResource("http://localhost:8080/xyz"));
    final QuerySolution solution = testObj.next();

    assertEquals("http://localhost:8080/xyz", solution.get("a").asResource().getURI());
  }
Ejemplo n.º 13
0
  @Test
  public void testBindingVars() throws Exception {
    final Binding binding = testObj.nextBinding();
    final List<String> vars =
        ImmutableList.copyOf(
            Iterators.transform(
                binding.vars(),
                new Function<Var, String>() {
                  @Override
                  public String apply(final Var var) {
                    return var.getVarName();
                  }
                }));

    assertArrayEquals(columnNames, vars.toArray());
    assertFalse(binding.isEmpty());
  }
Ejemplo n.º 14
0
 @Test
 public void testGetResourceModel() throws Exception {
   assertNull(testObj.getResourceModel());
 }
Ejemplo n.º 15
0
 @Test
 public void testGetResultVars() throws Exception {
   assertArrayEquals(columnNames, testObj.getResultVars().toArray());
 }
Ejemplo n.º 16
0
 @Test
 public void testGetRowNumber() throws Exception {
   assertEquals(0, testObj.getRowNumber());
 }
Ejemplo n.º 17
0
 @Test
 public void testBindingEmpty() throws Exception {
   final Binding binding = testObj.nextBinding();
   assertFalse(binding.isEmpty());
 }
Ejemplo n.º 18
0
 @Test(expected = java.lang.UnsupportedOperationException.class)
 public void testRemove() throws Exception {
   testObj.remove();
 }
Ejemplo n.º 19
0
 @Test
 public void testHasNext() throws Exception {
   when(mockRows.hasNext()).thenReturn(true);
   assertTrue(testObj.hasNext());
   verify(mockRows).hasNext();
 }
Ejemplo n.º 20
0
 @Test
 public void testBindingSize() throws Exception {
   final Binding binding = testObj.nextBinding();
   assertEquals(2, binding.size());
 }