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
}
}