use of com.microsoft.graph.logger.DefaultLogger in project msgraph-sdk-java by microsoftgraph.
the class DefaultClientConfig method getLogger.
/**
* Gets the logger
*
* @return the logger
*/
public ILogger getLogger() {
if (logger == null) {
logger = new DefaultLogger();
logger.logDebug("Created DefaultLogger");
}
return logger;
}
use of com.microsoft.graph.logger.DefaultLogger in project msgraph-sdk-java by microsoftgraph.
the class DefaultSeralizerTests method testRecurrenceRangeSerialization.
@Test
public void testRecurrenceRangeSerialization() throws Exception {
final String expected = "{\"type\":\"endDate\",\"startDate\":\"2016-04-25\",\"endDate\":\"2016-05-25\",\"recurrenceTimeZone\":\"PST\",\"numberOfOccurrences\":4}";
final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
BaseRecurrenceRange brr = new BaseRecurrenceRange();
brr.type = RecurrenceRangeType.END_DATE;
brr.startDate = new DateOnly(2016, 4, 25);
brr.endDate = new DateOnly(2016, 5, 25);
brr.recurrenceTimeZone = "PST";
brr.numberOfOccurrences = 4;
String jsonOut = serializer.serializeObject(brr);
assertNotNull(jsonOut);
assertEquals(expected, jsonOut);
}
use of com.microsoft.graph.logger.DefaultLogger in project msgraph-sdk-java by microsoftgraph.
the class DefaultSeralizerTests method testDriveDeserialization.
/**
* Make sure that deserializing a Drive also returns members from BaseDrive
*
* @throws Exception If there is an exception during the test
*/
@Test
public void testDriveDeserialization() throws Exception {
final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
String source = "{\"@odata.context\":\"https://graph.microsoft.com/v1.0/$metadata#drives/$entity\",\"id\":\"8bf6ae90006c4a4c\",\"driveType\":\"personal\",\"owner\":{\"user\":{\"displayName\":\"Peter\",\"id\":\"8bf6ae90006c4a4c\"}},\"quota\":{\"deleted\":1485718314,\"remaining\":983887466461,\"state\":\"normal\",\"total\":1142461300736,\"used\":158573834275}}";
Drive result = serializer.deserializeObject(source, Drive.class);
assertNotNull(result);
assertEquals("personal", result.driveType);
assertEquals(Long.valueOf(983887466461L), result.quota.remaining);
assertEquals("8bf6ae90006c4a4c", result.id);
}
use of com.microsoft.graph.logger.DefaultLogger in project msgraph-sdk-java by microsoftgraph.
the class DefaultSeralizerTests method testDeserializeDerivedType.
@Test
public void testDeserializeDerivedType() throws Exception {
final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
String source = "{\"@odata.context\": \"/attachments/$entity\",\"@odata.type\": \"#microsoft.graph.fileAttachment\",\"id\": \"AAMkAGQ0MjBmNWVkLTYxZjUtNDRmYi05Y2NiLTBlYjIwNzJjNmM1NgBGAAAAAAC6ff7latYeQqu_gLrhSAIhBwCF7iGjpaOmRqVwbZc-xXzwAAAAAAEMAACF7iGjpaOmRqVwbZc-xXzwAABQStA0AAABEgAQAFbGmeisbjtLnQdp7kC_9Fk=\",\"lastModifiedDateTime\": \"2018-01-23T21:50:22Z\",\"name\": \"Test Book.xlsx\",\"contentType\": \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\"size\": 8457,\"isInline\": false,\"contentId\": null,\"contentLocation\": null,\"contentBytes\": \"bytedata\"}";
Attachment result = serializer.deserializeObject(source, Attachment.class);
assert (result instanceof FileAttachment);
FileAttachment fileAttachment = (FileAttachment) result;
assertNotNull(fileAttachment.contentBytes);
JsonObject o = fileAttachment.getRawObject();
assertNotNull(o);
assertEquals("#microsoft.graph.fileAttachment", o.get("@odata.type").getAsString());
}
use of com.microsoft.graph.logger.DefaultLogger in project msgraph-sdk-java by microsoftgraph.
the class DefaultSeralizerTests method testResponseHeaders.
@Test
public void testResponseHeaders() throws Exception {
MockConnection connection = new MockConnection(null);
final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
User user = serializer.deserializeObject("{\"id\":\"1\"}", User.class, connection.getResponseHeaders());
JsonElement responseHeaders = user.additionalDataManager().get("graphResponseHeaders");
assertNotNull(responseHeaders);
JsonElement responseHeader = responseHeaders.getAsJsonObject().get("header1");
assertNotNull(responseHeader);
assertEquals("value1", responseHeader.getAsJsonArray().get(0).getAsString());
}
Aggregations