Skip to content

Commit 4ea96a5

Browse files
authored
Merge pull request #134 from avaje/feature/update-client-generation
#133 - [http-client] Disable more client tests that hit github api
2 parents bce6bb3 + df083a9 commit 4ea96a5

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

http-client/src/main/java/io/avaje/http/client/DHttpApi.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void init() {
3131
log.log(DEBUG, "providers for {0}", providerMap.keySet());
3232
}
3333

34-
void addProvider(HttpApiProvider apiProvider) {
34+
void addProvider(HttpApiProvider<?> apiProvider) {
3535
providerMap.put(apiProvider.type(), apiProvider);
3636
}
3737

@@ -41,7 +41,7 @@ private <T> HttpApiProvider<T> lookup(Class<T> type) {
4141
}
4242

4343
@SuppressWarnings("unchecked")
44-
<T> T provideFor(Class<T> type, HttpClientContext clientContext) {
44+
<T> T provideFor(Class<T> type, HttpClient clientContext) {
4545
final HttpApiProvider<T> apiProvider = lookup(type);
4646
if (apiProvider == null) {
4747
throw new IllegalArgumentException("No registered HttpApiProvider for type: " + type);
@@ -52,7 +52,7 @@ <T> T provideFor(Class<T> type, HttpClientContext clientContext) {
5252
/**
5353
* Return the client implementation via service loading.
5454
*/
55-
static <T> T provide(Class<T> type, HttpClientContext clientContext) {
55+
static <T> T provide(Class<T> type, HttpClient clientContext) {
5656
return INSTANCE.provideFor(type, clientContext);
5757
}
5858

http-client/src/test/java/io/avaje/http/client/DHttpApiTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import static org.assertj.core.api.Assertions.assertThat;
1414

15-
public class DHttpApiTest {
15+
class DHttpApiTest {
1616

1717
@Disabled
1818
@Test
@@ -31,22 +31,22 @@ void test_github_listRepos() {
3131
assertThat(repos).isNotEmpty();
3232
}
3333

34+
@Disabled
3435
@Test
3536
void jsonb_github_listRepos() {
3637

37-
Jsonb jsonb = Jsonb.newBuilder()
38+
Jsonb jsonb = Jsonb.builder()
3839
.add(Repo.class, RepoJsonAdapter::new)
39-
//.adapter(new JacksonAdapter())
4040
.build();
4141

42-
final HttpClientContext clientContext = HttpClientContext.builder()
42+
final HttpClient client = HttpClient.builder()
4343
.baseUrl("https://api.github.com")
4444
.bodyAdapter(new JsonbBodyAdapter(jsonb))
4545
.build();
4646

4747
DHttpApi httpApi = new DHttpApi();
4848
httpApi.addProvider(new Simple$HttpClient.Provider());
49-
final Simple simple = httpApi.provideFor(Simple.class, clientContext);
49+
final Simple simple = httpApi.provideFor(Simple.class, client);
5050

5151
final List<Repo> repos = simple.listRepos("rbygrave", "junk");
5252
assertThat(repos).isNotEmpty();

tests/test-client-generation/src/test/java/org/example/GitHubServiceTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import java.io.IOException;
1313
import java.util.List;
1414

15-
public class GitHubServiceTest {
15+
class GitHubServiceTest {
1616

1717
@Disabled
1818
@Test
@@ -37,9 +37,6 @@ public void onFailure(Call<List<Repo>> call, Throwable throwable) {
3737
System.out.println("onFailure: " + throwable);
3838
}
3939
});
40-
// final Response<List<Repo>> res = call.execute();
41-
// final List<Repo> body = res.body();
42-
// System.out.println("done count: "+body.size());
4340

4441
final Call<String> call2 = service.list2("octocat");
4542
final Response<String> res2 = call2.execute();

tests/test-client-generation/src/test/java/org/example/SimpleTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.fasterxml.jackson.databind.ObjectMapper;
55
import io.avaje.http.client.HttpApiProvider;
66
import io.avaje.http.client.HttpClient;
7-
import io.avaje.http.client.HttpClientContext;
87
import io.avaje.http.client.JacksonBodyAdapter;
98
import org.example.httpclient.GitHubUsersHttpClient;
109
import org.junit.jupiter.api.Disabled;
@@ -14,22 +13,21 @@
1413

1514
import static org.assertj.core.api.Assertions.assertThat;
1615

17-
public class SimpleTest {
16+
class SimpleTest {
1817

1918
@Disabled
2019
@Test
2120
void listRepos() {
22-
2321
final ObjectMapper objectMapper = new ObjectMapper()
2422
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
2523

26-
final HttpClientContext clientContext =
27-
HttpClientContext.builder()
24+
final HttpClient client =
25+
HttpClient.builder()
2826
.baseUrl("https://api.github.com")
2927
.bodyAdapter(new JacksonBodyAdapter(objectMapper))
3028
.build();
3129

32-
GitHubUsers simple = clientContext.create(GitHubUsers.class);
30+
GitHubUsers simple = client.create(GitHubUsers.class);
3331

3432
final List<Repo> repos = simple.listRepos("rbygrave");
3533
System.out.println("got repos - " + repos.size());

tests/test-client/src/test/java/example/github/GithubTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,39 @@
22

33
import com.google.gson.Gson;
44
import io.avaje.http.client.BodyAdapter;
5-
import io.avaje.http.client.HttpClientContext;
5+
import io.avaje.http.client.HttpClient;
66
import io.avaje.http.client.JacksonBodyAdapter;
77
import io.avaje.http.client.gson.GsonBodyAdapter;
8+
import org.junit.jupiter.api.Disabled;
89
import org.junit.jupiter.api.Test;
910

1011
import java.util.List;
1112

1213
import static org.assertj.core.api.Assertions.assertThat;
1314

14-
public class GithubTest {
15+
class GithubTest {
1516

17+
@Disabled
1618
@Test
1719
void test_with_jackson() {
1820
assertListRepos(jacksonBodyAdapter());
1921
}
2022

23+
@Disabled
2124
@Test
2225
void test_with_gson() {
2326
assertListRepos(gsonBodyAdapter());
2427
}
2528

2629
private void assertListRepos(BodyAdapter bodyAdapter) {
27-
final HttpClientContext clientContext = HttpClientContext.builder()
30+
final HttpClient client = HttpClient.builder()
2831
.baseUrl("https://api.github.com")
2932
.bodyAdapter(bodyAdapter)
3033
// .requestLogging(false)
3134
// .requestListener(new RequestLogger())
3235
.build();
3336

34-
final Simple simple = clientContext.create(Simple.class);
37+
final Simple simple = client.create(Simple.class);
3538

3639
final List<Repo> repos = simple.listRepos("rbygrave", "junk");
3740
assertThat(repos).isNotEmpty();

0 commit comments

Comments
 (0)