use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class GroupAttributeServiceTest method changeListservStatusTest.
@Test
public void changeListservStatusTest() {
// expect actions by "Random" to fail
GroupingsServiceResult turnOnWhenOnRandom;
GroupingsServiceResult turnOnWhenOffRandom;
GroupingsServiceResult turnOffWhenOnRandom;
GroupingsServiceResult turnOffWhenOffRandom;
Grouping grouping = groupingRepository.findByPath(GROUPING_4_PATH);
assertFalse(grouping.isListservOn());
try {
turnOnWhenOffRandom = groupingsService.changeListservStatus(GROUPING_4_PATH, users.get(1).getUsername(), true);
} catch (GroupingsServiceResultException gsre) {
turnOnWhenOffRandom = gsre.getGsr();
}
grouping = groupingRepository.findByPath(GROUPING_4_PATH);
assertFalse(grouping.isListservOn());
GroupingsServiceResult turnOnWhenOffOwner = groupingsService.changeListservStatus(GROUPING_4_PATH, users.get(0).getUsername(), true);
grouping = groupingRepository.findByPath(GROUPING_4_PATH);
assertTrue(grouping.isListservOn());
try {
turnOnWhenOnRandom = groupingsService.changeListservStatus(GROUPING_4_PATH, users.get(1).getUsername(), true);
} catch (GroupingsServiceResultException gsre) {
turnOnWhenOnRandom = gsre.getGsr();
}
grouping = groupingRepository.findByPath(GROUPING_4_PATH);
assertTrue(grouping.isListservOn());
GroupingsServiceResult turnOnWhenOnOwner = groupingsService.changeListservStatus(GROUPING_4_PATH, users.get(0).getUsername(), true);
grouping = groupingRepository.findByPath(GROUPING_4_PATH);
assertTrue(grouping.isListservOn());
GroupingsServiceResult turnOnWhenOnAdmin = groupingsService.changeListservStatus(GROUPING_4_PATH, ADMIN_USER, true);
grouping = groupingRepository.findByPath(GROUPING_4_PATH);
assertTrue(grouping.isListservOn());
try {
turnOffWhenOnRandom = groupingsService.changeListservStatus(GROUPING_4_PATH, users.get(1).getUsername(), false);
} catch (GroupingsServiceResultException gsre) {
turnOffWhenOnRandom = gsre.getGsr();
}
grouping = groupingRepository.findByPath(GROUPING_4_PATH);
assertTrue(grouping.isListservOn());
GroupingsServiceResult turnOffWhenOnOwner = groupingsService.changeListservStatus(GROUPING_4_PATH, users.get(0).getUsername(), false);
grouping = groupingRepository.findByPath(GROUPING_4_PATH);
assertFalse(grouping.isListservOn());
GroupingsServiceResult turnOnWhenOffAdmin = groupingsService.changeListservStatus(GROUPING_4_PATH, ADMIN_USER, true);
grouping = groupingRepository.findByPath(GROUPING_4_PATH);
assertTrue(grouping.isListservOn());
GroupingsServiceResult turnOffWhenOnAdmin = groupingsService.changeListservStatus(GROUPING_4_PATH, ADMIN_USER, false);
grouping = groupingRepository.findByPath(GROUPING_4_PATH);
assertFalse(grouping.isListservOn());
try {
turnOffWhenOffRandom = groupingsService.changeListservStatus(GROUPING_4_PATH, users.get(1).getUsername(), false);
} catch (GroupingsServiceResultException gsre) {
turnOffWhenOffRandom = gsre.getGsr();
}
grouping = groupingRepository.findByPath(GROUPING_4_PATH);
assertFalse(grouping.isListservOn());
GroupingsServiceResult turnOffWhenOffOwner = groupingsService.changeListservStatus(GROUPING_4_PATH, users.get(0).getUsername(), false);
grouping = groupingRepository.findByPath(GROUPING_4_PATH);
assertFalse(grouping.isListservOn());
GroupingsServiceResult turnOffWhenOffAdmin = groupingsService.changeListservStatus(GROUPING_4_PATH, ADMIN_USER, false);
grouping = groupingRepository.findByPath(GROUPING_4_PATH);
assertFalse(grouping.isListservOn());
assertTrue(turnOnWhenOnRandom.getResultCode().startsWith(FAILURE));
assertTrue(turnOnWhenOnOwner.getResultCode().startsWith(SUCCESS));
assertTrue(turnOnWhenOnAdmin.getResultCode().startsWith(SUCCESS));
assertTrue(turnOffWhenOnRandom.getResultCode().startsWith(FAILURE));
assertTrue(turnOffWhenOnOwner.getResultCode().startsWith(SUCCESS));
assertTrue(turnOffWhenOnAdmin.getResultCode().startsWith(SUCCESS));
assertTrue(turnOnWhenOffRandom.getResultCode().startsWith(FAILURE));
assertTrue(turnOnWhenOffOwner.getResultCode().startsWith(SUCCESS));
assertTrue(turnOnWhenOffAdmin.getResultCode().startsWith(SUCCESS));
assertTrue(turnOffWhenOffRandom.getResultCode().startsWith(FAILURE));
assertTrue(turnOffWhenOffOwner.getResultCode().startsWith(SUCCESS));
assertTrue(turnOffWhenOffAdmin.getResultCode().startsWith(SUCCESS));
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class MemberAttributeServiceTest method assignOwnershipTest.
@Test
public void assignOwnershipTest() {
// expect this to fail
GroupingsServiceResult randomUserAdds;
Person randomUser = personRepository.findByUsername(users.get(1).getUsername());
Grouping grouping = groupingRepository.findByPath(GROUPING_0_PATH);
assertFalse(grouping.getOwners().getMembers().contains(randomUser));
assertFalse(grouping.getOwners().isMember(randomUser));
try {
randomUserAdds = memberAttributeService.assignOwnership(GROUPING_0_PATH, randomUser.getUsername(), randomUser.getUsername());
} catch (GroupingsServiceResultException gsre) {
randomUserAdds = gsre.getGsr();
}
grouping = groupingRepository.findByPath(GROUPING_0_PATH);
assertFalse(grouping.getOwners().getMembers().contains(randomUser));
assertFalse(grouping.getOwners().isMember(randomUser));
assertNotEquals(randomUserAdds.getResultCode(), SUCCESS);
GroupingsServiceResult ownerAdds = memberAttributeService.assignOwnership(GROUPING_0_PATH, users.get(0).getUsername(), randomUser.getUsername());
grouping = groupingRepository.findByPath(GROUPING_0_PATH);
assertTrue(grouping.getOwners().getMembers().contains(randomUser));
assertTrue(grouping.getOwners().isMember(randomUser));
assertEquals(ownerAdds.getResultCode(), SUCCESS);
GroupingsServiceResult adminAdds = memberAttributeService.assignOwnership(GROUPING_0_PATH, ADMIN_USER, randomUser.getUsername());
grouping = groupingRepository.findByPath(GROUPING_0_PATH);
assertTrue(grouping.getOwners().getMembers().contains(randomUser));
assertTrue(grouping.getOwners().isMember(randomUser));
assertEquals(SUCCESS, adminAdds.getResultCode());
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class MembershipServiceTest method deleteGroupingMemberByUuidTest.
// Debug statement to look at contents of database
// Delete user from include group to remove them
// Use user number not slot in array
// Use assert to check if it worked
@Test
public void deleteGroupingMemberByUuidTest() {
Iterable<Grouping> group = groupingRepository.findAll();
List<GroupingsServiceResult> listGsr;
GroupingsServiceResult gsr;
// Base test
// Remove person from include and composite
listGsr = membershipService.deleteGroupingMemberByUuid(users.get(0).getUsername(), GROUPING_3_PATH, users.get(5).getUuid());
assertTrue(listGsr.get(0).getResultCode().startsWith(SUCCESS));
// If person is in composite and basis, add to exclude group
listGsr = membershipService.deleteGroupingMemberByUuid(users.get(0).getUsername(), GROUPING_3_PATH, users.get(1).getUuid());
for (GroupingsServiceResult gsrFor : listGsr) {
assertTrue(gsrFor.getResultCode().startsWith(SUCCESS));
}
// Not in composite, do nothing but return success
listGsr = membershipService.deleteGroupingMemberByUuid(users.get(0).getUsername(), GROUPING_3_PATH, users.get(2).getUuid());
assertTrue(listGsr.get(0).getResultCode().startsWith(SUCCESS));
// Test if user is not an owner
try {
listGsr = membershipService.deleteGroupingMemberByUuid(users.get(5).getUsername(), GROUPING_3_PATH, users.get(6).getUuid());
assertTrue(listGsr.get(0).getResultCode().startsWith(SUCCESS));
} catch (GroupingsServiceResultException gsre) {
gsr = gsre.getGsr();
}
// Test if user is admin
listGsr = membershipService.deleteGroupingMemberByUuid(ADMIN_USER, GROUPING_3_PATH, users.get(6).getUuid());
assertTrue(listGsr.get(0).getResultCode().startsWith(SUCCESS));
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class MembershipServiceTest method deleteGroupingMemberbyUsernameTest.
@Test
public void deleteGroupingMemberbyUsernameTest() {
Iterable<Grouping> group = groupingRepository.findAll();
List<GroupingsServiceResult> listGsr;
GroupingsServiceResult gsr;
// Base test
// Remove person from include and composite
listGsr = membershipService.deleteGroupingMemberByUsername(users.get(0).getUsername(), GROUPING_3_PATH, users.get(5).getUsername());
assertTrue(listGsr.get(0).getResultCode().startsWith(SUCCESS));
// If person is in composite and basis, add to exclude group
listGsr = membershipService.deleteGroupingMemberByUsername(users.get(0).getUsername(), GROUPING_3_PATH, users.get(1).getUsername());
for (GroupingsServiceResult gsrFor : listGsr) {
assertTrue(gsrFor.getResultCode().startsWith(SUCCESS));
}
// Not in composite, do nothing but return success
listGsr = membershipService.deleteGroupingMemberByUuid(users.get(0).getUsername(), GROUPING_3_PATH, users.get(2).getUsername());
assertTrue(listGsr.get(0).getResultCode().startsWith(SUCCESS));
// Test if user is not an owner
try {
listGsr = membershipService.deleteGroupingMemberByUuid(users.get(5).getUsername(), GROUPING_3_PATH, users.get(6).getUuid());
assertTrue(listGsr.get(0).getResultCode().startsWith(SUCCESS));
} catch (GroupingsServiceResultException gsre) {
gsr = gsre.getGsr();
}
// Test if user is admin
listGsr = membershipService.deleteGroupingMemberByUuid(ADMIN_USER, GROUPING_3_PATH, users.get(6).getUuid());
assertTrue(listGsr.get(0).getResultCode().startsWith(SUCCESS));
}
use of edu.hawaii.its.api.type.GroupingsServiceResult in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestGroupingAssignmentService method updateLastModifiedTest.
@Test
public void updateLastModifiedTest() {
// Test is accurate to the minute, and if checks to see if the current
// time gets added to the lastModified attribute of a group if the
// minute happens to change in between getting the time and setting
// the time, the test will fail.
final String group = GROUPING_INCLUDE;
GroupingsServiceResult gsr = membershipService.updateLastModified(group);
String dateStr = gsr.getAction().split(" to time ")[1];
WsGetAttributeAssignmentsResults assignments = groupAttributeService.attributeAssignmentsResults(ASSIGN_TYPE_GROUP, group, YYYYMMDDTHHMM);
String assignedValue = assignments.getWsAttributeAssigns()[0].getWsAttributeAssignValues()[0].getValueSystem();
assertEquals(dateStr, assignedValue);
}
Aggregations