Skip to content

Commit afc695f

Browse files
Fix
1 parent 433e80f commit afc695f

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

java/src/main/java/de/gdata/vaas/authentication/TokenReceiver.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22

33
import com.google.gson.JsonObject;
44
import com.google.gson.JsonParser;
5-
6-
import de.gdata.vaas.CompletableFutureExceptionHandler;
75
import de.gdata.vaas.exceptions.VaasAuthenticationException;
86
import lombok.NonNull;
97
import org.jetbrains.annotations.NotNull;
108

11-
import java.io.IOException;
129
import java.net.URI;
13-
import java.net.URISyntaxException;
1410
import java.net.http.HttpClient;
1511
import java.net.http.HttpRequest;
1612
import java.net.http.HttpResponse;
@@ -39,8 +35,8 @@ public TokenReceiver(@NotNull URI tokenUrl) {
3935
this(tokenUrl, HttpClient.newHttpClient());
4036
}
4137

42-
public TokenReceiver() throws URISyntaxException {
43-
this(new URI("https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"),
38+
public TokenReceiver() {
39+
this(URI.create("https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"),
4440
HttpClient.newHttpClient());
4541
}
4642

java/src/test/java/de/gdata/test/integration/RealApiIntegrationTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ public void forSha256_IfBadRequest_ThrowsVaasClientException() throws Exception
238238
when(mockResponse.statusCode()).thenReturn(400);
239239
when(mockHttpClient.sendAsync(any(HttpRequest.class), any(HttpResponse.BodyHandler.class)))
240240
.thenAnswer(invocation -> CompletableFuture.completedFuture(mockResponse));
241+
when(mockResponse.body()).thenReturn(
242+
new Gson().toJson(new ProblemDetails("VaasClientException", "Bad Request")));
241243

242244
vaas = getVaasWithCredentials(mockHttpClient);
243245

@@ -271,10 +273,10 @@ public void forSha256_IfUnauthorized_ThrowsVaasAuthenticationException() throws
271273
when(mockHttpClient.sendAsync(any(HttpRequest.class), any(HttpResponse.BodyHandler.class)))
272274
.thenAnswer(invocation -> CompletableFuture.completedFuture(mockResponse));
273275

274-
vaas = getVaasWithCredentials(mockHttpClient);
276+
var authenticator = getAuthenticator(mockHttpClient);
277+
vaas = getVaasWithCredentials(authenticator);
275278

276-
var exception = assertThrows(CompletionException.class, () -> vaas.forSha256Async(sha256).join());
277-
assertInstanceOf(VaasAuthenticationException.class, exception.getCause());
279+
assertThrows(VaasAuthenticationException.class, () -> vaas.forSha256Async(sha256).join());
278280
}
279281

280282
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)