@Test public void testFindByUrl() { Widget expected = new Widget(); expected.setName("Widget1"); expected.setUrl("/url/widget1"); expected.setDescription("This is widget 1"); Widget sample = new Widget(); sample.setUrl("/url/widget1"); when(widgetDao.findByExample(sample, true)).thenReturn(Arrays.asList(expected)); Widget actual = widgetService.findByUrl("/url/widget1"); verify(widgetDao).findByExample(sample, true); assertEquals(expected, actual); Mockito.reset(widgetDao); when(widgetDao.findByExample(sample, true)).thenReturn(null); actual = widgetService.findByUrl("/url/widget1"); verify(widgetDao).findByExample(sample, true); assertNull(actual); }
@Override public Widget findByUrl(String url) { Widget example = new Widget(); example.setUrl(url); List<Widget> dashboardList = getDao().findByExample(example, true); if (dashboardList != null && dashboardList.size() > 0) { return dashboardList.get(0); } return null; }
WidgetServiceImpl extends BaseCrudServiceImpl<Widget> implements
		WidgetService { @Override public Widget findByUrl(String url) { Widget example = new Widget(); example.setUrl(url); List<Widget> dashboardList = getDao().findByExample(example, true); if (dashboardList != null && dashboardList.size() > 0) { return dashboardList.get(0); } return null; } }
WidgetServiceImpl extends BaseCrudServiceImpl<Widget> implements
		WidgetService { @Override public Widget findByUrl(String url) { Widget example = new Widget(); example.setUrl(url); List<Widget> dashboardList = getDao().findByExample(example, true); if (dashboardList != null && dashboardList.size() > 0) { return dashboardList.get(0); } return null; }  }
WidgetServiceImpl extends BaseCrudServiceImpl<Widget> implements
		WidgetService { @Override public Widget findByUrl(String url) { Widget example = new Widget(); example.setUrl(url); List<Widget> dashboardList = getDao().findByExample(example, true); if (dashboardList != null && dashboardList.size() > 0) { return dashboardList.get(0); } return null; }  @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 Widget findByUrl(String url) { Widget example = new Widget(); example.setUrl(url); List<Widget> dashboardList = getDao().findByExample(example, true); if (dashboardList != null && dashboardList.size() > 0) { return dashboardList.get(0); } return null; }  @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);  }