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;
}
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);
}
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);
}
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());
}
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());
}
Aggregations