Download this file

RecommendationServiceImplTests.java    165 lines (146 with data), 7.0 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
package eu.alfred.recommendation_engine;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;
import org.junit.Before;
import org.junit.Test;
import eu.alfred.event_manager.client.EventManagerClient;
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 eu.alfred.personalization_manager.model.Address;
import eu.alfred.personalization_manager.model.Contact;
import eu.alfred.personalization_manager.model.Relation;
import eu.alfred.personalization_manager.model.UserProfile;
import static org.junit.Assert.*;
public class RecommendationServiceImplTests {
private UserProfile testUser = new UserProfile();
private UserProfile similarUser1 = new UserProfile();
private UserProfile similarUser2 = new UserProfile();
private UserProfile friendUser = new UserProfile();
private UserProfile createdTestUser = new UserProfile();
private UserProfile createdSimilarUser1 = new UserProfile();
private UserProfile createdSimilarUser2 = new UserProfile();
private UserProfile createdFriendUser = new UserProfile();
private PersonalProfileClient ppClient = new PersonalProfileClient();
private EventManagerClient emClient = new EventManagerClient();
private UserContactsClient ucClient = new UserContactsClient();
private String testUserId;
private String similarUser1Id;
private String similarUser2Id;
private String friendUserId;
private Event testTagsEvent1 = new Event();
private Event createdTestTagsEvent1 = new Event();
private String testTagsEvent1Id;
private Event testTagsEvent2 = new Event();
private Event createdTestTagsEvent2 = new Event();
private String testTagsEvent2Id;
private Date d = new Date(Long.parseLong("1442102400000")); // This has to change based on when the test is run
private RecommenderServiceImpl recommendationServices = new RecommenderServiceImpl();
@Before
public void setup() {
/*// Create test user, friend users, and similar participant users
// Create a participant of a certain age and participants like him and not like him
testUser .setAlfredUserName("testUser");
testUser.setFirstName("tasos");
Address testUserAddress = new Address();
testUserAddress.setCity("Utrecht");
testUser.setResidentialAddress(testUserAddress);
testUser.setInterests(new String[] {"music","opera"});
testUser.setDateOfBirth(new Date(Long.parseLong("-630374400000")));
testUserId = ppClient.createUserProfile(testUser);
createdTestUser = (UserProfile)ppClient.retrieveUserProfile(testUserId).get(0);
similarUser1.setAlfredUserName("user1");
similarUser1.setFirstName("SimilarUser1");
Address similarUser1Address = new Address();
similarUser1Address.setCity("Utrecht");
similarUser1.setResidentialAddress(similarUser1Address);
similarUser1.setInterests(new String[] {"music","opera"});
similarUser1.setDateOfBirth(new Date(Long.parseLong("-535680000000")));
similarUser1Id = ppClient.createUserProfile(similarUser1);
createdSimilarUser1 = (UserProfile)ppClient.retrieveUserProfile(similarUser1Id).get(0);
similarUser2.setAlfredUserName("testUser");
similarUser2.setFirstName("similarUser2");
Address similarUser2Address = new Address();
similarUser2Address.setCity("Utrecht");
similarUser2.setResidentialAddress(similarUser2Address);
similarUser2.setInterests(new String[] {"music","opera"});
similarUser2.setDateOfBirth(new Date(Long.parseLong("-93916800000")));
similarUser2Id = ppClient.createUserProfile(similarUser2);
createdSimilarUser2 = (UserProfile)ppClient.retrieveUserProfile(similarUser2Id).get(0);
friendUser.setAlfredUserName("friendUser");
friendUser.setFirstName("similarUser2");
Address friendUserAddress = new Address();
friendUserAddress.setCity("Utrecht");
friendUser.setResidentialAddress(friendUserAddress);
friendUser.setInterests(new String[] {"music","opera"});
friendUser.setDateOfBirth(new Date(Long.parseLong("-93916800000")));
friendUserId = ppClient.createUserProfile(friendUser);
createdFriendUser = (UserProfile)ppClient.retrieveUserProfile(friendUserId).get(0);
// create the contact to the friend user
Contact userContact = new Contact();
userContact.setContactsAlfredId(testUserId);
userContact.setAlfredUserName("friendUser");
userContact.setRelationToUser(new Relation[] {Relation.FRIEND});
ucClient.createUserContact(testUserId, userContact);*/
// create the different events
// add participation of users to events
HashMap<String,String> values = new HashMap<>();
values.put("alfredUserName", "anastasios.martidis@tiekinetix.com");
testUser = (UserProfile) ppClient.retrieveUserProfiles(values).get(0);
System.out.println(testUser);
}
@Test
public void testCaseWhereOnlyTheTagsParametersInfluence() {
/* // Create events with different tags
testTagsEvent1Id = "1_event-" + UUID.randomUUID().toString();
testTagsEvent1.setEventID(testTagsEvent1Id);
testTagsEvent1.setTags(Arrays.asList(new String[] {"music","opera"}));
testTagsEvent1.setCategories(Arrays.asList(new String[] {"N.A."}));
Venue venueA = new Venue();
venueA.setCity("Utrecht");
testTagsEvent1.setVenue(venueA);
testTagsEvent1.setStart_date(d);
testTagsEvent1.setEnd_date(d);
Organizer tasos = new Organizer();
tasos.setName("Tasos");
testTagsEvent1.setOrganizer(tasos);
testTagsEvent1.setStatus("Live");
testTagsEvent1.setTickets(Arrays.asList(new Tickets[] {}));
createdTestTagsEvent1 = emClient.addEvent(testTagsEvent1);
testTagsEvent2Id = "1_event-" + UUID.randomUUID().toString();
testTagsEvent2.setEventID(testTagsEvent2Id);
testTagsEvent2.setTags(Arrays.asList(new String[] {"sports","golf"}));
testTagsEvent2.setCategories(Arrays.asList(new String[] {"N.A."}));
testTagsEvent2.setVenue(venueA);
testTagsEvent2.setStart_date(d);
testTagsEvent2.setEnd_date(d);
testTagsEvent2.setOrganizer(tasos);
testTagsEvent2.setStatus("Live");
testTagsEvent2.setTickets(Arrays.asList(new Tickets[] {}));
createdTestTagsEvent2 = emClient.addEvent(testTagsEvent2);
// Check that the event with the tags is suggested and the other isn't
try {
assertTrue(recommendationServices.getEventRecommendations(testUserId).contains(createdTestTagsEvent1));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
}
@Test
public void testCaseWhereOnlyTheSimilarParticipantsParametersInfluence() {
// create events for similar and not similar friends
}
@Test
public void testCaseWhereOnlyTheFriendsParticipatingParametersInfluence() {
// create events where friends are joining
}
@Test
public void testCaseWhereAllParametersInfluence() {
// create events where all cases are in play
}
}