@Test public void testGetCurrentUserWidgets() { Widget widget1 = new Widget(); widget1.setName("Widget 1"); widget1.setDescription("Description 1"); widget1.setUrl("/url/widget1"); widget1.setAccessCode("ACCESS_WIDGET_1"); widget1.setIsUserDefined(true); Widget widget2 = new Widget(); widget2.setName("Widget 2"); widget2.setDescription("Description 2"); widget2.setUrl("/url/widget2"); widget2.setAccessCode("ACCESS_WIDGET_2"); widget2.setIsUserDefined(true); Widget widget3 = new Widget(); widget3.setName("Widget 3"); widget3.setDescription("Description 3"); widget3.setUrl("/url/widget3"); widget3.setAccessCode("ACCESS_WIDGET_3"); widget3.setIsUserDefined(true); Widget widget4 = new Widget(); widget4.setName("Widget 4"); widget4.setDescription("Description 4"); widget4.setUrl("/url/widget4"); widget4.setAccessCode(""); widget4.setIsUserDefined(true); List<Widget> widgets = Arrays.asList(widget1, widget2, widget3, widget4); Widget sample = new Widget(); sample.setIsUserDefined(true); List<Widget> expected = Arrays.asList(widget1, widget2, widget4); when(widgetDao.findByExample(sample, true)).thenReturn(widgets); List<Widget> actual = widgetService.getCurrentUserWidgets(); assertEquals(expected, actual); }
@Override public List<Widget> getCurrentUserWidgets() { Widget example = new Widget(); example.setIsUserDefined(true); List<Widget> widgets = new ArrayList<Widget>(); for (Widget widget:findByExample(example, true)) { if (StringUtil.isEmpty(widget.getAccessCode())) { widgets.add(widget); } else if (SecurityUtil.currentUserHasPermission(widget.getAccessCode())) { widgets.add(widget); } } return widgets; }
WidgetServiceImpl extends BaseCrudServiceImpl<Widget> implements
		WidgetService { @Override public List<Widget> getCurrentUserWidgets() { Widget example = new Widget(); example.setIsUserDefined(true); List<Widget> widgets = new ArrayList<Widget>(); for (Widget widget:findByExample(example, true)) { if (StringUtil.isEmpty(widget.getAccessCode())) { widgets.add(widget); } else if (SecurityUtil.currentUserHasPermission(widget.getAccessCode())) { widgets.add(widget); } } return widgets; } }
WidgetServiceImpl extends BaseCrudServiceImpl<Widget> implements
		WidgetService { @Override public List<Widget> getCurrentUserWidgets() { Widget example = new Widget(); example.setIsUserDefined(true); List<Widget> widgets = new ArrayList<Widget>(); for (Widget widget:findByExample(example, true)) { if (StringUtil.isEmpty(widget.getAccessCode())) { widgets.add(widget); } else if (SecurityUtil.currentUserHasPermission(widget.getAccessCode())) { widgets.add(widget); } } return widgets; }  }
WidgetServiceImpl extends BaseCrudServiceImpl<Widget> implements
		WidgetService { @Override public List<Widget> getCurrentUserWidgets() { Widget example = new Widget(); example.setIsUserDefined(true); List<Widget> widgets = new ArrayList<Widget>(); for (Widget widget:findByExample(example, true)) { if (StringUtil.isEmpty(widget.getAccessCode())) { widgets.add(widget); } else if (SecurityUtil.currentUserHasPermission(widget.getAccessCode())) { widgets.add(widget); } } return widgets; }  @Override Widget findByName(String name); @Override Widget findByUrl(String url); @Override List<Widget> getCurrentUserWidgets(); @Override Widget requestWidget(String widgetUrl, String name,
			HttpServletRequest req); @Override int getColumnConfig(); @Override List<Widget> findDefaultWidget(BaseUser user); @Override List<Widget> findWidgetWithAccessCode(List<String> accessCodes); void setIPAddress(String iPAddress); String getWidgetColumn(); void setWidgetColumn(String widgetColumn); }
WidgetServiceImpl extends BaseCrudServiceImpl<Widget> implements
		WidgetService { @Override public List<Widget> getCurrentUserWidgets() { Widget example = new Widget(); example.setIsUserDefined(true); List<Widget> widgets = new ArrayList<Widget>(); for (Widget widget:findByExample(example, true)) { if (StringUtil.isEmpty(widget.getAccessCode())) { widgets.add(widget); } else if (SecurityUtil.currentUserHasPermission(widget.getAccessCode())) { widgets.add(widget); } } return widgets; }  @Override Widget findByName(String name); @Override Widget findByUrl(String url); @Override List<Widget> getCurrentUserWidgets(); @Override Widget requestWidget(String widgetUrl, String name,
			HttpServletRequest req); @Override int getColumnConfig(); @Override List<Widget> findDefaultWidget(BaseUser user); @Override List<Widget> findWidgetWithAccessCode(List<String> accessCodes); void setIPAddress(String iPAddress); String getWidgetColumn(); void setWidgetColumn(String widgetColumn);  }