From 7af78faa111f1bc1f56bc64691c13c10ee32efa8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 May 2022 08:04:07 +0000 Subject: [PATCH 1/3] Bump com.github.spotbugs from 5.0.6 to 5.0.7 Bumps com.github.spotbugs from 5.0.6 to 5.0.7. --- updated-dependencies: - dependency-name: com.github.spotbugs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 808a7db0f..dc2e30692 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ plugins { id 'maven-publish' id 'signing' id 'jacoco' - id 'com.github.spotbugs' version '5.0.6' + id 'com.github.spotbugs' version '5.0.7' id "org.sonarqube" version "3.3" } From 9e5890f424129d7a08412b7c835df13ddb269371 Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Thu, 26 May 2022 03:30:22 -0700 Subject: [PATCH 2/3] Suppress FB Warnings on Tests, Make some Exceptions Explicit --- .../graph/http/IStatefulResponseHandler.java | 8 ++++++-- .../tasks/LargeFileUploadResponseHandler.java | 2 +- .../microsoft/graph/tasks/LargeFileUploadTask.java | 5 ++++- .../TokenCredentialAuthProviderTest.java | 2 ++ .../graph/content/BatchRequestContentTest.java | 2 ++ .../graph/content/BatchResponseContentTest.java | 2 ++ .../com/microsoft/graph/core/BaseClientTests.java | 2 +- .../microsoft/graph/core/ClientExceptionTests.java | 2 +- .../graph/core/GraphServiceClientTest.java | 2 ++ .../graph/http/BaseCollectionPageTests.java | 2 +- .../graph/http/BaseCollectionRequestTests.java | 2 ++ .../graph/http/BaseRequestBuilderTests.java | 2 +- .../com/microsoft/graph/http/BaseRequestTests.java | 2 ++ .../graph/http/BaseStreamRequestTests.java | 4 +++- .../http/CoreHttpCallbackFutureWrapperTests.java | 2 ++ .../graph/http/CoreHttpProviderTests.java | 3 +++ .../graph/httpcore/AuthenticationHandlerTest.java | 2 ++ .../microsoft/graph/httpcore/RetryHandlerTest.java | 2 ++ .../middlewareoption/RedirectOptionsTest.java | 2 ++ .../middlewareoption/RetryOptionsTest.java | 5 ++++- .../com/microsoft/graph/options/OptionTests.java | 2 ++ .../graph/serializer/ByteArraySerializerTests.java | 4 +++- .../microsoft/graph/serializer/DateOnlyTests.java | 2 ++ .../microsoft/graph/serializer/DurationTests.java | 2 ++ .../serializer/EdmNativeTypeSerializerTests.java | 14 +++++++------- .../microsoft/graph/serializer/ISO8601Test.java | 5 +++-- .../serializer/OffsetDateTimeSerializerTests.java | 7 ++++--- .../microsoft/graph/serializer/TimeOfDayTests.java | 4 +++- 28 files changed, 71 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/microsoft/graph/http/IStatefulResponseHandler.java b/src/main/java/com/microsoft/graph/http/IStatefulResponseHandler.java index 893691a86..3d5bba8ed 100644 --- a/src/main/java/com/microsoft/graph/http/IStatefulResponseHandler.java +++ b/src/main/java/com/microsoft/graph/http/IStatefulResponseHandler.java @@ -25,9 +25,11 @@ import com.microsoft.graph.logger.ILogger; import com.microsoft.graph.serializer.ISerializer; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import javax.annotation.Nullable; import javax.annotation.Nonnull; +import java.io.IOException; /** * The handler interface for requests having stateful response from server. @@ -47,11 +49,13 @@ public interface IStatefulResponseHandler { * @param logger the logger * @param the native http client response type * @return the result generated by this handler - * @throws Exception an exception occurs if the request was unable to complete for any reason + * @throws IOException an exception occurs if the request was unable to complete for any reason + * @throws GraphServiceException an exception is there is an interruption related to the GraphService */ @Nullable + @SuppressFBWarnings ResultType generateResult(@Nonnull final IHttpRequest request, @Nonnull final ResponseType response, @Nonnull final ISerializer serializer, - @Nonnull final ILogger logger) throws Exception; + @Nonnull final ILogger logger) throws IOException, GraphServiceException; } diff --git a/src/main/java/com/microsoft/graph/tasks/LargeFileUploadResponseHandler.java b/src/main/java/com/microsoft/graph/tasks/LargeFileUploadResponseHandler.java index 9d28bbdb4..0a1c69213 100644 --- a/src/main/java/com/microsoft/graph/tasks/LargeFileUploadResponseHandler.java +++ b/src/main/java/com/microsoft/graph/tasks/LargeFileUploadResponseHandler.java @@ -76,7 +76,7 @@ public LargeFileUploadResponse generateResult( @Nonnull final IHttpRequest request, @Nonnull final ResponseType response, @Nonnull final ISerializer serializer, - @Nonnull final ILogger logger) throws Exception { + @Nonnull final ILogger logger) throws IOException, GraphServiceException { Objects.requireNonNull(request, "parameter request cannot be null"); Objects.requireNonNull(response, "parameter response cannot be null"); Objects.requireNonNull(serializer, "parameter serializer cannot be null"); diff --git a/src/main/java/com/microsoft/graph/tasks/LargeFileUploadTask.java b/src/main/java/com/microsoft/graph/tasks/LargeFileUploadTask.java index 78da111b2..72b8f3c1d 100644 --- a/src/main/java/com/microsoft/graph/tasks/LargeFileUploadTask.java +++ b/src/main/java/com/microsoft/graph/tasks/LargeFileUploadTask.java @@ -24,6 +24,8 @@ import com.microsoft.graph.core.ClientException; import com.microsoft.graph.core.IBaseClient; +import com.microsoft.graph.http.GraphFatalServiceException; +import com.microsoft.graph.http.GraphServiceException; import com.microsoft.graph.options.Option; import java.io.IOException; @@ -98,12 +100,13 @@ public class LargeFileUploadTask { * @param inputStream the input stream * @param streamSize the stream size * @param uploadTypeClass the upload type class + * @throws GraphServiceException if there is an interruption in the service */ public LargeFileUploadTask(@Nonnull final IUploadSession uploadSession, @Nonnull final IBaseClient client, @Nonnull final InputStream inputStream, final long streamSize, - @Nonnull final Class uploadTypeClass) { + @Nonnull final Class uploadTypeClass) throws GraphServiceException { Objects.requireNonNull(uploadSession, "Upload session is null."); if (streamSize <= 0) { diff --git a/src/test/java/com/microsoft/graph/authentication/TokenCredentialAuthProviderTest.java b/src/test/java/com/microsoft/graph/authentication/TokenCredentialAuthProviderTest.java index 6868eb01c..0c2a53f40 100644 --- a/src/test/java/com/microsoft/graph/authentication/TokenCredentialAuthProviderTest.java +++ b/src/test/java/com/microsoft/graph/authentication/TokenCredentialAuthProviderTest.java @@ -3,6 +3,7 @@ import com.azure.core.credential.TokenCredential; import com.microsoft.graph.mocks.MockTokenCredential; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; @@ -13,6 +14,7 @@ import java.util.ArrayList; import java.util.concurrent.ExecutionException; +@SuppressFBWarnings public class TokenCredentialAuthProviderTest { private static final String testToken = "CredentialTestToken"; diff --git a/src/test/java/com/microsoft/graph/content/BatchRequestContentTest.java b/src/test/java/com/microsoft/graph/content/BatchRequestContentTest.java index 827ebb862..e39e0426f 100644 --- a/src/test/java/com/microsoft/graph/content/BatchRequestContentTest.java +++ b/src/test/java/com/microsoft/graph/content/BatchRequestContentTest.java @@ -29,6 +29,7 @@ import com.microsoft.graph.serializer.IJsonBackedObject; import com.microsoft.graph.serializer.ISerializer; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -41,6 +42,7 @@ import okhttp3.Response; import okhttp3.ResponseBody; +@SuppressFBWarnings class BatchRequestContentTest { String testurl = "http://graph.microsoft.com/v1.0/me"; diff --git a/src/test/java/com/microsoft/graph/content/BatchResponseContentTest.java b/src/test/java/com/microsoft/graph/content/BatchResponseContentTest.java index a39b9255b..1384e1a07 100644 --- a/src/test/java/com/microsoft/graph/content/BatchResponseContentTest.java +++ b/src/test/java/com/microsoft/graph/content/BatchResponseContentTest.java @@ -20,8 +20,10 @@ import com.microsoft.graph.serializer.DefaultSerializer; import com.microsoft.graph.serializer.ISerializer; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.Test; +@SuppressFBWarnings public class BatchResponseContentTest { @Test public void testValidBatchResponseContent() { diff --git a/src/test/java/com/microsoft/graph/core/BaseClientTests.java b/src/test/java/com/microsoft/graph/core/BaseClientTests.java index 3d853e493..924b6eb6d 100644 --- a/src/test/java/com/microsoft/graph/core/BaseClientTests.java +++ b/src/test/java/com/microsoft/graph/core/BaseClientTests.java @@ -38,7 +38,7 @@ public class BaseClientTests { private ISerializer mSerializer; @BeforeEach - public void setUp() throws Exception { + public void setUp() { baseClient = new BaseClient<>(); mLogger = mock(ILogger.class); mSerializer = mock(ISerializer.class); diff --git a/src/test/java/com/microsoft/graph/core/ClientExceptionTests.java b/src/test/java/com/microsoft/graph/core/ClientExceptionTests.java index 62b68a7c2..603588d8c 100644 --- a/src/test/java/com/microsoft/graph/core/ClientExceptionTests.java +++ b/src/test/java/com/microsoft/graph/core/ClientExceptionTests.java @@ -12,7 +12,7 @@ public class ClientExceptionTests { private String expectMessage = "This is test exception message"; @BeforeEach - public void setUp() throws Exception { + public void setUp() { clientException = new ClientException(expectMessage, null); } diff --git a/src/test/java/com/microsoft/graph/core/GraphServiceClientTest.java b/src/test/java/com/microsoft/graph/core/GraphServiceClientTest.java index 14c211583..0e19c46b3 100644 --- a/src/test/java/com/microsoft/graph/core/GraphServiceClientTest.java +++ b/src/test/java/com/microsoft/graph/core/GraphServiceClientTest.java @@ -12,6 +12,7 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.Test; import okhttp3.Request; @@ -28,6 +29,7 @@ import javax.annotation.Nullable; +@SuppressFBWarnings public class GraphServiceClientTest { private IAuthenticationProvider getAuthProvider() { return mock(IAuthenticationProvider.class); diff --git a/src/test/java/com/microsoft/graph/http/BaseCollectionPageTests.java b/src/test/java/com/microsoft/graph/http/BaseCollectionPageTests.java index 9cf1b7e68..2604aa19c 100644 --- a/src/test/java/com/microsoft/graph/http/BaseCollectionPageTests.java +++ b/src/test/java/com/microsoft/graph/http/BaseCollectionPageTests.java @@ -26,7 +26,7 @@ public class BaseCollectionPageTests { @BeforeEach @SuppressWarnings("unchecked") - public void setUp() throws Exception { + public void setUp() { list = new ArrayList(); list.add("Object1"); list.add("Object2"); diff --git a/src/test/java/com/microsoft/graph/http/BaseCollectionRequestTests.java b/src/test/java/com/microsoft/graph/http/BaseCollectionRequestTests.java index 7865618a9..e9ce66e08 100644 --- a/src/test/java/com/microsoft/graph/http/BaseCollectionRequestTests.java +++ b/src/test/java/com/microsoft/graph/http/BaseCollectionRequestTests.java @@ -10,6 +10,7 @@ import com.microsoft.graph.options.QueryOption; import com.microsoft.graph.serializer.ISerializer; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -56,6 +57,7 @@ public class BaseCollectionRequestTests { private BaseEntityCollectionRequest, BaseCollectionPage>> mRequest; @BeforeEach + @SuppressFBWarnings @SuppressWarnings("unchecked") public void setUp() throws Exception { mBaseClient = mock(IBaseClient.class); diff --git a/src/test/java/com/microsoft/graph/http/BaseRequestBuilderTests.java b/src/test/java/com/microsoft/graph/http/BaseRequestBuilderTests.java index c61caf5f2..b40c0ebef 100644 --- a/src/test/java/com/microsoft/graph/http/BaseRequestBuilderTests.java +++ b/src/test/java/com/microsoft/graph/http/BaseRequestBuilderTests.java @@ -18,7 +18,7 @@ public class BaseRequestBuilderTests { private BaseRequestBuilder baseRequestBuilder; @BeforeEach - public void setUp() throws Exception { + public void setUp() { baseRequestBuilder = new BaseRequestBuilder<>(expectedRequestUrl, mock(IBaseClient.class), null){}; } diff --git a/src/test/java/com/microsoft/graph/http/BaseRequestTests.java b/src/test/java/com/microsoft/graph/http/BaseRequestTests.java index 27c8d95c3..ee615cb3d 100644 --- a/src/test/java/com/microsoft/graph/http/BaseRequestTests.java +++ b/src/test/java/com/microsoft/graph/http/BaseRequestTests.java @@ -11,6 +11,7 @@ import static org.mockito.Mockito.mock; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -37,6 +38,7 @@ public class BaseRequestTests { private BaseRequest mRequest; @BeforeEach + @SuppressFBWarnings public void setUp() throws Exception { final Response response = new Response.Builder() .request(new Request.Builder().url("https://a.b.c").build()) diff --git a/src/test/java/com/microsoft/graph/http/BaseStreamRequestTests.java b/src/test/java/com/microsoft/graph/http/BaseStreamRequestTests.java index bbbfd8f2c..395c768d3 100644 --- a/src/test/java/com/microsoft/graph/http/BaseStreamRequestTests.java +++ b/src/test/java/com/microsoft/graph/http/BaseStreamRequestTests.java @@ -10,6 +10,7 @@ import java.io.InputStream; import java.util.concurrent.ExecutionException; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.stubbing.Answer; @@ -33,13 +34,14 @@ /** * Test cases for {@see BaseStreamRequest} */ +@SuppressFBWarnings public class BaseStreamRequestTests { private BaseClient mBaseClient; @BeforeEach @SuppressWarnings("unchecked") - public void setUp() throws Exception { + public void setUp() { mBaseClient = mock(BaseClient.class); } diff --git a/src/test/java/com/microsoft/graph/http/CoreHttpCallbackFutureWrapperTests.java b/src/test/java/com/microsoft/graph/http/CoreHttpCallbackFutureWrapperTests.java index 83b1d1f54..3458e0894 100644 --- a/src/test/java/com/microsoft/graph/http/CoreHttpCallbackFutureWrapperTests.java +++ b/src/test/java/com/microsoft/graph/http/CoreHttpCallbackFutureWrapperTests.java @@ -9,11 +9,13 @@ import java.io.IOException; import java.util.concurrent.ExecutionException; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.Test; import okhttp3.Call; import okhttp3.Response; +@SuppressFBWarnings class CoreHttpCallbackFutureWrapperTests { @Test diff --git a/src/test/java/com/microsoft/graph/http/CoreHttpProviderTests.java b/src/test/java/com/microsoft/graph/http/CoreHttpProviderTests.java index 43b8ebe76..2ea0ad618 100644 --- a/src/test/java/com/microsoft/graph/http/CoreHttpProviderTests.java +++ b/src/test/java/com/microsoft/graph/http/CoreHttpProviderTests.java @@ -20,6 +20,7 @@ import com.microsoft.graph.serializer.DefaultSerializer; import com.microsoft.graph.serializer.ISerializer; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import okio.Buffer; import org.junit.jupiter.api.Test; @@ -62,6 +63,7 @@ class CoreHttpProviderTests { private Gson GSON = new GsonBuilder().create(); @Test + @SuppressFBWarnings void testErrorResponse() throws Exception { final GraphErrorCodes expectedErrorCode = GraphErrorCodes.INVALID_REQUEST; final String expectedMessage = "Test error!"; @@ -85,6 +87,7 @@ void testErrorResponse() throws Exception { } @Test + @SuppressFBWarnings void testVerboseErrorResponse() throws Exception { final GraphErrorCodes expectedErrorCode = GraphErrorCodes.INVALID_REQUEST; final String expectedMessage = "Test error!"; diff --git a/src/test/java/com/microsoft/graph/httpcore/AuthenticationHandlerTest.java b/src/test/java/com/microsoft/graph/httpcore/AuthenticationHandlerTest.java index 4f77c93e9..a57c91bb2 100644 --- a/src/test/java/com/microsoft/graph/httpcore/AuthenticationHandlerTest.java +++ b/src/test/java/com/microsoft/graph/httpcore/AuthenticationHandlerTest.java @@ -10,6 +10,7 @@ import java.net.URL; import java.util.concurrent.CompletableFuture; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.Test; import okhttp3.OkHttpClient; @@ -17,6 +18,7 @@ public class AuthenticationHandlerTest { @Test + @SuppressFBWarnings public void testAuthenticationHandler() throws Exception { IAuthenticationProvider authProvider = mock(IAuthenticationProvider.class); when(authProvider.getAuthorizationTokenAsync(any(URL.class))).thenReturn(CompletableFuture.completedFuture("a token")); diff --git a/src/test/java/com/microsoft/graph/httpcore/RetryHandlerTest.java b/src/test/java/com/microsoft/graph/httpcore/RetryHandlerTest.java index f786c3e34..c6c1c4817 100644 --- a/src/test/java/com/microsoft/graph/httpcore/RetryHandlerTest.java +++ b/src/test/java/com/microsoft/graph/httpcore/RetryHandlerTest.java @@ -9,6 +9,7 @@ import java.io.IOException; import java.net.HttpURLConnection; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.Test; import com.microsoft.graph.httpcore.middlewareoption.IShouldRetry; @@ -21,6 +22,7 @@ import okhttp3.Response; import okio.BufferedSink; +@SuppressFBWarnings public class RetryHandlerTest { private static final String testmeurl = "https://graph.microsoft.com/v1.0/me"; diff --git a/src/test/java/com/microsoft/graph/httpcore/middlewareoption/RedirectOptionsTest.java b/src/test/java/com/microsoft/graph/httpcore/middlewareoption/RedirectOptionsTest.java index 81be8c023..3e4c8ec6a 100644 --- a/src/test/java/com/microsoft/graph/httpcore/middlewareoption/RedirectOptionsTest.java +++ b/src/test/java/com/microsoft/graph/httpcore/middlewareoption/RedirectOptionsTest.java @@ -5,10 +5,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.Test; import okhttp3.Response; +@SuppressFBWarnings public class RedirectOptionsTest { @Test public void constructorDefensiveProgramming() { diff --git a/src/test/java/com/microsoft/graph/httpcore/middlewareoption/RetryOptionsTest.java b/src/test/java/com/microsoft/graph/httpcore/middlewareoption/RetryOptionsTest.java index 91502144d..2ae089484 100644 --- a/src/test/java/com/microsoft/graph/httpcore/middlewareoption/RetryOptionsTest.java +++ b/src/test/java/com/microsoft/graph/httpcore/middlewareoption/RetryOptionsTest.java @@ -3,11 +3,14 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.Test; +@SuppressFBWarnings public class RetryOptionsTest { @Test - public void constructorDefensiveProgramming() { + @SuppressFBWarnings + public void constructorDefensiveProgramming() throws IllegalArgumentException { assertThrows(IllegalArgumentException.class, () -> { new RetryOptions(null, RetryOptions.MAX_RETRIES +1, 0); }); diff --git a/src/test/java/com/microsoft/graph/options/OptionTests.java b/src/test/java/com/microsoft/graph/options/OptionTests.java index 45f163a5a..0f9c07d7e 100644 --- a/src/test/java/com/microsoft/graph/options/OptionTests.java +++ b/src/test/java/com/microsoft/graph/options/OptionTests.java @@ -5,8 +5,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.Test; +@SuppressFBWarnings public class OptionTests { @Test diff --git a/src/test/java/com/microsoft/graph/serializer/ByteArraySerializerTests.java b/src/test/java/com/microsoft/graph/serializer/ByteArraySerializerTests.java index 179d39889..1862813ca 100644 --- a/src/test/java/com/microsoft/graph/serializer/ByteArraySerializerTests.java +++ b/src/test/java/com/microsoft/graph/serializer/ByteArraySerializerTests.java @@ -3,12 +3,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.Test; public class ByteArraySerializerTests { @Test - public void testByteSerialization() throws Exception { + public void testByteSerialization() { String expectedString = "abcd"; String serializeString = ByteArraySerializer.serialize(new byte[]{105,-73,29}); assertEquals(expectedString, serializeString); @@ -16,6 +17,7 @@ public void testByteSerialization() throws Exception { } @Test + @SuppressFBWarnings public void testStringDeserialization() throws Exception { byte[] deserializeBytes = ByteArraySerializer.deserialize("abcd"); assertEquals(3, deserializeBytes.length); diff --git a/src/test/java/com/microsoft/graph/serializer/DateOnlyTests.java b/src/test/java/com/microsoft/graph/serializer/DateOnlyTests.java index ad9d9b20d..23d92e8e4 100644 --- a/src/test/java/com/microsoft/graph/serializer/DateOnlyTests.java +++ b/src/test/java/com/microsoft/graph/serializer/DateOnlyTests.java @@ -2,10 +2,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.Test; import com.microsoft.graph.core.DateOnly; +@SuppressFBWarnings public class DateOnlyTests { @Test diff --git a/src/test/java/com/microsoft/graph/serializer/DurationTests.java b/src/test/java/com/microsoft/graph/serializer/DurationTests.java index c691754b6..f833f1445 100644 --- a/src/test/java/com/microsoft/graph/serializer/DurationTests.java +++ b/src/test/java/com/microsoft/graph/serializer/DurationTests.java @@ -5,8 +5,10 @@ import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.Duration; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.Test; +@SuppressFBWarnings public class DurationTests { @Test diff --git a/src/test/java/com/microsoft/graph/serializer/EdmNativeTypeSerializerTests.java b/src/test/java/com/microsoft/graph/serializer/EdmNativeTypeSerializerTests.java index 952fe422a..cffc2733e 100644 --- a/src/test/java/com/microsoft/graph/serializer/EdmNativeTypeSerializerTests.java +++ b/src/test/java/com/microsoft/graph/serializer/EdmNativeTypeSerializerTests.java @@ -11,7 +11,7 @@ public class EdmNativeTypeSerializerTests { @Test - public void testBoolean() throws Exception { + public void testBoolean() { final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger()); final String source = "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#Edm.Null\",\"@odata.null\":true}"; @@ -20,7 +20,7 @@ public void testBoolean() throws Exception { assertEquals(Boolean.valueOf(true), result); } @Test - public void testInteger() throws Exception { + public void testInteger() { final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger()); final String source = "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#Edm.Null\",\"@odata.null\":12}"; @@ -29,7 +29,7 @@ public void testInteger() throws Exception { assertEquals(Integer.valueOf(12), result); } @Test - public void testString() throws Exception { + public void testString() { final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger()); final String source = "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#Edm.Null\",\"@odata.null\":\"toto\"}"; @@ -38,7 +38,7 @@ public void testString() throws Exception { assertEquals("toto", result); } @Test - public void testFloat() throws Exception { + public void testFloat() { final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger()); final String source = "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#Edm.Null\",\"@odata.null\":12.5}"; @@ -47,7 +47,7 @@ public void testFloat() throws Exception { assertEquals(Float.valueOf("12.5"), result); } @Test - public void testLong() throws Exception { + public void testLong() { final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger()); final String source = "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#Edm.Null\",\"@odata.null\":12}"; @@ -56,7 +56,7 @@ public void testLong() throws Exception { assertEquals(Long.valueOf(12), result); } @Test - public void testBigDecimal() throws Exception { + public void testBigDecimal() { final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger()); final String source = "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#Edm.Null\",\"@odata.null\":12}"; @@ -65,7 +65,7 @@ public void testBigDecimal() throws Exception { assertEquals(BigDecimal.valueOf(12), result); } @Test - public void testUUID() throws Exception { + public void testUUID() { final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger()); final String source = "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#Edm.Null\",\"@odata.null\":\"0E6558C3-9640-4385-860A-2A894AC5C246\"}"; diff --git a/src/test/java/com/microsoft/graph/serializer/ISO8601Test.java b/src/test/java/com/microsoft/graph/serializer/ISO8601Test.java index ed8e45eac..1f1315f9e 100644 --- a/src/test/java/com/microsoft/graph/serializer/ISO8601Test.java +++ b/src/test/java/com/microsoft/graph/serializer/ISO8601Test.java @@ -7,16 +7,16 @@ import java.util.Date; import java.util.TimeZone; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.Test; public class ISO8601Test { /** * Make sure that dates with and without millis can be converted properly into strings - * @throws Exception If there is an exception during the test */ @Test - public void testFromDate() throws Exception { + public void testFromDate() { TimeZone.setDefault(TimeZone.getTimeZone("PST")); final OffsetDateTime date = OffsetDateTime.of(5882, 3, 11, 00, 30, 12, 345000000, ZoneOffset.UTC); assertEquals("5882-03-11T00:30:12.345Z", OffsetDateTimeSerializer.serialize(date)); @@ -30,6 +30,7 @@ public void testFromDate() throws Exception { * @throws Exception If there is an exception during the test */ @Test + @SuppressFBWarnings public void testToDate() throws Exception { TimeZone.setDefault(TimeZone.getTimeZone("PST")); final long toTheSecondDate = 123456789012L; diff --git a/src/test/java/com/microsoft/graph/serializer/OffsetDateTimeSerializerTests.java b/src/test/java/com/microsoft/graph/serializer/OffsetDateTimeSerializerTests.java index 9480a36ba..8bbb61dd6 100644 --- a/src/test/java/com/microsoft/graph/serializer/OffsetDateTimeSerializerTests.java +++ b/src/test/java/com/microsoft/graph/serializer/OffsetDateTimeSerializerTests.java @@ -8,6 +8,7 @@ import java.time.ZoneOffset; import java.util.TimeZone; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.Test; /** @@ -16,14 +17,14 @@ * @author mobilal * */ +@SuppressFBWarnings public class OffsetDateTimeSerializerTests { /** * Validate if a offsetDateTime date instance could be serialized - * @throws Exception if offsetDateTime couldn't be serialized - */ + */ @Test - public void testDateSerialization() throws Exception { + public void testDateSerialization() { final OffsetDateTime offsetDateTime = OffsetDateTime.ofInstant(Instant.ofEpochMilli(1561162355000L), ZoneOffset.UTC); final String expected = "2019-06-22T00:12:35Z"; final String actual = OffsetDateTimeSerializer.serialize(offsetDateTime); diff --git a/src/test/java/com/microsoft/graph/serializer/TimeOfDayTests.java b/src/test/java/com/microsoft/graph/serializer/TimeOfDayTests.java index 288c2953c..8a3fbba2b 100644 --- a/src/test/java/com/microsoft/graph/serializer/TimeOfDayTests.java +++ b/src/test/java/com/microsoft/graph/serializer/TimeOfDayTests.java @@ -3,11 +3,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.junit.jupiter.api.Test; import com.microsoft.graph.core.TimeOfDay; import com.microsoft.graph.logger.ILogger; +@SuppressFBWarnings public class TimeOfDayTests { @Test @@ -46,7 +48,7 @@ public void testTimeOfDayDeserializerWithFraction() throws Exception{ assertEquals(44, time.getSecond()); } @Test - public void testTimeOfDaySerialization() throws Exception { + public void testTimeOfDaySerialization() { final TimeOfDay time = new TimeOfDay(12, 30, 44); final ILogger logger = mock(ILogger.class); final ISerializer serializer = new DefaultSerializer(logger); From 52e51ef0dc1c140fcee643fdf6ebdb0c6296fb82 Mon Sep 17 00:00:00 2001 From: ramsessanchez <63934382+ramsessanchez@users.noreply.github.com> Date: Thu, 26 May 2022 09:56:19 -0700 Subject: [PATCH 3/3] RollBack breaking changes --- .../com/microsoft/graph/http/IStatefulResponseHandler.java | 7 ++----- .../graph/tasks/LargeFileUploadResponseHandler.java | 4 +++- .../com/microsoft/graph/tasks/LargeFileUploadTask.java | 7 +++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/microsoft/graph/http/IStatefulResponseHandler.java b/src/main/java/com/microsoft/graph/http/IStatefulResponseHandler.java index 3d5bba8ed..5a2206ade 100644 --- a/src/main/java/com/microsoft/graph/http/IStatefulResponseHandler.java +++ b/src/main/java/com/microsoft/graph/http/IStatefulResponseHandler.java @@ -22,14 +22,12 @@ package com.microsoft.graph.http; - import com.microsoft.graph.logger.ILogger; import com.microsoft.graph.serializer.ISerializer; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import javax.annotation.Nullable; import javax.annotation.Nonnull; -import java.io.IOException; /** * The handler interface for requests having stateful response from server. @@ -49,13 +47,12 @@ public interface IStatefulResponseHandler { * @param logger the logger * @param the native http client response type * @return the result generated by this handler - * @throws IOException an exception occurs if the request was unable to complete for any reason - * @throws GraphServiceException an exception is there is an interruption related to the GraphService + * @throws Exception an exception occurs if the request was unable to complete for any reason */ @Nullable @SuppressFBWarnings ResultType generateResult(@Nonnull final IHttpRequest request, @Nonnull final ResponseType response, @Nonnull final ISerializer serializer, - @Nonnull final ILogger logger) throws IOException, GraphServiceException; + @Nonnull final ILogger logger) throws Exception; } diff --git a/src/main/java/com/microsoft/graph/tasks/LargeFileUploadResponseHandler.java b/src/main/java/com/microsoft/graph/tasks/LargeFileUploadResponseHandler.java index 0a1c69213..00b8a6816 100644 --- a/src/main/java/com/microsoft/graph/tasks/LargeFileUploadResponseHandler.java +++ b/src/main/java/com/microsoft/graph/tasks/LargeFileUploadResponseHandler.java @@ -40,6 +40,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import okhttp3.MediaType; import okhttp3.Response; import okhttp3.ResponseBody; @@ -72,11 +73,12 @@ protected LargeFileUploadResponseHandler(@Nonnull final Class upload @Override @Nullable + @SuppressFBWarnings public LargeFileUploadResponse generateResult( @Nonnull final IHttpRequest request, @Nonnull final ResponseType response, @Nonnull final ISerializer serializer, - @Nonnull final ILogger logger) throws IOException, GraphServiceException { + @Nonnull final ILogger logger) throws Exception { Objects.requireNonNull(request, "parameter request cannot be null"); Objects.requireNonNull(response, "parameter response cannot be null"); Objects.requireNonNull(serializer, "parameter serializer cannot be null"); diff --git a/src/main/java/com/microsoft/graph/tasks/LargeFileUploadTask.java b/src/main/java/com/microsoft/graph/tasks/LargeFileUploadTask.java index 72b8f3c1d..f7fabb0e1 100644 --- a/src/main/java/com/microsoft/graph/tasks/LargeFileUploadTask.java +++ b/src/main/java/com/microsoft/graph/tasks/LargeFileUploadTask.java @@ -24,9 +24,8 @@ import com.microsoft.graph.core.ClientException; import com.microsoft.graph.core.IBaseClient; -import com.microsoft.graph.http.GraphFatalServiceException; -import com.microsoft.graph.http.GraphServiceException; import com.microsoft.graph.options.Option; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; import java.io.InputStream; @@ -100,13 +99,13 @@ public class LargeFileUploadTask { * @param inputStream the input stream * @param streamSize the stream size * @param uploadTypeClass the upload type class - * @throws GraphServiceException if there is an interruption in the service */ + @SuppressFBWarnings public LargeFileUploadTask(@Nonnull final IUploadSession uploadSession, @Nonnull final IBaseClient client, @Nonnull final InputStream inputStream, final long streamSize, - @Nonnull final Class uploadTypeClass) throws GraphServiceException { + @Nonnull final Class uploadTypeClass) { Objects.requireNonNull(uploadSession, "Upload session is null."); if (streamSize <= 0) {