Skip to content

Commit 9e5890f

Browse files
committed
Suppress FB Warnings on Tests, Make some Exceptions Explicit
1 parent 7af78fa commit 9e5890f

28 files changed

+71
-24
lines changed

src/main/java/com/microsoft/graph/http/IStatefulResponseHandler.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@
2525

2626
import com.microsoft.graph.logger.ILogger;
2727
import com.microsoft.graph.serializer.ISerializer;
28+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2829

2930
import javax.annotation.Nullable;
3031
import javax.annotation.Nonnull;
32+
import java.io.IOException;
3133

3234
/**
3335
* The handler interface for requests having stateful response from server.
@@ -47,11 +49,13 @@ public interface IStatefulResponseHandler<ResultType, DeserializedType> {
4749
* @param logger the logger
4850
* @param <ResponseType> the native http client response type
4951
* @return the result generated by this handler
50-
* @throws Exception an exception occurs if the request was unable to complete for any reason
52+
* @throws IOException an exception occurs if the request was unable to complete for any reason
53+
* @throws GraphServiceException an exception is there is an interruption related to the GraphService
5154
*/
5255
@Nullable
56+
@SuppressFBWarnings
5357
<ResponseType> ResultType generateResult(@Nonnull final IHttpRequest request,
5458
@Nonnull final ResponseType response,
5559
@Nonnull final ISerializer serializer,
56-
@Nonnull final ILogger logger) throws Exception;
60+
@Nonnull final ILogger logger) throws IOException, GraphServiceException;
5761
}

src/main/java/com/microsoft/graph/tasks/LargeFileUploadResponseHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public <ResponseType> LargeFileUploadResponse<UploadType> generateResult(
7676
@Nonnull final IHttpRequest request,
7777
@Nonnull final ResponseType response,
7878
@Nonnull final ISerializer serializer,
79-
@Nonnull final ILogger logger) throws Exception {
79+
@Nonnull final ILogger logger) throws IOException, GraphServiceException {
8080
Objects.requireNonNull(request, "parameter request cannot be null");
8181
Objects.requireNonNull(response, "parameter response cannot be null");
8282
Objects.requireNonNull(serializer, "parameter serializer cannot be null");

src/main/java/com/microsoft/graph/tasks/LargeFileUploadTask.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
import com.microsoft.graph.core.ClientException;
2626
import com.microsoft.graph.core.IBaseClient;
27+
import com.microsoft.graph.http.GraphFatalServiceException;
28+
import com.microsoft.graph.http.GraphServiceException;
2729
import com.microsoft.graph.options.Option;
2830

2931
import java.io.IOException;
@@ -98,12 +100,13 @@ public class LargeFileUploadTask<UploadType> {
98100
* @param inputStream the input stream
99101
* @param streamSize the stream size
100102
* @param uploadTypeClass the upload type class
103+
* @throws GraphServiceException if there is an interruption in the service
101104
*/
102105
public LargeFileUploadTask(@Nonnull final IUploadSession uploadSession,
103106
@Nonnull final IBaseClient<?> client,
104107
@Nonnull final InputStream inputStream,
105108
final long streamSize,
106-
@Nonnull final Class<UploadType> uploadTypeClass) {
109+
@Nonnull final Class<UploadType> uploadTypeClass) throws GraphServiceException {
107110
Objects.requireNonNull(uploadSession, "Upload session is null.");
108111

109112
if (streamSize <= 0) {

src/test/java/com/microsoft/graph/authentication/TokenCredentialAuthProviderTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.azure.core.credential.TokenCredential;
44
import com.microsoft.graph.mocks.MockTokenCredential;
55

6+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
67
import org.junit.jupiter.api.Test;
78

89
import static org.junit.jupiter.api.Assertions.*;
@@ -13,6 +14,7 @@
1314
import java.util.ArrayList;
1415
import java.util.concurrent.ExecutionException;
1516

17+
@SuppressFBWarnings
1618
public class TokenCredentialAuthProviderTest {
1719

1820
private static final String testToken = "CredentialTestToken";

src/test/java/com/microsoft/graph/content/BatchRequestContentTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.microsoft.graph.serializer.IJsonBackedObject;
3030
import com.microsoft.graph.serializer.ISerializer;
3131

32+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
3233
import org.junit.jupiter.api.Test;
3334
import org.junit.jupiter.params.ParameterizedTest;
3435
import org.junit.jupiter.params.provider.ValueSource;
@@ -41,6 +42,7 @@
4142
import okhttp3.Response;
4243
import okhttp3.ResponseBody;
4344

45+
@SuppressFBWarnings
4446
class BatchRequestContentTest {
4547

4648
String testurl = "http://graph.microsoft.com/v1.0/me";

src/test/java/com/microsoft/graph/content/BatchResponseContentTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
import com.microsoft.graph.serializer.DefaultSerializer;
2121
import com.microsoft.graph.serializer.ISerializer;
2222

23+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2324
import org.junit.jupiter.api.Test;
2425

26+
@SuppressFBWarnings
2527
public class BatchResponseContentTest {
2628
@Test
2729
public void testValidBatchResponseContent() {

src/test/java/com/microsoft/graph/core/BaseClientTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class BaseClientTests {
3838
private ISerializer mSerializer;
3939

4040
@BeforeEach
41-
public void setUp() throws Exception {
41+
public void setUp() {
4242
baseClient = new BaseClient<>();
4343
mLogger = mock(ILogger.class);
4444
mSerializer = mock(ISerializer.class);

src/test/java/com/microsoft/graph/core/ClientExceptionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class ClientExceptionTests {
1212
private String expectMessage = "This is test exception message";
1313

1414
@BeforeEach
15-
public void setUp() throws Exception {
15+
public void setUp() {
1616
clientException = new ClientException(expectMessage, null);
1717
}
1818

src/test/java/com/microsoft/graph/core/GraphServiceClientTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.Map;
1313
import java.util.concurrent.CompletableFuture;
1414

15+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
1516
import org.junit.jupiter.api.Test;
1617

1718
import okhttp3.Request;
@@ -28,6 +29,7 @@
2829

2930
import javax.annotation.Nullable;
3031

32+
@SuppressFBWarnings
3133
public class GraphServiceClientTest {
3234
private IAuthenticationProvider getAuthProvider() {
3335
return mock(IAuthenticationProvider.class);

src/test/java/com/microsoft/graph/http/BaseCollectionPageTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class BaseCollectionPageTests {
2626

2727
@BeforeEach
2828
@SuppressWarnings("unchecked")
29-
public void setUp() throws Exception {
29+
public void setUp() {
3030
list = new ArrayList<String>();
3131
list.add("Object1");
3232
list.add("Object2");

0 commit comments

Comments
 (0)