mirror of
https://gitlab.com/spaceti-app/integrations/acs/colnod-connector.git
synced 2026-07-12 15:40:40 +02:00
Finish unit test
This commit is contained in:
parent
988e01ef1b
commit
0efd39d4ae
6
src/colnod/colnodapi.cpp
Normal file
6
src/colnod/colnodapi.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include "colnodapi.h"
|
||||||
|
|
||||||
|
ColnodAPI::ColnodAPI()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
11
src/colnod/colnodapi.h
Normal file
11
src/colnod/colnodapi.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#ifndef COLNODAPI_H
|
||||||
|
#define COLNODAPI_H
|
||||||
|
|
||||||
|
|
||||||
|
class ColnodAPI
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ColnodAPI();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // COLNODAPI_H
|
||||||
@ -4,7 +4,7 @@ DataProcessor::DataProcessor(Data *data)
|
|||||||
{
|
{
|
||||||
|
|
||||||
db = new DatabaseManager("192.168.1.94", "deloitte", "postgres", "34rjkciea12");
|
db = new DatabaseManager("192.168.1.94", "deloitte", "postgres", "34rjkciea12");
|
||||||
reqMan = new RequestManager(data);
|
reqMan = new RequestManager();
|
||||||
dataToProcess = data;
|
dataToProcess = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
#include "requestmanager.h"
|
#include "requestmanager.h"
|
||||||
|
|
||||||
RequestManager::RequestManager(Data *data)
|
RequestManager::RequestManager()
|
||||||
{
|
{
|
||||||
manager = new QNetworkAccessManager();
|
manager = new QNetworkAccessManager();
|
||||||
token = "";
|
token = "";
|
||||||
loginStatus = false; //should be false, true for testing request header
|
loginStatus = false; //should be false, true for testing request header
|
||||||
this->data = data;
|
|
||||||
/*
|
/*
|
||||||
QFile configFile(QDir::current().filePath("config.json"));
|
QFile configFile(QDir::current().filePath("config.json"));
|
||||||
if (!configFile.open(QIODevice::ReadOnly)) {
|
if (!configFile.open(QIODevice::ReadOnly)) {
|
||||||
|
|||||||
@ -31,7 +31,7 @@ class RequestManager : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RequestManager(Data *data);
|
RequestManager();
|
||||||
void getSubjects();
|
void getSubjects();
|
||||||
void login(QString endpoint, QString username, QString password);
|
void login(QString endpoint, QString username, QString password);
|
||||||
void getRequest(QString endpoint);
|
void getRequest(QString endpoint);
|
||||||
|
|||||||
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
void UnitTest::loginSuccessfully()
|
void UnitTest::loginSuccessfully()
|
||||||
{
|
{
|
||||||
Data *data = new Data();
|
RequestManager* testAccess = new RequestManager();
|
||||||
RequestManager* testAccess = new RequestManager(data);
|
|
||||||
QJsonDocument config = testAccess->getConfig();
|
QJsonDocument config = testAccess->getConfig();
|
||||||
QSignalSpy spy(testAccess, SIGNAL(successLogin()));
|
QSignalSpy spy(testAccess, SIGNAL(successLogin()));
|
||||||
testAccess->login(host, email, password);
|
testAccess->login(host, email, password);
|
||||||
@ -19,8 +18,7 @@ void UnitTest::loginSuccessfully()
|
|||||||
//POST request w/o datas
|
//POST request w/o datas
|
||||||
void UnitTest::getSubjects()
|
void UnitTest::getSubjects()
|
||||||
{
|
{
|
||||||
Data *data = new Data();
|
RequestManager* testAccess = new RequestManager();
|
||||||
RequestManager* testAccess = new RequestManager(data);
|
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
||||||
testAccess->getRequest("/SubjectManager/getSubjects");
|
testAccess->getRequest("/SubjectManager/getSubjects");
|
||||||
spy.wait();
|
spy.wait();
|
||||||
@ -38,21 +36,25 @@ void UnitTest::getSubjects()
|
|||||||
|
|
||||||
void UnitTest::getTokens()
|
void UnitTest::getTokens()
|
||||||
{
|
{
|
||||||
Data *data = new Data();
|
RequestManager* testAccess = new RequestManager();
|
||||||
RequestManager* testAccess = new RequestManager(data);
|
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
||||||
testAccess->getRequest("/TokenManager/getTokens");
|
testAccess->getRequest("/TokenManager/getTokens");
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
spy.wait();
|
spy.wait();
|
||||||
QVERIFY(spy.isValid());
|
QVERIFY(spy.isValid());
|
||||||
QCOMPARE(spy.count(), 1);
|
QCOMPARE(spy.count(), 1);
|
||||||
qDebug() << testAccess->getResponse();
|
QString json = testAccess->getResponse();
|
||||||
|
qDebug() << json;
|
||||||
|
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
||||||
|
QVERIFY(doc.isObject());
|
||||||
|
QVERIFY2(doc.object().value("items").isArray(), "No parameter 'id' in response");
|
||||||
|
qDebug() << doc.object().value("items").toArray()[0].toObject()["id"].toString();
|
||||||
|
QVERIFY2(doc.object().value("items").toArray()[0].toObject()["id"].isString(), "ada");
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::getTokensOpenManager()
|
void UnitTest::getTokensOpenManager()
|
||||||
{
|
{
|
||||||
Data *data = new Data();
|
RequestManager* testAccess = new RequestManager();
|
||||||
RequestManager* testAccess = new RequestManager(data);
|
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
||||||
testAccess->getRequest("/OpenManager/getTokenSubject");
|
testAccess->getRequest("/OpenManager/getTokenSubject");
|
||||||
QCOMPARE(spy.count(), 0);
|
QCOMPARE(spy.count(), 0);
|
||||||
@ -79,12 +81,8 @@ void UnitTest::subjectJSONParser()
|
|||||||
QJsonObject obj = doc.object();
|
QJsonObject obj = doc.object();
|
||||||
QJsonArray arr = obj["items"].toArray();
|
QJsonArray arr = obj["items"].toArray();
|
||||||
*/
|
*/
|
||||||
QVERIFY(true);
|
|
||||||
//return;
|
|
||||||
|
|
||||||
|
RequestManager* testAccess = new RequestManager();
|
||||||
Data *data = new Data();
|
|
||||||
RequestManager* testAccess = new RequestManager(data);
|
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
||||||
testAccess->getRequest("/SubjectManager/getSubjects");
|
testAccess->getRequest("/SubjectManager/getSubjects");
|
||||||
spy.wait();
|
spy.wait();
|
||||||
@ -99,22 +97,17 @@ void UnitTest::subjectJSONParser()
|
|||||||
|
|
||||||
void UnitTest::tokenJSONParser()
|
void UnitTest::tokenJSONParser()
|
||||||
{
|
{
|
||||||
Data *data = new Data();
|
RequestManager* testAccess = new RequestManager();
|
||||||
RequestManager* testAccess = new RequestManager(data);
|
|
||||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
||||||
testAccess->getRequest("/TokenManager/getTokens");
|
testAccess->getRequest("/TokenManager/getTokens");
|
||||||
spy.wait();
|
spy.wait();
|
||||||
QString response = testAccess->getResponse();
|
QString response = testAccess->getResponse();
|
||||||
|
QJsonDocument doc = QJsonDocument::fromJson(response.toUtf8());
|
||||||
//TODO
|
|
||||||
/* QJsonDocument doc = QJsonDocument::fromJson(response.toUtf8());
|
|
||||||
QJsonArray arr = doc.object()["items"].toArray();
|
QJsonArray arr = doc.object()["items"].toArray();
|
||||||
auto testSubject = new Subject();
|
auto testToken = new Token();
|
||||||
testSubject->fromJSON(arr[1].toObject());
|
testToken->fromJSON(arr[5].toObject());
|
||||||
qDebug() << testSubject->getName();
|
qDebug() << testToken->getName() << " Size: " << arr.size();
|
||||||
QVERIFY(!testSubject->getName().isEmpty());*/
|
QVERIFY(!testToken->getName().isEmpty());
|
||||||
QVERIFY(true);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitTest::connectToDB()
|
void UnitTest::connectToDB()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user