Search in sources :

Example 21 with Group

use of org.gluu.oxtrust.model.scim2.Group in project camel by apache.

the class GroupProducerTest method setUp.

@Before
public void setUp() {
    producer = new GroupProducer(endpoint, client);
    when(groupService.create(any(Group.class))).thenReturn(testOSgroup);
    when(groupService.get(anyString())).thenReturn(testOSgroup);
    List<Group> getAllList = new ArrayList<>();
    getAllList.add(testOSgroup);
    getAllList.add(testOSgroup);
    doReturn(getAllList).when(groupService).list();
    dummyGroup = createGroup();
    when(testOSgroup.getName()).thenReturn(dummyGroup.getName());
    when(testOSgroup.getDescription()).thenReturn(dummyGroup.getDescription());
}
Also used : Group(org.openstack4j.model.identity.v3.Group) GroupProducer(org.apache.camel.component.openstack.keystone.producer.GroupProducer) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Example 22 with Group

use of org.gluu.oxtrust.model.scim2.Group in project camel by apache.

the class GroupProducerTest method updateTest.

@Test
public void updateTest() throws Exception {
    final String id = "myID";
    msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.UPDATE);
    final String newName = "newName";
    when(testOSgroup.getId()).thenReturn(id);
    when(testOSgroup.getName()).thenReturn(newName);
    when(testOSgroup.getDescription()).thenReturn("desc");
    when(groupService.update(any(Group.class))).thenReturn(testOSgroup);
    msg.setBody(testOSgroup);
    producer.process(exchange);
    ArgumentCaptor<Group> captor = ArgumentCaptor.forClass(Group.class);
    verify(groupService).update(captor.capture());
    assertEqualsGroup(testOSgroup, captor.getValue());
    assertNotNull(captor.getValue().getId());
    assertEquals(newName, msg.getBody(Group.class).getName());
}
Also used : Group(org.openstack4j.model.identity.v3.Group) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 23 with Group

use of org.gluu.oxtrust.model.scim2.Group in project ORCID-Source by ORCID.

the class Api2_0_rc3_LastModifiedDatesHelper method calculateLastModified.

public static void calculateLastModified(GroupsContainer groupsContainerRc3) {
    if (groupsContainerRc3.retrieveGroups() != null && !groupsContainerRc3.retrieveGroups().isEmpty()) {
        List<? extends Group> groupsRc1 = new ArrayList<>(groupsContainerRc3.retrieveGroups());
        List<org.orcid.jaxb.model.record_rc3.Group> groupsRc3 = new ArrayList<>(groupsContainerRc3.retrieveGroups());
        if (groupsRc1.get(0).getActivities() != null && !groupsRc1.get(0).getActivities().isEmpty()) {
            LastModifiedDate latest = null;
            for (Group group : groupsRc3) {
                calculateLastModified(group);
                if (group.getLastModifiedDate() != null && group.getLastModifiedDate().after(latest)) {
                    latest = group.getLastModifiedDate();
                }
            }
            groupsContainerRc3.setLastModifiedDate(latest);
        }
    }
}
Also used : Group(org.orcid.jaxb.model.record_rc3.Group) LastModifiedDate(org.orcid.jaxb.model.common_rc3.LastModifiedDate) ArrayList(java.util.ArrayList)

Example 24 with Group

use of org.gluu.oxtrust.model.scim2.Group in project ORCID-Source by ORCID.

the class Api2_0_rc2_LastModifiedDatesHelper method calculateLatest.

public static Date calculateLatest(GroupsContainer groupsContainerRc2) {
    Date latestGrp = null;
    if (groupsContainerRc2.retrieveGroups() != null && !groupsContainerRc2.retrieveGroups().isEmpty()) {
        List<? extends Group> groupsRc1 = new ArrayList<>(groupsContainerRc2.retrieveGroups());
        List<org.orcid.jaxb.model.record_rc2.Group> groupsRc2 = new ArrayList<>(groupsContainerRc2.retrieveGroups());
        if (groupsRc1.get(0).getActivities() != null && !groupsRc1.get(0).getActivities().isEmpty()) {
            for (int index = 0; index < groupsRc2.size(); index++) {
                latestGrp = calculateLatest(groupsRc2.get(index));
            }
            groupsContainerRc2.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendarNoTimeZoneNoMillis(latestGrp)));
        }
    }
    return latestGrp;
}
Also used : Group(org.orcid.jaxb.model.record_rc2.Group) LastModifiedDate(org.orcid.jaxb.model.common_rc2.LastModifiedDate) ArrayList(java.util.ArrayList) LastModifiedDate(org.orcid.jaxb.model.common_rc2.LastModifiedDate) Date(java.util.Date)

Example 25 with Group

use of org.gluu.oxtrust.model.scim2.Group in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV2Test method setVisibility.

private void setVisibility(GroupsContainer container, Visibility... vs) {
    assertEquals(container.retrieveGroups().size(), vs.length);
    int idx = 0;
    for (Group g : container.retrieveGroups()) {
        // Every group have just one element
        assertEquals(1, g.getActivities().size());
        for (Filterable f : g.getActivities()) {
            f.setVisibility(vs[idx++]);
        }
    }
}
Also used : WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) FundingGroup(org.orcid.jaxb.model.record.summary_v2.FundingGroup) Group(org.orcid.jaxb.model.record_v2.Group) Filterable(org.orcid.jaxb.model.common_v2.Filterable)

Aggregations

ArrayList (java.util.ArrayList)12 DuplicateEntryException (org.gluu.site.ldap.exception.DuplicateEntryException)12 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)10 DefaultValue (javax.ws.rs.DefaultValue)9 HeaderParam (javax.ws.rs.HeaderParam)9 Produces (javax.ws.rs.Produces)9 GluuGroup (org.gluu.oxtrust.model.GluuGroup)9 Group (org.gluu.oxtrust.model.scim2.Group)9 URI (java.net.URI)8 Group (org.openstack4j.model.identity.v3.Group)8 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)7 Response (javax.ws.rs.core.Response)7 ListResponse (org.gluu.oxtrust.model.scim2.ListResponse)7 Group (com.google.monitoring.v3.Group)5 Path (javax.ws.rs.Path)5 Test (org.junit.Test)5 VirtualListViewResponse (org.xdi.ldap.model.VirtualListViewResponse)5 IOException (java.io.IOException)4 Map (java.util.Map)4 GET (javax.ws.rs.GET)4