@Before public void setUp() throws Exception { // Setup HTTP Context Http.Context context = Mockito.mock(Http.Context.class); // Mocking flash session, request, etc... as required Http.Flash flash = Mockito.mock(Http.Flash.class); when(context.flash()).thenReturn(flash); Http.Context.current.set(context); }
public static Result index(String name) { Http.Context.current().args.put("name", name); String n = (String) Http.Context.current().args.get("name"); return ok(index.render(n)); }