@Test public void testInvokeOnUndefinedVariable() { try { // injector undefined StatementBuilder.create() .loadVariable("injector") .invoke("provide", Refs.get("param"), Refs.get("param2")) .toJavaString(); fail("expected OutOfScopeException"); } catch (OutOfScopeException oose) { // expected assertTrue("Wrong exception thrown", oose.getMessage().contains("injector")); } }
@Test public void testInvokeWithUndefinedVariable() { try { // param2 undefined StatementBuilder.create() .declareVariable("obj", Object.class) .declareVariable("param", String.class) .loadVariable("obj") .invoke("undefinedMethod", Variable.get("param"), Variable.get("param2")) .toJavaString(); fail("expected OutOfScopeException"); } catch (OutOfScopeException oose) { // expected assertTrue(oose.getMessage().contains("param2")); } }