-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #504 from microsoftgraph/dev
api release for java v3
- Loading branch information
Showing
5 changed files
with
167 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ public class JavaGeneratorShould | |
{ | ||
private const string ServiceRootUrl = "https://graph.microsoft.com/v1.0"; | ||
private readonly IEdmModel _edmModel = CsdlReader.Parse(XmlReader.Create(CommonGeneratorShould.CleanV1Metadata)); | ||
private const string AuthProviderPrefix = "IGraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();\r\n\r\n"; | ||
private const string AuthProviderPrefix = "GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();\r\n\r\n"; | ||
|
||
[Fact] | ||
public void MapCorrectTypeForGuidReturnType() | ||
|
@@ -116,7 +116,7 @@ public void MapCorrectTypeForDateTimeProperties() | |
//Act by generating the code snippet | ||
var result = new JavaGenerator(_edmModel).GenerateCodeSnippet(snippetModel, expressions); | ||
|
||
Assert.Contains(" CalendarSerializer.deserialize(\"datetime-value\")", result); | ||
Assert.Contains(" OffsetDateTimeSerializer.deserialize(\"datetime-value\")", result); | ||
} | ||
[Fact] | ||
public void MapCorrectTypeForDoubleProperties() | ||
|
@@ -495,7 +495,7 @@ public void GeneratesSnippetsWithQueryOptions() | |
"requestOptions.add(new QueryOption(\"startDateTime\", \"2017-01-01T19:00:00.0000000\"));\r\n" + //Query Options present | ||
"requestOptions.add(new QueryOption(\"endDateTime\", \"2017-01-07T19:00:00.0000000\"));\r\n" + //Query Options present | ||
"\r\n" + | ||
"IEventCollectionPage calendarView = graphClient.me().calendar().calendarView()\r\n" + | ||
"EventCollectionPage calendarView = graphClient.me().calendar().calendarView()\r\n" + | ||
"\t.buildRequest( requestOptions )\r\n" + | ||
"\t.get();"; | ||
|
||
|
@@ -667,7 +667,10 @@ public void GeneratesSnippetsForOdataActionsWithParameters() | |
|
||
//Assert code snippet string matches expectation | ||
const string expectedSnippet = "WorkbookRange workbookRange = graphClient.me().drive().items(\"{id}\").workbook().worksheets(\"{id|name}\")\r\n" + | ||
"\t.range(\"A1:B2\")\r\n" +//parameter has double quotes | ||
"\t.range(WorkbookWorksheetRangeParameterSet\r\n" + | ||
"\t\t.newBuilder()\r\n" + | ||
"\t\t.withAddress(\"A1:B2\")\r\n" + | ||
"\t\t.build())\r\n" +//parameter has double quotes | ||
"\t.buildRequest()\r\n" + | ||
"\t.get();"; | ||
|
||
|
@@ -701,7 +704,11 @@ public void GeneratesSnippetsWithOptionalParametersInCorrectOrder() | |
"Boolean hasHeaders = true;\r\n" + | ||
"\r\n" + | ||
"graphClient.me().drive().items(\"{id}\").workbook().tables()\r\n" + | ||
"\t.add(address,hasHeaders)\r\n" + | ||
"\t.add(WorkbookTableAddParameterSet\r\n" + | ||
"\t\t.newBuilder()\r\n" + | ||
"\t\t.withAddress(address)\r\n" + | ||
"\t\t.withHasHeaders(hasHeaders)\r\n" + | ||
"\t\t.build())\r\n" + | ||
"\t.buildRequest()\r\n" + | ||
"\t.post();"; | ||
|
||
|
@@ -1077,5 +1084,50 @@ public void GenerateProfilePicture() | |
var result = new JavaGenerator(_edmModel).GenerateCodeSnippet(snippetModel, expressions); | ||
Assert.Contains("byte[]", result); | ||
} | ||
[Fact] | ||
public void NotIncludeParenthesisInIdentifiers() | ||
{ | ||
LanguageExpressions expressions = new JavaExpressions(); | ||
const string jsonObject = "{" + | ||
"\"value\":" + | ||
"[" + | ||
"{" + | ||
"\"id\": \"contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,712a596e-90a1-49e3-9b48-bfa80bee8740\"" + | ||
"}," + | ||
"{" + | ||
"\"id\": \"contoso.sharepoint.com,da60e844-ba1d-49bc-b4d4-d5e36bae9019,0271110f-634f-4300-a841-3a8a2e851851\"" + | ||
"}" + | ||
"] " + | ||
"}"; | ||
|
||
var requestPayload = | ||
new HttpRequestMessage(HttpMethod.Post, "https://graph.microsoft.com/v1.0/users/{user-id}/followedSites/add") | ||
{ | ||
Content = new StringContent(jsonObject) | ||
}; | ||
var snippetModel = new SnippetModel(requestPayload, ServiceRootUrl, _edmModel); | ||
var result = new JavaGenerator(_edmModel).GenerateCodeSnippet(snippetModel, expressions); | ||
Assert.DoesNotContain("Site(Add", result);// in case it's a collection we need to trim the ) at the end of the type name | ||
} | ||
[Fact] | ||
public void UseTheRightTypePrefixForParameterSets() { | ||
LanguageExpressions expressions = new JavaExpressions(); | ||
const string jsonObject = "{" + | ||
"\"EmailAddresses\": [" + | ||
"\"[email protected]\", " + | ||
"\"[email protected]\"" + | ||
"]," + | ||
"\"MailTipsOptions\": \"automaticReplies, mailboxFullStatus\"" + | ||
"}"; | ||
|
||
var requestPayload = | ||
new HttpRequestMessage(HttpMethod.Post, "https://graph.microsoft.com/v1.0/me/getMailTips") | ||
{ | ||
Content = new StringContent(jsonObject) | ||
}; | ||
var snippetModel = new SnippetModel(requestPayload, ServiceRootUrl, _edmModel); | ||
var result = new JavaGenerator(_edmModel).GenerateCodeSnippet(snippetModel, expressions); | ||
Assert.Contains("UserGetMailTipsParameterSet", result); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.