### Question:
ModelingSchemaAnnotator implements MondrianSchemaAnnotator { @Override public InputStream getInputStream( final InputStream schemaInputStream, final InputStream annotationsInputStream ) { ModelAnnotationGroupXmlReader reader = new ModelAnnotationGroupXmlReader(); try { Document annotationsDoc = XMLHandler.loadXMLFile( annotationsInputStream ); Document schemaDoc = XMLHandler.loadXMLFile( schemaInputStream ); ModelAnnotationGroup modelAnnotations = reader.readModelAnnotationGroup( annotationsDoc ); modelAnnotations.applyAnnotations( schemaDoc ); return IOUtils.toInputStream( XMLHandler.formatNode( schemaDoc ) ); } catch ( Exception e ) { throw new RepositoryException( e ); } }  @Override InputStream getInputStream(
      final InputStream schemaInputStream, final InputStream annotationsInputStream );  }### Answer:
@Test public void testAppliesAnnotationsFromAFile() throws Exception { ModelingSchemaAnnotator annotator = new ModelingSchemaAnnotator(); InputStream schemaInput = getClass().getResourceAsStream( "resources/simple.mondrian.xml" ); InputStream annotationsInput = getClass().getResourceAsStream( "resources/annotations.xml" ); InputStream expectedInput = getClass().getResourceAsStream( "resources/annotated.mondrian.xml" ); InputStream actualInput = annotator.getInputStream( schemaInput, annotationsInput ); assertEquals( IOUtils.toString( expectedInput ).replaceAll( "\\r\\n", "\\\n" ), IOUtils.toString( actualInput ) .replaceAll( "\\r\\n", "\\\n" ) ); }
@Test public void testExceptionsThrowRepositoryException() throws Exception { ModelingSchemaAnnotator annotator = new ModelingSchemaAnnotator(); InputStream schemaInput = getClass().getResourceAsStream( "resources/simple.mondrian.xml" ); InputStream annotationsInput = getClass().getResourceAsStream( "resources/annotations.xml" ); schemaInput.close(); try { annotator.getInputStream( schemaInput, annotationsInput ); } catch ( RepositoryException e ) { return; } catch ( Exception e ) { fail( "got wrong exception" ); } fail( "should have got exception" ); }