]> SALOME platform Git repositories - modules/gde.git/blob - projects/GDE_API_CPP/api/tests/ProfilesTest.cpp
Salome HOME
178a2d130b77845bab0e6e2556d96c2182e89078
[modules/gde.git] / projects / GDE_API_CPP / api / tests / ProfilesTest.cpp
1 #include <TestUtilities.hpp>
2 #include <Profile.hpp>
3 #include <GDESession.hpp>
4 #include <ProfilesTest.hpp>
5
6 void
7 ProfilesTest::testCreateDeleteProfile()
8 {
9   gde::GDESession session(serverAddress, credentials);
10
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());
16
17   CPPUNIT_ASSERT(session.deleteProfile(profile));
18 }
19
20 void
21 ProfilesTest::testReadProfile()
22 {
23   gde::GDESession session(serverAddress, credentials);
24
25   gde::Profile myProfile("myProfile");
26   CPPUNIT_ASSERT(myProfile.getId() == 0);
27   gde::Profile profile = session.createProfile(myProfile);
28   CPPUNIT_ASSERT(profile.getId() > 0);
29
30   {
31     const gde::Profile& prf = session.readProfile(profile.getId());
32     CPPUNIT_ASSERT(prf.getName() == myProfile.getName());
33     CPPUNIT_ASSERT(prf.getId() > 0);
34   }
35
36   CPPUNIT_ASSERT(session.deleteProfile(profile));
37 }
38
39 void
40 ProfilesTest::testUpdateProfile()
41 {
42   gde::GDESession session(serverAddress, credentials);
43
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");
50
51   {
52     const gde::Profile& prf = session.updateProfile(profile);
53     CPPUNIT_ASSERT(prf.getName() == profile.getName());
54     CPPUNIT_ASSERT(prf.getId() == profile.getId());
55   }
56
57   CPPUNIT_ASSERT(session.deleteProfile(profile));
58 }
59
60 void
61 ProfilesTest::testCreateDeleteProfileAttribute()
62 {
63   gde::GDESession session(serverAddress, credentials);
64
65   gde::Profile profile = session.createProfile(gde::Profile("myProfile"));
66   CPPUNIT_ASSERT(profile.getId() > 0);
67
68   gde::ProfileAttribute myAttribute = session.createProfileAttribute("myAttribute", "float", profile.getId(), true);
69
70   CPPUNIT_ASSERT(myAttribute.getId() > 0);
71   CPPUNIT_ASSERT(myAttribute.getName() == "myAttribute");
72   CPPUNIT_ASSERT(myAttribute.getType() == "float");
73   CPPUNIT_ASSERT(myAttribute.getMandatory());
74
75   CPPUNIT_ASSERT(session.deleteProfile(profile));
76 }
77
78 void
79 ProfilesTest::testUpdateProfileAttribute()
80 {
81   gde::GDESession session(serverAddress, credentials);
82
83   gde::Profile profile = session.createProfile(gde::Profile("myProfile"));
84   CPPUNIT_ASSERT(profile.getId() > 0);
85
86   gde::ProfileAttribute myAttribute = session.createProfileAttribute("myAttribute", "float", profile.getId(), true);
87
88   CPPUNIT_ASSERT(myAttribute.getId() > 0);
89   CPPUNIT_ASSERT(myAttribute.getName() == "myAttribute");
90   CPPUNIT_ASSERT(myAttribute.getType() == "float");
91   CPPUNIT_ASSERT(myAttribute.getMandatory());
92
93   myAttribute.setType("std::string");
94
95   {
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());
101   }
102
103   CPPUNIT_ASSERT(session.deleteProfile(profile));
104 }
105
106 void
107 ProfilesTest::testReadProfileAttribute()
108 {
109   gde::GDESession session(serverAddress, credentials);
110
111   gde::Profile profile = session.createProfile(gde::Profile("myProfile"));
112   CPPUNIT_ASSERT(profile.getId() > 0);
113
114   gde::ProfileAttribute myAttribute = session.createProfileAttribute("myAttribute", "float", profile.getId(), true);
115   CPPUNIT_ASSERT(myAttribute.getId() > 0);
116
117   {
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());
123   }
124
125   CPPUNIT_ASSERT(session.deleteProfile(profile));
126 }