Search in sources :

Example 11 with GroupingAssignment

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

the class TestGroupingsRestController method groupingAssignmentTest.

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

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

the class GroupingAssignmentServiceTest method getMyGroupingsTest.

@Test
public void getMyGroupingsTest() {
    GroupingAssignment myGroupings = groupingAssignmentService.getGroupingAssignment(users.get(1).getUsername());
    assertEquals(0, myGroupings.getGroupingsOwned().size());
    assertEquals(5, myGroupings.getGroupingsIn().size());
    assertEquals(0, myGroupings.getGroupingsOptedInTo().size());
    assertEquals(0, myGroupings.getGroupingsOptedOutOf().size());
    assertEquals(0, myGroupings.getGroupingsToOptInTo().size());
    assertEquals(2, myGroupings.getGroupingsToOptOutOf().size());
}
Also used : GroupingAssignment(edu.hawaii.its.api.type.GroupingAssignment) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with GroupingAssignment

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

the class TestGroupingAssignmentService method groupingsInTest.

@Test
public void groupingsInTest() {
    GroupingAssignment groupingAssignment = groupingAssignmentService.getGroupingAssignment(username[0]);
    boolean inGrouping = false;
    for (Grouping grouping : groupingAssignment.getGroupingsIn()) {
        if (grouping.getPath().contains(GROUPING)) {
            inGrouping = true;
            break;
        }
    }
    assertTrue(inGrouping);
    inGrouping = false;
    groupingAssignment = groupingAssignmentService.getGroupingAssignment(username[3]);
    for (Grouping grouping : groupingAssignment.getGroupingsIn()) {
        if (grouping.getPath().contains(GROUPING)) {
            inGrouping = true;
            break;
        }
    }
    assertFalse(inGrouping);
}
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)

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