Merge pull request #8125 from eugenp/revert-8119-BAEL-3275-2

Revert "BAEL-3275: Using blocking queue for pub-sub"
This commit is contained in:
Eric Martin
2019-10-31 20:43:47 -05:00
committed by GitHub
parent db85c8f275
commit 3225470df5
20543 changed files with 1642750 additions and 0 deletions
@@ -0,0 +1,52 @@
package com.baeldung.retrofit.basic;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import com.baeldung.retrofit.basic.GitHubBasicApi;
import com.baeldung.retrofit.models.Contributor;
import com.baeldung.retrofit.models.Repository;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class GitHubBasicApiLiveTest {
GitHubBasicApi gitHub;
@Before
public void init() {
Retrofit retrofit = new Retrofit.Builder().baseUrl("https://api.github.com/").addConverterFactory(GsonConverterFactory.create()).build();
gitHub = retrofit.create(GitHubBasicApi.class);
}
@Test
public void whenListRepos_thenExpectReposThatContainTutorials() {
try {
List<Repository> repos = gitHub.listRepos("eugenp").execute().body();
assertThat(repos).isNotEmpty().extracting(Repository::getName).contains("tutorials");
} catch (IOException e) {
fail("Can not communicate with GitHub API");
}
}
@Test
public void whenListRepoContributers_thenExpectContributorsThatContainEugenp() {
try {
List<Contributor> contributors = gitHub.listRepoContributors("eugenp", "tutorials").execute().body();
assertThat(contributors).isNotEmpty().extracting(Contributor::getName).contains("eugenp");
} catch (IOException e) {
fail("Can not communicate with GitHub API");
}
}
}
@@ -0,0 +1,41 @@
package com.baeldung.retrofit.rx;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Before;
import org.junit.Test;
import com.baeldung.retrofit.models.Contributor;
import com.baeldung.retrofit.models.Repository;
import com.baeldung.retrofit.rx.GitHubRxApi;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
public class GitHubRxLiveTest {
GitHubRxApi gitHub;
@Before
public void init() {
Retrofit retrofit = new Retrofit.Builder().baseUrl("https://api.github.com/").addConverterFactory(GsonConverterFactory.create()).addCallAdapterFactory(RxJavaCallAdapterFactory.create()).build();
gitHub = retrofit.create(GitHubRxApi.class);
}
@Test
public void whenListRepos_thenExpectReposThatContainTutorials() {
gitHub.listRepos("eugenp").subscribe(repos -> {
assertThat(repos).isNotEmpty().extracting(Repository::getName).contains("tutorials");
});
}
@Test
public void whenListRepoContributers_thenExpectContributorsThatContainEugenp() {
gitHub.listRepoContributors("eugenp", "tutorials").subscribe(contributors -> {
assertThat(contributors).isNotEmpty().extracting(Contributor::getName).contains("eugenp");
});
}
}