Search in sources :

Example 6 with GroupingAssignment

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

the class GroupingAssignmentServiceImpl method getGroupingAssignment.

// get a GroupingAssignment object containing the groups that a user is in and can opt into
@Override
public GroupingAssignment getGroupingAssignment(String username) {
    GroupingAssignment groupingAssignment = new GroupingAssignment();
    List<String> groupPaths = getGroupPaths(username);
    groupingAssignment.setGroupingsIn(groupingsIn(groupPaths));
    groupingAssignment.setGroupingsOwned(groupingsOwned(groupPaths));
    groupingAssignment.setGroupingsToOptInTo(groupingsToOptInto(username, groupPaths));
    groupingAssignment.setGroupingsToOptOutOf(groupingsToOptOutOf(username, groupPaths));
    groupingAssignment.setGroupingsOptedOutOf(groupingsOptedOutOf(username, groupPaths));
    groupingAssignment.setGroupingsOptedInTo(groupingsOptedInto(username, groupPaths));
    return groupingAssignment;
}
Also used : GroupingAssignment(edu.hawaii.its.api.type.GroupingAssignment)

Example 7 with GroupingAssignment

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

the class GroupingsRestControllerTest method myGroupings.

// Test data.
private GroupingAssignment myGroupings() {
    GroupingAssignment mg = new GroupingAssignment();
    List<Grouping> groupings = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        groupings.add(grouping());
        groupings.get(i).setPath("grouping" + i);
    }
    mg.setGroupingsIn(groupings);
    mg.setGroupingsOwned(groupings);
    mg.setGroupingsOptedOutOf(groupings);
    mg.setGroupingsOptedInTo(groupings);
    mg.setGroupingsToOptOutOf(groupings);
    mg.setGroupingsToOptInTo(groupings);
    return mg;
}
Also used : ArrayList(java.util.ArrayList) Grouping(edu.hawaii.its.api.type.Grouping) GroupingAssignment(edu.hawaii.its.api.type.GroupingAssignment)

Example 8 with GroupingAssignment

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

the class TestGroupingsRestController method myGroupingsTest3.

@Test
@WithMockUhUser(username = "iamtst04")
public void myGroupingsTest3() throws Exception {
    boolean optedIn = false;
    GroupingAssignment tst4Groupings = mapGroupingAssignment();
    assertEquals(tst4Groupings.getGroupingsOptedInTo().size(), 0);
    mapGSRs("/api/groupings/" + GROUPING + "/optIn");
    tst4Groupings = mapGroupingAssignment();
    for (Grouping grouping : tst4Groupings.getGroupingsOptedInTo()) {
        if (grouping.getPath().contains(GROUPING)) {
            optedIn = true;
        }
    }
    // in basis
    assertFalse(optedIn);
}
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 9 with GroupingAssignment

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

the class TestGroupingsRestController method myGroupingsTest2.

@Test
@WithMockUhUser(username = "iamtst04")
public void myGroupingsTest2() throws Exception {
    GroupingAssignment groupings = mapGroupingAssignment();
    boolean inGrouping = false;
    for (Grouping grouping : groupings.getGroupingsIn()) {
        if (grouping.getPath().contains(this.GROUPING)) {
            inGrouping = true;
            break;
        }
    }
    assertFalse(inGrouping);
    boolean ownsGrouping = false;
    for (Grouping grouping : groupings.getGroupingsOwned()) {
        if (grouping.getPath().contains(this.GROUPING)) {
            ownsGrouping = true;
            break;
        }
    }
    assertFalse(ownsGrouping);
}
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 10 with GroupingAssignment

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

the class TestGroupingsRestController method aaronTest.

@Test
@WithMockUhUser(username = "aaronvil")
public void aaronTest() throws Exception {
    // This test often fails because the test server is very slow.
    // Because the server caches some results and gets quicker the more times
    // it is run, we let it run a few times if it starts failing
    int i = 0;
    while (i < 5) {
        try {
            GroupingAssignment aaronsGroupings = mapGroupingAssignment();
            assertNotNull(aaronsGroupings);
            break;
        } catch (AssertionError ae) {
            i++;
        }
    }
    assertTrue(i < 5);
}
Also used : 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)

Aggregations

GroupingAssignment (edu.hawaii.its.api.type.GroupingAssignment)13 Test (org.junit.Test)11 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)11 Grouping (edu.hawaii.its.api.type.Grouping)10 WithMockUhUser (edu.hawaii.its.groupings.controller.WithMockUhUser)7 ArrayList (java.util.ArrayList)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1