Search in sources :

Example 1 with Grouping

use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingsRestControllerTest method getMyGroupings.

@Test
@WithMockUhUser
public void getMyGroupings() throws Exception {
    ObjectMapper om = new ObjectMapper();
    final String username = "user";
    List<Grouping> groupings = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        groupings.add(grouping());
        groupings.get(i).setPath("grouping" + i);
    }
    given(groupingAssignmentService.getGroupingAssignment(username)).willReturn(myGroupings());
    String mvcResult = mockMvc.perform(get("/api/groupings/groupingAssignment")).andExpect(status().isOk()).andReturn().getResponse().getContentAsString();
    GroupingAssignment mg = om.readValue(mvcResult, GroupingAssignment.class);
    Assert.assertTrue(mg.getGroupingsIn().get(0).getName().equals(groupings.get(0).getName()));
    Assert.assertTrue(mg.getGroupingsIn().get(0).getPath().equals(groupings.get(0).getPath()));
    Assert.assertTrue(mg.getGroupingsIn().get(0).getOwners().getNames().equals(groupings.get(0).getOwners().getNames()));
    Assert.assertTrue(mg.getGroupingsIn().get(0).getOwners().getUsernames().equals(groupings.get(0).getOwners().getUsernames()));
    Assert.assertTrue(mg.getGroupingsIn().get(0).getOwners().getUuids().equals(groupings.get(0).getOwners().getUuids()));
    Assert.assertTrue(mg.getGroupingsOwned().get(0).getName().equals(groupings.get(0).getName()));
    Assert.assertTrue(mg.getGroupingsOwned().get(0).getPath().equals(groupings.get(0).getPath()));
    Assert.assertTrue(mg.getGroupingsOwned().get(0).getOwners().getNames().equals(groupings.get(0).getOwners().getNames()));
    Assert.assertTrue(mg.getGroupingsOwned().get(0).getOwners().getUsernames().equals(groupings.get(0).getOwners().getUsernames()));
    Assert.assertTrue(mg.getGroupingsOwned().get(0).getOwners().getUuids().equals(groupings.get(0).getOwners().getUuids()));
    Assert.assertTrue(mg.getGroupingsToOptInTo().get(0).getName().equals(groupings.get(0).getName()));
    Assert.assertTrue(mg.getGroupingsToOptInTo().get(0).getPath().equals(groupings.get(0).getPath()));
    Assert.assertTrue(mg.getGroupingsToOptInTo().get(0).getOwners().getNames().equals(groupings.get(0).getOwners().getNames()));
    Assert.assertTrue(mg.getGroupingsToOptInTo().get(0).getOwners().getUsernames().equals(groupings.get(0).getOwners().getUsernames()));
    Assert.assertTrue(mg.getGroupingsToOptInTo().get(0).getOwners().getUuids().equals(groupings.get(0).getOwners().getUuids()));
    Assert.assertTrue(mg.getGroupingsToOptOutOf().get(0).getName().equals(groupings.get(0).getName()));
    Assert.assertTrue(mg.getGroupingsToOptOutOf().get(0).getPath().equals(groupings.get(0).getPath()));
    Assert.assertTrue(mg.getGroupingsToOptOutOf().get(0).getOwners().getNames().equals(groupings.get(0).getOwners().getNames()));
    Assert.assertTrue(mg.getGroupingsToOptOutOf().get(0).getOwners().getUsernames().equals(groupings.get(0).getOwners().getUsernames()));
    Assert.assertTrue(mg.getGroupingsToOptOutOf().get(0).getOwners().getUuids().equals(groupings.get(0).getOwners().getUuids()));
    Assert.assertTrue(mg.getGroupingsOptedInTo().get(0).getName().equals(groupings.get(0).getName()));
    Assert.assertTrue(mg.getGroupingsOptedInTo().get(0).getPath().equals(groupings.get(0).getPath()));
    Assert.assertTrue(mg.getGroupingsOptedInTo().get(0).getOwners().getNames().equals(groupings.get(0).getOwners().getNames()));
    Assert.assertTrue(mg.getGroupingsOptedInTo().get(0).getOwners().getUsernames().equals(groupings.get(0).getOwners().getUsernames()));
    Assert.assertTrue(mg.getGroupingsOptedInTo().get(0).getOwners().getUuids().equals(groupings.get(0).getOwners().getUuids()));
    Assert.assertTrue(mg.getGroupingsOptedOutOf().get(0).getName().equals(groupings.get(0).getName()));
    Assert.assertTrue(mg.getGroupingsOptedOutOf().get(0).getPath().equals(groupings.get(0).getPath()));
    Assert.assertTrue(mg.getGroupingsOptedOutOf().get(0).getOwners().getNames().equals(groupings.get(0).getOwners().getNames()));
    Assert.assertTrue(mg.getGroupingsOptedOutOf().get(0).getOwners().getUsernames().equals(groupings.get(0).getOwners().getUsernames()));
    Assert.assertTrue(mg.getGroupingsOptedOutOf().get(0).getOwners().getUuids().equals(groupings.get(0).getOwners().getUuids()));
}
Also used : ArrayList(java.util.ArrayList) Grouping(edu.hawaii.its.api.type.Grouping) GroupingAssignment(edu.hawaii.its.api.type.GroupingAssignment) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) WithMockUhUser(edu.hawaii.its.groupings.controller.WithMockUhUser)

Example 2 with Grouping

use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.

the class TestGroupingsRestController method getEmptyGroupingTest.

@Test
@WithMockUhUser(username = "iamtst01")
public void getEmptyGroupingTest() throws Exception {
    Grouping storeEmpty = mapGrouping(GROUPING_STORE_EMPTY);
    Grouping trueEmpty = mapGrouping(GROUPING_TRUE_EMPTY);
    assertTrue(storeEmpty.getBasis().getMembers().size() == 1);
    assertTrue(storeEmpty.getComposite().getMembers().size() == 0);
    assertTrue(storeEmpty.getExclude().getMembers().size() == 0);
    assertTrue(storeEmpty.getInclude().getMembers().size() == 0);
    assertTrue(storeEmpty.getOwners().getUsernames().contains(tst[0]));
    assertTrue(trueEmpty.getBasis().getMembers().size() == 0);
    assertTrue(trueEmpty.getComposite().getMembers().size() == 0);
    assertTrue(trueEmpty.getExclude().getMembers().size() == 0);
    assertTrue(trueEmpty.getInclude().getMembers().size() == 0);
    assertTrue(trueEmpty.getOwners().getUsernames().contains(tst[0]));
}
Also used : Grouping(edu.hawaii.its.api.type.Grouping) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) WithMockUhUser(edu.hawaii.its.groupings.controller.WithMockUhUser)

Example 3 with Grouping

use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.

the class TestGroupingsRestController method groupingsAssignmentEmptyTest.

@Test
@WithMockUhUser(username = "iamtst05")
public void groupingsAssignmentEmptyTest() throws Exception {
    GroupingAssignment groupings = mapGroupingAssignment();
    assertEquals(groupings.getGroupingsIn().size(), groupings.getGroupingsToOptOutOf().size());
    for (Grouping grouping : groupings.getGroupingsIn()) {
        mapGSRs("/api/groupings/" + grouping.getPath() + "/optOut");
    }
    groupings = mapGroupingAssignment();
    assertEquals(0, groupings.getGroupingsIn().size());
    assertEquals(0, groupings.getGroupingsToOptOutOf().size());
}
Also used : Grouping(edu.hawaii.its.api.type.Grouping) GroupingAssignment(edu.hawaii.its.api.type.GroupingAssignment) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) WithMockUhUser(edu.hawaii.its.groupings.controller.WithMockUhUser)

Example 4 with Grouping

use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.

the class TestGroupingsRestController method myGroupingsTest4.

@Test
@WithMockUhUser(username = "iamtst06")
public void myGroupingsTest4() throws Exception {
    boolean optedOut = false;
    GroupingAssignment tst5Groupings = mapGroupingAssignment();
    assertEquals(tst5Groupings.getGroupingsOptedOutOf().size(), 0);
    mapGSRs("/api/groupings/" + GROUPING + "/optOut");
    tst5Groupings = mapGroupingAssignment();
    for (Grouping grouping : tst5Groupings.getGroupingsOptedOutOf()) {
        if (grouping.getPath().contains(this.GROUPING)) {
            optedOut = true;
        }
    }
    assertTrue(optedOut);
    membershipService.deleteGroupMemberByUsername(tst[0], GROUPING_EXCLUDE, tst[5]);
}
Also used : Grouping(edu.hawaii.its.api.type.Grouping) GroupingAssignment(edu.hawaii.its.api.type.GroupingAssignment) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) WithMockUhUser(edu.hawaii.its.groupings.controller.WithMockUhUser)

Example 5 with Grouping

use of edu.hawaii.its.api.type.Grouping in project uhgroupings by uhawaii-system-its-ti-iam.

the class TestGroupingsRestController method getGroupingTest.

@Test
@WithMockUhUser(username = "iamtst01")
public void getGroupingTest() throws Exception {
    Grouping grouping = mapGrouping(GROUPING);
    Group basis = grouping.getBasis();
    Group composite = grouping.getComposite();
    Group exclude = grouping.getExclude();
    Group include = grouping.getInclude();
    // basis
    assertTrue(basis.getUsernames().contains(tst[3]));
    assertTrue(basis.getUsernames().contains(tst[4]));
    assertTrue(basis.getUsernames().contains(tst[5]));
    assertTrue(basis.getNames().contains(tstName[3]));
    assertTrue(basis.getNames().contains(tstName[4]));
    assertTrue(basis.getNames().contains(tstName[5]));
    // composite
    assertTrue(composite.getUsernames().contains(tst[0]));
    assertTrue(composite.getUsernames().contains(tst[1]));
    assertTrue(composite.getUsernames().contains(tst[2]));
    assertTrue(composite.getUsernames().contains(tst[4]));
    assertTrue(composite.getUsernames().contains(tst[5]));
    assertTrue(composite.getNames().contains(tstName[0]));
    assertTrue(composite.getNames().contains(tstName[1]));
    assertTrue(composite.getNames().contains(tstName[2]));
    assertTrue(composite.getNames().contains(tstName[4]));
    assertTrue(composite.getNames().contains(tstName[5]));
    // exclude
    assertTrue(exclude.getUsernames().contains(tst[3]));
    assertTrue(exclude.getNames().contains(tstName[3]));
    // include
    assertTrue(include.getUsernames().contains(tst[0]));
    assertTrue(include.getUsernames().contains(tst[1]));
    assertTrue(include.getUsernames().contains(tst[2]));
    assertTrue(include.getNames().contains(tstName[0]));
    assertTrue(include.getNames().contains(tstName[1]));
    assertTrue(include.getNames().contains(tstName[2]));
    assertFalse(grouping.getOwners().getNames().contains(tstName[5]));
    mapGSR("/api/groupings/" + grouping.getPath() + "/" + tst[5] + "/assignOwnership");
    grouping = mapGrouping(GROUPING);
    assertTrue(grouping.getOwners().getNames().contains(tstName[5]));
    mapGSR("/api/groupings/" + grouping.getPath() + "/" + tst[5] + "/removeOwnership");
    grouping = mapGrouping(GROUPING);
    assertFalse(grouping.getOwners().getNames().contains(tstName[5]));
}
Also used : Group(edu.hawaii.its.api.type.Group) Grouping(edu.hawaii.its.api.type.Grouping) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) WithMockUhUser(edu.hawaii.its.groupings.controller.WithMockUhUser)

Aggregations

Grouping (edu.hawaii.its.api.type.Grouping)45 Test (org.junit.Test)28 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)28 ArrayList (java.util.ArrayList)14 Group (edu.hawaii.its.api.type.Group)13 GroupingAssignment (edu.hawaii.its.api.type.GroupingAssignment)11 WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)11 WithMockUhUser (edu.hawaii.its.groupings.controller.WithMockUhUser)9 Person (edu.hawaii.its.api.type.Person)8 GroupingsServiceResult (edu.hawaii.its.api.type.GroupingsServiceResult)6 GroupingsServiceResultException (edu.hawaii.its.api.type.GroupingsServiceResultException)6 WsAttributeAssign (edu.internet2.middleware.grouperClient.ws.beans.WsAttributeAssign)5 WsResultMeta (edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta)5 WsAssignAttributesResults (edu.internet2.middleware.grouperClient.ws.beans.WsAssignAttributesResults)3 WsGetAttributeAssignmentsResults (edu.internet2.middleware.grouperClient.ws.beans.WsGetAttributeAssignmentsResults)3 AdminListsHolder (edu.hawaii.its.api.type.AdminListsHolder)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Membership (edu.hawaii.its.api.type.Membership)1 StemScope (edu.internet2.middleware.grouperClient.ws.StemScope)1 WsAddMemberResults (edu.internet2.middleware.grouperClient.ws.beans.WsAddMemberResults)1