Skip to content
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

Review petstore0 documentation (#8) #50

Merged
merged 3 commits into from
Dec 17, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
/**
* Common configuration and customization for all Swagger Petstore tests.
*
* There are two different set of test clases:
* There are two different sets of test classes:
*
* - Classes containing Petstore0 in the name: It is an initial
* proof of concept of of TDG using simplified entities (Pet0, Pet1...)
* proof of concept 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.
* entities in the Petstore OpenApi model.
*
* The former tests (Petstore0) also serve to illustrate using examples the main
* The former tests (Petstore0) also serve to illustrate by means of 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
* Documentation is more exhaustive in TestPetstore0DatagenLocal and TestPetstoreDatagenLocal.
* The others are the different variants to include data generation and a live SUT.
*/
public class BasePetstore extends BaseAll{
protected static final String PETSTORE_SCHEMA_LOCAL = "../sut-petstore/src/main/resources/openapi.yaml";
Expand Down Expand Up @@ -51,10 +51,10 @@ protected String getDeleteAllDataLiveEndpoint() {

@Override
protected TdSchema getSchema() {
// 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,
// Configures the schema idResolver to use id attribute as uid, but there are exceptions:
// - Tag has an id, but looking at the source code, a post endpoint inserts unconditionally,
// allowing repeated id values. Considers this id as no uid
// - Order0 has been created for some tests, it does not follow strictely
// - Order0 has been created for some tests. It does not strictly follow
// the conventions (attribute petId references Pet0.id)
OaSchemaApi api = new OaSchemaApi(PETSTORE_SCHEMA_LOCAL)
.setIdResolver(new OaSchemaIdResolver().setIdName("id")
Expand All @@ -63,7 +63,7 @@ protected TdSchema getSchema() {
}

/**
* Dictionary to load more user friendly petstore data, includes values enumertions for strings and masks
* Dictionary to load more user friendly Petstore data. It includes values enumerations for strings and masks
*/
protected IAttrGen getDictionaryAttrGen() {
return new DictionaryAttrGen()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package test4giis.tdrules.tdg.st.test.petstore;

/**
* Proof of concept of Test Data generation for APIs (TDG)
* 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.
* into a running (live) SUT backend.
*/
public class TestPetstore0DatagenLive extends TestPetstore0DatagenLocal {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
import giis.tdrules.store.loader.DataLoader;

/**
* Proof of concept of Test Data generation for APIs (TDG)
* 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.
* the commands sent to the Data Loader and get the data to be loaded.
*
* This also serves to illustrate using examples the main transformations performed on the
* This also serves to illustrate by means of 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
* 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
* which is then represented as a DbSchema model (see the tdrules project).
* The TDS is also transformed into a query to generate the FPC
* coverage rules.
*/
public class TestPetstore0DatagenLocal extends BasePetstore {

Expand All @@ -31,24 +31,24 @@ public class TestPetstore0DatagenLocal extends BasePetstore {
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
// The rules look for a category that matches Dogs and another 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.
// 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:
* Using a simplified schema: Pet0 without arrays or external references.
* Specifies pets with a given category that are available for sale:
*
* 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.
* Note the :: notation to access an attribute that is inside an object.
*/
public static String queryPet0ByCategoryAndStatus =
"tds Pet0 where Pet0.category::name='Dogs' and Pet0.status='available'";
Expand All @@ -67,19 +67,19 @@ public void testPet0ByCategoryAndStatus() {
}

/**
* 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:
* Using a simplified schema: Pet1 without arrays but with external references.
* As in the previous test case, specifies pets with a given category that are available for sale:
*
* tds Pet1 where Pet1.category::name='Dogs' and Pet1.status='available'
* TDS Pet1 where Pet1.category::name='Dogs' and Pet1.status='available'
*
* Here the external reference is transformed by creating a type Pet1_category_xt
* 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
* Since the schema references an independent object (Category), the 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.
* To support this, the rule generation performs a transformation by adding a join to Category.
* The data generator produces data that is consistent with this relationship, and the data loader
* ensures that the appropriate data is stored in both Category and Pet1::category.
* Internally, the transformed query that generates the rules will be:
*
* SELECT * FROM Pet1
Expand All @@ -94,11 +94,11 @@ public void testPet1ByCategoryAndStatus() {
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)
// First three rules are 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
dg.load("Pet1", "id=@pid2, category::id=@cid1, status=sold");//sold is a value !=available selected by qagrow among those allowed
// 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");
Expand All @@ -109,15 +109,16 @@ public void testPet1ByCategoryAndStatus() {
}

/**
* Relational join, 3 entities:
* Specifies a Client with a given name such that his Order0 reference a Pet1 with category Dogs and status placed
* Using a simplified schema: Pet0 without arrays or external references.
* Relational join of 3 entities: Customer0, Order0 and Pet0
* Specifies a client such that his order refers to a pet 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'
* TDS Customer0 xjoin Order0 xjoin Pet0 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'
* TDS Customer0, Order0, Pet0 where Pet0.category::name='Dogs' and Order0.status='placed'
*
* Internally, the transformed query that generates the rules will be:
*
Expand All @@ -144,8 +145,8 @@ public void testPlacedPet0OrdersByCategoryAndOrderStatus() {
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
dg.load("Order0","id=@oid3, customerId=@cid1, petId=@pid1, status=delivered"); // delivered is a value !=placed selected by qagrow

// 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");
Expand All @@ -154,7 +155,7 @@ public void testPlacedPet0OrdersByCategoryAndOrderStatus() {
}

/**
* Same query than before, but using aliases for some entity names
* Same query as before, but using aliases for some entity names
*/
public static String queryPlacedPet0OrdersWithAlias=
"tds Customer0 c, \"Order0\" o, Pet0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package test4giis.tdrules.tdg.st.test.petstore;

/**
* Proof of concept of Test Data generation for APIs (TDG)
* 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
* Tests in this class automatically generate the test data
* and load the data in a running (live) SUT backend.
*
* This is the true system test that integrates all main components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import giis.tdrules.store.loader.DataLoader;

/**
* Proof of concept of Test Data generation for APIs (TDG)
* 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.
* Tests in this class automatically generate the test data,
* but working locally.
*/
public class TestPetstore0QagrowLocal extends BasePetstore {

Expand Down
Loading