Search in sources :

Example 46 with DefaultSerializer

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

the class DefaultSerializerTests method testDeserializeDerivedType.

@Test
public void testDeserializeDerivedType() throws Exception {
    final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
    final 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\"}";
    final Attachment result = serializer.deserializeObject(source, Attachment.class);
    assert (result instanceof FileAttachment);
    final FileAttachment fileAttachment = (FileAttachment) result;
    assertNotNull(fileAttachment.contentBytes);
    assertEquals("#microsoft.graph.fileAttachment", fileAttachment.oDataType);
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) FileAttachment(com.microsoft.graph.models.FileAttachment) Attachment(com.microsoft.graph.models.Attachment) FileAttachment(com.microsoft.graph.models.FileAttachment) DefaultLogger(com.microsoft.graph.logger.DefaultLogger) Test(org.junit.jupiter.api.Test)

Example 47 with DefaultSerializer

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

the class DefaultSerializerTests method testDoubleDeserialization.

@Test
public void testDoubleDeserialization() {
    final DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
    final String source = " [{\"streamId\": \"12976\",\"startDateTime\": null,\"endDateTime\": null,\"streamDirection\": \"callerToCallee\",\"averageAudioDegradation\": null,\"averageJitter\": null,\"maxJitter\": null,\"averagePacketLossRate\": null,\"maxPacketLossRate\": null,\"averageRatioOfConcealedSamples\": null,\"maxRatioOfConcealedSamples\": null,\"averageRoundTripTime\": null,\"maxRoundTripTime\": null,\"packetUtilization\": 0,\"averageBandwidthEstimate\": null,\"wasMediaBypassed\": null,\"postForwardErrorCorrectionPacketLossRate\": null,\"averageVideoFrameLossPercentage\": null,\"averageReceivedFrameRate\": null,\"lowFrameRateRatio\": null,\"averageVideoPacketLossRate\": null,\"averageVideoFrameRate\": null,\"lowVideoProcessingCapabilityRatio\": null,\"averageAudioNetworkJitter\": null,\"maxAudioNetworkJitter\": null},{\"streamId\": \"3303\",\"startDateTime\": null,\"endDateTime\": null,\"streamDirection\": \"calleeToCaller\",\"averageAudioDegradation\": null,\"averageJitter\": \"PT0S\",\"maxJitter\": \"PT0S\",\"averagePacketLossRate\": 0,\"maxPacketLossRate\": 0,\"averageRatioOfConcealedSamples\": null,\"maxRatioOfConcealedSamples\": null,\"averageRoundTripTime\": \"PT0.02S\",\"maxRoundTripTime\": \"PT0.02S\",\"packetUtilization\": 1184,\"averageBandwidthEstimate\": null,\"wasMediaBypassed\": null,\"postForwardErrorCorrectionPacketLossRate\": 0,\"averageVideoFrameLossPercentage\": 0,\"averageReceivedFrameRate\": null,\"lowFrameRateRatio\": 0,\"averageVideoPacketLossRate\": null,\"averageVideoFrameRate\": 25.6,\"lowVideoProcessingCapabilityRatio\": null,\"averageAudioNetworkJitter\": null,\"maxAudioNetworkJitter\": null}]";
    final MediaStream[] result = serializer.deserializeObject(source, MediaStream[].class);
    assertNotNull(result);
    assertNotNull(result[0]);
    assertNotNull(result[1]);
    assertNull(result[0].averagePacketLossRate);
    assertEquals(0f, result[1].averagePacketLossRate, 0f);
}
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 48 with DefaultSerializer

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

the class CollectionPageSerializerTests method testEntityWithCollectionOfMultipleTypes.

@Test
public void testEntityWithCollectionOfMultipleTypes() throws Exception {
    final String jsonString = "{\"@odata.context\": \"https://graph.microsoft.com/v1.0/$metadata#groups/$entity\",\"id\": \"01b4b70e-2ea6-432f-a3d7-eefd826c2a8e\",\"deletedDateTime\": null,\"classification\": null,\"createdDateTime\": \"2019-11-23T15:48:33Z\",\"creationOptions\": [],\"description\": \"wovinewovinewvoinwev\",\"displayName\": \"Toronto Basketball Raptors\",\"expirationDateTime\": null,\"groupTypes\": [\"Unified\"],\"isAssignableToRole\": null,\"mail\": \"TBR@contoso.onmicrosoft.com\",\"mailEnabled\": true,\"mailNickname\": \"TBR\",\"membershipRule\": null,\"membershipRuleProcessingState\": null,\"onPremisesDomainName\": null,\"onPremisesLastSyncDateTime\": null,\"onPremisesNetBiosName\": null,\"onPremisesSamAccountName\": null,\"onPremisesSecurityIdentifier\": null,\"onPremisesSyncEnabled\": null,\"preferredDataLocation\": null,\"preferredLanguage\": null,\"proxyAddresses\": [\"SPO:SPO_c0b1d860-d3d3-444c-98ee-c34365caa414@SPO_bd4c6c31-c49c-4ab6-a0aa-742e07c20232\",\"SMTP:TBR@contoso.onmicrosoft.com\"],\"renewedDateTime\": \"2019-11-23T15:48:33Z\",\"resourceBehaviorOptions\": [],\"resourceProvisioningOptions\": [\"Team\"],\"securityEnabled\": false,\"securityIdentifier\": \"S-1-12-1-28620558-1127165606-4260288419-2385144962\",\"theme\": null,\"visibility\": \"Private\",\"onPremisesProvisioningErrors\": [],\"members\": [{\"@odata.type\": \"#microsoft.graph.user\",\"id\": \"c2e8df37-c6a7-4d88-89b1-feb4f1fda7c5\",\"businessPhones\": [\"4388888888\"],\"displayName\": \"Vincent Biret\",\"givenName\": \"Vincent\",\"jobTitle\": null,\"mail\": \"vincent@contoso.onmicrosoft.com\",\"mobilePhone\": \"+1 4388888888\",\"officeLocation\": \"Quebec\",\"preferredLanguage\": \"en-US\",\"surname\": \"Biret\",\"userPrincipalName\": \"vincent@contoso.onmicrosoft.com\"},{\"@odata.type\": \"#microsoft.graph.servicePrincipal\",\"id\": \"004ea702-a572-4f1b-8bb0-74598985e0c0\",\"deletedDateTime\": null,\"accountEnabled\": true,\"alternativeNames\": [],\"appDisplayName\": \"OCPS Checkin Service\",\"appDescription\": null,\"appId\": \"23c898c1-f7e8-41da-9501-f16571f8d097\",\"applicationTemplateId\": null,\"appOwnerOrganizationId\": \"f8cdef31-a31e-4b4a-93e4-5f571e91255a\",\"appRoleAssignmentRequired\": false,\"createdDateTime\": \"2018-11-13T02:28:32Z\",\"description\": null,\"displayName\": \"OCPS Checkin Service\",\"homepage\": null,\"loginUrl\": null,\"logoutUrl\": null,\"notes\": null,\"notificationEmailAddresses\": [],\"preferredSingleSignOnMode\": null,\"preferredTokenSigningKeyThumbprint\": null,\"replyUrls\": [\"https://ocps.manage.microsoft.com\"],\"resourceSpecificApplicationPermissions\": [],\"samlSingleSignOnSettings\": null,\"servicePrincipalNames\": [\"23c898c1-f7e8-41da-9501-f16571f8d097\",\"https://ocps.manage.microsoft.com\"],\"servicePrincipalType\": \"Application\",\"tags\": [],\"tokenEncryptionKeyId\": null,\"verifiedPublisher\": {\"displayName\": null,\"verifiedPublisherId\": null,\"addedDateTime\": null},\"addIns\": [],\"appRoles\": [],\"info\": {\"logoUrl\": null,\"marketingUrl\": null,\"privacyStatementUrl\": null,\"supportUrl\": null,\"termsOfServiceUrl\": null},\"keyCredentials\": [],\"oauth2PermissionScopes\": [],\"passwordCredentials\": []}]}";
    final DefaultSerializer defaultSerializer = new DefaultSerializer(logger);
    final Group group = defaultSerializer.deserializeObject(jsonString, Group.class);
    assertNotNull(group);
    assertNotNull(group.members);
    final List<DirectoryObject> page = group.members.getCurrentPage();
    assertTrue(page.size() == 2);
    assertTrue(page.get(0) instanceof User);
    assertTrue(page.get(1) instanceof ServicePrincipal);
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) Group(com.microsoft.graph.models.Group) User(com.microsoft.graph.models.User) ServicePrincipal(com.microsoft.graph.models.ServicePrincipal) DirectoryObject(com.microsoft.graph.models.DirectoryObject) Test(org.junit.jupiter.api.Test)

Example 49 with DefaultSerializer

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

the class CollectionPageSerializerTests method testEntityWithCollectionOnDefaultDeserializer.

@Test
public void testEntityWithCollectionOnDefaultDeserializer() throws Exception {
    final String jsonString = "{\"createdBy\":{\"application\":{\"displayName\":\"UmtPlus\",\"id\":\"4458250c\"},\"user\":{\"id\":\"c1fba35378bf924c\"}},\"createdDateTime\":\"2020-09-16T14:53:53.61Z\",\"cTag\":\"aYzpDMUZCQTM1Mzc4QkY5MjRDITIzNDkyNS4yNTc\",\"eTag\":\"aQzFGQkEzNTM3OEJGOTI0QyEyMzQ5MjUuMTE\",\"id\":\"C1FBA35378BF924C!234925\",\"lastModifiedBy\":{\"application\":{\"displayName\":\"UmtPlus\",\"id\":\"4458250c\"},\"user\":{\"id\":\"c1fba35378bf924c\"}},\"lastModifiedDateTime\":\"2020-09-16T17:42:17.847Z\",\"name\":\"Change Flat Tire.sco\",\"parentReference\":{\"driveId\":\"c1fba35378bf924c\",\"driveType\":\"personal\",\"id\":\"C1FBA35378BF924C!234867\",\"name\":\"UmtPlus\",\"path\":\"/drive/root:/UmtPlus\"},\"size\":59228,\"webUrl\":\"https://1drv.ms/u/s!AEySv3hTo_vBjqst\",\"items\":[],\"file\":{\"hashes\":{\"quickXorHash\":\"RjqF6zG7yzMKxLlRmXkKr0tK7oQ=\",\"sha1Hash\":\"A7A1DB7C7355A372E6097C5BD7DF6CF702AFA897\",\"sha256Hash\":\"97EF73D523368EE939D084F87DE22E28BD9236CC55D6A67EE69183FFC456CA08\"},\"mimeType\":\"application/octet-stream\"},\"fileSystemInfo\":{\"createdDateTime\":\"2020-09-16T14:53:53.61Z\",\"lastModifiedDateTime\":\"2020-09-16T17:42:17.846Z\"},\"reactions\":{\"commentCount\":0},\"tags\":[],\"lenses\":[],\"thumbnails\":[{\"id\":\"0\",\"large\":{\"height\":800,\"url\":\"https://oxo45g.bl.files.1drv.com/y4pi3j1XhJr0-LmucbMAY7erAc5yeeX8yXaxUqk7p5O1mYVUMnRmzIeFC8LgpZLXCNFkFfVzt_PlChpIBL2VwTp9bdXVToVWsHRKC5MmEiO4Zv3eR9_JCc2ih4jstMbx6AusvkIpCW7FEpWWSeyFQEJR0jbaNNZSs_n6Ryrio2xYl9LhINf19-xYBxVCR4kV188?width=800&height=800&cropmode=none\",\"width\":800},\"medium\":{\"height\":176,\"url\":\"https://oxo45g.bl.files.1drv.com/y4pi3j1XhJr0-LmucbMAY7erAc5yeeX8yXaxUqk7p5O1mYVUMnRmzIeFC8LgpZLXCNFkFfVzt_PlChpIBL2VwTp9bdXVToVWsHRKC5MmEiO4Zv3eR9_JCc2ih4jstMbx6AusvkIpCW7FEpWWSeyFQEJR0jbaNNZSs_n6Ryrio2xYl9LhINf19-xYBxVCR4kV188?width=176&height=176&cropmode=none\",\"width\":176},\"small\":{\"height\":96,\"url\":\"https://oxo45g.bl.files.1drv.com/y4pi3j1XhJr0-LmucbMAY7erAc5yeeX8yXaxUqk7p5O1mYVUMnRmzIeFC8LgpZLXCNFkFfVzt_PlChpIBL2VwTp9bdXVToVWsHRKC5MmEiO4Zv3eR9_JCc2ih4jstMbx6AusvkIpCW7FEpWWSeyFQEJR0jbaNNZSs_n6Ryrio2xYl9LhINf19-xYBxVCR4kV188?width=96&height=96&cropmode=none\",\"width\":96}}]}";
    final DefaultSerializer defaultSerializer = new DefaultSerializer(logger);
    final DriveItem driveItem = defaultSerializer.deserializeObject(jsonString, DriveItem.class);
    assertNotNull(driveItem);
    assertNotNull(driveItem.thumbnails);
    assertTrue(driveItem.thumbnails.getCurrentPage().size() > 0);
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) DriveItem(com.microsoft.graph.models.DriveItem) Test(org.junit.jupiter.api.Test)

Example 50 with DefaultSerializer

use of com.microsoft.graph.serializer.DefaultSerializer in project msgraph-beta-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