Search in sources :

Example 11 with GroupingsServiceResultException

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));
}
Also used : GroupingsServiceResultException(edu.hawaii.its.api.type.GroupingsServiceResultException) GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with GroupingsServiceResultException

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());
}
Also used : GroupingsServiceResultException(edu.hawaii.its.api.type.GroupingsServiceResultException) GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with GroupingsServiceResultException

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));
}
Also used : GroupingsServiceResultException(edu.hawaii.its.api.type.GroupingsServiceResultException) GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with GroupingsServiceResultException

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]));
}
Also used : GroupingsServiceResultException(edu.hawaii.its.api.type.GroupingsServiceResultException) GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 15 with GroupingsServiceResultException

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;
}
Also used : GroupingsServiceResultException(edu.hawaii.its.api.type.GroupingsServiceResultException) GroupingsServiceResult(edu.hawaii.its.api.type.GroupingsServiceResult)

Aggregations

GroupingsServiceResultException (edu.hawaii.its.api.type.GroupingsServiceResultException)16 GroupingsServiceResult (edu.hawaii.its.api.type.GroupingsServiceResult)15 Test (org.junit.Test)14 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)14 Grouping (edu.hawaii.its.api.type.Grouping)6 Group (edu.hawaii.its.api.type.Group)1 Membership (edu.hawaii.its.api.type.Membership)1 Person (edu.hawaii.its.api.type.Person)1