### Question:
DefaultDashboardsApi extends ApiBase implements DashboardsApi { @Override public List<Dashboard> getByTitle(String dashboardTitle) { String dashboardTitleEncoded = UriComponent.encode(dashboardTitle, QUERY_PARAM_SPACE_ENCODED); Invocation.Builder builder = client .target(DASHBOARDS_URL) .queryParam("filter[title]", dashboardTitleEncoded) .request(APPLICATION_JSON_TYPE); return getPageable(builder, DashboardList.class) .getList(); } DefaultDashboardsApi(NewRelicClient client); @Override Dashboard getById(int dashboardId); @Override List<Dashboard> getByTitle(String dashboardTitle); @Override Dashboard create(Dashboard dashboard); @Override Dashboard update(Dashboard dashboard); @Override Dashboard delete(int dashboardId);  }### Answer:
@Test public void getByTitle_shouldReturnDashboards_whenClientReturnsNotUniqueResult() { when(responseMock.readEntity(DashboardList.class)).thenReturn(new DashboardList(asList( Dashboard.builder().title(DASHBOARD_FILTER_VALUE).build(), Dashboard.builder().title("dashboard1").build() ))); List<Dashboard> dashboard = testee.getByTitle(DASHBOARD_FILTER_VALUE); assertThat(dashboard).isNotEmpty(); assertThat(dashboard).hasSize(2); }
@Test public void getByTitle_shouldReturnDashboard_whenClientReturnsResultContainingQueriedTitle() { when(responseMock.readEntity(DashboardList.class)).thenReturn(new DashboardList(Collections.singletonList( Dashboard.builder().title("dashboard1").build() ))); List<Dashboard> dashboard = testee.getByTitle(DASHBOARD_FILTER_VALUE); assertThat(dashboard).isNotEmpty(); }
@Test public void getByTitle_shouldNotReturnDashboard_whenClientReturnsEmptyList() { when(responseMock.readEntity(DashboardList.class)).thenReturn(new DashboardList(Collections.emptyList())); List<Dashboard> dashboard = testee.getByTitle(DASHBOARD_FILTER_VALUE); assertThat(dashboard).isEmpty(); }