-
Notifications
You must be signed in to change notification settings - Fork 293
Implement the GET verb for FindById operation for MsSql #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
9f94124
Add a RestController
Aniruddh25 9e5bf89
Add a RestService
Aniruddh25 fa237e0
Add a RequestParser
Aniruddh25 3aa95bd
Add a QueryStructure
Aniruddh25 e5d23b0
Add new apis to QueryEngine and QueryBuilder to build query using Que…
Aniruddh25 99cfb17
Rename to FindQueryStructure
Aniruddh25 e989102
Fix route
Aniruddh25 3687547
Default initialize lists and dictionaries
Aniruddh25 8791d2f
Use * by default for fields, and quoteidentifier
Aniruddh25 918c308
Fix compilation issues
Aniruddh25 ff1aaba
Add Build for Postgres
Aniruddh25 ad63a6f
Add validation functions
Aniruddh25 fd3d39c
RequestParser has static functions
Aniruddh25 d63fb14
Add a RestService
Aniruddh25 94ae193
Add placeholder for CosmosQueryEngine
Aniruddh25 db2454e
Add comments to controller
Aniruddh25 e24880d
Add comments to MsSqlQueryBuilder
Aniruddh25 f236f0f
Add comments for the QueryEngine
Aniruddh25 bcd10a2
Add comments to RestService
Aniruddh25 21a74cb
Fix comments
Aniruddh25 29f0533
Add summary comment to RequestParser
Aniruddh25 d814132
Merge from origin main
Aniruddh25 45657c9
Add databasename to the route
Aniruddh25 798df01
Rename to primaryKeyRoute
Aniruddh25 efadbbe
Add MsSqlRestApiTests and base class MsSqlTestBase
Aniruddh25 7d8a07d
Fix the tests to use separate table name
Aniruddh25 f14f007
Fix formatting
Aniruddh25 105d640
Make sure any changes to the appsettings are reflected in the Functio…
Aniruddh25 f67f680
remove empty comment line
Aniruddh25 86335ae
Make sure Rest works from Functions project too
Aniruddh25 74f4cc4
Address PR comments
Aniruddh25 216f7aa
Remove RestApis from functions project since code duplication became …
Aniruddh25 fa8838a
Be explicit about FindMany not yet supported
Aniruddh25 515b406
Keep separate test for FindByIdTestWithQueryField
Aniruddh25 a403aaf
Add more explanation to summary comments
Aniruddh25 0f6cf3c
Add a negative test for null field name
Aniruddh25 df64083
Merge origin/main
Aniruddh25 9bbd7b0
Fix order of using
Aniruddh25 8f302f0
Fix system using
Aniruddh25 d78620f
Fix order of imports
Aniruddh25 89de05e
Fix order of imports
Aniruddh25 295c666
Services comes after Service.Resolvers
Aniruddh25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
DataGateway.Service.Tests/MsSqlTests/MsSqlGraphQLQueryTests.cs
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| using System.Text.Json; | ||
| using System.Threading.Tasks; | ||
| using Azure.DataGateway.Service.Controllers; | ||
| using Azure.DataGateway.Services; | ||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
|
||
| namespace Azure.DataGateway.Service.Tests.MsSql | ||
| { | ||
| /// <summary> | ||
| /// Test GraphQL Queries validating proper resolver/engine operation. | ||
| /// </summary> | ||
| [TestClass, TestCategory(TestCategory.MSSQL)] | ||
| public class MsSqlGraphQLQueryTests : MsSqlTestBase | ||
| { | ||
| #region Test Fixture Setup | ||
| private static GraphQLService _graphQLService; | ||
| private static GraphQLController _graphQLController; | ||
| private static readonly string _integrationTableName = "character"; | ||
|
|
||
| /// <summary> | ||
| /// Sets up test fixture for class, only to be run once per test run, as defined by | ||
| /// MSTest decorator. | ||
| /// </summary> | ||
| /// <param name="context"></param> | ||
| [ClassInitialize] | ||
| public static void InitializeTestFixture(TestContext context) | ||
| { | ||
| InitializeTestFixture(context, _integrationTableName); | ||
|
|
||
| // Setup GraphQL Components | ||
| // | ||
| _graphQLService = new GraphQLService(_queryEngine, mutationEngine: null, _metadataStoreProvider); | ||
| _graphQLController = new GraphQLController(_graphQLService); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Cleans up querying table used for Tests in this class. Only to be run once at | ||
| /// conclusion of test run, as defined by MSTest decorator. | ||
| /// </summary> | ||
| [ClassCleanup] | ||
| public static void CleanupTestFixture() | ||
| { | ||
| CleanupTestFixture(_integrationTableName); | ||
Aniruddh25 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| #endregion | ||
|
|
||
| #region Tests | ||
| /// <summary> | ||
| /// Gets result of quering singular object | ||
| /// </summary> | ||
| /// <returns></returns> | ||
| [TestMethod] | ||
| public async Task SingleResultQuery() | ||
| { | ||
| string graphQLQueryName = "characterById"; | ||
| string graphQLQuery = "{\"query\":\"{\\n characterById(id:2){\\n name\\n primaryFunction\\n}\\n}\\n\"}"; | ||
| string msSqlQuery = $"SELECT name, primaryFunction FROM { _integrationTableName } WHERE id = 2 FOR JSON PATH, INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER"; | ||
|
|
||
| string actual = await GetGraphQLResultAsync(graphQLQuery, graphQLQueryName); | ||
| string expected = await GetDatabaseResultAsync(msSqlQuery); | ||
|
|
||
| Assert.AreEqual(actual, expected); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets array of results for querying more than one item. | ||
| /// </summary> | ||
| /// <returns></returns> | ||
| [TestMethod] | ||
| public async Task MultipleResultQuery() | ||
| { | ||
| string graphQLQueryName = "characterList"; | ||
| string graphQLQuery = "{\"query\":\"{\\n characterList {\\n name\\n primaryFunction\\n }\\n}\\n\"}"; | ||
| string msSqlQuery = $"SELECT name, primaryFunction FROM character FOR JSON PATH, INCLUDE_NULL_VALUES"; | ||
|
|
||
| string actual = await GetGraphQLResultAsync(graphQLQuery, graphQLQueryName); | ||
| string expected = await GetDatabaseResultAsync(msSqlQuery); | ||
|
|
||
| Assert.AreEqual(actual, expected); | ||
| } | ||
|
|
||
| #endregion | ||
|
|
||
| #region Query Test Helper Functions | ||
| /// <summary> | ||
| /// Sends graphQL query through graphQL service, consisting of gql engine processing (resolvers, object serialization) | ||
| /// returning JSON formatted result from 'data' property. | ||
| /// </summary> | ||
| /// <param name="graphQLQuery"></param> | ||
| /// <param name="graphQLQueryName"></param> | ||
| /// <returns>string in JSON format</returns> | ||
| public static async Task<string> GetGraphQLResultAsync(string graphQLQuery, string graphQLQueryName) | ||
| { | ||
| _graphQLController.ControllerContext.HttpContext = MsSqlTestBase.GetHttpContextWithBody(graphQLQuery); | ||
| JsonDocument graphQLResult = await _graphQLController.PostAsync(); | ||
| JsonElement graphQLResultData = graphQLResult.RootElement.GetProperty("data").GetProperty(graphQLQueryName); | ||
| return graphQLResultData.ToString(); | ||
| } | ||
|
|
||
| #endregion | ||
| } | ||
| } | ||
180 changes: 0 additions & 180 deletions
180
DataGateway.Service.Tests/MsSqlTests/MsSqlQueryTests.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.