### Question:
RhinoCompiledScript extends CompiledScript { @Override public Object eval(final ScriptContext scriptContext) throws ScriptException { return engine.evalCompiled(compiledScript, scriptContext); } RhinoCompiledScript(final RhinoScriptEngine engine, final Script compiledScript); @Override Object eval(final ScriptContext scriptContext); @Override ScriptEngine getEngine(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void shouldDelegateToScriptEngine() throws ScriptException { ScriptContext context = mock(ScriptContext.class); Object expectedResult = "a result"; given(mockEngine.evalCompiled(mockScript, context)).willReturn(expectedResult); Object result = testScript.eval(context); verify(mockEngine).evalCompiled(mockScript, context); assertThat(result).isEqualTo(expectedResult); }
@Test(expectedExceptions = ScriptException.class) public void shouldPropagateExceptions() throws ScriptException { ScriptContext context = mock(ScriptContext.class); given(mockEngine.evalCompiled(mockScript, context)).willThrow(new ScriptException("test exception")); testScript.eval(context); }