@Ignore @Test public void testGetSearchUserGridWidgetDefinitionWithoutAuthentication() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException, IOException { AbstractLicensableWidget searchUserGridWidget = uIService.getWidgetDefinition(SearchUserGridWidgetName); SecurityContext securityContext = SecurityContextHolder.getContext(); securityContext.setAuthentication(null); Assert.notNull(searchUserGridWidget); Assert.notNull(searchUserGridWidget.getDataURL()); Assert.isTrue( searchUserGridWidget.getActionConfig().getActionConfig().size() == 2, "Search user grid widget action config does not have expected # of permissions values"); Assert.isTrue( searchUserGridWidget .getActionConfig() .getActionConfig() .get("widget-actions") .get(new Permission("delete-user")) == Boolean.FALSE, "Search user grid widget action config does not have delete-user permission false"); Assert.isTrue( searchUserGridWidget .getActionConfig() .getActionConfig() .get("widget-actions") .get(new Permission("disable-user")) == Boolean.FALSE, "Search user grid widget action config does not have disable-user permission false"); }
@Test public void testGetPicklineByWaveBarChartWidgetDefinition() throws JsonProcessingException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException { AbstractLicensableWidget picklineByWaveBarChartWidget = uIService.getWidgetDefinition(PicklineByWaveBarChartWidgetName); Assert.notNull(picklineByWaveBarChartWidget); }
@Test @Transactional(readOnly = true) public void testGetEventGridWidgetDefinitionWithAuthentication() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException, IOException { SecurityContext securityContext = SecurityContextHolder.getContext(); securityContext.setAuthentication(auth); AbstractLicensableWidget eventGridWidget = uIService.getWidgetDefinition(EventGridWidgetName); Assert.notNull(eventGridWidget); Assert.isTrue( eventGridWidget.getActionConfig().getActionConfig().size() == 2, "Event grid widget action config does not have expected # of permissions values"); Assert.isTrue( eventGridWidget .getActionConfig() .getActionConfig() .get("widget-actions") .get(new Permission("create-event")) == Boolean.TRUE, "Event grid widget action config does not have create-event permission true"); Assert.isTrue( eventGridWidget .getActionConfig() .getActionConfig() .get("widget-actions") .get(new Permission("edit-event")) == Boolean.TRUE, "Event grid widget action config does not have edit-event permission true"); // Assertions for AutoRefreshConfig JSONObject defaultViewConfigJSON = new JSONObject(eventGridWidget.getDefaultViewConfig()); Assert.isTrue( defaultViewConfigJSON.has("autoRefreshConfig"), "Could not find property 'AutoRefreshConfig'"); JSONObject autoRefreshConfigJSON = new JSONObject(defaultViewConfigJSON.get("autoRefreshConfig").toString()); Assert.isTrue( autoRefreshConfigJSON.has("globalOverride"), "Could not find property 'globalOverride'"); Assert.isTrue(autoRefreshConfigJSON.has("enabled"), "Could not find property 'enabled'"); Assert.isTrue(autoRefreshConfigJSON.has("interval"), "Could not find property 'interval'"); Assert.isTrue( autoRefreshConfigJSON.getBoolean("globalOverride") == false, "Incorrect value for property 'globalOverride'"); Assert.isTrue( autoRefreshConfigJSON.getBoolean("enabled") == true, "Incorrect value for property 'enabled'"); Assert.isTrue( autoRefreshConfigJSON.getInt("interval") == 120, "Incorrect value for property 'interval'"); }
@Transactional(readOnly = true) @Test public void testGetUserCreationFormWidgetDefinition() throws JsonProcessingException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException { String listenForListString = "\"listensForList\": [ \"userName\"]"; AbstractLicensableWidget userCreationFormWidget = uIService.getWidgetDefinition(UserCreationFormWidgetName); Assert.notNull(userCreationFormWidget); Assert.notNull(userCreationFormWidget.getReactToList()); Assert.notNull(userCreationFormWidget.getBroadcastList()); String defaultViewConfig = userCreationFormWidget.getDefaultViewConfig(); Assert.isTrue( defaultViewConfig.contains(listenForListString), "Default view config does not have the expected listen for list"); }
@Test @Transactional(readOnly = true) public void testGetSearchUserGridWidgetDefinitionWithAuthentication() throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException, IOException { String listenForListString = "\"listensForList\":[\"userName\"]"; SecurityContext securityContext = SecurityContextHolder.getContext(); securityContext.setAuthentication(auth); AbstractLicensableWidget searchUserGridWidget = uIService.getWidgetDefinition(SearchUserGridWidgetName); Assert.notNull(searchUserGridWidget); Assert.isTrue( searchUserGridWidget.getActionConfig().getActionConfig().size() == 2, "Search user grid widget action config does not have expected # of permissions values"); Assert.isTrue( searchUserGridWidget .getActionConfig() .getActionConfig() .get("widget-actions") .get(new Permission("delete-user")) == Boolean.TRUE, "Search user grid widget action config does not have delete-user permission true"); Assert.isTrue( searchUserGridWidget .getActionConfig() .getActionConfig() .get("widget-actions") .get(new Permission("disable-user")) == Boolean.TRUE, "Search user grid widget action config does not have disable-user permission true"); Assert.notNull( searchUserGridWidget.getReactToList(), "Search user grid widget definition does not have react to map"); Assert.notNull( searchUserGridWidget.getBroadcastList(), "Search user grid widget definition does not have the broadcast list"); Assert.isTrue( searchUserGridWidget.getBroadcastList().size() == 1, "Search user grid widget definition does not have the required broadcast list size"); String defaultViewConfig = searchUserGridWidget.getDefaultViewConfig(); Assert.isTrue( defaultViewConfig.contains(listenForListString), "Default view config does not have the expected listen for list"); // Assertions for AutoRefreshConfig JSONObject defaultViewConfigJSON = new JSONObject(searchUserGridWidget.getDefaultViewConfig()); Assert.isTrue( defaultViewConfigJSON.has("autoRefreshConfig"), "Could not find property 'AutoRefreshConfig'"); JSONObject autoRefreshConfigJSON = new JSONObject(defaultViewConfigJSON.get("autoRefreshConfig").toString()); Assert.isTrue( autoRefreshConfigJSON.has("globalOverride"), "Could not find property 'globalOverride'"); Assert.isTrue(autoRefreshConfigJSON.has("enabled"), "Could not find property 'enabled'"); Assert.isTrue(autoRefreshConfigJSON.has("interval"), "Could not find property 'interval'"); Assert.isTrue( autoRefreshConfigJSON.getBoolean("globalOverride") == false, "Incorrect value for property 'globalOverride'"); Assert.isTrue( autoRefreshConfigJSON.getBoolean("enabled") == true, "Incorrect value for property 'enabled'"); Assert.isTrue( autoRefreshConfigJSON.getInt("interval") == 120, "Incorrect value for property 'interval'"); }