@Test public void getByName_shouldNotReturnApplication_whenClientReturnsEmptyList() throws Exception { when(responseMock.readEntity(ApplicationList.class)).thenReturn(new ApplicationList(Collections.emptyList())); Optional<Application> applicationOptional = testee.getByName("app"); assertThat(applicationOptional).isEmpty(); }
@Override public Optional<Application> getByName(String applicationName) { Invocation.Builder builder = client .target(APPLICATIONS_URL) .queryParam("filter[name]", applicationName) .request(APPLICATION_JSON_TYPE); return getPageable(builder, ApplicationList.class) .filter(application -> application.getName().equals(applicationName)) .getSingle(); }
DefaultApplicationsApi extends ApiBase implements ApplicationsApi { @Override public Optional<Application> getByName(String applicationName) { Invocation.Builder builder = client .target(APPLICATIONS_URL) .queryParam("filter[name]", applicationName) .request(APPLICATION_JSON_TYPE); return getPageable(builder, ApplicationList.class) .filter(application -> application.getName().equals(applicationName)) .getSingle(); } }
DefaultApplicationsApi extends ApiBase implements ApplicationsApi { @Override public Optional<Application> getByName(String applicationName) { Invocation.Builder builder = client .target(APPLICATIONS_URL) .queryParam("filter[name]", applicationName) .request(APPLICATION_JSON_TYPE); return getPageable(builder, ApplicationList.class) .filter(application -> application.getName().equals(applicationName)) .getSingle(); } DefaultApplicationsApi(NewRelicClient client); }
DefaultApplicationsApi extends ApiBase implements ApplicationsApi { @Override public Optional<Application> getByName(String applicationName) { Invocation.Builder builder = client .target(APPLICATIONS_URL) .queryParam("filter[name]", applicationName) .request(APPLICATION_JSON_TYPE); return getPageable(builder, ApplicationList.class) .filter(application -> application.getName().equals(applicationName)) .getSingle(); } DefaultApplicationsApi(NewRelicClient client); @Override Optional<Application> getByName(String applicationName); @Override Application update(int applicationId, Application application); }
DefaultApplicationsApi extends ApiBase implements ApplicationsApi { @Override public Optional<Application> getByName(String applicationName) { Invocation.Builder builder = client .target(APPLICATIONS_URL) .queryParam("filter[name]", applicationName) .request(APPLICATION_JSON_TYPE); return getPageable(builder, ApplicationList.class) .filter(application -> application.getName().equals(applicationName)) .getSingle(); } DefaultApplicationsApi(NewRelicClient client); @Override Optional<Application> getByName(String applicationName); @Override Application update(int applicationId, Application application);  }