Clean the database before running Karate test using Azure logic app - NextensArelB/SwaggerGenerationTool GitHub Wiki
[WIP] ##Introduction With the regression test of Intelligence API we trigger the Opportunities one-by-one by invoking the API with a set of parameters like what happens if you finalize the aangifte. To be able to do so the aangifte needs to be there in the database and filled in the correct manner. If you log in to the "Adviespostbode" account this has been arranged and we have clients per opportunity having the right aangifte so the opportunity should trigger for this specific customer.
If a Opportunity has been trigger it will not trigger again. Therefor you need to clean the database before running the test. Before we where doing this by hand: run a SQL script in SQL server Management studio. Now this cleaning can be done using an Karate script by invoking an Azure logic app running an stored procedure that does the cleanup on the database. This maybe sounds complicated but is is not.
##Karate's native database connection Karate has a way to connect to databases is using JDBC to connect to the database. The dependency for using JDBC is handled in Eclipse and Maven. Since we are not nativly developing Java and we don't want to too much dependencies to Java components we came up with the solution of using an Azure Logic app.
On the database we have an stored procedure that does the cleaning:
In Azure we have created an very basic Logic app that will invoke the Store procedure:
We call the logic app with some parameters that are passed to the stored procedure and will steer what data will be removed. By leaving the parameter empty or null this means all will be deleted.