Search in sources :

Example 21 with Group

use of org.orcid.jaxb.model.record_rc2.Group in project ORCID-Source by ORCID.

the class Api2_0_rc2_LastModifiedDatesHelper method calculateLatest.

public static Date calculateLatest(Group groupRc2) {
    Date latestAct = null;
    Collection<? extends GroupableActivity> activities = groupRc2.getActivities();
    if (activities != null && !activities.isEmpty()) {
        Iterator<? extends GroupableActivity> activitiesIterator = activities.iterator();
        XMLGregorianCalendar latest = activitiesIterator.next().getLastModifiedDate().getValue();
        while (activitiesIterator.hasNext()) {
            GroupableActivity activity = activitiesIterator.next();
            if (latest.compare(activity.getLastModifiedDate().getValue()) == -1) {
                latest = activity.getLastModifiedDate().getValue();
            }
        }
        latestAct = latest.toGregorianCalendar().getTime();
        groupRc2.setLastModifiedDate(new LastModifiedDate(latest));
    }
    return latestAct;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) LastModifiedDate(org.orcid.jaxb.model.common_rc2.LastModifiedDate) GroupableActivity(org.orcid.jaxb.model.record_rc2.GroupableActivity) LastModifiedDate(org.orcid.jaxb.model.common_rc2.LastModifiedDate) Date(java.util.Date)

Example 22 with Group

use of org.orcid.jaxb.model.record_rc2.Group in project camel by apache.

the class GroupProducer method doGet.

private void doGet(Exchange exchange) {
    final Message msg = exchange.getIn();
    final String id = msg.getHeader(OpenstackConstants.ID, msg.getHeader(KeystoneConstants.GROUP_ID, String.class), String.class);
    ObjectHelper.notEmpty(id, "Group ID");
    final Group result = osV3Client.identity().groups().get(id);
    msg.setBody(result);
}
Also used : Group(org.openstack4j.model.identity.v3.Group) Message(org.apache.camel.Message)

Example 23 with Group

use of org.orcid.jaxb.model.record_rc2.Group in project camel by apache.

the class GroupProducer method doCreate.

private void doCreate(Exchange exchange) {
    final Group in = messageToGroup(exchange.getIn());
    final Group out = osV3Client.identity().groups().create(in);
    exchange.getIn().setBody(out);
}
Also used : Group(org.openstack4j.model.identity.v3.Group)

Example 24 with Group

use of org.orcid.jaxb.model.record_rc2.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 25 with Group

use of org.orcid.jaxb.model.record_rc2.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)

Aggregations

Test (org.junit.Test)9 Group (org.gluu.oxtrust.model.scim2.Group)8 Group (org.openstack4j.model.identity.v3.Group)8 ArrayList (java.util.ArrayList)7 GluuGroup (org.gluu.oxtrust.model.GluuGroup)7 DuplicateEntryException (org.gluu.site.ldap.exception.DuplicateEntryException)7 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)6 Group (com.google.monitoring.v3.Group)5 Date (java.util.Date)4 GroupName (com.google.monitoring.v3.GroupName)3 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)3 ClientResponse (com.sun.jersey.api.client.ClientResponse)3 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)3 URI (java.net.URI)3 DefaultValue (javax.ws.rs.DefaultValue)3 HeaderParam (javax.ws.rs.HeaderParam)3 Produces (javax.ws.rs.Produces)3 Response (javax.ws.rs.core.Response)3 ListResponse (org.gluu.oxtrust.model.scim2.ListResponse)3 ExternalID (org.orcid.jaxb.model.record_rc2.ExternalID)3