Skip to content

Commit 0b9319e

Browse files
authored
Merge pull request #262 from microsoftgraph/bugfix/linting-and-release-comments
release 2.0.8 comments correction
2 parents 9744dff + 1caf683 commit 0b9319e

File tree

4 files changed

+27
-17
lines changed

4 files changed

+27
-17
lines changed

src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ public DefaultSerializer(@Nonnull final ILogger logger) {
7272
/**
7373
* Creates a DefaultSerializer with an option to enable serializing of the null values.
7474
*
75+
* Serializing of null values can have side effects on the service behavior.
76+
* Sending null values in a PATCH request might reset existing values on the service side.
77+
* Sending null values in a POST request might prevent the service from assigning default values to the properties.
78+
* It is not recommended to send null values to the service in general and this setting should only be used when serializing information for a local store.
79+
*
7580
* @param logger the logger
7681
* @param serializeNulls the setting of whether or not to serialize the null values in the JSON object
7782
*/

src/main/java/com/microsoft/graph/serializer/GsonFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ public static Gson getGsonInstance(@Nonnull final ILogger logger) {
7878
/**
7979
* Creates an instance of GSON
8080
*
81+
* Serializing of null values can have side effects on the service behavior.
82+
* Sending null values in a PATCH request might reset existing values on the service side.
83+
* Sending null values in a POST request might prevent the service from assigning default values to the properties.
84+
* It is not recommended to send null values to the service in general and this setting should only be used when serializing information for a local store.
85+
*
8186
* @param logger the logger
8287
* @param serializeNulls the setting of whether or not to serialize the null values in the JSON object
8388
* @return the new instance

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@
5656
import static org.mockito.Mockito.verify;
5757
import static org.mockito.Mockito.when;
5858

59-
public class CoreHttpProviderTests {
59+
class CoreHttpProviderTests {
6060

6161
private CoreHttpProvider mProvider;
6262
private Gson GSON = new GsonBuilder().create();
6363

6464
@Test
65-
public void testErrorResponse() throws Exception {
65+
void testErrorResponse() throws Exception {
6666
final GraphErrorCodes expectedErrorCode = GraphErrorCodes.INVALID_REQUEST;
6767
final String expectedMessage = "Test error!";
6868
final GraphErrorResponse toSerialize = new GraphErrorResponse();
@@ -85,7 +85,7 @@ public void testErrorResponse() throws Exception {
8585
}
8686

8787
@Test
88-
public void testVerboseErrorResponse() throws Exception {
88+
void testVerboseErrorResponse() throws Exception {
8989
final GraphErrorCodes expectedErrorCode = GraphErrorCodes.INVALID_REQUEST;
9090
final String expectedMessage = "Test error!";
9191
final GraphErrorResponse toSerialize = new GraphErrorResponse();
@@ -119,25 +119,25 @@ public void testVerboseErrorResponse() throws Exception {
119119
}
120120

121121
@Test
122-
public void testHasHeaderReturnsTrue() {
122+
void testHasHeaderReturnsTrue() {
123123
HeaderOption h = new HeaderOption("name", "value");
124124
assertTrue(CoreHttpProvider.hasHeader(Arrays.asList(h), "name"));
125125
}
126126

127127
@Test
128-
public void testHasHeaderReturnsTrueWhenDifferentCase() {
128+
void testHasHeaderReturnsTrueWhenDifferentCase() {
129129
HeaderOption h = new HeaderOption("name", "value");
130130
assertTrue(CoreHttpProvider.hasHeader(Arrays.asList(h), "NAME"));
131131
}
132132

133133
@Test
134-
public void testHasHeaderReturnsFalse() {
134+
void testHasHeaderReturnsFalse() {
135135
HeaderOption h = new HeaderOption("name", "value");
136136
assertFalse(CoreHttpProvider.hasHeader(Arrays.asList(h), "blah"));
137137
}
138138

139139
@Test
140-
public void testStreamToStringReturnsData() {
140+
void testStreamToStringReturnsData() {
141141
String data = GSON.toJson(Maps.newHashMap(
142142
ImmutableMap.<String, String>builder()
143143
.put("key", "value")
@@ -149,14 +149,14 @@ public void testStreamToStringReturnsData() {
149149
}
150150

151151
@Test
152-
public void testStreamToStringReturnsEmpty() {
152+
void testStreamToStringReturnsEmpty() {
153153
final InputStream inputStream = new ByteArrayInputStream(new byte[0]);
154154

155155
String convertedData = CoreHttpProvider.streamToString(inputStream);
156156
assertEquals("", convertedData);
157157
}
158158
@Test
159-
public void emptyPostContentTypeIsNotReset() {
159+
void emptyPostContentTypeIsNotReset() {
160160
final String contentTypeValue = "application/json";
161161
final HeaderOption ctype = new HeaderOption("Content-Type", contentTypeValue);
162162
final ArrayList<Option> options = new ArrayList<>();
@@ -173,7 +173,7 @@ public void emptyPostContentTypeIsNotReset() {
173173
assertEquals(contentTypeValue, request.body().contentType().toString());
174174
}
175175
@Test
176-
public void emptyPostContentTypeIsNotSet() {
176+
void emptyPostContentTypeIsNotSet() {
177177
final IHttpRequest absRequest = new BaseRequest<String>("https://localhost", mock(IBaseClient.class), Collections.emptyList(), String.class) {{
178178
this.setHttpMethod(HttpMethod.POST);
179179
}};
@@ -210,7 +210,7 @@ private void setCoreHttpProvider(final Object toSerialize) throws IOException {
210210
mClient);
211211
}
212212
@Test
213-
public void getHttpRequestDoesntSetRetryOrRedirectOptionsOnDefaultValues() throws MalformedURLException {
213+
void getHttpRequestDoesntSetRetryOrRedirectOptionsOnDefaultValues() throws MalformedURLException {
214214
final IHttpRequest absRequest = mock(IHttpRequest.class);
215215
when(absRequest.getRequestUrl()).thenReturn(new URL("https://graph.microsoft.com/v1.0/me"));
216216
when(absRequest.getHttpMethod()).thenReturn(HttpMethod.GET);
@@ -239,7 +239,7 @@ public void getHttpRequestDoesntSetRetryOrRedirectOptionsOnDefaultValues() throw
239239
}
240240

241241
@Test
242-
public void getHttpRequestSetsRetryOrRedirectOptionsOnNonDefaultValues() throws MalformedURLException {
242+
void getHttpRequestSetsRetryOrRedirectOptionsOnNonDefaultValues() throws MalformedURLException {
243243
final IHttpRequest absRequest = mock(IHttpRequest.class);
244244
when(absRequest.getRequestUrl()).thenReturn(new URL("https://graph.microsoft.com/v1.0/me"));
245245
when(absRequest.getHttpMethod()).thenReturn(HttpMethod.GET);
@@ -295,7 +295,7 @@ public void getHttpRequestSetsRetryOrRedirectOptionsOnNonDefaultValues() throws
295295
}
296296

297297
@Test
298-
public void getHttpRequestWithTextPlainBodyDoesNotSerializeAsJson() throws IOException {
298+
void getHttpRequestWithTextPlainBodyDoesNotSerializeAsJson() throws IOException {
299299
final IHttpRequest absRequest = mock(IHttpRequest.class);
300300
when(absRequest.getRequestUrl()).thenReturn(new URL("https://graph.microsoft.com/v1.0/me"));
301301
when(absRequest.getHttpMethod()).thenReturn(HttpMethod.POST);

src/test/java/com/microsoft/graph/serializer/DefaultSerializerTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
import static org.junit.jupiter.api.Assertions.assertTrue;
1515
import static org.mockito.Mockito.mock;
1616

17-
public class DefaultSerializerTest {
17+
class DefaultSerializerTest {
1818

1919
final ILogger logger = mock(ILogger.class);
2020
Gson gson = GsonFactory.getGsonInstance(logger);
2121
DefaultSerializer defaultSerializer = new DefaultSerializer(logger);
2222

2323
@Test
24-
public void testDeserializationOfObjectWithODataTypeProperty() {
24+
void testDeserializationOfObjectWithODataTypeProperty() {
2525
// Given
2626
final String testJsonResponse =
2727
"{\"@odata.type\": \"#microsoft.graph.subReactionStub1\"}";
@@ -36,7 +36,7 @@ public void testDeserializationOfObjectWithODataTypeProperty() {
3636
}
3737

3838
@Test
39-
public void testDefaultSerializerDoesNotIncludeNullValuesByDefault() {
39+
void testDefaultSerializerDoesNotIncludeNullValuesByDefault() {
4040
// Given
4141
final String testJsonResponse =
4242
"{\"@odata.type\": \"#microsoft.graph.messageStub\", \"body\": null}";
@@ -50,7 +50,7 @@ public void testDefaultSerializerDoesNotIncludeNullValuesByDefault() {
5050
}
5151

5252
@Test
53-
public void testDefaultNullSerializerDoesIncludeNullValues() {
53+
void testDefaultNullSerializerDoesIncludeNullValues() {
5454
// Given
5555
final String testJsonResponse =
5656
"{\"@odata.type\": \"#microsoft.graph.messageStub\",\"body\":null}";

0 commit comments

Comments
 (0)