### Question:
ScriptParser { public List<AnalysisResult> parse() throws IOException { List<AnalysisResult> results = new LinkedList<>(); CommonTokenStream tokens = new CommonTokenStream(lexer); OALParser parser = new OALParser(tokens); ParseTree tree = parser.root(); ParseTreeWalker walker = new ParseTreeWalker(); walker.walk(new OALListener(results), tree); return results; } private  ScriptParser(); static ScriptParser createFromFile(String scriptFilepath); static ScriptParser createFromScriptText(String script); List<AnalysisResult> parse(); void close();  }### Answer:
@Test public void testParse() throws IOException { ScriptParser parser = ScriptParser.createFromScriptText( "Endpoint_avg = from(Endpoint.latency).longAvg(); "Service_avg = from(Service.latency).longAvg()" ); List<AnalysisResult> results = parser.parse(); Assert.assertEquals(2, results.size()); AnalysisResult endpointAvg = results.get(0); Assert.assertEquals("EndpointAvg", endpointAvg.getMetricName()); Assert.assertEquals("Endpoint", endpointAvg.getSourceName()); Assert.assertEquals("latency", endpointAvg.getSourceAttribute()); Assert.assertEquals("longAvg", endpointAvg.getAggregationFunctionName()); AnalysisResult serviceAvg = results.get(1); Assert.assertEquals("ServiceAvg", serviceAvg.getMetricName()); Assert.assertEquals("Service", serviceAvg.getSourceName()); Assert.assertEquals("latency", serviceAvg.getSourceAttribute()); Assert.assertEquals("longAvg", serviceAvg.getAggregationFunctionName()); }