Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion config-generators/dwsql-commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ add Notebook --config "dab-config.DwSql.json" --source "notebooks" --permissions
add Journal --config "dab-config.DwSql.json" --source "journals" --rest true --graphql true --permissions "policy_tester_noupdate:create,delete" --source.key-fields "id"
add ArtOfWar --config "dab-config.DwSql.json" --source "aow" --rest true --graphql false --permissions "anonymous:*" --source.key-fields "NoteNum"
add stocks_view_selected --config "dab-config.DwSql.json" --source stocks_view_selected --source.type "view" --source.key-fields "categoryid,pieceid" --permissions "anonymous:*" --rest true --graphql true
add GetBook --config "dab-config.DwSql.json" --source "get_book_by_id" --source.type "stored-procedure" --permissions "anonymous:execute" --rest true --graphql false
add GetBooks --config "dab-config.DwSql.json" --source "get_books" --source.type "stored-procedure" --permissions "anonymous:execute" --rest true --graphql true
add GetPublisher --config "dab-config.DwSql.json" --source "get_publisher_by_id" --source.type "stored-procedure" --permissions "anonymous:execute" --rest true --graphql true --graphql.operation "query"
add GetAuthorsHistoryByFirstName --config "dab-config.DwSql.json" --source "get_authors_history_by_first_name" --source.type "stored-procedure" --source.params "firstName:Aaron" --permissions "anonymous:execute" --rest true --graphql SearchAuthorByFirstName
Expand Down Expand Up @@ -150,7 +151,8 @@ update DeleteLastInsertedBook --config "dab-config.DwSql.json" --permissions "au
update UpdateBookTitle --config "dab-config.DwSql.json" --permissions "authenticated:execute"
update InsertAndDisplayAllBooksUnderGivenPublisher --config "dab-config.DwSql.json" --permissions "authenticated:execute"
update GetPublisher --config "dab-config.DwSql.json" --permissions "authenticated:execute"
update GetBooks --config "dab-config.DwSql.json" --permissions "authenticated:execute" --graphql.operation "Query"
update GetBooks --config "dab-config.DwSql.json" --permissions "authenticated:execute" --graphql.operation "Query" --rest.methods "Get"
update GetBook --config "dab-config.DwSql.json" --permissions "authenticated:execute" --rest.methods "Get"
update CountBooks --config "dab-config.DwSql.json" --permissions "authenticated:execute"
update Sales --config "dab-config.DwSql.json" --permissions "authenticated:*"
update GetAuthorsHistoryByFirstName --config "dab-config.DwSql.json" --permissions "authenticated:execute"
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using Azure.DataApiBuilder.Config.ObjectModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Azure.DataApiBuilder.Service.Tests.SqlTests.RestApiTests.Delete
{
/// <summary>
/// Test REST Apis validating expected results are obtained.
/// </summary>
[TestClass, TestCategory(TestCategory.DWSQL)]
public class DwSqlDeleteApiTests : DeleteApiTestBase
{
private static Dictionary<string, string> _queryMap = new()
{
{
"DeleteOneWithStoredProcedureTest",
$"SELECT [id] FROM { _integrationTableName } " +
$"WHERE id = 14"
}
};
#region Test Fixture Setup

/// <summary>
/// Sets up test fixture for class, only to be run once per test run, as defined by
/// MSTest decorator.
/// </summary>
[ClassInitialize]
public static async Task SetupAsync(TestContext context)
{
DatabaseEngine = TestCategory.DWSQL;
await InitializeTestFixture();
}

/// <summary>
/// Runs after every test to reset the database state
/// </summary>
[TestCleanup]
public async Task TestCleanup()
{
await ResetDbStateAsync();
}

#endregion

[TestMethod]
public async Task DeleteOneInViewBadRequestTest()
{
string expectedErrorMessage = $"View or function '{_defaultSchemaName}.{_composite_subset_bookPub}' is not updatable " +
"because the modification affects multiple base tables.";
await base.DeleteOneInViewBadRequestTest(expectedErrorMessage);
}

/// <summary>
/// Delete the last inserted row (row with max id) from books.
/// Verify that the row doesn't exist anymore.
/// </summary>
[TestMethod]
public async Task DeleteOneWithStoredProcedureTest()
{
// Delete one from stored-procedure based on books table.
await SetupAndRunRestApiTest(
primaryKeyRoute: null,
queryString: null,
entityNameOrPath: _integrationProcedureDeleteOne_EntityName,
sqlQuery: GetQuery(nameof(DeleteOneWithStoredProcedureTest)),
operationType: EntityActionOperation.Execute,
requestBody: null,
expectedStatusCode: HttpStatusCode.NoContent,
expectJson: false
);
}

#region RestApiTestBase Overrides

public override string GetQuery(string key)
{
return _queryMap[key];
}

#endregion

}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
Expand Down Expand Up @@ -344,7 +343,6 @@ public class DwSqlFindApiTests : FindApiTestBase
$"ORDER BY id asc " +
$"FOR JSON PATH, INCLUDE_NULL_VALUES"
},

{
"FindTestWithFirstTwoOrderByAndPagination",
$"SELECT TOP 2 * FROM { _integrationTableName } " +
Expand Down Expand Up @@ -551,7 +549,15 @@ public class DwSqlFindApiTests : FindApiTestBase
$"FROM {_integrationTableName} " +
$"ORDER BY [publisher_id] ASC, [id] ASC " +
$"FOR JSON PATH, INCLUDE_NULL_VALUES"
}
},
{
"FindManyStoredProcedureTest",
$"EXECUTE {_integrationProcedureFindMany_ProcName}"
},
{
"FindOneStoredProcedureTestUsingParameter",
$"EXECUTE {_integrationProcedureFindOne_ProcName} @id = 1"
},
};
#region Test Fixture Setup

Expand Down Expand Up @@ -603,48 +609,6 @@ public override string GetQuery(string key)
return _queryMap[key];
}

// Pending Stored Procedure Support
[TestMethod]
[Ignore]
public override Task FindManyStoredProcedureTest()
{
throw new NotImplementedException();
}

[TestMethod]
[Ignore]
public override Task FindOneStoredProcedureTestUsingParameter()
{
throw new NotImplementedException();
}

[TestMethod]
[Ignore]
public override Task FindStoredProcedureWithNonEmptyPrimaryKeyRoute()
{
throw new NotImplementedException();
}

[TestMethod]
[Ignore]
public override Task FindStoredProcedureWithMissingParameter()
{
throw new NotImplementedException();
}

[TestMethod]
[Ignore]
public override Task FindStoredProcedureWithNonexistentParameter()
{
throw new NotImplementedException();
}

[TestMethod]
[Ignore]
public override Task FindApiTestForSPWithRequiredParamsInRequestBody()
{
throw new NotImplementedException();
}
#endregion
}
}
38 changes: 38 additions & 0 deletions src/Service.Tests/dab-config.DwSql.json
Original file line number Diff line number Diff line change
Expand Up @@ -2227,6 +2227,44 @@
}
]
},
"GetBook": {
"source": {
"object": "get_book_by_id",
"type": "stored-procedure"
},
"graphql": {
"enabled": false,
"operation": "mutation",
"type": {
"singular": "GetBook",
"plural": "GetBooks"
}
},
"rest": {
"enabled": true,
"methods": [
"get"
]
},
"permissions": [
{
"role": "anonymous",
"actions": [
{
"action": "execute"
}
]
},
{
"role": "authenticated",
"actions": [
{
"action": "execute"
}
]
}
]
},
"GetPublisher": {
"source": {
"object": "get_publisher_by_id",
Expand Down