Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit 8804180

Browse files
author
Peter Nied
committed
Fix broken testErrorResponse unit test
1 parent 68fc6d7 commit 8804180

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

onedrivesdk/src/androidTest/java/com/onedrive/sdk/http/DefaultHttpProviderTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,9 @@ public String getJsonResponse() {
306306

307307
@Override
308308
public Map<String, String> getHeaders() {
309-
return new HashMap<>();
309+
final HashMap<String, String> headers = new HashMap<>();
310+
headers.put("Content-Type", "application/json");
311+
return headers;
310312
}
311313
};
312314
mProvider.setConnectionFactory(new MockSingleConnectionFactory(new TestDataConnection(data)));

onedrivesdk/src/main/java/com/onedrive/sdk/http/OneDriveServiceException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ public static <T> OneDriveServiceException createFromConnection(final IHttpReque
300300
OneDriveErrorResponse error = null;
301301
Exception parsingException = null;
302302

303-
if (headers.get(DefaultHttpProvider.ContentTypeHeaderName).contains(DefaultHttpProvider.JsonContentType)) {
303+
final String contentType = headers.get(DefaultHttpProvider.ContentTypeHeaderName);
304+
if (contentType != null && contentType.contains(DefaultHttpProvider.JsonContentType)) {
304305
try {
305306
error = serializer.deserializeObject(rawOutput, OneDriveErrorResponse.class);
306307
} catch (final Exception ex) {

0 commit comments

Comments
 (0)