Switch to unified view

a b/recommendation-engine/src/test/java/eu/alfred/recommendation_engine/RecommendationServiceImplTests.java
1
package eu.alfred.recommendation_engine;
2
3
import java.util.Arrays;
4
import java.util.Date;
5
import java.util.HashMap;
6
import java.util.UUID;
7
8
import org.junit.Before;
9
import org.junit.Test;
10
11
import eu.alfred.event_manager.client.EventManagerClient;
12
import eu.alfred.event_manager.model.Event;
13
import eu.alfred.event_manager.model.Organizer;
14
import eu.alfred.event_manager.model.Tickets;
15
import eu.alfred.event_manager.model.Venue;
16
import eu.alfred.personalization_manager.client.PersonalProfileClient;
17
import eu.alfred.personalization_manager.client.UserContactsClient;
18
import eu.alfred.personalization_manager.model.Address;
19
import eu.alfred.personalization_manager.model.Contact;
20
import eu.alfred.personalization_manager.model.Relation;
21
import eu.alfred.personalization_manager.model.UserProfile;
22
import static org.junit.Assert.*;
23
24
public class RecommendationServiceImplTests {
25
26
  private UserProfile testUser = new UserProfile();
27
  private UserProfile similarUser1 = new UserProfile();
28
  private UserProfile similarUser2 = new UserProfile();
29
  private UserProfile friendUser = new UserProfile(); 
30
  private UserProfile createdTestUser = new UserProfile();
31
  private UserProfile createdSimilarUser1 = new UserProfile();
32
  private UserProfile createdSimilarUser2 = new UserProfile();
33
  private UserProfile createdFriendUser = new UserProfile(); 
34
  private PersonalProfileClient ppClient = new PersonalProfileClient();
35
  private EventManagerClient emClient = new EventManagerClient();
36
  private UserContactsClient ucClient = new UserContactsClient();
37
  private String testUserId;
38
  private String similarUser1Id;
39
  private String similarUser2Id;
40
  private String friendUserId;
41
  private Event testTagsEvent1 = new Event();
42
  private Event createdTestTagsEvent1 = new Event();
43
  private String testTagsEvent1Id; 
44
  private Event testTagsEvent2 = new Event();
45
  private Event createdTestTagsEvent2 = new Event();
46
  private String testTagsEvent2Id;
47
  private Date d = new Date(Long.parseLong("1442102400000")); // This has to change based on when the test is run
48
  private RecommenderServiceImpl recommendationServices = new RecommenderServiceImpl();
49
50
  @Before
51
  public void setup() {
52
      /*// Create test user, friend users, and similar participant users
53
      // Create a participant of a certain age and participants like him and not like him
54
      testUser .setAlfredUserName("testUser");
55
      testUser.setFirstName("tasos");
56
      Address testUserAddress = new Address();
57
      testUserAddress.setCity("Utrecht");
58
      testUser.setResidentialAddress(testUserAddress);
59
      testUser.setInterests(new String[] {"music","opera"});
60
      testUser.setDateOfBirth(new Date(Long.parseLong("-630374400000")));
61
      testUserId = ppClient.createUserProfile(testUser);
62
      createdTestUser = (UserProfile)ppClient.retrieveUserProfile(testUserId).get(0);
63
      
64
      similarUser1.setAlfredUserName("user1");
65
      similarUser1.setFirstName("SimilarUser1");
66
      Address similarUser1Address = new Address();
67
      similarUser1Address.setCity("Utrecht");
68
      similarUser1.setResidentialAddress(similarUser1Address);
69
      similarUser1.setInterests(new String[] {"music","opera"});
70
      similarUser1.setDateOfBirth(new Date(Long.parseLong("-535680000000")));
71
      similarUser1Id = ppClient.createUserProfile(similarUser1);
72
      createdSimilarUser1 = (UserProfile)ppClient.retrieveUserProfile(similarUser1Id).get(0);
73
      
74
      similarUser2.setAlfredUserName("testUser");
75
      similarUser2.setFirstName("similarUser2");
76
      Address similarUser2Address = new Address();
77
      similarUser2Address.setCity("Utrecht");
78
      similarUser2.setResidentialAddress(similarUser2Address);
79
      similarUser2.setInterests(new String[] {"music","opera"});
80
      similarUser2.setDateOfBirth(new Date(Long.parseLong("-93916800000")));
81
      similarUser2Id = ppClient.createUserProfile(similarUser2);
82
      createdSimilarUser2 = (UserProfile)ppClient.retrieveUserProfile(similarUser2Id).get(0);
83
      
84
      friendUser.setAlfredUserName("friendUser");
85
      friendUser.setFirstName("similarUser2");
86
      Address friendUserAddress = new Address();
87
      friendUserAddress.setCity("Utrecht");
88
      friendUser.setResidentialAddress(friendUserAddress);
89
      friendUser.setInterests(new String[] {"music","opera"});
90
      friendUser.setDateOfBirth(new Date(Long.parseLong("-93916800000")));
91
      friendUserId = ppClient.createUserProfile(friendUser);
92
      createdFriendUser = (UserProfile)ppClient.retrieveUserProfile(friendUserId).get(0);
93
              
94
      // create the contact to the friend user
95
      Contact userContact = new Contact();
96
      userContact.setContactsAlfredId(testUserId);
97
      userContact.setAlfredUserName("friendUser");
98
      userContact.setRelationToUser(new Relation[] {Relation.FRIEND});
99
      ucClient.createUserContact(testUserId, userContact);*/
100
      
101
      // create the different events
102
      
103
      // add participation of users to events
104
      HashMap<String,String> values = new HashMap<>();
105
      values.put("alfredUserName", "anastasios.martidis@tiekinetix.com");
106
      testUser = (UserProfile) ppClient.retrieveUserProfiles(values).get(0);
107
      System.out.println(testUser);
108
  }
109
  
110
  @Test
111
  public void testCaseWhereOnlyTheTagsParametersInfluence() {
112
  /*  // Create events with different tags 
113
      testTagsEvent1Id = "1_event-" + UUID.randomUUID().toString();
114
      testTagsEvent1.setEventID(testTagsEvent1Id); 
115
      testTagsEvent1.setTags(Arrays.asList(new String[] {"music","opera"}));
116
      testTagsEvent1.setCategories(Arrays.asList(new String[] {"N.A."}));
117
      Venue venueA = new Venue();
118
      venueA.setCity("Utrecht");
119
      testTagsEvent1.setVenue(venueA);
120
      testTagsEvent1.setStart_date(d);
121
      testTagsEvent1.setEnd_date(d); 
122
      Organizer tasos = new Organizer();
123
      tasos.setName("Tasos");
124
      testTagsEvent1.setOrganizer(tasos);
125
      testTagsEvent1.setStatus("Live"); 
126
      testTagsEvent1.setTickets(Arrays.asList(new Tickets[] {}));
127
      createdTestTagsEvent1 = emClient.addEvent(testTagsEvent1); 
128
      
129
      testTagsEvent2Id = "1_event-" + UUID.randomUUID().toString();
130
      testTagsEvent2.setEventID(testTagsEvent2Id); 
131
      testTagsEvent2.setTags(Arrays.asList(new String[] {"sports","golf"}));
132
      testTagsEvent2.setCategories(Arrays.asList(new String[] {"N.A."}));      
133
      testTagsEvent2.setVenue(venueA);
134
      testTagsEvent2.setStart_date(d);
135
      testTagsEvent2.setEnd_date(d);  
136
      testTagsEvent2.setOrganizer(tasos);
137
      testTagsEvent2.setStatus("Live"); 
138
      testTagsEvent2.setTickets(Arrays.asList(new Tickets[] {}));
139
      createdTestTagsEvent2 = emClient.addEvent(testTagsEvent2);
140
      
141
      // Check that the event with the tags is suggested and the other isn't
142
      try {
143
          assertTrue(recommendationServices.getEventRecommendations(testUserId).contains(createdTestTagsEvent1)); 
144
      } catch (Exception e) {
145
          // TODO Auto-generated catch block
146
          e.printStackTrace();
147
      }*/
148
  }
149
  
150
  @Test
151
  public void testCaseWhereOnlyTheSimilarParticipantsParametersInfluence() {
152
      // create events for similar and not similar friends
153
  }
154
  
155
  @Test
156
  public void testCaseWhereOnlyTheFriendsParticipatingParametersInfluence() {
157
      // create events where friends are joining
158
  }
159
  
160
  @Test
161
  public void testCaseWhereAllParametersInfluence() {
162
      // create events where all cases are in play
163
  }
164
}