edited in order to comments

This commit is contained in:
Ondřej Fischer 2019-10-11 14:25:27 +02:00
parent 235ddc637d
commit 3c65d89b54
7 changed files with 78 additions and 252 deletions

View File

@ -3,10 +3,7 @@
ColnodAPI::ColnodAPI() ColnodAPI::ColnodAPI()
{ {
reqMan = new RequestManager(); reqMan = new RequestManager();
//data = new Data();
dataMan = new DataManager(); dataMan = new DataManager();
connect(this, &ColnodAPI::partReady, this, &ColnodAPI::checkPartOfData);
connect(this, &ColnodAPI::partReady, this, &ColnodAPI::areDataReady);
} }
@ -16,14 +13,14 @@ void ColnodAPI::downloadData()
Response* resp0 = reqMan->getSubjects(); Response* resp0 = reqMan->getSubjects();
connect(resp0, &Response::ready, [=](){ connect(resp0, &Response::ready, [=](){
dataMan->localSaveSubjects(resp0->reply->readAll()); dataMan->localSaveSubjects(resp0->reply->readAll());
emit partReady(); areDataReady();
resp0->deleteLater(); resp0->deleteLater();
}); });
Response* resp1 = reqMan->getTokens(); Response* resp1 = reqMan->getTokens();
connect(resp1, &Response::ready, [=](){ connect(resp1, &Response::ready, [=](){
dataMan->localSaveTokens(resp1->reply->readAll()); dataMan->localSaveTokens(resp1->reply->readAll());
emit partReady(); areDataReady();
resp1->deleteLater(); resp1->deleteLater();
}); });
@ -43,14 +40,8 @@ void ColnodAPI::syncData()
// PRIVATE FUNCTIONS // PRIVATE FUNCTIONS
void ColnodAPI::areDataReady() void ColnodAPI::areDataReady()
{ {
if (index >= numOfMembers) if (dataMan->haveData())
{
emit dataDownloaded(); emit dataDownloaded();
} }
}
void ColnodAPI::checkPartOfData()
{
index++;
}

View File

@ -23,7 +23,6 @@ signals:
private slots: private slots:
void areDataReady(); void areDataReady();
void checkPartOfData();
private: private:

View File

@ -52,4 +52,11 @@ void DataManager::pushDataToDB()
qDebug() << counter << " tokens has been updated"; qDebug() << counter << " tokens has been updated";
} }
bool DataManager::haveData() {
if ( !subjects.isEmpty() && !tokens.isEmpty() )
return true;
return false;
}

View File

@ -20,6 +20,7 @@ public:
void localSaveSubjects(QString jsonResponse); void localSaveSubjects(QString jsonResponse);
void localSaveTokens(QString jsonResponse); void localSaveTokens(QString jsonResponse);
void pushDataToDB(); void pushDataToDB();
bool haveData();

View File

@ -97,7 +97,43 @@ QNetworkReply* RequestManager::postRequest(QString endpoint, QByteArray json)
return reply; return reply;
} }
Response* RequestManager::getRequestReturnLogic(QString endpoint)
{
Response* response = new Response;
if (!loginStatus){
login(host, user, password);
connect(this, &RequestManager::successLogin, [=](){
response->reply = getRequest(endpoint);
connect(response->reply, &QNetworkReply::finished, response, &Response::ready);
});
}
else
{
response->reply = getRequest(endpoint);
connect(response->reply, &QNetworkReply::finished, response, &Response::ready);
}
return response;
}
Response* RequestManager::postRequestReturnLogic(QString endpoint, QByteArray data)
{
Response* response = new Response;
if (!loginStatus){
login(host, user, password);
connect(this, &RequestManager::successLogin, [=](){
response->reply = postRequest(endpoint, data);
connect(response->reply, &QNetworkReply::finished, response, &Response::ready);
});
}
else
{
response->reply = postRequest(endpoint, data);
connect(response->reply, &QNetworkReply::finished, response, &Response::ready);
}
return response;
}
QString RequestManager::getFromJson(QString json, const QString &member) QString RequestManager::getFromJson(QString json, const QString &member)
{ {
@ -150,262 +186,67 @@ QByteArray RequestManager::makeTimeStampJson(uint64_t time)
Response* RequestManager::getSubjects() Response* RequestManager::getSubjects()
{ {
auto response = new Response; return getRequestReturnLogic("/SubjectManager/getSubjects");
if (!loginStatus){
login(host, user, password);
connect(this, &RequestManager::successLogin, [=](){
auto subjectReply = getRequest("/SubjectManager/getSubjects");
response->reply = subjectReply;
connect(subjectReply, &QNetworkReply::finished, response, &Response::ready);
});
}
else
{
QNetworkReply* reply = getRequest("/SubjectManager/getSubjects");
connect(reply, &QNetworkReply::finished, response, &Response::ready);
}
return response;
} }
Response* RequestManager::getTokens() Response* RequestManager::getTokens()
{ {
auto response = new Response; return getRequestReturnLogic("/TokenManager/getTokens");
if (!loginStatus){
login(host, user, password);
connect(this, &RequestManager::successLogin, [=](){
auto subjectReply = getRequest("/TokenManager/getTokens");
response->reply = subjectReply;
connect(subjectReply, &QNetworkReply::finished, response, &Response::ready);
});
}
else
{
QNetworkReply* reply = getRequest("/TokenManager/getTokens");
connect(reply, &QNetworkReply::finished, response, &Response::ready);
}
return response;
} }
Response* RequestManager::getTokenSubject() Response* RequestManager::getTokenSubject()
{ {
auto response = new Response; return getRequestReturnLogic("/OpenManager/getTokenSubject");
if (!loginStatus){
login(host, user, password);
connect(this, &RequestManager::successLogin, [=](){
auto subjectReply = getRequest("/OpenManager/getTokenSubject");
response->reply = subjectReply;
connect(subjectReply, &QNetworkReply::finished, response, &Response::ready);
});
}
else
{
QNetworkReply* reply = getRequest("/OpenManager/getTokenSubject");
connect(reply, &QNetworkReply::finished, response, &Response::ready);
}
return response;
} }
Response* RequestManager::getSubjectsUpdated(uint64_t time) Response* RequestManager::getSubjectsUpdated(uint64_t time)
{ {
auto response = new Response; return postRequestReturnLogic("/SubjectManager/getSubjectsUpdated", makeTimeStampJson(time));
if (!loginStatus){
login(host, user, password);
connect(this, &RequestManager::successLogin, [=](){
auto subjectReply = postRequest("/SubjectManager/getSubjectsUpdated", makeTimeStampJson(time));
response->reply = subjectReply;
connect(subjectReply, &QNetworkReply::finished, response, &Response::ready);
});
}
else
{
QNetworkReply* reply = postRequest("/SubjectManager/getSubjectsUpdated", makeTimeStampJson(time));
connect(reply, &QNetworkReply::finished, response, &Response::ready);
}
return response;
} }
Response* RequestManager::getSubjectsDeleted(uint64_t time) Response* RequestManager::getSubjectsDeleted(uint64_t time)
{ {
auto response = new Response; return postRequestReturnLogic("/SubjectManager/getSubjectsDeleted", makeTimeStampJson(time));
if (!loginStatus){
login(host, user, password);
connect(this, &RequestManager::successLogin, [=](){
auto subjectReply = postRequest("/SubjectManager/getSubjectsDeleted", makeTimeStampJson(time));
response->reply = subjectReply;
connect(subjectReply, &QNetworkReply::finished, response, &Response::ready);
});
}
else
{
QNetworkReply* reply = postRequest("/SubjectManager/getSubjectsDeleted", makeTimeStampJson(time));
connect(reply, &QNetworkReply::finished, response, &Response::ready);
}
return response;
} }
Response* RequestManager::getTokensUpdated(uint64_t time) Response* RequestManager::getTokensUpdated(uint64_t time)
{ {
auto response = new Response; return postRequestReturnLogic("/TokenManager/getTokensUpdated", makeTimeStampJson(time));
if (!loginStatus){
login(host, user, password);
connect(this, &RequestManager::successLogin, [=](){
auto subjectReply = postRequest("/TokenManager/getTokensUpdated", makeTimeStampJson(time));
response->reply = subjectReply;
connect(subjectReply, &QNetworkReply::finished, response, &Response::ready);
});
}
else
{
QNetworkReply* reply = postRequest("/TokenManager/getTokensUpdated", makeTimeStampJson(time));
connect(reply, &QNetworkReply::finished, response, &Response::ready);
}
return response;
} }
Response* RequestManager::getTokensDeleted(uint64_t time) Response* RequestManager::getTokensDeleted(uint64_t time)
{ {
auto response = new Response; return postRequestReturnLogic("/TokenManager/getTokensDeleted", makeTimeStampJson(time));
if (!loginStatus){
login(host, user, password);
connect(this, &RequestManager::successLogin, [=](){
auto subjectReply = postRequest("/TokenManager/getTokensDeleted", makeTimeStampJson(time));
response->reply = subjectReply;
connect(subjectReply, &QNetworkReply::finished, response, &Response::ready);
});
}
else
{
QNetworkReply* reply = postRequest("/TokenManager/getTokensDeleted", makeTimeStampJson(time));
connect(reply, &QNetworkReply::finished, response, &Response::ready);
}
return response;
} }
Response* RequestManager::getAccessGroups() Response* RequestManager::getAccessGroups()
{ {
auto response = new Response; return getRequestReturnLogic("/AccessManager/getAccessGroups");
if (!loginStatus){
login(host, user, password);
connect(this, &RequestManager::successLogin, [=](){
auto subjectReply = getRequest("/AccessManager/getAccessGroups");
response->reply = subjectReply;
connect(subjectReply, &QNetworkReply::finished, response, &Response::ready);
});
}
else
{
QNetworkReply* reply = getRequest("/AccessManager/getAccessGroups");
connect(reply, &QNetworkReply::finished, response, &Response::ready);
}
return response;
} }
Response* RequestManager::getAccessGroupsUpdated(uint64_t time) Response* RequestManager::getAccessGroupsUpdated(uint64_t time)
{ {
auto response = new Response; return postRequestReturnLogic("/AccessManager/getAccessGroupsUpdated", makeTimeStampJson(time));
if (!loginStatus){
login(host, user, password);
connect(this, &RequestManager::successLogin, [=](){
auto subjectReply = postRequest("/AccessManager/getAccessGroupsUpdated", makeTimeStampJson(time));
response->reply = subjectReply;
connect(subjectReply, &QNetworkReply::finished, response, &Response::ready);
});
}
else
{
QNetworkReply* reply = postRequest("/AccessManager/getAccessGroupsUpdated", makeTimeStampJson(time));
connect(reply, &QNetworkReply::finished, response, &Response::ready);
}
return response;
} }
Response* RequestManager::getAccessGroupsDeleted(uint64_t time) Response* RequestManager::getAccessGroupsDeleted(uint64_t time)
{ {
auto response = new Response; return postRequestReturnLogic("/AccessManager/getAccessGroupsDeleted", makeTimeStampJson(time));
if (!loginStatus){
login(host, user, password);
connect(this, &RequestManager::successLogin, [=](){
auto subjectReply = postRequest("/AccessManager/getAccessGroupsDeleted", makeTimeStampJson(time));
response->reply = subjectReply;
connect(subjectReply, &QNetworkReply::finished, response, &Response::ready);
});
}
else
{
QNetworkReply* reply = postRequest("/AccessManager/getAccessGroupsDeleted", makeTimeStampJson(time));
connect(reply, &QNetworkReply::finished, response, &Response::ready);
}
return response;
} }
Response* RequestManager::getAccessGroupMembership() Response* RequestManager::getAccessGroupMembership()
{ {
auto response = new Response; return getRequestReturnLogic("/AccessManager/getAccessGroupMembership");
if (!loginStatus){
login(host, user, password);
connect(this, &RequestManager::successLogin, [=](){
auto subjectReply = getRequest("/AccessManager/getAccessGroupMembership");
response->reply = subjectReply;
connect(subjectReply, &QNetworkReply::finished, response, &Response::ready);
});
}
else
{
QNetworkReply* reply = getRequest("/AccessManager/getAccessGroupMembership");
connect(reply, &QNetworkReply::finished, response, &Response::ready);
}
return response;
} }
Response* RequestManager::getAccessGroupMembershipUpdated(uint64_t time) Response* RequestManager::getAccessGroupMembershipUpdated(uint64_t time)
{ {
auto response = new Response; return postRequestReturnLogic("/AccessManager/getAccessGroupMembershipUpdated", makeTimeStampJson(time));
if (!loginStatus){
login(host, user, password);
connect(this, &RequestManager::successLogin, [=](){
auto subjectReply = postRequest("/AccessManager/getAccessGroupMembershipUpdated", makeTimeStampJson(time));
response->reply = subjectReply;
connect(subjectReply, &QNetworkReply::finished, response, &Response::ready);
});
}
else
{
QNetworkReply* reply = postRequest("/AccessManager/getAccessGroupMembershipUpdated", makeTimeStampJson(time));
connect(reply, &QNetworkReply::finished, response, &Response::ready);
}
return response;
} }
Response* RequestManager::getAccessGroupMembershipDeleted(uint64_t time) Response* RequestManager::getAccessGroupMembershipDeleted(uint64_t time)
{ {
auto response = new Response; return postRequestReturnLogic("/AccessManager/getAccessGroupMembershipDeleted", makeTimeStampJson(time));
if (!loginStatus){
login(host, user, password);
connect(this, &RequestManager::successLogin, [=](){
auto subjectReply = postRequest("/AccessManager/getAccessGroupMembershipDeleted", makeTimeStampJson(time));
response->reply = subjectReply;
connect(subjectReply, &QNetworkReply::finished, response, &Response::ready);
});
}
else
{
QNetworkReply* reply = postRequest("/AccessManager/getAccessGroupMembershipDeleted", makeTimeStampJson(time));
connect(reply, &QNetworkReply::finished, response, &Response::ready);
}
return response;
} }

View File

@ -55,6 +55,8 @@ public:
private: private:
QNetworkReply* getRequest(QString endpoint); QNetworkReply* getRequest(QString endpoint);
QNetworkReply* postRequest(QString endpoints, QByteArray json); QNetworkReply* postRequest(QString endpoints, QByteArray json);
Response* getRequestReturnLogic(QString endpoint);
Response* postRequestReturnLogic(QString endpoint, QByteArray data);
QString getFromJson(QString json, const QString &member); QString getFromJson(QString json, const QString &member);
QString encryptedPassword(QString password); QString encryptedPassword(QString password);
QString getLoginHeader(QString username, QString hash); QString getLoginHeader(QString username, QString hash);

View File

@ -18,10 +18,9 @@ void UnitTest::loginSuccessfully()
//POST request w/o datas //POST request w/o datas
void UnitTest::getSubjects() void UnitTest::getSubjects()
{ {
Response* response = new Response;
RequestManager* testAccess = new RequestManager(); RequestManager* testAccess = new RequestManager();
QSignalSpy spy(testAccess, SIGNAL(responseReady())); QSignalSpy spy(testAccess, SIGNAL(responseReady()));
response = testAccess->getSubjects(); Response* response = testAccess->getSubjects();
spy.wait(10000); spy.wait(10000);
QVERIFY(spy.isValid()); QVERIFY(spy.isValid());
QCOMPARE(spy.count(), 1); QCOMPARE(spy.count(), 1);
@ -36,10 +35,9 @@ void UnitTest::getSubjects()
void UnitTest::getTokens() void UnitTest::getTokens()
{ {
Response* response = new Response;
RequestManager* testAccess = new RequestManager(); RequestManager* testAccess = new RequestManager();
QSignalSpy spy(testAccess, SIGNAL(responseReady())); QSignalSpy spy(testAccess, SIGNAL(responseReady()));
response = testAccess->getTokens(); Response* response = testAccess->getTokens();
QCOMPARE(spy.count(), 0); QCOMPARE(spy.count(), 0);
spy.wait(10000); spy.wait(10000);
QVERIFY(spy.isValid()); QVERIFY(spy.isValid());
@ -54,10 +52,9 @@ void UnitTest::getTokens()
void UnitTest::getTokenSubject() void UnitTest::getTokenSubject()
{ {
Response* response = new Response;
RequestManager* testAccess = new RequestManager(); RequestManager* testAccess = new RequestManager();
QSignalSpy spy(testAccess, SIGNAL(responseReady())); QSignalSpy spy(testAccess, SIGNAL(responseReady()));
response = testAccess->getTokenSubject(); Response* response = testAccess->getTokenSubject();
QCOMPARE(spy.count(), 0); QCOMPARE(spy.count(), 0);
spy.wait(10000); spy.wait(10000);
QVERIFY(spy.isValid()); QVERIFY(spy.isValid());
@ -68,10 +65,9 @@ void UnitTest::getTokenSubject()
void UnitTest::getSubjectsUpdated() void UnitTest::getSubjectsUpdated()
{ {
Response* response = new Response;
RequestManager* testAccess = new RequestManager(); RequestManager* testAccess = new RequestManager();
QSignalSpy spy(testAccess, SIGNAL(responseReady())); QSignalSpy spy(testAccess, SIGNAL(responseReady()));
response = testAccess->getSubjectsUpdated(1568646217767); Response* response = testAccess->getSubjectsUpdated(1568646217767);
QCOMPARE(spy.count(), 0); QCOMPARE(spy.count(), 0);
spy.wait(10000); spy.wait(10000);
QVERIFY(spy.isValid()); QVERIFY(spy.isValid());
@ -82,10 +78,9 @@ void UnitTest::getSubjectsUpdated()
void UnitTest::getSubjectsDeleted() void UnitTest::getSubjectsDeleted()
{ {
Response* response = new Response;
RequestManager* testAccess = new RequestManager(); RequestManager* testAccess = new RequestManager();
QSignalSpy spy(testAccess, SIGNAL(responseReady())); QSignalSpy spy(testAccess, SIGNAL(responseReady()));
response = testAccess->getSubjectsDeleted(1568646217767); Response* response = testAccess->getSubjectsDeleted(1568646217767);
QCOMPARE(spy.count(), 0); QCOMPARE(spy.count(), 0);
spy.wait(10000); spy.wait(10000);
QVERIFY(spy.isValid()); QVERIFY(spy.isValid());
@ -96,10 +91,9 @@ void UnitTest::getSubjectsDeleted()
void UnitTest::getTokensUpdated() void UnitTest::getTokensUpdated()
{ {
Response* response = new Response;
RequestManager* testAccess = new RequestManager(); RequestManager* testAccess = new RequestManager();
QSignalSpy spy(testAccess, SIGNAL(responseReady())); QSignalSpy spy(testAccess, SIGNAL(responseReady()));
response = testAccess->getTokensUpdated(1570109859681); Response* response = testAccess->getTokensUpdated(1570109859681);
QCOMPARE(spy.count(), 0); QCOMPARE(spy.count(), 0);
spy.wait(10000); spy.wait(10000);
QVERIFY(spy.isValid()); QVERIFY(spy.isValid());
@ -110,10 +104,9 @@ void UnitTest::getTokensUpdated()
void UnitTest::getTokensDeleted() void UnitTest::getTokensDeleted()
{ {
Response* response = new Response;
RequestManager* testAccess = new RequestManager(); RequestManager* testAccess = new RequestManager();
QSignalSpy spy(testAccess, SIGNAL(responseReady())); QSignalSpy spy(testAccess, SIGNAL(responseReady()));
response = testAccess->getTokensDeleted(1570109859681); Response* response = testAccess->getTokensDeleted(1570109859681);
QCOMPARE(spy.count(), 0); QCOMPARE(spy.count(), 0);
spy.wait(10000); spy.wait(10000);
QVERIFY(spy.isValid()); QVERIFY(spy.isValid());
@ -124,10 +117,9 @@ void UnitTest::getTokensDeleted()
void UnitTest::getAccessGroups() void UnitTest::getAccessGroups()
{ {
Response* response = new Response;
RequestManager* testAccess = new RequestManager(); RequestManager* testAccess = new RequestManager();
QSignalSpy spy(testAccess, SIGNAL(responseReady())); QSignalSpy spy(testAccess, SIGNAL(responseReady()));
response = testAccess->getAccessGroups(); Response* response = testAccess->getAccessGroups();
QCOMPARE(spy.count(), 0); QCOMPARE(spy.count(), 0);
spy.wait(10000); spy.wait(10000);
QVERIFY(spy.isValid()); QVERIFY(spy.isValid());
@ -138,10 +130,9 @@ void UnitTest::getAccessGroups()
void UnitTest::getAccessGroupsUpdated() void UnitTest::getAccessGroupsUpdated()
{ {
Response* response = new Response;
RequestManager* testAccess = new RequestManager(); RequestManager* testAccess = new RequestManager();
QSignalSpy spy(testAccess, SIGNAL(responseReady())); QSignalSpy spy(testAccess, SIGNAL(responseReady()));
response = testAccess->getAccessGroupsUpdated(1568646217767); Response* response = testAccess->getAccessGroupsUpdated(1568646217767);
QCOMPARE(spy.count(), 0); QCOMPARE(spy.count(), 0);
spy.wait(10000); spy.wait(10000);
QVERIFY(spy.isValid()); QVERIFY(spy.isValid());
@ -152,10 +143,9 @@ void UnitTest::getAccessGroupsUpdated()
void UnitTest::getAccessGroupsDeleted() void UnitTest::getAccessGroupsDeleted()
{ {
Response* response = new Response;
RequestManager* testAccess = new RequestManager(); RequestManager* testAccess = new RequestManager();
QSignalSpy spy(testAccess, SIGNAL(responseReady())); QSignalSpy spy(testAccess, SIGNAL(responseReady()));
response = testAccess->getAccessGroupsDeleted(1568646217767); Response* response = testAccess->getAccessGroupsDeleted(1568646217767);
QCOMPARE(spy.count(), 0); QCOMPARE(spy.count(), 0);
spy.wait(10000); spy.wait(10000);
QVERIFY(spy.isValid()); QVERIFY(spy.isValid());
@ -166,10 +156,9 @@ void UnitTest::getAccessGroupsDeleted()
void UnitTest::getAccessGroupMembership() void UnitTest::getAccessGroupMembership()
{ {
Response* response = new Response;
RequestManager* testAccess = new RequestManager(); RequestManager* testAccess = new RequestManager();
QSignalSpy spy(testAccess, SIGNAL(responseReady())); QSignalSpy spy(testAccess, SIGNAL(responseReady()));
response = testAccess->getAccessGroupMembership(); Response* response = testAccess->getAccessGroupMembership();
QCOMPARE(spy.count(), 0); QCOMPARE(spy.count(), 0);
spy.wait(10000); spy.wait(10000);
QVERIFY(spy.isValid()); QVERIFY(spy.isValid());
@ -180,10 +169,9 @@ void UnitTest::getAccessGroupMembership()
void UnitTest::getAccessGroupMembershipUpdated() void UnitTest::getAccessGroupMembershipUpdated()
{ {
Response* response = new Response;
RequestManager* testAccess = new RequestManager(); RequestManager* testAccess = new RequestManager();
QSignalSpy spy(testAccess, SIGNAL(responseReady())); QSignalSpy spy(testAccess, SIGNAL(responseReady()));
response = testAccess->getAccessGroupMembershipUpdated(1568646217767); Response* response = testAccess->getAccessGroupMembershipUpdated(1568646217767);
QCOMPARE(spy.count(), 0); QCOMPARE(spy.count(), 0);
spy.wait(10000); spy.wait(10000);
QVERIFY(spy.isValid()); QVERIFY(spy.isValid());
@ -194,10 +182,9 @@ void UnitTest::getAccessGroupMembershipUpdated()
void UnitTest::getAccessGroupMembershipDeleted() void UnitTest::getAccessGroupMembershipDeleted()
{ {
Response* response = new Response;
RequestManager* testAccess = new RequestManager(); RequestManager* testAccess = new RequestManager();
QSignalSpy spy(testAccess, SIGNAL(responseReady())); QSignalSpy spy(testAccess, SIGNAL(responseReady()));
response = testAccess->getAccessGroupMembershipDeleted(1568646217767); Response* response = testAccess->getAccessGroupMembershipDeleted(1568646217767);
QCOMPARE(spy.count(), 0); QCOMPARE(spy.count(), 0);
spy.wait(10000); spy.wait(10000);
QVERIFY(spy.isValid()); QVERIFY(spy.isValid());
@ -221,10 +208,9 @@ void UnitTest::subjectJSONParser()
QJsonObject obj = doc.object(); QJsonObject obj = doc.object();
QJsonArray arr = obj["items"].toArray(); QJsonArray arr = obj["items"].toArray();
*/ */
Response* response = new Response;
RequestManager* testAccess = new RequestManager(); RequestManager* testAccess = new RequestManager();
QSignalSpy spy(testAccess, SIGNAL(responseReady())); QSignalSpy spy(testAccess, SIGNAL(responseReady()));
response = testAccess->getSubjects(); Response* response = testAccess->getSubjects();
spy.wait(10000); spy.wait(10000);
QString json = response->reply->readAll(); QString json = response->reply->readAll();
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8()); QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
@ -237,10 +223,9 @@ void UnitTest::subjectJSONParser()
void UnitTest::tokenJSONParser() void UnitTest::tokenJSONParser()
{ {
Response* response = new Response;
RequestManager* testAccess = new RequestManager(); RequestManager* testAccess = new RequestManager();
QSignalSpy spy(testAccess, SIGNAL(responseReady())); QSignalSpy spy(testAccess, SIGNAL(responseReady()));
response = testAccess->getTokens(); Response* response = testAccess->getTokens();
spy.wait(10000); spy.wait(10000);
QString json = response->reply->readAll(); QString json = response->reply->readAll();
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8()); QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
@ -258,7 +243,7 @@ void UnitTest::connectToDB()
qDebug() << db->getTestMessage(1); qDebug() << db->getTestMessage(1);
QVERIFY(true); QVERIFY(true);
QCOMPARE(db->getTestMessage(1), QStringLiteral("Hello world")); QCOMPARE(db->getTestMessage(1), QStringLiteral("Hello world"));
QCOMPARE(db->getTestMessage(db->createTestRecord("Now it's diffrent")), QStringLiteral("Does it work?")); QCOMPARE(db->getTestMessage(db->createTestRecord("Now it's diffrent")), QStringLiteral("Now it's diffrent"));
} }
/* /*