use of edu.hawaii.its.api.type.GroupingsServiceResultException in project uhgroupings by uhawaii-system-its-ti-iam.
the class MembershipServiceTest method addAdminTest.
@Test
public void addAdminTest() {
GroupingsServiceResult gsr;
try {
// user is not super user
gsr = membershipService.addAdmin(users.get(9).getUsername(), users.get(9).getUsername());
} catch (GroupingsServiceResultException gsre) {
gsr = gsre.getGsr();
}
assertTrue(gsr.getResultCode().startsWith(FAILURE));
// user is super user
gsr = membershipService.addAdmin(ADMIN_USER, users.get(9).getUsername());
assertEquals(SUCCESS, gsr.getResultCode());
// users.get(9) is already and admin
gsr = membershipService.addAdmin(ADMIN_USER, users.get(9).getUsername());
assertTrue(gsr.getResultCode().startsWith(SUCCESS));
}
use of edu.hawaii.its.api.type.GroupingsServiceResultException in project uhgroupings by uhawaii-system-its-ti-iam.
the class MembershipServiceTest method deleteAdminTest.
@Test
public void deleteAdminTest() {
GroupingsServiceResult gsr;
// usernameToDelete is not a superuser
String usernameToDelete = users.get(9).getUsername();
try {
// user is not super user
gsr = membershipService.deleteAdmin(usernameToDelete, ADMIN_USER);
} catch (GroupingsServiceResultException gsre) {
gsr = gsre.getGsr();
}
assertTrue(gsr.getResultCode().startsWith(FAILURE));
// user is super user usernameToDelete is not superuser
gsr = membershipService.deleteAdmin(ADMIN_USER, usernameToDelete);
assertEquals(SUCCESS, gsr.getResultCode());
// make usernameToDelete a superuser
membershipService.addAdmin(ADMIN_USER, usernameToDelete);
assertTrue(memberAttributeService.isAdmin(usernameToDelete));
// user is super user usernameToDelete is not superuser
gsr = membershipService.deleteAdmin(ADMIN_USER, usernameToDelete);
assertEquals(SUCCESS, gsr.getResultCode());
}
use of edu.hawaii.its.api.type.GroupingsServiceResultException in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestGroupAttributeService method changeListServeStatusTest.
@Test
public void changeListServeStatusTest() {
GroupingsServiceResult groupingsServiceResult;
assertTrue(memberAttributeService.isOwner(GROUPING, username[0]));
assertTrue(groupAttributeService.hasListserv(GROUPING));
groupAttributeService.changeListservStatus(GROUPING, username[0], true);
assertTrue(groupAttributeService.hasListserv(GROUPING));
groupAttributeService.changeListservStatus(GROUPING, username[0], false);
assertFalse(groupAttributeService.hasListserv(GROUPING));
groupAttributeService.changeListservStatus(GROUPING, username[0], false);
assertFalse(groupAttributeService.hasListserv(GROUPING));
assertFalse(memberAttributeService.isOwner(GROUPING, username[1]));
try {
groupingsServiceResult = groupAttributeService.changeListservStatus(GROUPING, username[1], true);
} catch (GroupingsServiceResultException gsre) {
groupingsServiceResult = gsre.getGsr();
}
assertTrue(groupingsServiceResult.getResultCode().startsWith(FAILURE));
assertFalse(groupAttributeService.hasListserv(GROUPING));
groupAttributeService.changeListservStatus(GROUPING, username[0], true);
assertTrue(groupAttributeService.hasListserv(GROUPING));
try {
groupingsServiceResult = groupAttributeService.changeListservStatus(GROUPING, username[1], false);
} catch (GroupingsServiceResultException gsre) {
groupingsServiceResult = gsre.getGsr();
}
assertTrue(groupingsServiceResult.getResultCode().startsWith(FAILURE));
assertTrue(groupAttributeService.hasListserv(GROUPING));
}
use of edu.hawaii.its.api.type.GroupingsServiceResultException in project uhgroupings by uhawaii-system-its-ti-iam.
the class TestMembershipService method addRemoveSelfOptedTest.
@Test
public void addRemoveSelfOptedTest() {
// username[2] is not in the include, but not self opted
assertTrue(memberAttributeService.isMember(GROUPING_INCLUDE, username[2]));
assertFalse(memberAttributeService.isSelfOpted(GROUPING_INCLUDE, username[2]));
// add the self opted attribute for username[2]'s membership for the include group
membershipService.addSelfOpted(GROUPING_INCLUDE, username[2]);
// username[2] should now be self opted
assertTrue(memberAttributeService.isSelfOpted(GROUPING_INCLUDE, username[2]));
// remove the self opted attribute for username[2]'s membership from the include group
membershipService.removeSelfOpted(GROUPING_INCLUDE, username[2]);
// username[2] should no longer be self opted into the include
assertFalse(memberAttributeService.isSelfOpted(GROUPING_INCLUDE, username[2]));
// try to add self opted attribute when not in the group
GroupingsServiceResult groupingsServiceResult;
try {
groupingsServiceResult = membershipService.addSelfOpted(GROUPING_EXCLUDE, username[2]);
} catch (GroupingsServiceResultException gsre) {
groupingsServiceResult = gsre.getGsr();
}
assertTrue(groupingsServiceResult.getResultCode().startsWith(FAILURE));
assertFalse(memberAttributeService.isSelfOpted(GROUPING_EXCLUDE, username[2]));
}
use of edu.hawaii.its.api.type.GroupingsServiceResultException in project uhgroupings by uhawaii-system-its-ti-iam.
the class HelperServiceImpl method makeGroupingsServiceResult.
// makes a groupingsServiceResult with the result code from the metadataHolder and the action string
@Override
public GroupingsServiceResult makeGroupingsServiceResult(ResultMetadataHolder resultMetadataHolder, String action) {
GroupingsServiceResult groupingsServiceResult = new GroupingsServiceResult();
groupingsServiceResult.setAction(action);
groupingsServiceResult.setResultCode(resultMetadataHolder.getResultMetadata().getResultCode());
if (groupingsServiceResult.getResultCode().startsWith(FAILURE)) {
throw new GroupingsServiceResultException(groupingsServiceResult);
}
return groupingsServiceResult;
}
Aggregations