Search in sources :

Example 1 with UserActivity

use of com.microsoft.graph.models.UserActivity in project msgraph-sdk-java by microsoftgraph.

the class CustomRequestTests method testCustomPut.

/**
 * Test PUT with a custom request for both serialized and JSON content
 */
@Test
public void testCustomPut() {
    DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
    String str = "{ \"appActivityId\": \"/article?12345\", \"activitySourceHost\": \"https://www.contoso.com\", \"userTimezone\": \"Africa/Casablanca\"," + " \"appDisplayName\": \"Contoso, Ltd.\", \"activationUrl\": \"https://www.contoso.com/article?id=12345\", \"contentUrl\": \"https://www.contoso.com/article?id=12345\", " + "\"fallbackUrl\": \"https://www.contoso.com/article?id=12345\", \"contentInfo\": { \"@context\": \"https://schema.org\", \"@type\": \"Article\", \"author\": \"Jennifer Booth\", " + "\"name\": \"How to Tie a Reef Knot\" }, \"visualElements\": { \"attribution\": { \"iconUrl\": \"https://www.contoso.com/icon\", \"alternateText\": \"Contoso, Ltd.\", " + "\"addImageQuery\": false }, \"description\": \"How to Tie a Reef Knot. A step-by-step visual guide to the art of nautical knot-tying.\", \"backgroundColor\": \"#ff0000\"," + " \"displayText\": \"Contoso How-To: How to Tie a Reef Knot\", \"content\": { \"$schema\": \"https://adaptivecards.io/schemas/adaptive-card.json\", \"type\": \"AdaptiveCard\"," + " \"body\": [{ \"type\": \"TextBlock\", \"text\": \"Contoso MainPage\" }] } } }";
    JsonObject response = testBase.graphClient.customRequest("/me/activities/%2Farticle%3F12346").buildRequest().put(JsonParser.parseString(str).getAsJsonObject()).getAsJsonObject();
    UserActivity userActivity = serializer.deserializeObject(str, UserActivity.class);
    UserActivity responseWithClass = testBase.graphClient.customRequest("/me/activities/2", UserActivity.class).buildRequest().put(userActivity);
    assertNotNull(response);
    assertNotNull(responseWithClass);
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) JsonObject(com.google.gson.JsonObject) UserActivity(com.microsoft.graph.models.UserActivity) DefaultLogger(com.microsoft.graph.logger.DefaultLogger) Test(org.junit.jupiter.api.Test)

Example 2 with UserActivity

use of com.microsoft.graph.models.UserActivity in project msgraph-beta-sdk-java by microsoftgraph.

the class CustomRequestTests method testCustomPut.

/**
 * Test PUT with a custom request for both serialized and JSON content
 */
@Test
public void testCustomPut() {
    DefaultSerializer serializer = new DefaultSerializer(new DefaultLogger());
    String str = "{ \"appActivityId\": \"/article?12345\", \"activitySourceHost\": \"https://www.contoso.com\", \"userTimezone\": \"Africa/Casablanca\"," + " \"appDisplayName\": \"Contoso, Ltd.\", \"activationUrl\": \"https://www.contoso.com/article?id=12345\", \"contentUrl\": \"https://www.contoso.com/article?id=12345\", " + "\"fallbackUrl\": \"https://www.contoso.com/article?id=12345\", \"contentInfo\": { \"@context\": \"https://schema.org\", \"@type\": \"Article\", \"author\": \"Jennifer Booth\", " + "\"name\": \"How to Tie a Reef Knot\" }, \"visualElements\": { \"attribution\": { \"iconUrl\": \"https://www.contoso.com/icon\", \"alternateText\": \"Contoso, Ltd.\", " + "\"addImageQuery\": false }, \"description\": \"How to Tie a Reef Knot. A step-by-step visual guide to the art of nautical knot-tying.\", \"backgroundColor\": \"#ff0000\"," + " \"displayText\": \"Contoso How-To: How to Tie a Reef Knot\", \"content\": { \"$schema\": \"https://adaptivecards.io/schemas/adaptive-card.json\", \"type\": \"AdaptiveCard\"," + " \"body\": [{ \"type\": \"TextBlock\", \"text\": \"Contoso MainPage\" }] } } }";
    JsonObject response = testBase.graphClient.customRequest("/me/activities/%2Farticle%3F12346").buildRequest().put(JsonParser.parseString(str).getAsJsonObject()).getAsJsonObject();
    UserActivity userActivity = serializer.deserializeObject(str, UserActivity.class);
    UserActivity responseWithClass = testBase.graphClient.customRequest("/me/activities/2", UserActivity.class).buildRequest().put(userActivity);
    assertNotNull(response);
    assertNotNull(responseWithClass);
}
Also used : DefaultSerializer(com.microsoft.graph.serializer.DefaultSerializer) JsonObject(com.google.gson.JsonObject) UserActivity(com.microsoft.graph.models.UserActivity) DefaultLogger(com.microsoft.graph.logger.DefaultLogger) Test(org.junit.jupiter.api.Test)

Aggregations

JsonObject (com.google.gson.JsonObject)2 DefaultLogger (com.microsoft.graph.logger.DefaultLogger)2 UserActivity (com.microsoft.graph.models.UserActivity)2 DefaultSerializer (com.microsoft.graph.serializer.DefaultSerializer)2 Test (org.junit.jupiter.api.Test)2