}
@Test
public void addOrUpdateManyTest() {
Center sgp = CenterRepository.add("singapore");
ContactDetails contactDetails = new ContactDetails();
contactDetails.email = "sathya.t@ishafoundation.org";
contactDetails.firstName = "sathya";
MemberRepository.add(contactDetails, sgp.id, SUPER_USER);
contactDetails.email = "thulasidhar@gmail.com";
contactDetails.firstName = "thulasi";
MemberRepository.add(contactDetails, sgp.id, SUPER_USER);
List<ContactDetails> contactDetailslList = new ArrayList<>();
ContactDetails c1 = new ContactDetails();
c1.email = "isha.srividhya@gmail.com";
c1.firstName = "srividhya";
c1.lastName = "radhakrishnan";
contactDetailslList.add(c1);
ContactDetails c2 = new ContactDetails();
c2.email = "isha.vijay@gmail.com";
c2.firstName = "vijaykumar";
c2.lastName = "krishnamurthy";
contactDetailslList.add(c2);
ContactDetails c3 = new ContactDetails();
c3.email = "sathya.t@ishafoundation.org";
c3.lastName = "thilakan";
contactDetailslList.add(c3);
ContactDetails c4 = new ContactDetails();
c4.email = "thulasidhar@gmail.com";
c4.firstName = "thulasidhar";
c4.lastName = "kosalram";
contactDetailslList.add(c4);
MemberRepository.addOrUpdateMany(sgp.id, contactDetailslList, USER_WITH_EDITMEMBER_PRIVILEGE);
Member member = MemberRepository.get("sathya.t@ishafoundation.org", SUPER_USER);
assertTrue(member != null);
assertTrue(member.contactDetails.email.equals("sathya.t@ishafoundation.org"));
assertTrue(member.contactDetails.firstName.equals("sathya"));
assertTrue(member.contactDetails.lastName.equals("thilakan"));
member = MemberRepository.get("thulasidhar@gmail.com", SUPER_USER);
assertTrue(member != null);
assertTrue(member.contactDetails.email.equals("thulasidhar@gmail.com"));
assertTrue(member.contactDetails.firstName.equals("thulasidhar"));
assertTrue(member.contactDetails.lastName.equals("kosalram"));
member = MemberRepository.get("isha.srividhya@gmail.com", SUPER_USER);
assertTrue(member != null);
assertTrue(member.contactDetails.email.equals("isha.srividhya@gmail.com"));
assertTrue(member.contactDetails.firstName.equals("srividhya"));
assertTrue(member.contactDetails.lastName.equals("radhakrishnan"));
member = MemberRepository.get("isha.vijay@gmail.com", SUPER_USER);
assertTrue(member != null);
assertTrue(member.contactDetails.email.equals("isha.vijay@gmail.com"));
assertTrue(member.contactDetails.firstName.equals("vijaykumar"));
assertTrue(member.contactDetails.lastName.equals("krishnamurthy"));
//privilege required
try {
MemberRepository.addOrUpdateMany(sgp.id, contactDetailslList, VALID_USER);
} catch (APIException ex) {
assertTrue(ex.statusCode == Status.ERROR_INSUFFICIENT_PERMISSION);
}
//cannot add more than limit
for (int i = 0; i < Limits.Member.MAX_NUMRECORDS_BULKIMPORT + 1; i++) {
ContactDetails c5 = new ContactDetails();
c5.email = "dummy" + i + "@dummy.com";
contactDetailslList.add(c5);
}
try {
MemberRepository.addOrUpdateMany(sgp.id, contactDetailslList, USER_WITH_EDITMEMBER_PRIVILEGE);