From bb63bef50cfe403b9fd0fa5f9d122d56f66fd119 Mon Sep 17 00:00:00 2001 From: Javier <10879637+javiertuya@users.noreply.github.com> Date: Fri, 12 Jul 2024 20:18:53 +0200 Subject: [PATCH] Reorganize Petstore and doc review --- .../tdrules/tdg/st/test/BaseAll.java | 69 +++-- .../tdg/st/test/petstore/BasePetstore.java | 25 +- .../petstore/TestPetstore0DatagenLive.java | 20 ++ .../petstore/TestPetstore0DatagenLocal.java | 168 ++++++++++++ .../petstore/TestPetstore0QagrowLive.java | 22 ++ .../petstore/TestPetstore0QagrowLocal.java | 51 ++++ .../petstore/TestPetstoreDatagenLive.java | 7 +- .../TestPetstoreDatagenLiveBackId.java | 23 +- .../petstore/TestPetstoreDatagenLocal.java | 245 +++--------------- .../test/petstore/TestPetstoreQagrowLive.java | 7 +- .../TestPetstoreQagrowLiveBackId.java | 13 +- .../petstore/TestPetstoreQagrowLocal.java | 50 +--- .../petstore/TestPetstoreSchemaLocal.java | 3 +- .../test/resources/petstore/rules-smoke.xml | 2 +- 14 files changed, 378 insertions(+), 327 deletions(-) create mode 100644 st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstore0DatagenLive.java create mode 100644 st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstore0DatagenLocal.java create mode 100644 st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstore0QagrowLive.java create mode 100644 st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstore0QagrowLocal.java diff --git a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/BaseAll.java b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/BaseAll.java index d793d33..5e9b532 100644 --- a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/BaseAll.java +++ b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/BaseAll.java @@ -32,29 +32,29 @@ import in2test.application.qagrow.QAGrowApiProcess; /** - * This is a base class for all system and integration tests that - * defines basic configurations to manage the different items involved in the tests: + * This is the base class for all system and integration tests to + * define basic configurations to manage the different items involved in the tests: * * - Abstract methods to configure main test parameters * - Methods to configure the main test objects (can be overriden for fine tuning) * - Test utilities (making assertions, serialization, etc.) * - * The two main configuration methods are getSubjectName (to identify the SUT) and - * isLiveBackend to indicate whether the test generates and sends data to a live backend - * or everything is performed in local (no SUT needed). + * The two main configurations for every test are getSubjectName() (to identify the SUT) and + * isLiveBackend() to indicate whether the test generates and sends data to a live backend + * or everything is performed in local (no running SUT needed). * These values in combination with the test inheritance, allow creating four * different flavours of the tests: * - * - datagen-local: a simulation of the data generation that manually specifies + * - datagen-local: the test simulates the data generation by specifying * the commands sent to the Data Loader and gets the data that would be loaded. * - datagen-live: manually specifies the commands sent to the Data Loader, - * but loads the data in a live SUT backend + * but loads the data in a running (live) SUT backend. * - qagrow-local: Automatically generates the test data, but working in local - * - qagrow-live: Automatically generates the test data and loads the data + * - qagrow-live: Automatically generates and loads the test data * in a live SUT backend. * * The last is the true system test that integrates all main components: - * data loader, qagrow generator, fpc rule generator and the SUT backend + * data loader, qagrow data generator, fpc rule generator and the SUT backend. */ public abstract class BaseAll { protected Logger log = LoggerFactory.getLogger(this.getClass()); @@ -75,8 +75,10 @@ public void setUp() { } /** - * Returns a string to identify the test subject (e.g. petstore, market) + * Returns a string to identify the SUT (e.g. petstore, market) * to allow identify separate the expected and actual outputs + * (must be overriden by all test methods, usually in a base + * class for this SUT) */ protected abstract String getSutName(); @@ -89,23 +91,23 @@ protected boolean isLiveBackend() { } /** - * Returns the url of the backend + * Returns the url of the SUT backend */ protected abstract String getServerUrl(); /** - * Returns the endpoint to get all data from the backend + * Returns the endpoint to get all data from the SUT backend */ protected abstract String getAllDataLiveEndpoint(); /** - * Returns the endpoint to reset all data in the backend + * Returns the endpoint to reset all data in the SUT backend */ protected abstract String getDeleteAllDataLiveEndpoint(); /** * Returns the data schema for each test. - * Each base test should configure the appropriate IdResolver and location of the OpenApi specification + * Each SUT base test should configure the appropriate IdResolver and location of the OpenApi specification */ protected abstract TdSchema getSchema(); @@ -117,14 +119,13 @@ protected TdRulesApi getRulesApi() { } /** - * Gets the TdRules model for a given query, and reprocess the version numbers + * Gets the TdRules model for a given query and reprocess the version numbers * to allow comparison of expected test results */ protected TdRules getRules(String query) { TdRules rules = getRulesApi() .getRules(getSchema(), query, "noboundaries gettransformedquery formatquery clientname=" + getSutName()); - // remove version to allow result comparison - return filterRulesVersion(rules); + return filterRulesVersion(rules); // remove version to allow result comparison } /** @@ -132,8 +133,9 @@ protected TdRules getRules(String query) { * - In local tests uses the default OaLocalAdapter. * - In live tests uses the default OaLiveAdapter and the default OaPathResolver * configured to resolve paths from the schema model. - * If a custom path resolver is needed the test must override the getLiveDataLoader() - * method with the appropriate configuration. Calling getDataLoader() will invoke + * + * If a custom path resolver is needed, the test must override the getLiveDataLoader() + * method with the appropriate configuration so that calling getDataLoader() will invoke * the overriden method. */ protected DataLoader getDataLoader() { @@ -173,14 +175,14 @@ protected void generateAndLoad(DataLoader loader, String[] queries, IAttrGen dic /** - * Gets all data from the backend + * Gets all data stored in the SUT backend */ protected String getAllLiveData() { ApiWriter api=new ApiWriter(); return api.get(getAllDataLiveEndpoint()).getBody(); } /** - * Resets all data in the backend + * Resets all data stored in the SUT backend */ protected String deleteAllLiveData() { ApiWriter api=new ApiWriter(); @@ -188,7 +190,7 @@ protected String deleteAllLiveData() { } /** - * General assert on the content of a model (as string) against the expected. + * General assert on a model (as string) against the expected. * Actual outputs are saved and then comparison is made between the content of * the expected and actual files. */ @@ -210,12 +212,6 @@ protected void assertModel(String fileName, String actualModel) { * or if it has been loaded to a live backend (in this case * a call to get the data content is made before comparison) */ - /** - * Gets a data loader according to the current configuration. - * The actual output data is obtanied as indicated: - * - In local uses the output produced by the data adapter. - * - In live tests queries the backend to get all stored data. - */ protected void assertData(String fileName, DataLoader dg) { if (isLiveBackend()) assertLiveData(fileName, dg); @@ -226,8 +222,8 @@ protected void assertLocalData(String fileName, DataLoader dg) { assertModel(fileName, dg.getDataAdapter().getAllAsString()); } protected void assertLiveData(String fileName, DataLoader dg) { - // Gets the data from the backend and - // uses a more compact presentation for easier comparison (an object per line) + // Gets the data from the backend and transforms into + // a more compact presentation for easier comparison (an object per line) String payload=getAllLiveData(); payload=reserializeStoredData(payload); log.info("Actual data stored in the backend\n{}", reserializeStoredData(payload)); @@ -237,7 +233,7 @@ protected void assertLiveData(String fileName, DataLoader dg) { /** * Removes the version number of the FPC rules to allow repeatable comparisons - * (saves the version in target to use during debugging) + * (saves the renamed version in target to use during debugging) */ protected TdRules filterRulesVersion(TdRules rules) { String version=rules.getVersion(); @@ -248,19 +244,16 @@ protected TdRules filterRulesVersion(TdRules rules) { } /** - * Serializa un objeto cualquiera a json mostrando los atributos vacios o nulos + * General purpose serialization of an object to use in test comparison */ protected String serialize(TdSchema model) { return new ModelJsonSerializer().serialize(model, true); } /** - * Serializa el contenido de toda la base de datos como: - * - un objeto cuyos items son el contenido de cada una de las tablas - * - cada item es un objeto de clave nombre de tabla y valor un array - * con el contenido de cada fila de la tabla - * Devuelve un string donde cada linea es un objeto de clave - * nombre de tabla y valor el objeto con los valores de la fila + * Given a serialized json string that represents the data stored in a SUT, + * transforms the json to get a compact representation of the data + * (a line for each object) suitable for display and test comparison */ protected String reserializeStoredData(String payload) { return new Reserializer().reserializeData(payload); diff --git a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/BasePetstore.java b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/BasePetstore.java index e30ed8a..1a5d256 100644 --- a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/BasePetstore.java +++ b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/BasePetstore.java @@ -7,8 +7,24 @@ import giis.tdrules.store.loader.gen.DictionaryAttrGen; import test4giis.tdrules.tdg.st.test.BaseAll; +/** + * Common configuration and customization for all Swagger Petstore tests. + * + * There are two different set of test clases: + * + * - Classes containing Petstore0 in the name: It is an initial + * proof of concept of of TDG using simplified entities (Pet0, Pet1...) + * from the Swagger Petstore. + * - Classes containing Petstore in the name: They use the real + * entities in the petstore OpenApi model. + * + * The former tests (Petstore0) also serve to illustrate using examples the main + * transformations performed on the model and the coverage rules. + * + * Documentation is more exhaustive in TestPetstore0DatagenLocal and TestPetstore0DatagenLocal + * The others are the different flavour variants to include data generation and a live SUT + */ public class BasePetstore extends BaseAll{ - //Para la generacion "live" arrancar antes el container de petstore con docker-run (asegurar tener el puerto 8081 libre) protected static final String PETSTORE_SCHEMA_LOCAL = "../sut-petstore/src/main/resources/openapi.yaml"; protected static final String PETSTORE_SCHEMA_LIVE = "http://localhost:8081/api/v3/openapi.json"; private static final String PETSTORE_URL_LIVE = "http://localhost:8081/api/v3"; @@ -35,10 +51,10 @@ protected String getDeleteAllDataLiveEndpoint() { @Override protected TdSchema getSchema() { - // Configure the schema id resolver to use id attribute as uid, but there are exceptions: + // Configures the schema id resolver to use id attribute as uid, but there are exceptions: // - Tag has an id, but looking at the source code, a post inserts unconditionally, // allowing repeated id values. Considers this id as no uid - // - Order0 has been artificially created for some tests, it does not follow strictely + // - Order0 has been created for some tests, it does not follow strictely // the conventions (attribute petId references Pet0.id) OaSchemaApi api = new OaSchemaApi(PETSTORE_SCHEMA_LOCAL) .setIdResolver(new OaSchemaIdResolver().setIdName("id") @@ -47,8 +63,7 @@ protected TdSchema getSchema() { } /** - * Instancia un generador de datos configurado con un diccionario para que los datos - * generados no sean solo numeros, sino valores procedentes de un diccionario o mascaras + * Dictionary to load more user friendly petstore data, includes values enumertions for strings and masks */ protected IAttrGen getDictionaryAttrGen() { return new DictionaryAttrGen() diff --git a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstore0DatagenLive.java b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstore0DatagenLive.java new file mode 100644 index 0000000..ab37af4 --- /dev/null +++ b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstore0DatagenLive.java @@ -0,0 +1,20 @@ +package test4giis.tdrules.tdg.st.test.petstore; + +/** + * Proof of concept of Test Data generation for APIs (TDG) + * using simplified entities from the Swagger Petstore. + * + * Tests in this class simulate the data generation by specifying + * the commands sent to the Data Loader and load the data + * in a running (live) SUT backend. + */ +public class TestPetstore0DatagenLive extends TestPetstore0DatagenLocal { + + @Override + protected boolean isLiveBackend() { + return true; + } + + // all test methods are inherited + +} diff --git a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstore0DatagenLocal.java b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstore0DatagenLocal.java new file mode 100644 index 0000000..9067501 --- /dev/null +++ b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstore0DatagenLocal.java @@ -0,0 +1,168 @@ +package test4giis.tdrules.tdg.st.test.petstore; + +import org.junit.Test; + +import giis.tdrules.model.io.TdRulesXmlSerializer; +import giis.tdrules.openapi.model.TdRules; +import giis.tdrules.store.loader.DataLoader; + +/** + * Proof of concept of Test Data generation for APIs (TDG) + * using simplified entities from the Swagger Petstore. + * + * Tests in this class simulate the data generation by specifying + * the commands sent to the Data Loader and gets the data that would be loaded. + * + * This also serves to illustrate using examples the main transformations performed on the + * model and the coverage rules. + * + * Test data specification is written as a query in a SQL like language + * called "Test Data Specification" (TDS). + * The OpenApi model is first transformed into the Test Data Model (TDM) + * that is represented as a DbSchema model (see the tdrules project) + * and the TDS is also transformed into a query to generate the FPC + * coverage rules + */ +public class TestPetstore0DatagenLocal extends BasePetstore { + + /** + * The simplest TDS with a single entity and a single condition + */ + public static String querySmoke = "tds Category where name='Dogs'"; + @Test + public void testSmoke() { + // The rules look for a category that matches Dogs and other that doesn't + TdRules rules=getRules(querySmoke); + assertModel("rules-smoke.xml", new TdRulesXmlSerializer().serialize(rules)); + // The data generator should issue the appropriate commands to the data loader + // to cover each of the rules, this is simulated here. + DataLoader dg = getDataLoader(); + dg.load("Category","name=Dogs"); + dg.load("Category",""); + assertData("datagen-local-smoke.txt", dg); + } + + /** + * Using a simplified schema: Pet0 without arrays and external references. + * Specifies pets with a given category that are available to be sold: + * + * TDS Pet0 where Pet0.category::name='Dogs' and Pet0.status='available' + * + * Note the :: notation to access to an attribute that is inside of an object. + */ + public static String queryPet0ByCategoryAndStatus = + "tds Pet0 where Pet0.category::name='Dogs' and Pet0.status='available'"; + @Test + public void testPet0ByCategoryAndStatus() { + TdRules rules = getRules(queryPet0ByCategoryAndStatus); + assertModel("rules-pet0-by-category-status.xml", new TdRulesXmlSerializer().serialize(rules)); + + DataLoader dg = getDataLoader(); + // Rules to specify category=Dogs and status=available + dg.load("Pet0","category::name=Dogs, status=available"); + // Other rows, one for each condition that must not match + dg.load("Pet0","category::name=1, status=available"); + dg.load("Pet0","category::name=Dogs, status=sold"); + assertData("datagen-local-pet0-by-category-status.txt", dg); + } + + /** + * Using a simplified schema: Pet1 without arrays bat with external references. + * As in the previous, specifies pets with a given category that are available to be sold: + * + * tds Pet1 where Pet1.category::name='Dogs' and Pet1.status='available' + * + * Here the external reference is transformed by creating a type Pet1_category_xt + * that references a Category. This is the data type assigned to Pet1.category + * + * As the schema references an independent object (Category), data of Pet1::category + * must be consistent with those that are in Category (there is duplicated data). + * To support this, the rule generation makes a transformation by adding a join to Category. + * The data generator produces data that is consistent with this relation and the data loader + * ensures that the appropriated data is stored both in Category and in Pet1::category. + * Internally, the transformed query that generates the rules will be: + * + * SELECT * FROM Pet1 + * LEFT JOIN Category Pet1_category_xref ON Pet1.category::id = Pet1_category_xref.id + * WHERE Pet1.category::name = 'Dogs' AND Pet1.status = 'available' + */ + public static String queryPet1ByCategoryAndStatus = + "tds Pet1 where Pet1.category::name='Dogs' and Pet1.status='available'"; + @Test + public void testPet1ByCategoryAndStatus() { + TdRules rules = getRules(queryPet1ByCategoryAndStatus); + assertModel("rules-pet1-by-category-status.xml", new TdRulesXmlSerializer().serialize(rules)); + + DataLoader dg = getDataLoader(); + // First three rules like the previous test, but here, the data is in another entity (category) + // that must be loaded before + dg.load("Category", "id=@cid1, name=Dogs"); + dg.load("Pet1", "id=@pid1, category::id=@cid1, status=available"); + dg.load("Pet1", "id=@pid2, category::id=@cid1, status=sold");//sold es un valor !=available indicado por qagrow entre los permitidos + // Now the rules look for Pet1.category!=Dogs, a new category must be created + dg.load("Category", "id=@cid2, name=1"); //1 is any value !=Dogs created by the generator + dg.load("Pet1", "id=@pid3, category::id=@cid2, status=available"); + // Finally, a category without any related pet + dg.load("Category", "id=@cid3"); + + assertData("datagen-local-pet1-by-category-status.txt", dg); + } + + /** + * Relational join, 3 entities: + * Specifies a Client with a given name such that his Order0 reference a Pet1 with category Dogs and status placed + * This can be specified as: + * + * tds Customer0 xjoin Order0 xjoin Pet where Pet0.category::name='Dogs' and Order0.status='placed' + * + * or more more simple: + * + * tds Customer0, Order0, Pet where Pet0.category::name='Dogs' and Order0.status='placed' + * + * Internally, the transformed query that generates the rules will be: + * + * SELECT * FROM Customer0 + * INNER JOIN "Order0" ON Customer0.id = Order0.CustomerId + * INNER JOIN Pet0 ON Order0.petId = Pet0.id + * WHERE Pet0.category::name = 'Dogs' AND "Order0".status = 'placed' + */ + public static String queryPlacedPet0OrdersByCategoryAndOrderStatus= + "tds Customer0, \"Order0\", Pet0" + + " where Pet0.category::name='Dogs' and \"Order0\".status='placed'"; + @Test + public void testPlacedPet0OrdersByCategoryAndOrderStatus() { + TdRules rules = getRules(queryPlacedPet0OrdersByCategoryAndOrderStatus); + assertModel("rules-placed-pet0-orders-by-category-order-status.xml", new TdRulesXmlSerializer().serialize(rules)); + + DataLoader dg = getDataLoader(); + // To cover the first rule we need to generate the master entities before + dg.load("Customer0", "id=@cid1"); + dg.load("Pet0", "id=@pid1, category::name=Dogs"); + dg.load("Order0", "id=@oid1, customerId=@cid1, petId=@pid1, status=placed"); + + // To cover the second rule that requires Pet0.category::name!=Dogs, requires a new master + dg.load("Pet0","id=@pid2, category::name=1"); + dg.load("Order0","id=@oid2, customerId=@cid1, petId=@pid2, status=placed"); + // Third rule requires status!=placed, reusing the previous master entities + dg.load("Order0","id=@oid3, customerId=@cid1, petId=@pid1, status=delivered"); //status indicado por qagrow !=placed + + // Four and five rules require a Customer0 without Order0, and a Pet0 without Order0 + dg.load("Customer0", "id=@cid2"); + dg.load("Pet0", "id=@pid2, category::name=Dogs"); + + assertData("datagen-local-placed-pet0-orders-by-category-order-status.txt", dg); + } + + /** + * Same query than before, but using aliases for some entity names + */ + public static String queryPlacedPet0OrdersWithAlias= + "tds Customer0 c, \"Order0\" o, Pet0" + + " where category::name='Dogs' and o.status='placed'"; + @Test + public void testPlacedPet0OrdersWithAlias() { + TdRules rules = getRules(queryPlacedPet0OrdersWithAlias); + assertModel("rules-placed-pet0-orders-with-alias.xml", new TdRulesXmlSerializer().serialize(rules)); + } + +} diff --git a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstore0QagrowLive.java b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstore0QagrowLive.java new file mode 100644 index 0000000..79adf85 --- /dev/null +++ b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstore0QagrowLive.java @@ -0,0 +1,22 @@ +package test4giis.tdrules.tdg.st.test.petstore; + +/** + * Proof of concept of Test Data generation for APIs (TDG) + * using simplified entities from the Swagger Petstore. + * + * Tests in this class Automatically generates the test data + * and load the data in a running (live) SUT backend. + * + * This is the true system test that integrates all main components: + * data loader, qagrow data generator, fpc rule generator and the SUT backend. + */ +public class TestPetstore0QagrowLive extends TestPetstore0QagrowLocal { + + @Override + protected boolean isLiveBackend() { + return true; + } + + // all test methods are inherited + +} diff --git a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstore0QagrowLocal.java b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstore0QagrowLocal.java new file mode 100644 index 0000000..9d7095e --- /dev/null +++ b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstore0QagrowLocal.java @@ -0,0 +1,51 @@ +package test4giis.tdrules.tdg.st.test.petstore; + +import org.junit.Test; + +import giis.tdrules.store.loader.DataLoader; + +/** + * Proof of concept of Test Data generation for APIs (TDG) + * using simplified entities from the Swagger Petstore. + * + * Tests in this class Automatically generates the test data, + * but working in local. + */ +public class TestPetstore0QagrowLocal extends BasePetstore { + + @Test + public void testSmoke() { + DataLoader dg = getDataLoader(); + generateAndLoad(dg, TestPetstore0DatagenLocal.querySmoke); + assertData("qagrow-local-smoke.txt", dg); + } + + @Test + public void testPet0ByCategoryAndStatus() { + DataLoader dg = getDataLoader(); + generateAndLoad(dg, TestPetstore0DatagenLocal.queryPet0ByCategoryAndStatus); + assertData("qagrow-local-pet0-by-category-status.txt", dg); + } + + @Test + public void testPet1ByCategoryAndStatus() { + DataLoader dg = getDataLoader(); + generateAndLoad(dg, TestPetstore0DatagenLocal.queryPet1ByCategoryAndStatus); + assertData("qagrow-local-pet1-by-category-status.txt", dg); + } + + @Test + public void testPlacedPet0OrdersByCategoryAndOrderStatus() { + DataLoader dg = getDataLoader(); + generateAndLoad(dg, TestPetstore0DatagenLocal.queryPlacedPet0OrdersByCategoryAndOrderStatus); + assertData("qagrow-local-placed-pet0-orders-by-category-order-status.txt", dg); + } + + @Test + public void testPlacedPet0OrdersWithAlias() { + DataLoader dg = getDataLoader(); + generateAndLoad(dg, TestPetstore0DatagenLocal.queryPlacedPet0OrdersWithAlias); + assertData("qagrow-local-placed-pet0-orders-by-category-order-status.txt", dg); + } + +} diff --git a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreDatagenLive.java b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreDatagenLive.java index 2aa87fd..acb2f3f 100644 --- a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreDatagenLive.java +++ b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreDatagenLive.java @@ -1,9 +1,8 @@ package test4giis.tdrules.tdg.st.test.petstore; -/** - * Mismos test que TestPetstoreDatagenLocal, pero accediendo al servidor de swagger-petstore, - * heredan de la base salvo la forma de crear el generador y comparar los datos - * (asegurar que el container ha sido arrancado con docker-run) +/** + * Test Data generation for APIs (TDG) for the Swagger Petstore as SUT: + * Only data loading, but using a live SUT. */ public class TestPetstoreDatagenLive extends TestPetstoreDatagenLocal { diff --git a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreDatagenLiveBackId.java b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreDatagenLiveBackId.java index d496d88..40590a9 100644 --- a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreDatagenLiveBackId.java +++ b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreDatagenLiveBackId.java @@ -8,9 +8,10 @@ import giis.tdrules.store.loader.oa.OaLiveUidGen; import giis.tdrules.store.loader.oa.OaPathResolver; -/** - * Tests adicionales para comprobar la generacion de claves en el backend - * extendiendo algunas funcionalidades del petstore para que generen valores de estas +/** + * Test Data generation for APIs (TDG) for the Swagger Petstore as SUT: + * Only data loading, but using a live SUT where the uids of each generated + * object are generated by the backend. */ public class TestPetstoreDatagenLiveBackId extends BasePetstore { @@ -19,8 +20,10 @@ protected boolean isLiveBackend() { return true; } - //los endpoints estan bajo el path backid - //no se pueden resolver utilizando el resolver estandar que utiliza el modelo + // The swagger petstore does not generate uids in the backend. + // A new endpoint (backid) has been included to illustrate this funcionality. + // As this is not specified in the model, we use a custom path resolver + // to identify the appropriate endpoint public class CustomPathResolver extends OaPathResolver { @Override public String getEndpointPath(String tableName) { @@ -30,6 +33,9 @@ public String getEndpointPath(String tableName) { return super.getEndpointPath(tableName); } } + + // The BaseAll class instantiates data loaders using the default path resolver. + // We override this method to allow the custom path resolver be injected y the data adapter @Override protected DataLoader getLiveDataLoader() { IPathResolver pathResolver=new CustomPathResolver().setServerUrl(getServerUrl()); @@ -37,8 +43,7 @@ protected DataLoader getLiveDataLoader() { } /** - * Prueba de con dos entidades con referencias, no genera reglas, solo los comandos de generacion - * que se tienen en tests similares para comprobacion del valor de las claves generadas en el backend + * Example of two related entities. */ @Test public void testPetByCategoryAndStatus() { @@ -50,9 +55,9 @@ public void testPetByCategoryAndStatus() { dg.load("Pet_Tags_xa", "fk_xa=@pid2"); dg.load("Pet_photoUrls_xa", "fk_xa=@pid2"); - dg.load("Pet", "id=@pid2, category::id=@cid1, status=sold");//sold es un valor !=available indicado por qagrow entre los permitidos + dg.load("Pet", "id=@pid2, category::id=@cid1, status=sold"); - dg.load("Category", "id=@cid2, name=1"); //1 es un valor !=Dogs indicado por qagrow + dg.load("Category", "id=@cid2, name=1"); dg.load("Pet_Tags_xa", "fk_xa=@pid3"); dg.load("Pet_photoUrls_xa", "fk_xa=@pid3"); dg.load("Pet", "id=@pid3, category::id=@cid2, status=available"); diff --git a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreDatagenLocal.java b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreDatagenLocal.java index 03217b5..db929cb 100644 --- a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreDatagenLocal.java +++ b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreDatagenLocal.java @@ -6,196 +6,21 @@ import giis.tdrules.openapi.model.TdRules; import giis.tdrules.store.loader.DataLoader; -/** - * Prueba de concepto de generacion de datos de prueba a partir de una especificacion openapi. - * - * El escenario inicial es estamos especificando un escenario de prueba en Gherkin para una aplicacion - * que hace un uso intensivo de datos. Para ello sera necesario especificar una serie de ejemplos - * que estan formados por diferentes conjuntos de datos que representen diferentes casuisticas - * (situaciones a probar). - * - * En vez de especificar estos datos se especificara una query en un lenguaje similar a sql - * (en realidad es una extension de sql). Esta query se denomina "Test Data Specification" (TDS) - * - * El modelo openapi sera trasformado en un modelo Test Data Model (TDM) - * que se implementa como un modelo DbSchema que permite generar - * reglas de cobertura fpc, las cuales determinaran las diferentes casuisticas a partir de esta especificacion. - * Posteriormente se generaran los datos que satisfagan esas reglas - * y se insertaran en la aplicacion utilizando su propia api. - * - * Esta clase genera las reglas e cobertura fpc y establece manualmente los comandos de generacion de datos para cubrirlas. - * Utiliza un un esquema y un DataAdapter local, que no requiere una conexion activa a un servidor. +/** + * Test Data generation for APIs (TDG) for the Swagger Petstore as SUT: + * Only data loading in local. */ public class TestPetstoreDatagenLocal extends BasePetstore { - /** - * Una query simple con una unica tabla para la prueba inicial que comprueba que se genera correctamente - */ - public static String querySmoke = "select * from Category where name='Dogs'"; - @Test - public void testSmoke() { - TdRules rules=getRules(querySmoke); - assertModel("rules-smoke.xml", new TdRulesXmlSerializer().serialize(rules)); - //Las reglas buscan una categoria que no sea Dogs y otra que si lo sea. - DataLoader dg = getDataLoader(); - dg.load("Category","name=Dogs"); - dg.load("Category",""); - assertData("datagen-local-smoke.txt", dg); - } - - /** - * Sobre una variante simplificada Pet0 sin arrays ni referencias externas - * Una query que busca Pets con categoria Dogs y que esten disponibles para la venta, la query es: - * - * TDS Pet0 where Pet0.category::name='Dogs' and Pet0.status='available' - * - * Utiliza la notacion TDS para las queries (especificaciones) - * El tipo de datos de la propiedad category no es primitivo, sino que esta definida inline como otro objeto. - * La notacion :: indica el acceso a las propiedades un objeto interno. - */ - public static String queryPet0ByCategoryAndStatus = - "tds Pet0 where Pet0.category::name='Dogs' and Pet0.status='available'"; - @Test - public void testPet0ByCategoryAndStatus() { - TdRules rules = getRules(queryPet0ByCategoryAndStatus); - assertModel("rules-pet0-by-category-status.xml", new TdRulesXmlSerializer().serialize(rules)); - - DataLoader dg = getDataLoader(); - //Las reglas category=Dogs y status=available - dg.load("Pet0","category::name=Dogs, status=available"); - //y luego otras dos filas en las que falla la igualdad en cada una de estas propiedades - dg.load("Pet0","category::name=1, status=available"); //1 es un valor !=Dogs indicado por qagrow - dg.load("Pet0","category::name=Dogs, status=sold"); //sold es un valor !=available indicado por qagrow entre los permitidos - assertData("datagen-local-pet0-by-category-status.txt", dg); - } - /** - * Sobre una variante simplificada Pet1 sin arrays pero con referencias externas - * La query es la misma que la anterior: - * - * tds Pet1 where Pet1.category::name='Dogs' and Pet1.status='available' - * - * La primera transformacion realizada al crear el esquema es crear un tipo Pet1_category_xt - * que tiene una FK a Category, este sera el tipo asignado a Pet1.category - * - * Como el esquema referencia un objeto independiente Category, los datos de Pet1::category - * deben ser consistentes con los que haya en Category (se esta desnormalizando/duplicando datos). - * Para ello en la generacion de reglas se hace otra transformacion anyadiendo un left join con Category - * (a la que se le asigna el alias Pet1_category_xref por si hay otros composites que referencian a Category). - * La query transformada sera: - * - * SELECT * FROM Pet1 - * LEFT JOIN Category Pet1_category_xref ON Pet1.category::id = Pet1_category_xref.id - * WHERE Pet1.category::name = 'Dogs' AND Pet1.status = 'available' - */ - public static String queryPet1ByCategoryAndStatus = - "tds Pet1 where Pet1.category::name='Dogs' and Pet1.status='available'"; - @Test - public void testPet1ByCategoryAndStatus() { - TdRules rules = getRules(queryPet1ByCategoryAndStatus); - assertModel("rules-pet1-by-category-status.xml", new TdRulesXmlSerializer().serialize(rules)); - - DataLoader dg = getDataLoader(); - //Las tres primeras reglas son como en la anterior, pero ahora los datos estan en otra tabla Category - //la primera crea una category=Dogs y Pet1 que satisface las dos condiciones del where - dg.load("Category", "id=@cid1, name=Dogs"); - dg.load("Pet1", "id=@pid1, category::id=@cid1, status=available"); - //la segunda busca Pet1.status!=available, por lo que reutiliza la categoria anterior - dg.load("Pet1", "id=@pid2, category::id=@cid1, status=sold");//sold es un valor !=available indicado por qagrow entre los permitidos - //la tercera busca Pet1.category diferente de Dogs, por lo que debe crear un maestro nuevo - dg.load("Category", "id=@cid2, name=1"); //1 es un valor !=Dogs indicado por qagrow - dg.load("Pet1", "id=@pid3, category::id=@cid2, status=available"); - - //La regla de pet sin categoria no se genera porque hay integridad referencial y la categoria en el pet es no nullable - //NOTA: el parser de swagger siempre devuelve no nullables los composites que provienen de una regla externa - - //La quinta busca una fila de Category sin Pet1, - //notar que las dos condiciones sobre pet se han reducido por estar en el outer increment - dg.load("Category", "id=@cid3"); - - assertData("datagen-local-pet1-by-category-status.txt", dg); - } - - /** - * Join relacional entre tres tablas: - * Busca el Client de un nombre dado y sus Order0 que tienen status=placed para Pet1 con category=Dogs - * La notacion de esta query seria: - * - * tds Customer0 xjoin Order0 xjoin Pet where Pet0.category::name='Dogs' and Order0.status='placed' - * - * que se representa de forma simplificada como: - * - * tds Customer0, Order0, Pet where Pet0.category::name='Dogs' and Order0.status='placed' - * - * donde cada xjoin se transforma en una join por las pk y fk de las tablas involucradas (similar a natural join), - * dando lugar a una query transformada como la siguiente (usando notacion postgres): - * - * SELECT * FROM Customer0 - * INNER JOIN "Order0" ON Customer0.id = Order0.CustomerId - * INNER JOIN Pet0 ON Order0.petId = Pet0.id - * WHERE (Pet0.category).name = 'Dogs' AND "Order0".status = 'placed' - */ - public static String queryPlacedPet0OrdersByCategoryAndOrderStatus= - "tds Customer0, \"Order0\", Pet0" - + " where Pet0.category::name='Dogs' and \"Order0\".status='placed'"; - @Test - public void testPlacedPet0OrdersByCategoryAndOrderStatus() { - TdRules rules = getRules(queryPlacedPet0OrdersByCategoryAndOrderStatus); - assertModel("rules-placed-pet0-orders-by-category-order-status.xml", new TdRulesXmlSerializer().serialize(rules)); - - DataLoader dg = getDataLoader(); - //la primera crea maestros Customer0 y Pet0 con un Order0 que satisface las dos condiciones del where - dg.load("Customer0", "id=@cid1"); - dg.load("Pet0", "id=@pid1, category::name=Dogs"); - dg.load("Order0", "id=@oid1, customerId=@cid1, petId=@pid1, status=placed"); - - //la segunda require (Pet0.category).name!=Dogs, necesita un nuevo maestro - dg.load("Pet0","id=@pid2, category::name=1"); //name indicado por qagrow !=Dogs - dg.load("Order0","id=@oid2, customerId=@cid1, petId=@pid2, status=placed"); //status indicado por qagrow !=placed - //la tercera require status!=placed, reutiliza los primeros mestros - dg.load("Order0","id=@oid3, customerId=@cid1, petId=@pid1, status=delivered"); //status indicado por qagrow !=placed - - //La cuarta es un Customer0 sin Order0, - //notar que como no hay order, tampoco habra pet y las condiciones del where han reducido por estar en el outer increment - dg.load("Customer0", "id=@cid2"); - //La quinta es un Pet0 sin Order0, en este caso debe mantenerse ((Pet0.category).name = 'Dogs') - dg.load("Pet0", "id=@pid2, category::name=Dogs"); - - assertData("datagen-local-placed-pet0-orders-by-category-order-status.txt", dg); - } - - /** - * La misma query debe procesarse correctamente si se usan alias o no se usan prefijos: - * En Pet la category se usa sin prefijo, en Order el status con alias (para distinguir del status de un Pet) - */ - public static String queryPlacedPet0OrdersWithAlias= - "tds Customer0 c, \"Order0\" o, Pet0" - + " where category::name='Dogs' and o.status='placed'"; - @Test - public void testPlacedPet0OrdersWithAlias() { - TdRules rules = getRules(queryPlacedPet0OrdersWithAlias); - assertModel("rules-placed-pet0-orders-with-alias.xml", new TdRulesXmlSerializer().serialize(rules)); - } - - ////////////////////////////// Generacion de arrays ////////////////////////////// - - /** - * La query es la misma que la que usa Pet1, pero ahora se usa Pet que contiene dos arrays + * Specifies pets with a given category that are available to be sold: * * tds Pet where Pet.category::name='Dogs' and Pet.status='available' * - * Las transformaciones del esquema, ademas de crear el tipo Pet_category_xref - * crean dos arrays Pet_Tags_xa y Pet_photoUrls_xa. - * Estos arrays se muestran como tablas de tipo array - * con sus propias claves pk y fk que referencian a Pet - * - * Aunque son tablas detalle, en la generacion se deberan incluir antes que la - * generacion de la correspondiente fila de Pet usando como fk el valor simbolico de la pk de Pet - * (nota: la pk se genera automaticamente de forma secuencial, - * podria ser innecesaria, dependiendo de si la necesita o no QAGrow) - * - * Las transformaciones de reglas anyaden joins para estas dos tablas. - * La query transformada (usando notacion postgres) sera: + * The difference with the equivalent testPet1ByCategoryAndStatus in Petstore0 + * test is that entities have arrays. + * The model transformation extracts arrays to another entity. + * Internally, the transformed query to generate the rules is: * * SELECT * FROM Pet * LEFT JOIN Pet_tags_xa ON Pet.id = Pet_tags_xa.fk_xa @@ -203,7 +28,7 @@ public void testPlacedPet0OrdersWithAlias() { * LEFT JOIN Category Pet_category_xref ON Pet.category::id = Pet_category_xref.id * WHERE Pet.category::name = 'Dogs' AND Pet.status = 'available' * - * Este test contiene dos variante una usando el AttrGen por defecto y otra usando un diccionario + * There are two versions of this test: without and with a dictionary */ public static String queryPetByCategoryAndStatus = "tds Pet where Pet.category::name='Dogs' and Pet.status='available'"; @@ -216,14 +41,12 @@ public void testPetByCategoryAndStatus() { } @Test public void testPetByCategoryAndStatusWithDictionary() { - //no comprueba reglas aqui, son las mismas que el anterior DataLoader dg = getDataLoader().setAttrGen(getDictionaryAttrGen()); doTestPetByCategoryAndStatus(dg, "datagen-local-pet-by-category-status-dict.txt"); } private void doTestPetByCategoryAndStatus(DataLoader dg, String outputFileName) { - //Las reglas son como en testPet1ByCategoryAndStatus pero ahora hay arrays, con lo que antes de generar cada Pet - //se anyadiria al menos una fila con Pet_photoUrls_xa y Pet_Tags_xa, - //poniendo como fk la pk del pet que se generara a continuacion + // Rules are like in testPet1ByCategoryAndStatus, but now, with arrays, + // so that before generating each Pet, the objects of each array must be generated. dg.load("Pet_Tags_xa", "fk_xa=@pid1"); dg.load("Pet_photoUrls_xa", "fk_xa=@pid1"); dg.load("Category", "id=@cid1, name=Dogs"); @@ -231,16 +54,16 @@ private void doTestPetByCategoryAndStatus(DataLoader dg, String outputFileName) dg.load("Pet_Tags_xa", "fk_xa=@pid2"); dg.load("Pet_photoUrls_xa", "fk_xa=@pid2"); - dg.load("Pet", "id=@pid2, category::id=@cid1, status=sold");//sold es un valor !=available indicado por qagrow entre los permitidos + dg.load("Pet", "id=@pid2, category::id=@cid1, status=sold"); dg.load("Pet_Tags_xa", "fk_xa=@pid3"); dg.load("Pet_photoUrls_xa", "fk_xa=@pid3"); - dg.load("Category", "id=@cid2, name=1"); //1 es un valor !=Dogs indicado por qagrow + dg.load("Category", "id=@cid2, name=1"); dg.load("Pet", "id=@pid3, category::id=@cid2, status=available"); dg.load("Category", "id=@cid3"); - //estas dos ultimas son para dos reglas nuevas que implican pets que no tengan tags y pets que no tengan urls + // These are for two new rules that require Pets without Tags and Urls dg.load("Pet_photoUrls_xa", "fk_xa=@pid4"); dg.load("Pet", "id=@pid4, category::id=@cid1, status=available"); @@ -251,15 +74,13 @@ private void doTestPetByCategoryAndStatus(DataLoader dg, String outputFileName) } /** - * Una variante de la anterior, - * pero ahora las condiciones del where son referencias a items de los arrays - * (uno es array de primitivos y otro array de objetos) + * Specifies pets with a given url and tag * * tds Pet where Pet.photoUrls[]='URL' and Pet.tags[]::name='kitty'" * - * Ademas de las joins con los arrays se mantiene la join con Pet_category_xref - * puesto que aunque no se referencie en el where es necesaria para tener integridad referencial. - * Las transformaciones de los joins tambien transforma estas referencias en el where + * This has the same structure than the previous, but here, conditions + * are based on the items in arrays. + * Internally, the transformed query to generate the rules must join with the arrays: * * SELECT * FROM Pet * LEFT JOIN Pet_tags_xa ON Pet.id = Pet_tags_xa.fk_xa @@ -273,16 +94,18 @@ private void doTestPetByCategoryAndStatus(DataLoader dg, String outputFileName) public void testPetByUrlAndTag() { TdRules rules = getRules(queryPetByUrlAndTag); assertModel("rules-pet-by-url-tag.xml", new TdRulesXmlSerializer().serialize(rules)); - //a partir de aqui ya compruebo solo las reglas en la mayor parte de los tests + // data loading skipped from now } /** - * Join relacional entre tres tablas utilizando los objetos orignales Customer, Order y Pet + * Relational join, 3 entities: + * Specifies a Client with a given name such that his Order reference a Pet with category Dogs and status placed * * tds Customer, Order, Pet where Pet.category::name='Dogs' and Order.status='placed' - * - * Es la misma que testPlacedPet0OrdersByCategoryAndOrderStatus) pero ahora saldran otras tablas - * debido a los arrays (dos de Pet mas uno de Customer) mas el maestro de Category: + * + * The difference with the equivalent testPlacedPet0OrdersByCategoryAndOrderStatus in Petstore0 + * is that here the arrays. + * Internally they must be included and joined to generate the rules: * * SELECT * FROM Customer * LEFT JOIN Customer_address_xa ON Customer.id = Customer_address_xa.fk_xa @@ -303,10 +126,10 @@ public void testPlacedPetOrdersByCategoryAndOrderStatus() { } /** - * Otra join similar para ver las Orders a enviar a un zip de cliente dado, - * incluyen condiciones sobre otros atributos diferentes de la anterior, uno de ellos es array + * Specifies a the orders that must be sent to an address area (given by the zip). + * Includes two versions: without and with dictionary. * - * En esta se comprobara la generacion de una fila sin y con diccionario + * From now, we does not comment on the internal detals of queries needed to generate the rules */ public static String queryPlacedPetOrdersByAddressAndOrderStatus= "tds Customer, \"Order\", Pet" @@ -337,8 +160,11 @@ private void doPlacedPetOrdersByAddressAndOrderStatus(DataLoader dg, String outp ////////////////////////////// Generacion de datos con group by ////////////////////////////// /** - * Total de Orders a enviar (estado approved) agrupadas por zip de la direccion del cliente. - * Notar que la transformacion de la clausula tds introduce en el select las columnas del groupby y un count + * This TDS indicates that the generated test data must form groups, + * used when the SUT performs some kind of aggregation: + * + * Specifies that we want to count the total number of orders that must be sent (status is approved) + * to an address area (given by zip). */ public static String queryTotalOrdersToDeliverByAddress= "tds Customer, \"Order\", Pet" @@ -351,8 +177,8 @@ public void testTotalOrdersToDeliverByAddress() { } /** - * Como la anterior pero suma todas las unidades pedidas en cada Order, - * en este caso se pone un select explícito + * A variant of the previous to show that we also can use a sql syntax by specifying + * the values that the SUT is going to obtain is also allowed. */ public static String queryTotalPetsToDeliverByAddress= "select Customer.address[]::zip, sum(\"Order\".quantity) from Customer, \"Order\", Pet" @@ -363,4 +189,5 @@ public void testTotalPetsToDeliverByAddress() { TdRules rules = getRules(queryTotalPetsToDeliverByAddress); assertModel("rules-total-pets-by-address.xml", new TdRulesXmlSerializer().serialize(rules)); } + } diff --git a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreQagrowLive.java b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreQagrowLive.java index 0ca06b7..db02858 100644 --- a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreQagrowLive.java +++ b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreQagrowLive.java @@ -1,9 +1,8 @@ package test4giis.tdrules.tdg.st.test.petstore; -/** - * Mismos test que TestPetstoreQagrowLocal, pero accediendo al servidor de swagger-petstore, - * heredan de la base salvo la forma de crear el generador y comparar los datos - * (asegurar que el container ha sido arrancado con docker-run) +/** + * Test Data generation for APIs (TDG) for the Swagger Petstore as SUT: + * System test, including data generation and loading using a live SUT. */ public class TestPetstoreQagrowLive extends TestPetstoreQagrowLocal { diff --git a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreQagrowLiveBackId.java b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreQagrowLiveBackId.java index 9cd13ff..303d426 100644 --- a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreQagrowLiveBackId.java +++ b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreQagrowLiveBackId.java @@ -4,20 +4,15 @@ import giis.tdrules.store.loader.DataLoader; -/** - * Tests adicionales con QAGrow para comprobar la generacion de claves en el backend - * extendiendo algunas funcionalidades del petstore para que generen valores de estas +/** + * Test Data generation for APIs (TDG) for the Swagger Petstore as SUT: + * Full integration of data generation and loading using a live SUT where the uids + * of each generated object are generated by the backend. */ public class TestPetstoreQagrowLiveBackId extends TestPetstoreDatagenLiveBackId { - /** - * Prueba de con dos entidades con referencias generando claves en el backend - */ @Test public void testPetByCategoryAndStatus() { - //Deben ser los mismos que en el correspondiente live, pero cambia el valor - //que tienen las claves primarias (Category son multiplos de 10 y Pet multiplos de 1000) - DataLoader dg = getDataLoader(); generateAndLoad(dg, TestPetstoreDatagenLocal.queryPetByCategoryAndStatus); assertData("qagrow-livebackid-pet-by-category-status.txt", dg); diff --git a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreQagrowLocal.java b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreQagrowLocal.java index a26f9e0..334376e 100644 --- a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreQagrowLocal.java +++ b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreQagrowLocal.java @@ -5,56 +5,12 @@ import giis.tdrules.store.loader.DataLoader; import giis.tdrules.store.loader.IAttrGen; -/** - * Mismos test que TestPetstoreDatagenLocal, - * generando los datos de prueba en un archivo utilizando QAGrow. - * Utiliza un un esquema y un DataAdapter local, que no requiere una conexion activa a un servidor. - * - * Está implementado de forma similar a TestPetstoreDatagenLocal, - * usando las mismas queries que define como constantes - * y los mismos convenios (los ficheros para comparacion de salidas empiezan por qagrow-local-) - * +/** + * Test Data generation for APIs (TDG) for the Swagger Petstore as SUT: + * Data generation and loading in local. */ public class TestPetstoreQagrowLocal extends BasePetstore { - @Test - public void testSmoke() { - DataLoader dg = getDataLoader(); - generateAndLoad(dg, TestPetstoreDatagenLocal.querySmoke); - assertData("qagrow-local-smoke.txt", dg); - } - - @Test - public void testPet0ByCategoryAndStatus() { - DataLoader dg = getDataLoader(); - generateAndLoad(dg, TestPetstoreDatagenLocal.queryPet0ByCategoryAndStatus); - assertData("qagrow-local-pet0-by-category-status.txt", dg); - } - - @Test - public void testPet1ByCategoryAndStatus() { - DataLoader dg = getDataLoader(); - generateAndLoad(dg, TestPetstoreDatagenLocal.queryPet1ByCategoryAndStatus); - assertData("qagrow-local-pet1-by-category-status.txt", dg); - } - - @Test - public void testPlacedPet0OrdersByCategoryAndOrderStatus() { - DataLoader dg = getDataLoader(); - generateAndLoad(dg, TestPetstoreDatagenLocal.queryPlacedPet0OrdersByCategoryAndOrderStatus); - assertData("qagrow-local-placed-pet0-orders-by-category-order-status.txt", dg); - } - - @Test - public void testPlacedPet0OrdersWithAlias() { - DataLoader dg = getDataLoader(); - generateAndLoad(dg, TestPetstoreDatagenLocal.queryPlacedPet0OrdersWithAlias); - assertData("qagrow-local-placed-pet0-orders-by-category-order-status.txt", dg); - - } - - ////////////////////////////// Generacion datos de arrays ////////////////////////////// - @Test public void testPetByCategoryAndStatus() { DataLoader dg = getDataLoader(); diff --git a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreSchemaLocal.java b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreSchemaLocal.java index 2b32114..de28d6b 100644 --- a/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreSchemaLocal.java +++ b/st-tdg-test/src/test/java/test4giis/tdrules/tdg/st/test/petstore/TestPetstoreSchemaLocal.java @@ -14,7 +14,8 @@ import giis.tdrules.openapi.model.TdSchema; /** - * Genera el esquema a partir de la especificacion (leida de archivo) y lo comprueba en formato json y xml + * Checks the transformation of the OpenApi specification into the TdSchema model + * as well as utilities to serialization and generation of Mermaid graphs. */ public class TestPetstoreSchemaLocal extends BasePetstore { diff --git a/st-tdg-test/src/test/resources/petstore/rules-smoke.xml b/st-tdg-test/src/test/resources/petstore/rules-smoke.xml index 9760c3f..192feae 100644 --- a/st-tdg-test/src/test/resources/petstore/rules-smoke.xml +++ b/st-tdg-test/src/test/resources/petstore/rules-smoke.xml @@ -1,7 +1,7 @@ 0.0.0 -select * from Category where name='Dogs' +tds Category where name='Dogs' SELECT * FROM Category WHERE name = 'Dogs'