Download this file

FriendsBasedEventsFinderTests.java    220 lines (190 with data), 8.2 kB

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