use of org.openstack4j.model.identity.v3.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.openstack4j.model.identity.v3.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());
}
use of org.openstack4j.model.identity.v3.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);
}
}
}
use of org.openstack4j.model.identity.v3.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;
}
use of org.openstack4j.model.identity.v3.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++]);
}
}
}
Aggregations