1 #include <TestUtilities.hpp>
3 #include <GDESession.hpp>
4 #include <ProfilesTest.hpp>
7 ProfilesTest::testCreateDeleteProfile()
9 gde::GDESession session(serverAddress, credentials);
11 gde::Profile myProfile("myProfile");
12 CPPUNIT_ASSERT(myProfile.getId() == 0);
13 gde::Profile profile = session.createProfile(myProfile);
14 CPPUNIT_ASSERT(profile.getId() > 0);
15 CPPUNIT_ASSERT(profile.getName() == myProfile.getName());
17 CPPUNIT_ASSERT(session.deleteProfile(profile));
21 ProfilesTest::testReadProfile()
23 gde::GDESession session(serverAddress, credentials);
25 gde::Profile myProfile("myProfile");
26 CPPUNIT_ASSERT(myProfile.getId() == 0);
27 gde::Profile profile = session.createProfile(myProfile);
28 CPPUNIT_ASSERT(profile.getId() > 0);
31 const gde::Profile& prf = session.readProfile(profile.getId());
32 CPPUNIT_ASSERT(prf.getName() == myProfile.getName());
33 CPPUNIT_ASSERT(prf.getId() > 0);
36 CPPUNIT_ASSERT(session.deleteProfile(profile));
40 ProfilesTest::testUpdateProfile()
42 gde::GDESession session(serverAddress, credentials);
44 gde::Profile myProfile("myProfile");
45 CPPUNIT_ASSERT(myProfile.getId() == 0);
46 gde::Profile profile = session.createProfile(myProfile);
47 CPPUNIT_ASSERT(profile.getId() > 0);
48 CPPUNIT_ASSERT(profile.getName() == "myProfile");
49 profile.setName("myProfile2");
52 const gde::Profile& prf = session.updateProfile(profile);
53 CPPUNIT_ASSERT(prf.getName() == profile.getName());
54 CPPUNIT_ASSERT(prf.getId() == profile.getId());
57 CPPUNIT_ASSERT(session.deleteProfile(profile));
61 ProfilesTest::testCreateDeleteProfileAttribute()
63 gde::GDESession session(serverAddress, credentials);
65 gde::Profile profile = session.createProfile(gde::Profile("myProfile"));
66 CPPUNIT_ASSERT(profile.getId() > 0);
68 gde::ProfileAttribute myAttribute = session.createProfileAttribute("myAttribute", "float", profile.getId(), true);
70 CPPUNIT_ASSERT(myAttribute.getId() > 0);
71 CPPUNIT_ASSERT(myAttribute.getName() == "myAttribute");
72 CPPUNIT_ASSERT(myAttribute.getType() == "float");
73 CPPUNIT_ASSERT(myAttribute.getMandatory());
75 CPPUNIT_ASSERT(session.deleteProfile(profile));
79 ProfilesTest::testUpdateProfileAttribute()
81 gde::GDESession session(serverAddress, credentials);
83 gde::Profile profile = session.createProfile(gde::Profile("myProfile"));
84 CPPUNIT_ASSERT(profile.getId() > 0);
86 gde::ProfileAttribute myAttribute = session.createProfileAttribute("myAttribute", "float", profile.getId(), true);
88 CPPUNIT_ASSERT(myAttribute.getId() > 0);
89 CPPUNIT_ASSERT(myAttribute.getName() == "myAttribute");
90 CPPUNIT_ASSERT(myAttribute.getType() == "float");
91 CPPUNIT_ASSERT(myAttribute.getMandatory());
93 myAttribute.setType("std::string");
96 const gde::ProfileAttribute& attr = session.updateProfileAttribute(myAttribute);
97 CPPUNIT_ASSERT(attr.getId() == myAttribute.getId());
98 CPPUNIT_ASSERT(attr.getName() == "myAttribute");
99 CPPUNIT_ASSERT(attr.getType() == "std::string");
100 CPPUNIT_ASSERT(attr.getMandatory());
103 CPPUNIT_ASSERT(session.deleteProfile(profile));
107 ProfilesTest::testReadProfileAttribute()
109 gde::GDESession session(serverAddress, credentials);
111 gde::Profile profile = session.createProfile(gde::Profile("myProfile"));
112 CPPUNIT_ASSERT(profile.getId() > 0);
114 gde::ProfileAttribute myAttribute = session.createProfileAttribute("myAttribute", "float", profile.getId(), true);
115 CPPUNIT_ASSERT(myAttribute.getId() > 0);
118 const gde::ProfileAttribute& attr = session.readProfileAttribute(myAttribute.getId());
119 CPPUNIT_ASSERT(attr.getId() == myAttribute.getId());
120 CPPUNIT_ASSERT(attr.getName() == myAttribute.getName());
121 CPPUNIT_ASSERT(attr.getType() == myAttribute.getType());
122 CPPUNIT_ASSERT(attr.getMandatory() == myAttribute.getMandatory());
125 CPPUNIT_ASSERT(session.deleteProfile(profile));