示例#1
0
 @Test
 public void testGetRowNumberAfterGettingNext() throws Exception {
   testObj.next();
   testObj.next();
   testObj.next();
   testObj.next();
   testObj.next();
   assertEquals(5, testObj.getRowNumber());
 }
示例#2
0
  @Test
  public void testEmptyBinding() throws Exception {

    when(mockQueryResult.getColumnNames()).thenReturn(new String[] {});
    final Binding binding = testObj.nextBinding();
    assertTrue(binding.isEmpty());
  }
示例#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());
  }
示例#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());
  }
示例#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());
  }
示例#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());
  }
示例#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);
  }
示例#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());
  }
示例#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"));
  }
示例#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());
  }
示例#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"));
  }
示例#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());
  }
示例#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());
  }
示例#14
0
 @Test
 public void testGetResourceModel() throws Exception {
   assertNull(testObj.getResourceModel());
 }
示例#15
0
 @Test
 public void testGetResultVars() throws Exception {
   assertArrayEquals(columnNames, testObj.getResultVars().toArray());
 }
示例#16
0
 @Test
 public void testGetRowNumber() throws Exception {
   assertEquals(0, testObj.getRowNumber());
 }
示例#17
0
 @Test
 public void testBindingEmpty() throws Exception {
   final Binding binding = testObj.nextBinding();
   assertFalse(binding.isEmpty());
 }
示例#18
0
 @Test(expected = java.lang.UnsupportedOperationException.class)
 public void testRemove() throws Exception {
   testObj.remove();
 }
示例#19
0
 @Test
 public void testHasNext() throws Exception {
   when(mockRows.hasNext()).thenReturn(true);
   assertTrue(testObj.hasNext());
   verify(mockRows).hasNext();
 }
示例#20
0
 @Test
 public void testBindingSize() throws Exception {
   final Binding binding = testObj.nextBinding();
   assertEquals(2, binding.size());
 }