use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.DesktopWithNonDisplayableActions in project scout.rt by eclipse.
the class JsonDesktopTest method testDontSendNonDisplayableMenus.
/**
* Tests whether non displayable menus are sent.
* <p>
* This reduces response size and also leverages security because the menus are never visible to the user, not even
* with the dev tools of the browser
*/
@Test
public void testDontSendNonDisplayableMenus() throws Exception {
IDesktop desktop = new DesktopWithNonDisplayableActions();
desktop.initDesktop();
JsonDesktop<IDesktop> jsonDesktop = createJsonDesktop(desktop);
JsonMenu<IMenu> jsonDisplayableMenu = jsonDesktop.getAdapter(desktop.getMenu(DesktopWithNonDisplayableActions.DisplayableMenu.class));
JsonMenu<IMenu> jsonNonDisplayableMenu = jsonDesktop.getAdapter(desktop.getMenu(DesktopWithNonDisplayableActions.NonDisplayableMenu.class));
JsonFormMenu<IFormMenu<IForm>> jsonDisplayableFormMenu = jsonDesktop.getAdapter(desktop.getMenu(DesktopWithNonDisplayableActions.DisplayableFormMenu.class));
JsonFormMenu<IFormMenu<IForm>> jsonNonDisplayableFormMenu = jsonDesktop.getAdapter(desktop.getMenu(DesktopWithNonDisplayableActions.NonDisplayableFormMenu.class));
// Adapter for NonDisplayableMenu/Menu must not exist
assertNull(jsonNonDisplayableMenu);
assertNull(jsonNonDisplayableFormMenu);
// Json response must not contain NonDisplayableMenu/FormMenu
JSONObject json = jsonDesktop.toJson();
JSONArray jsonActions = json.getJSONArray("menus");
assertEquals(2, jsonActions.length());
List<String> ids = new ArrayList<String>();
ids.add(jsonActions.getString(0));
ids.add(jsonActions.getString(1));
assertTrue(ids.contains(jsonDisplayableMenu.getId()));
assertTrue(ids.contains(jsonDisplayableFormMenu.getId()));
}
use of org.eclipse.scout.rt.ui.html.json.desktop.fixtures.DesktopWithNonDisplayableActions in project scout.rt by eclipse.
the class JsonDesktopTest method testDontSendNonDisplayableViewButtons.
/**
* Tests whether non displayable view buttons are sent.
* <p>
* This reduces response size and also leverages security because the menus are never visible to the user, not even
* with the dev tools of the browser
*/
@Test
public void testDontSendNonDisplayableViewButtons() throws Exception {
IDesktop desktop = new DesktopWithNonDisplayableActions();
desktop.initDesktop();
JsonDesktop<IDesktop> jsonDesktop = createJsonDesktop(desktop);
JsonOutlineViewButton<IOutlineViewButton> jsonDisplayableAction = jsonDesktop.getAdapter(desktop.getViewButton(DesktopWithNonDisplayableActions.DisplayableOutlineViewButton.class));
JsonOutlineViewButton<IOutlineViewButton> jsonNonDisplayableAction = jsonDesktop.getAdapter(desktop.getViewButton(DesktopWithNonDisplayableActions.NonDisplayableOutlineViewButton.class));
// Adapter for NonDisplayableMenu must not exist
assertNull(jsonNonDisplayableAction);
// Json response must not contain NonDisplayableAction
JSONObject json = jsonDesktop.toJson();
JSONArray jsonActions = json.getJSONArray("viewButtons");
assertEquals(1, jsonActions.length());
assertEquals(jsonDisplayableAction.getId(), jsonActions.get(0));
}
Aggregations