QtiObjectReader implements RootNodeProvider { public QtiObjectReadResult<RootNode> lookupRootNode(final URI systemId) throws XmlResourceNotFoundException, QtiXmlInterpretationException { return lookupRootNode(systemId, RootNode.class); } QtiObjectReader(final QtiXmlReader qtiXmlReader, final ResourceLocator inputResourceLocator, final boolean schemaValidating); QtiXmlReader getQtiXmlReader(); ResourceLocator getInputResourceLocator(); boolean isSchemaValidating(); @Override JqtiExtensionManager getJqtiExtensionManager(); QtiObjectReadResult<RootNode> lookupRootNode(final URI systemId); @Override QtiObjectReadResult<E> lookupRootNode(final URI systemId, final Class<E> requiredRootNodeClass); @Override String toString();  }
@Test(expected=IllegalArgumentException.class) public void testLookupNullUri() throws Exception { qtiObjectReader.lookupRootNode(null, AssessmentItem.class); }
@Test(expected=IllegalArgumentException.class) public void testLookupNullResultClass() throws Exception { qtiObjectReader.lookupRootNode(choiceUri, null); }
@Test public void testLookupChoiceItemGood() throws Exception { final QtiObjectReadResult<AssessmentItem> result = qtiObjectReader.lookupRootNode(choiceUri, AssessmentItem.class); assertNotNull(result); assertEquals(QtiConstants.QTI_21_NAMESPACE_URI, result.getQtiNamespaceUri()); assertEquals(AssessmentItem.class, result.getRequestedRootNodeClass()); assertNotNull(result.getXmlParseResult()); assertNotNull(result.getRootNode()); assertEquals(AssessmentItem.class, result.getRootNode().getClass()); }
@Test public void testLookupChoiceItemVagueRoot() throws Exception { final QtiObjectReadResult<RootNode> result = qtiObjectReader.lookupRootNode(choiceUri); assertNotNull(result); assertEquals(RootNode.class, result.getRequestedRootNodeClass()); assertEquals(AssessmentItem.class, result.getRootNode().getClass()); }
@Test(expected=XmlResourceNotFoundException.class) public void testLookupNotFound() throws Exception { qtiObjectReader.lookupRootNode(UnitTestHelper.createTestResourceUri("notfound.xml")); }
@Test(expected=QtiXmlInterpretationException.class) public void testLookupChoiceItemWrongRoot() throws Exception { qtiObjectReader.lookupRootNode(choiceUri, AssessmentTest.class); }
@Test public void testLookupChoiceAssessmentResult() throws Exception { final QtiObjectReadResult<AssessmentResult> result = qtiObjectReader.lookupRootNode(choiceAssessmentResultUri, AssessmentResult.class); assertNotNull(result); assertEquals(QtiConstants.QTI_RESULT_21_NAMESPACE_URI, result.getQtiNamespaceUri()); assertEquals(AssessmentResult.class, result.getRequestedRootNodeClass()); assertNotNull(result.getXmlParseResult()); assertNotNull(result.getRootNode()); assertEquals(AssessmentResult.class, result.getRootNode().getClass()); }