Search in sources :

Example 31 with DefaultSerializer

use of com.microsoft.graph.serializer.DefaultSerializer in project msgraph-beta-sdk-java by microsoftgraph.

the class DefaultSerializerTests method testEnumActionParameterDeserialization.

@Test
public void testEnumActionParameterDeserialization() throws IOException {
    final ArrayList<String> users = new ArrayList<String>();
    users.add("michael@chambele.onmicrosoft.com");
    final EnumSet<MailTipsType> mailtips = EnumSet.of(MailTipsType.MAILBOX_FULL_STATUS, MailTipsType.MAX_MESSAGE_SIZE);
    final UserGetMailTipsParameterSet body = UserGetMailTipsParameterSet.newBuilder().withEmailAddresses(users).withMailTipsOptions(mailtips).build();
    final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
    final String serialized = serializer.serializeObject(body);
    assertTrue(serialized.contains("mailboxFullStatus"), "result contains camelCasedValues");
    final UserGetMailTipsParameterSet deserialized = serializer.deserializeObject(serialized, UserGetMailTipsParameterSet.class);
    assertEquals(2, deserialized.mailTipsOptions.size());
}
Also used : UserGetMailTipsParameterSet(com.microsoft.graph.models.UserGetMailTipsParameterSet) DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) ArrayList(java.util.ArrayList) MailTipsType(com.microsoft.graph.models.MailTipsType) DefaultLogger(com.microsoft.graph.logger.DefaultLogger) Test(org.junit.jupiter.api.Test)

Example 32 with DefaultSerializer

use of com.microsoft.graph.serializer.DefaultSerializer in project msgraph-beta-sdk-java by microsoftgraph.

the class DefaultSerializerTests method testDeserializerWhenCasingRespondedByServiceIsWrong.

@Test
public void testDeserializerWhenCasingRespondedByServiceIsWrong() {
    final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
    final String source = "{\"@odata.context\": \"https://outlook.office.com/api/v2.0/$metadata#Users('e45f52f5-f2dd-4359-abc5-e74f2960b831')/Messages/AAMkAGQ0MjBmNWVkLTYxZjUtNDRmYi05Y2NiLTBlYjIwNzJjNmM1NgBGAAAAAAC6ff7latYeQqu_gLrhSAIhBwCF7iGjpaOmRqVwbZc-xXzwAAAAAAEMAACF7iGjpaOmRqVwbZc-xXzwAABQStA0AAABEgAQAFbGmeisbjtLnQdp7kC_9Fk=/AttachmentSessions/$entity\",\"ExpirationDateTime\": \"2020-10-06T14:23:42.1027521Z\",\"NextExpectedRanges\": [\"5242880\"]}";
    final UploadSession result = serializer.deserializeObject(source, UploadSession.class);
    assertNotNull(result);
    assertNotNull(result.nextExpectedRanges);
    assertTrue(result.nextExpectedRanges.size() > 0);
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) UploadSession(com.microsoft.graph.models.UploadSession) DefaultLogger(com.microsoft.graph.logger.DefaultLogger) Test(org.junit.jupiter.api.Test)

Example 33 with DefaultSerializer

use of com.microsoft.graph.serializer.DefaultSerializer in project msgraph-beta-sdk-java by microsoftgraph.

the class DefaultSerializerTests method testDurationDeserialization.

@Test
public void testDurationDeserialization() {
    final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
    final String source = "{\"streamId\": \"2101\",\"startDateTime\": null,\"endDateTime\": null,\"streamDirection\": \"calleeToCaller\",\"averageAudioDegradation\": null,\"averageJitter\": \"PT0.004S\",\"maxJitter\": \"PT0.007S\",\"averagePacketLossRate\": 0,\"maxPacketLossRate\": 0,\"averageRatioOfConcealedSamples\": 0,\"maxRatioOfConcealedSamples\": null,\"averageRoundTripTime\": \"PT0.024S\",\"maxRoundTripTime\": \"PT0.05S\",\"packetUtilization\": 471,\"averageBandwidthEstimate\": 1174971,\"wasMediaBypassed\": null,\"postForwardErrorCorrectionPacketLossRate\": null,\"averageVideoFrameLossPercentage\": null,\"averageReceivedFrameRate\": null,\"lowFrameRateRatio\": null,\"averageVideoPacketLossRate\": null,\"averageVideoFrameRate\": null,\"lowVideoProcessingCapabilityRatio\": null,\"averageAudioNetworkJitter\": \"PT0.014S\",\"maxAudioNetworkJitter\": \"PT0.022S\"}";
    final MediaStream result = serializer.deserializeObject(source, MediaStream.class);
    assertNotNull(result);
    assertNotNull(result.maxRoundTripTime);
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) MediaStream(com.microsoft.graph.callrecords.models.MediaStream) DefaultLogger(com.microsoft.graph.logger.DefaultLogger) Test(org.junit.jupiter.api.Test)

Example 34 with DefaultSerializer

use of com.microsoft.graph.serializer.DefaultSerializer in project msgraph-sdk-java by microsoftgraph.

the class PlannerTests method testPlannerTaskDetailsDeserialization.

@Test
public void testPlannerTaskDetailsDeserialization() {
    String input = "{\r\n" + "	\"references\": {},\r\n" + "	\"@odata.etag\": \"W/\\\"JzEtVGFza0RldGFpbHMgQEBAQEBAQEBAQEBAQEBAUCc=\\\"\",\r\n" + "	\"description\": null,\r\n" + "	\"checklist\": {\r\n" + "		\"42660\": {\r\n" + "			\"lastModifiedDateTime\": \"2018-10-28T14:29:37.7423391Z\",\r\n" + "			\"@odata.type\": \"#microsoft.graph.plannerChecklistItem\",\r\n" + "			\"orderHint\": \"8586608699726429822PK\",\r\n" + "			\"lastModifiedBy\": {\r\n" + "				\"user\": {\r\n" + "					\"displayName\": null,\r\n" + "					\"id\": \"f3a1dfe8-f2ef-4870-9642-413d468c571c\"\r\n" + "				}\r\n" + "			},\r\n" + "			\"title\": \"Ein Checklisteneintrag\",\r\n" + "			\"isChecked\": false\r\n" + "		}\r\n" + "	},\r\n" + "	\"@odata.context\": \"https://graph.microsoft.com/v1.0/$metadata#planner/tasks('C6iIn6oJcEGcLX5XAiKeCZcAOv30')/details/$entity\",\r\n" + "	\"previewType\": \"automatic\",\r\n" + "	\"id\": \"C6iIn6oJcEGcLX5XAiKeCZcAOv30\"\r\n" + "}";
    final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
    PlannerTaskDetails ptd = serializer.deserializeObject(input, PlannerTaskDetails.class);
    assertNotNull(ptd);
    PlannerChecklistItem item = ptd.checklist.get("42660");
    assertEquals(item.title, "Ein Checklisteneintrag");
    assertEquals(item.isChecked, false);
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) PlannerTaskDetails(com.microsoft.graph.models.PlannerTaskDetails) PlannerChecklistItem(com.microsoft.graph.models.PlannerChecklistItem) DefaultLogger(com.microsoft.graph.logger.DefaultLogger) Test(org.junit.jupiter.api.Test)

Example 35 with DefaultSerializer

use of com.microsoft.graph.serializer.DefaultSerializer in project msgraph-sdk-java by microsoftgraph.

the class CollectionPageSerializerTests method testEntityCollectionWithSingleValueExtendedProperties.

@Test
public void testEntityCollectionWithSingleValueExtendedProperties() throws Exception {
    final String jsonString = "{\"@odata.context\": \"https://graph.microsoft.com/v1.0/$metadata#users('c2e8df37-c6a7-4d88-89b1-feb4f1fda7c5')/events\",\"@odata.nextLink\": \"https://graph.microsoft.com/v1.0/me/events?$skip=10\",\"value\": [{\"@odata.context\": \"https://graph.microsoft.com/v1.0/$metadata#Me/messages/$entity\",\"@odata.id\": \"https://graph.microsoft.com/v1.0/users('ddfcd489-628b-40d7-b48b-57002df800e5@1717622f-1d94-4d0c-9d74-709fad664b77')/messages('AAMkAGE1M2_bs88AACHsLqWAAA=')\",\"@odata.etag\": \"W/\\\"CQAAABYAAACY4MQpaFz9SbqUDe4+bs88AACbyS4H\\\"\",\"id\": \"AAMkAGE1M2_bs88AACHsLqWAAA=\",\"subject\": \"RE: Talk about emergency prep\",\"sender\": {\"emailAddress\": {\"name\": \"Christine Irwin\",\"address\": \"christine@contoso.com\"}},\"from\": null,\"toRecipients\": [{\"emailAddress\": {\"name\": \"Christine Irwin\",\"address\": \"christine@contoso.com\"}}],\"singleValueExtendedProperties@odata.context\": \"https://graph.microsoft.com/v1.0/$metadata#Me/messages('AAMkAGE1M2_bs88AACHsLqWAAA%3D')/singleValueExtendedProperties\",\"singleValueExtendedProperties\": [{\"id\": \"String {66f5a359-4659-4830-9070-00047ec6ac6e} Name Color\",\"value\": \"Green\"}]}]}";
    final DefaultSerializer defaultSerializer = new DefaultSerializer(logger);
    final EventCollectionResponse events = defaultSerializer.deserializeObject(jsonString, EventCollectionResponse.class);
    assertNotNull(events);
    assertTrue(events.value.get(0).singleValueExtendedProperties.getCurrentPage().size() > 0);
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) EventCollectionResponse(com.microsoft.graph.requests.EventCollectionResponse) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultSerializer (com.microsoft.graph.serializer.DefaultSerializer)59 Test (org.junit.jupiter.api.Test)54 DefaultLogger (com.microsoft.graph.logger.DefaultLogger)32 IHttpRequest (com.microsoft.graph.http.IHttpRequest)6 URL (java.net.URL)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 ILogger (com.microsoft.graph.logger.ILogger)5 JsonElement (com.google.gson.JsonElement)4 MediaStream (com.microsoft.graph.callrecords.models.MediaStream)4 GraphErrorResponse (com.microsoft.graph.http.GraphErrorResponse)4 PlannerChecklistItem (com.microsoft.graph.models.PlannerChecklistItem)4 PlannerTaskDetails (com.microsoft.graph.models.PlannerTaskDetails)4 RecurrenceRange (com.microsoft.graph.models.RecurrenceRange)4 User (com.microsoft.graph.models.User)4 ISerializer (com.microsoft.graph.serializer.ISerializer)4 GraphServiceException (com.microsoft.graph.http.GraphServiceException)3 OkHttpClient (okhttp3.OkHttpClient)3 Request (okhttp3.Request)3 JsonObject (com.google.gson.JsonObject)2 DateOnly (com.microsoft.graph.core.DateOnly)2