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();
|
||||
});
|
||||
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"});
|
||||
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
||||
@ -41,6 +45,11 @@ void PetApiTests::createAndGetPetTest() {
|
||||
petCreated = true;
|
||||
loop.quit();
|
||||
});
|
||||
connect(&api, &PFXPetApi::addPetSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||
qDebug() << "Error happened while issuing request : " << error_str;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
|
||||
PFXPet pet = createRandomPet();
|
||||
qint64 id = pet.getId();
|
||||
@ -55,10 +64,13 @@ void PetApiTests::createAndGetPetTest() {
|
||||
connect(&api, &PFXPetApi::getPetByIdSignal, [&](PFXPet pet) {
|
||||
QVERIFY(pet.getId() > 0);
|
||||
QVERIFY(pet.getStatus().compare("freaky") == 0);
|
||||
loop.quit();
|
||||
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);
|
||||
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
||||
loop.exec();
|
||||
@ -78,7 +90,10 @@ void PetApiTests::updatePetTest() {
|
||||
petAdded = true;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
connect(&api, &PFXPetApi::addPetSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||
qDebug() << "Error happened while issuing request : " << error_str;
|
||||
loop.quit();
|
||||
});
|
||||
// create pet
|
||||
api.addPet(pet);
|
||||
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
||||
@ -93,7 +108,10 @@ void PetApiTests::updatePetTest() {
|
||||
petToCheck = pet;
|
||||
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
|
||||
api.getPetById(id);
|
||||
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
||||
@ -106,6 +124,10 @@ void PetApiTests::updatePetTest() {
|
||||
petUpdated = true;
|
||||
loop.quit();
|
||||
});
|
||||
connect(&api, &PFXPetApi::updatePetSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||
qDebug() << "Error happened while issuing request : " << error_str;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
// update pet
|
||||
petToCheck.setStatus(QString("scary"));
|
||||
@ -122,6 +144,10 @@ void PetApiTests::updatePetTest() {
|
||||
QVERIFY(pet.getStatus().compare(petToCheck.getStatus()) == 0);
|
||||
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);
|
||||
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
||||
loop.exec();
|
||||
@ -142,6 +168,10 @@ void PetApiTests::updatePetWithFormTest() {
|
||||
petAdded = true;
|
||||
loop.quit();
|
||||
});
|
||||
connect(&api, &PFXPetApi::addPetSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||
qDebug() << "Error happened while issuing request : " << error_str;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
api.addPet(pet);
|
||||
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
||||
@ -155,6 +185,10 @@ void PetApiTests::updatePetWithFormTest() {
|
||||
petToCheck = pet;
|
||||
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);
|
||||
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
||||
@ -167,6 +201,10 @@ void PetApiTests::updatePetWithFormTest() {
|
||||
petUpdated = true;
|
||||
loop.quit();
|
||||
});
|
||||
connect(&api, &PFXPetApi::updatePetWithFormSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||
qDebug() << "Error happened while issuing request : " << error_str;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
QString name("gorilla");
|
||||
api.updatePetWithForm(id, name, nullptr);
|
||||
@ -181,6 +219,10 @@ void PetApiTests::updatePetWithFormTest() {
|
||||
QVERIFY(pet.getName().compare(QString("gorilla")) == 0);
|
||||
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);
|
||||
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
|
||||
|
@ -16,8 +16,8 @@ void StoreApiTests::placeOrderTest() {
|
||||
qDebug() << order.getShipDate();
|
||||
loop.quit();
|
||||
});
|
||||
connect(&api, &PFXStoreApi::placeOrderSignalE, [&]() {
|
||||
QFAIL("shouldn't trigger error");
|
||||
connect(&api, &PFXStoreApi::placeOrderSignalE, [&](PFXOrder, QNetworkReply::NetworkError, QString error_str) {
|
||||
qDebug() << "Error happened while issuing request : " << error_str;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
@ -46,6 +46,10 @@ void StoreApiTests::getOrderByIdTest() {
|
||||
qDebug() << order.getShipDate();
|
||||
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);
|
||||
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
||||
@ -65,6 +69,10 @@ void StoreApiTests::getInventoryTest() {
|
||||
}
|
||||
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();
|
||||
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
||||
|
@ -26,6 +26,10 @@ void UserApiTests::createUserTest() {
|
||||
userCreated = true;
|
||||
loop.quit();
|
||||
});
|
||||
connect(&api, &PFXUserApi::createUserSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||
qDebug() << "Error happened while issuing request : " << error_str;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
api.createUser(createRandomUser());
|
||||
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
||||
@ -42,6 +46,10 @@ void UserApiTests::createUsersWithArrayInputTest() {
|
||||
usersCreated = true;
|
||||
loop.quit();
|
||||
});
|
||||
connect(&api, &PFXUserApi::createUsersWithArrayInputSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||
qDebug() << "Error happened while issuing request : " << error_str;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
QList<PFXUser> users;
|
||||
users.append(createRandomUser());
|
||||
@ -62,6 +70,10 @@ void UserApiTests::createUsersWithListInputTest() {
|
||||
usersCreated = true;
|
||||
loop.quit();
|
||||
});
|
||||
connect(&api, &PFXUserApi::createUsersWithListInputSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||
qDebug() << "Error happened while issuing request : " << error_str;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
QList<PFXUser> users;
|
||||
auto johndoe = createRandomUser();
|
||||
@ -86,6 +98,11 @@ void UserApiTests::deleteUserTest() {
|
||||
userDeleted = true;
|
||||
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");
|
||||
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
||||
@ -104,6 +121,11 @@ void UserApiTests::getUserByNameTest() {
|
||||
QVERIFY(summary.getUsername() == "johndoe");
|
||||
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");
|
||||
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
||||
@ -121,6 +143,11 @@ void UserApiTests::loginUserTest() {
|
||||
qDebug() << summary;
|
||||
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");
|
||||
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
||||
@ -137,6 +164,10 @@ void UserApiTests::logoutUserTest() {
|
||||
userLoggedOut = true;
|
||||
loop.quit();
|
||||
});
|
||||
connect(&api, &PFXUserApi::logoutUserSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||
qDebug() << "Error happened while issuing request : " << error_str;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
api.logoutUser();
|
||||
QTimer::singleShot(14000, &loop, &QEventLoop::quit);
|
||||
@ -153,6 +184,10 @@ void UserApiTests::updateUserTest() {
|
||||
userUpdated = true;
|
||||
loop.quit();
|
||||
});
|
||||
connect(&api, &PFXUserApi::updateUserSignalE, [&](QNetworkReply::NetworkError, QString error_str) {
|
||||
qDebug() << "Error happened while issuing request : " << error_str;
|
||||
loop.quit();
|
||||
});
|
||||
|
||||
auto johndoe = createRandomUser();
|
||||
johndoe.setUsername("johndoe");
|
||||
|
Loading…
x
Reference in New Issue
Block a user