示例#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 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());
  }
示例#3
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());
  }
示例#4
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);
  }
示例#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 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"));
  }
示例#7
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());
  }
示例#8
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());
  }
示例#9
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"));
  }