@Test public void testGetRowNumberAfterGettingNext() throws Exception { testObj.next(); testObj.next(); testObj.next(); testObj.next(); testObj.next(); assertEquals(5, testObj.getRowNumber()); }
@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()); }
@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()); }
@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); }
@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()); }
@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")); }
@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()); }
@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()); }
@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")); }