Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 46d2de48

Von Christian Ehringfeld vor etwa 9 Jahren hinzugefügt

testcases fixxed

Unterschiede anzeigen:

src/attribute.cpp
#include "attribute.h"
using namespace CuteEntityManager;
Attribute::Attribute()
{
Attribute::Attribute(QString name, QString columnName, QString tableName,
QMetaObject *metaObj, QString relatedTable, QMetaObject *relatedClass,
QString conjunctedTable) {
this->name = name;
this->tableName = tableName;
this->metaObj = metaObj;
this->relatedTable = relatedTable;
this->relatedClass = relatedClass;
this->conjunctedTable = conjunctedTable;
}
QString Attribute::getName() const {
return name;
}
void Attribute::setName(const QString &value) {
name = value;
}
QString Attribute::getColumnName() const {
return columnName;
}
void Attribute::setColumnName(const QString &value) {
columnName = value;
}
QString Attribute::getTableName() const {
return tableName;
}
void Attribute::setTableName(const QString &value) {
tableName = value;
}
QString Attribute::getRelatedTable() const {
return relatedTable;
}
void Attribute::setRelatedTable(const QString &value) {
relatedTable = value;
}
QMetaObject *Attribute::getRelatedClass() const {
return relatedClass;
}
void Attribute::setRelatedClass(QMetaObject *value) {
relatedClass = value;
}
QString Attribute::getConjunctedTable() const {
return conjunctedTable;
}
void Attribute::setConjunctedTable(const QString &value) {
conjunctedTable = value;
}
QMetaObject *Attribute::getMetaObj() const {
return metaObj;
}
void Attribute::setMetaObj(QMetaObject *value) {
metaObj = value;
}
src/attribute.h
class Attribute {
public:
Attribute();
private:
Attribute(QString name, QString columnName, QString tableName, QMetaObject *metaObj,
QString relatedTable = "", QMetaObject *relatedClass = nullptr,
QString conjunctedTable = "");
QString getName() const;
void setName(const QString &value);
QString getColumnName() const;
void setColumnName(const QString &value);
QString getTableName() const;
void setTableName(const QString &value);
QString getRelatedTable() const;
void setRelatedTable(const QString &value);
QMetaObject *getRelatedClass() const;
void setRelatedClass(QMetaObject *value);
QString getConjunctedTable() const;
void setConjunctedTable(const QString &value);
QMetaObject *getMetaObj() const;
void setMetaObj(QMetaObject *value);
private:
QString name;
QString className;
QString relatedClass;
QString columnName;
QString tableName;
QMetaObject *metaObj;
QString relatedTable;
QMetaObject *relatedClass;
QString conjunctedTable;
};
}
#endif // ATTRIBUTE_H
src/entityhelper.h
static const QHash<Relation, QMetaProperty> getRelationProperties(
const Entity *entity);
static Entity* copyObject(const Entity *entity);
static Entity* getBaseClassObject(const QSharedPointer<Entity> &entity, QString attributeName);
static Entity* getBaseClassObject(const QSharedPointer<Entity> &entity,
QString attributeName);
static const char *getClassname(const Entity *entity);
static const QString getClassName(const Entity *entity);
static void addEntityToListProperty(const QSharedPointer<Entity> &entity,
tests/em/tst_querybuilder.cpp
void QuerybuilderTest::testFindByAttributesManyToManyRelation() {
QHash<QString, QVariant> attributes;
attributes["persNumber"] = 42;
attributes["firstName"] = "Kristina";
QSharedPointer<Person> p = e->findEntityByAttributes<Person>(attributes, true);
QVERIFY(p);
QCOMPARE(p->getNickName(), QString("Lotta"));
QCOMPARE(p->getFamilyName(), QString("Zero"));
attributes.clear();
attributes["persons"] = QVariant(p);
QSharedPointer<Group> group = e->findEntityByAttributes<Group>
......
q.setLimit(10);
QList<QSharedPointer<Person>> list = e->find<Person>(q, true);
QCOMPARE(list.size(), 2);
QCOMPARE(list.at(0)->getFirstName(), QString("Janine"));
QCOMPARE(list.at(1)->getFirstName(), QString("Lucien"));
QCOMPARE(list.at(0)->getFirstName(), QString("Fenja"));
QCOMPARE(list.at(0)->getFamilyName(), QString("Sey."));
QCOMPARE(list.at(1)->getFirstName(), QString("Fenja"));
QCOMPARE(list.at(1)->getFamilyName(), QString("Neu"));
}
void QuerybuilderTest::testQueryBuilderJoins() {
auto qb = e->getQueryBuilder();
Query q = Query();
q.appendWhere(q.equal(qb, "firstName", "Kristina"));
q.appendWhere(q.equal(qb, "firstName", "Milan"));
q.appendJoin(Join("person", "person.id = employee.id"));
QList<QSharedPointer<Employee>> list = e->find<Employee>(q, false);
QCOMPARE(list.size(), 1);
QCOMPARE(list.at(0)->getFirstName(), QString("Kristina"));
QCOMPARE(list.at(0)->getFirstName(), QString("Milan"));
QCOMPARE(list.at(0)->getFamilyName(), QString("Mes."));
}
void QuerybuilderTest::testQueryBuilderManyToOneRelation() {

Auch abrufbar als: Unified diff