|
a |
|
b/recommendation-engine/src/test/java/eu/alfred/recommendation_engine/FriendsBasedEventsFinderTests.java |
|
|
1 |
package eu.alfred.recommendation_engine;
|
|
|
2 |
|
|
|
3 |
import java.util.Arrays;
|
|
|
4 |
import java.util.Calendar;
|
|
|
5 |
import java.util.Date;
|
|
|
6 |
import java.util.List;
|
|
|
7 |
import java.util.UUID;
|
|
|
8 |
|
|
|
9 |
import eu.alfred.personalization_manager.model.*;
|
|
|
10 |
import org.junit.Before;
|
|
|
11 |
import org.junit.Test;
|
|
|
12 |
|
|
|
13 |
import eu.alfred.event_manager.client.EventManagerClient;
|
|
|
14 |
import eu.alfred.event_manager.model.AnalyticsParameters;
|
|
|
15 |
import eu.alfred.event_manager.model.Event;
|
|
|
16 |
import eu.alfred.event_manager.model.Organizer;
|
|
|
17 |
import eu.alfred.event_manager.model.Tickets;
|
|
|
18 |
import eu.alfred.event_manager.model.Venue;
|
|
|
19 |
import eu.alfred.personalization_manager.client.PersonalProfileClient;
|
|
|
20 |
import eu.alfred.personalization_manager.client.UserContactsClient;
|
|
|
21 |
|
|
|
22 |
import static org.junit.Assert.*;
|
|
|
23 |
|
|
|
24 |
public class FriendsBasedEventsFinderTests {
|
|
|
25 |
|
|
|
26 |
private Event testEventA = new Event();
|
|
|
27 |
private EventManagerClient emClient = new EventManagerClient();
|
|
|
28 |
private String eventAID;
|
|
|
29 |
private Event event1Created;
|
|
|
30 |
private Date d;
|
|
|
31 |
|
|
|
32 |
// TestUser
|
|
|
33 |
private UserProfile testUser = new UserProfile();
|
|
|
34 |
private UserProfile createdTestUser = new UserProfile();
|
|
|
35 |
private String testUserId;
|
|
|
36 |
|
|
|
37 |
// Contact 1
|
|
|
38 |
private UserProfile user1 = new UserProfile();
|
|
|
39 |
private UserProfile createdUser1 = new UserProfile();
|
|
|
40 |
private String user1Id;
|
|
|
41 |
|
|
|
42 |
// Contact 2
|
|
|
43 |
private UserProfile user2 = new UserProfile();
|
|
|
44 |
private UserProfile createdUser2 = new UserProfile();
|
|
|
45 |
private String user2Id;
|
|
|
46 |
|
|
|
47 |
// Contact 3
|
|
|
48 |
private UserProfile user3 = new UserProfile();
|
|
|
49 |
private UserProfile createdUser3 = new UserProfile();
|
|
|
50 |
private String user3Id;
|
|
|
51 |
|
|
|
52 |
// Contact 4
|
|
|
53 |
private UserProfile user4 = new UserProfile();
|
|
|
54 |
private UserProfile createdUser4 = new UserProfile();
|
|
|
55 |
private String user4Id;
|
|
|
56 |
|
|
|
57 |
private PersonalProfileClient ppClient = new PersonalProfileClient();
|
|
|
58 |
private UserContactsClient usClient = new UserContactsClient();
|
|
|
59 |
private FriendsBasedEventsFinder friendsBasedFinder = new FriendsBasedEventsFinder();
|
|
|
60 |
|
|
|
61 |
@Before
|
|
|
62 |
public void setup() {
|
|
|
63 |
Calendar cal = Calendar.getInstance();
|
|
|
64 |
cal.add(Calendar.DAY_OF_YEAR, 2);
|
|
|
65 |
d = cal.getTime();
|
|
|
66 |
|
|
|
67 |
// Create a user and another user as a friend contact
|
|
|
68 |
testUser.setAlfredUserName("swen");
|
|
|
69 |
testUser.setFirstName("Swen");
|
|
|
70 |
testUser.setLastName("Papst");
|
|
|
71 |
Address testUserAddress = new Address();
|
|
|
72 |
testUserAddress.setCity("Munich");
|
|
|
73 |
testUser.setResidentialAddress(testUserAddress);
|
|
|
74 |
testUser.setInterests(new String[] {"music","opera"});
|
|
|
75 |
testUser.setDateOfBirth(new Date(Long.parseLong("-630374400000")));
|
|
|
76 |
testUser.setMobilePhone("03591 23 12 27");
|
|
|
77 |
testUser.setEmail("SwenPapst@cuvox.de");
|
|
|
78 |
testUser.setMobilityLevel(MobilityLevel.HEALTHY);
|
|
|
79 |
testUserId = ppClient.createUserProfile(testUser);
|
|
|
80 |
createdTestUser = (UserProfile)ppClient.retrieveUserProfile(testUserId).get(0);
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
// Contact 1
|
|
|
84 |
|
|
|
85 |
user1.setAlfredUserName("peter");
|
|
|
86 |
user1.setFirstName("Peter");
|
|
|
87 |
user1.setLastName("Merz");
|
|
|
88 |
user1.setMobilePhone("00491727759581");
|
|
|
89 |
user1.setEmail("Peter.Merz@tiekinetix.com");
|
|
|
90 |
Address user1Address = new Address();
|
|
|
91 |
testUserAddress.setCity("Munich");
|
|
|
92 |
user1.setResidentialAddress(user1Address);
|
|
|
93 |
user1.setInterests(new String[] {"music","opera"});
|
|
|
94 |
user1.setDateOfBirth(new Date(Long.parseLong("-535680000000")));
|
|
|
95 |
user1Id = ppClient.createUserProfile(user1);
|
|
|
96 |
createdUser1 = (UserProfile)ppClient.retrieveUserProfile(user1Id).get(0);
|
|
|
97 |
|
|
|
98 |
Contact userContact = new Contact();
|
|
|
99 |
userContact.setContactsAlfredId(user1Id);
|
|
|
100 |
userContact.setAlfredUserName("peter");
|
|
|
101 |
userContact.setFirstName("Peter");
|
|
|
102 |
userContact.setLastName("Merz");
|
|
|
103 |
userContact.setPhone("00491727759581");
|
|
|
104 |
userContact.setEmail("Peter.Merz@tiekinetix.com");
|
|
|
105 |
userContact.setResidentialAddress(user1Address);
|
|
|
106 |
userContact.setRelationToUser(new Relation[] {Relation.FRIEND});
|
|
|
107 |
usClient.createUserContact(testUserId, userContact);
|
|
|
108 |
|
|
|
109 |
// Contact 2
|
|
|
110 |
user2.setAlfredUserName("deniz");
|
|
|
111 |
user2.setFirstName("Deniz");
|
|
|
112 |
user2.setLastName("Coskun");
|
|
|
113 |
user2.setMobilePhone("00491771708328");
|
|
|
114 |
user2.setEmail("Deniz.Coskun@tiekinetix.com");
|
|
|
115 |
Address user2Address = new Address();
|
|
|
116 |
testUserAddress.setCity("Munich");
|
|
|
117 |
user2.setResidentialAddress(user2Address);
|
|
|
118 |
user2.setInterests(new String[] {"music","opera"});
|
|
|
119 |
user2.setDateOfBirth(new Date(Long.parseLong("-535680000000")));
|
|
|
120 |
user2Id = ppClient.createUserProfile(user2);
|
|
|
121 |
createdUser2 = (UserProfile)ppClient.retrieveUserProfile(user2Id).get(0);
|
|
|
122 |
|
|
|
123 |
Contact userContact2 = new Contact();
|
|
|
124 |
userContact2.setContactsAlfredId(user2Id);
|
|
|
125 |
userContact2.setAlfredUserName("deniz");
|
|
|
126 |
userContact2.setFirstName("Deniz");
|
|
|
127 |
userContact2.setLastName("Coskun");
|
|
|
128 |
userContact2.setPhone("00491726391814");
|
|
|
129 |
userContact2.setEmail("Deniz.Coskun@tiekinetix.com");
|
|
|
130 |
userContact2.setResidentialAddress(user2Address);
|
|
|
131 |
userContact2.setRelationToUser(new Relation[] {Relation.FRIEND});
|
|
|
132 |
usClient.createUserContact(testUserId, userContact2);
|
|
|
133 |
|
|
|
134 |
// Contact 3
|
|
|
135 |
|
|
|
136 |
user3.setAlfredUserName("lill");
|
|
|
137 |
user3.setFirstName("Robert");
|
|
|
138 |
user3.setLastName("Lill");
|
|
|
139 |
user3.setMobilePhone("004915209119016");
|
|
|
140 |
user3.setEmail("Robert.Lill@tiekinetix.com");
|
|
|
141 |
Address user3Address = new Address();
|
|
|
142 |
testUserAddress.setCity("Munich");
|
|
|
143 |
user3.setResidentialAddress(user3Address);
|
|
|
144 |
user3.setInterests(new String[] {"music","opera"});
|
|
|
145 |
user3.setDateOfBirth(new Date(Long.parseLong("-535680000000")));
|
|
|
146 |
user3Id = ppClient.createUserProfile(user3);
|
|
|
147 |
createdUser3 = (UserProfile)ppClient.retrieveUserProfile(user3Id).get(0);
|
|
|
148 |
|
|
|
149 |
Contact userContact3 = new Contact();
|
|
|
150 |
userContact3.setContactsAlfredId(user3Id);
|
|
|
151 |
userContact3.setAlfredUserName("lill");
|
|
|
152 |
userContact3.setFirstName("Robert");
|
|
|
153 |
userContact3.setLastName("Lill");
|
|
|
154 |
userContact3.setPhone("004915209119016");
|
|
|
155 |
userContact3.setEmail("Robert.Lill@tiekinetix.com");
|
|
|
156 |
userContact3.setResidentialAddress(user3Address);
|
|
|
157 |
userContact3.setRelationToUser(new Relation[] {Relation.FRIEND});
|
|
|
158 |
usClient.createUserContact(testUserId, userContact3);
|
|
|
159 |
|
|
|
160 |
// Contact 4
|
|
|
161 |
user4.setAlfredUserName("arian");
|
|
|
162 |
user4.setFirstName("Arian");
|
|
|
163 |
user4.setLastName("Kuschki");
|
|
|
164 |
user4.setMobilePhone("004915222619029");
|
|
|
165 |
user4.setEmail("Arian.Kuschki@tiekinetix.com");
|
|
|
166 |
Address user4Address = new Address();
|
|
|
167 |
testUserAddress.setCity("Munich");
|
|
|
168 |
user4.setResidentialAddress(user4Address);
|
|
|
169 |
user4.setInterests(new String[] {"music","opera"});
|
|
|
170 |
user4.setDateOfBirth(new Date(Long.parseLong("-535680000000")));
|
|
|
171 |
user4Id = ppClient.createUserProfile(user4);
|
|
|
172 |
createdUser4 = (UserProfile)ppClient.retrieveUserProfile(user4Id).get(0);
|
|
|
173 |
|
|
|
174 |
Contact userContact4 = new Contact();
|
|
|
175 |
userContact4.setContactsAlfredId(user4Id);
|
|
|
176 |
userContact4.setAlfredUserName("arian");
|
|
|
177 |
userContact4.setFirstName("Arian");
|
|
|
178 |
userContact4.setLastName("Kuschki");
|
|
|
179 |
userContact4.setPhone("004915222619029");
|
|
|
180 |
userContact4.setEmail("Arian.Kuschki@tiekinetix.com");
|
|
|
181 |
userContact4.setResidentialAddress(user4Address);
|
|
|
182 |
userContact4.setRelationToUser(new Relation[] {Relation.FRIEND});
|
|
|
183 |
usClient.createUserContact(testUserId, userContact4);
|
|
|
184 |
|
|
|
185 |
|
|
|
186 |
// create some events
|
|
|
187 |
eventAID = "1_event-" + UUID.randomUUID().toString();
|
|
|
188 |
testEventA.setEventID(eventAID);
|
|
|
189 |
testEventA.setTags(Arrays.asList(new String[] {"music","opera"}));
|
|
|
190 |
testEventA.setCategories(Arrays.asList(new String[] {"N.A."}));
|
|
|
191 |
Venue venueA = new Venue();
|
|
|
192 |
venueA.setCity("Utrecht");
|
|
|
193 |
testEventA.setVenue(venueA);
|
|
|
194 |
testEventA.setStart_date(d);
|
|
|
195 |
testEventA.setEnd_date(d);
|
|
|
196 |
Organizer tasos = new Organizer();
|
|
|
197 |
tasos.setName("Tasos");
|
|
|
198 |
testEventA.setOrganizer(tasos);
|
|
|
199 |
testEventA.setStatus("Live");
|
|
|
200 |
testEventA.setTickets(Arrays.asList(new Tickets[] {}));
|
|
|
201 |
event1Created = emClient.addEvent(testEventA);
|
|
|
202 |
|
|
|
203 |
// add friends as participants to the events
|
|
|
204 |
emClient.addParticipant(event1Created.getEventID(), user1Id);
|
|
|
205 |
emClient.addParticipant(event1Created.getEventID(), user2Id);
|
|
|
206 |
emClient.addParticipant(event1Created.getEventID(), user3Id);
|
|
|
207 |
emClient.addParticipant(event1Created.getEventID(), user4Id);
|
|
|
208 |
}
|
|
|
209 |
|
|
|
210 |
@Test
|
|
|
211 |
public void testFindingEventsWithFriendsParticipating() {
|
|
|
212 |
try {
|
|
|
213 |
friendsBasedFinder.getEventsMyFriendsAlsoJoin(createdTestUser.getId());
|
|
|
214 |
assertTrue(friendsBasedFinder.getEventsMyFriendsAlsoJoin(createdTestUser.getId()).contains(event1Created));
|
|
|
215 |
} catch (Exception e) {
|
|
|
216 |
e.printStackTrace();
|
|
|
217 |
}
|
|
|
218 |
}
|
|
|
219 |
}
|