forked from loafle/openapi-generator-original
Handle negative response from the server (#5649)
This commit is contained in:
parent
96038addd3
commit
5de9deb6e7
@ -24,6 +24,10 @@ void PetApiTests::findPetsByStatusTest() {
|
|||||||
}
|
}
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXPetApi::findPetsByStatusSignalE, [&](QList<PFXPet>, QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
|
||||||
api.findPetsByStatus({"available", "sold"});
|
api.findPetsByStatus({"available", "sold"});
|
||||||
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
||||||
@ -41,6 +45,11 @@ void PetApiTests::createAndGetPetTest() {
|
|||||||
petCreated = true;
|
petCreated = true;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXPetApi::addPetSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
PFXPet pet = createRandomPet();
|
PFXPet pet = createRandomPet();
|
||||||
qint64 id = pet.getId();
|
qint64 id = pet.getId();
|
||||||
@ -55,10 +64,13 @@ void PetApiTests::createAndGetPetTest() {
|
|||||||
connect(&api, &PFXPetApi::getPetByIdSignal, [&](PFXPet pet) {
|
connect(&api, &PFXPetApi::getPetByIdSignal, [&](PFXPet pet) {
|
||||||
QVERIFY(pet.getId() > 0);
|
QVERIFY(pet.getId() > 0);
|
||||||
QVERIFY(pet.getStatus().compare("freaky") == 0);
|
QVERIFY(pet.getStatus().compare("freaky") == 0);
|
||||||
loop.quit();
|
|
||||||
petFetched = true;
|
petFetched = true;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
connect(&api, &PFXPetApi::getPetByIdSignalE, [&](PFXPet, QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
|
||||||
api.getPetById(id);
|
api.getPetById(id);
|
||||||
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
||||||
loop.exec();
|
loop.exec();
|
||||||
@ -78,7 +90,10 @@ void PetApiTests::updatePetTest() {
|
|||||||
petAdded = true;
|
petAdded = true;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXPetApi::addPetSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
// create pet
|
// create pet
|
||||||
api.addPet(pet);
|
api.addPet(pet);
|
||||||
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
||||||
@ -93,7 +108,10 @@ void PetApiTests::updatePetTest() {
|
|||||||
petToCheck = pet;
|
petToCheck = pet;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXPetApi::getPetByIdSignalE, this, [&](PFXPet, QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
// create pet
|
// create pet
|
||||||
api.getPetById(id);
|
api.getPetById(id);
|
||||||
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
||||||
@ -106,6 +124,10 @@ void PetApiTests::updatePetTest() {
|
|||||||
petUpdated = true;
|
petUpdated = true;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXPetApi::updatePetSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
|
||||||
// update pet
|
// update pet
|
||||||
petToCheck.setStatus(QString("scary"));
|
petToCheck.setStatus(QString("scary"));
|
||||||
@ -122,6 +144,10 @@ void PetApiTests::updatePetTest() {
|
|||||||
QVERIFY(pet.getStatus().compare(petToCheck.getStatus()) == 0);
|
QVERIFY(pet.getStatus().compare(petToCheck.getStatus()) == 0);
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXPetApi::getPetByIdSignalE, [&](PFXPet, QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
api.getPetById(id);
|
api.getPetById(id);
|
||||||
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
||||||
loop.exec();
|
loop.exec();
|
||||||
@ -142,6 +168,10 @@ void PetApiTests::updatePetWithFormTest() {
|
|||||||
petAdded = true;
|
petAdded = true;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXPetApi::addPetSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
|
||||||
api.addPet(pet);
|
api.addPet(pet);
|
||||||
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
||||||
@ -155,6 +185,10 @@ void PetApiTests::updatePetWithFormTest() {
|
|||||||
petToCheck = pet;
|
petToCheck = pet;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXPetApi::getPetByIdSignalE, [&](PFXPet, QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
|
||||||
api.getPetById(id);
|
api.getPetById(id);
|
||||||
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
||||||
@ -167,6 +201,10 @@ void PetApiTests::updatePetWithFormTest() {
|
|||||||
petUpdated = true;
|
petUpdated = true;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXPetApi::updatePetWithFormSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
|
||||||
QString name("gorilla");
|
QString name("gorilla");
|
||||||
api.updatePetWithForm(id, name, nullptr);
|
api.updatePetWithForm(id, name, nullptr);
|
||||||
@ -181,6 +219,10 @@ void PetApiTests::updatePetWithFormTest() {
|
|||||||
QVERIFY(pet.getName().compare(QString("gorilla")) == 0);
|
QVERIFY(pet.getName().compare(QString("gorilla")) == 0);
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXPetApi::getPetByIdSignalE, [&](PFXPet, QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
|
||||||
api.getPetById(id);
|
api.getPetById(id);
|
||||||
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
||||||
|
@ -16,8 +16,8 @@ void StoreApiTests::placeOrderTest() {
|
|||||||
qDebug() << order.getShipDate();
|
qDebug() << order.getShipDate();
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
connect(&api, &PFXStoreApi::placeOrderSignalE, [&]() {
|
connect(&api, &PFXStoreApi::placeOrderSignalE, [&](PFXOrder, QNetworkReply::NetworkError, QString error_str) {
|
||||||
QFAIL("shouldn't trigger error");
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -46,6 +46,10 @@ void StoreApiTests::getOrderByIdTest() {
|
|||||||
qDebug() << order.getShipDate();
|
qDebug() << order.getShipDate();
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXStoreApi::getOrderByIdSignalE, [&](PFXOrder, QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
|
||||||
api.getOrderById(500);
|
api.getOrderById(500);
|
||||||
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
||||||
@ -65,6 +69,10 @@ void StoreApiTests::getInventoryTest() {
|
|||||||
}
|
}
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXStoreApi::getInventorySignalE, [&](QMap<QString, qint32>, QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
|
||||||
api.getInventory();
|
api.getInventory();
|
||||||
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
||||||
|
@ -26,6 +26,10 @@ void UserApiTests::createUserTest() {
|
|||||||
userCreated = true;
|
userCreated = true;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXUserApi::createUserSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
|
||||||
api.createUser(createRandomUser());
|
api.createUser(createRandomUser());
|
||||||
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
||||||
@ -42,6 +46,10 @@ void UserApiTests::createUsersWithArrayInputTest() {
|
|||||||
usersCreated = true;
|
usersCreated = true;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXUserApi::createUsersWithArrayInputSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
|
||||||
QList<PFXUser> users;
|
QList<PFXUser> users;
|
||||||
users.append(createRandomUser());
|
users.append(createRandomUser());
|
||||||
@ -62,6 +70,10 @@ void UserApiTests::createUsersWithListInputTest() {
|
|||||||
usersCreated = true;
|
usersCreated = true;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXUserApi::createUsersWithListInputSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
|
||||||
QList<PFXUser> users;
|
QList<PFXUser> users;
|
||||||
auto johndoe = createRandomUser();
|
auto johndoe = createRandomUser();
|
||||||
@ -86,6 +98,11 @@ void UserApiTests::deleteUserTest() {
|
|||||||
userDeleted = true;
|
userDeleted = true;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXUserApi::deleteUserSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
userDeleted = true;
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
|
||||||
api.deleteUser("rambo");
|
api.deleteUser("rambo");
|
||||||
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
||||||
@ -104,6 +121,11 @@ void UserApiTests::getUserByNameTest() {
|
|||||||
QVERIFY(summary.getUsername() == "johndoe");
|
QVERIFY(summary.getUsername() == "johndoe");
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXUserApi::getUserByNameSignalE, [&](PFXUser, QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
userFetched = true;
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
|
||||||
api.getUserByName("johndoe");
|
api.getUserByName("johndoe");
|
||||||
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
||||||
@ -121,6 +143,11 @@ void UserApiTests::loginUserTest() {
|
|||||||
qDebug() << summary;
|
qDebug() << summary;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXUserApi::loginUserSignalE, [&](QString, QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
userLogged = true;
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
|
||||||
api.loginUser("johndoe", "123456789");
|
api.loginUser("johndoe", "123456789");
|
||||||
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
||||||
@ -137,6 +164,10 @@ void UserApiTests::logoutUserTest() {
|
|||||||
userLoggedOut = true;
|
userLoggedOut = true;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXUserApi::logoutUserSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
|
||||||
api.logoutUser();
|
api.logoutUser();
|
||||||
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
||||||
@ -153,6 +184,10 @@ void UserApiTests::updateUserTest() {
|
|||||||
userUpdated = true;
|
userUpdated = true;
|
||||||
loop.quit();
|
loop.quit();
|
||||||
});
|
});
|
||||||
|
connect(&api, &PFXUserApi::updateUserSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||||
|
qDebug() << "Error happened while issuing request : " << error_str;
|
||||||
|
loop.quit();
|
||||||
|
});
|
||||||
|
|
||||||
auto johndoe = createRandomUser();
|
auto johndoe = createRandomUser();
|
||||||
johndoe.setUsername("johndoe");
|
johndoe.setUsername("johndoe");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user