use of com.zimbra.soap.account.type.HABGroup in project zm-mailbox by Zimbra.
the class TestHabGroupSort method testSort1.
@Test
public void testSort1() {
HABGroup grp = new HABGroup();
grp.setName("MyOrg");
grp.setId("1");
grp.setRootGroup(ZmBoolean.ONE);
List<HABGroup> childList1 = new ArrayList<HABGroup>();
grp.setChildGroups(childList1);
HABGroup grp1 = new HABGroup();
grp1.setName("Prod");
grp1.setId("2");
grp1.setSeniorityIndex(100);
childList1.add(grp1);
HABGroup grp2 = new HABGroup();
grp2.setName("Sales");
grp2.setId("3");
childList1.add(grp2);
HABGroup grp3 = new HABGroup();
grp3.setName("Market");
grp3.setId("4");
childList1.add(grp3);
HABGroup grp4 = new HABGroup();
grp4.setName("QA");
grp4.setSeniorityIndex(55);
grp4.setId("5");
childList1.add(grp4);
HABGroup grp5 = new HABGroup();
grp5.setName("Engg");
grp5.setSeniorityIndex(45);
grp5.setId("6");
childList1.add(grp5);
HABGroup grp7 = new HABGroup();
grp7.setName("NQA");
grp7.setId("7");
childList1.add(grp7);
HABGroup grp8 = new HABGroup();
grp8.setName("Dev");
grp8.setId("8");
childList1.add(grp8);
Collections.sort(childList1, new SortBySeniorityIndexThenName());
System.out.println(childList1);
Assert.assertEquals("Prod", childList1.get(0).getName());
Assert.assertEquals("Engg", childList1.get(2).getName());
Assert.assertEquals("Sales", childList1.get(6).getName());
}
use of com.zimbra.soap.account.type.HABGroup in project zm-mailbox by Zimbra.
the class ToXML method encodeHabGroup.
/**
* @param parent parent element of XML response
* @param grp the group to encode
* @param parentId id of the parent group
*/
public static void encodeHabGroup(Element parent, HABGroup grp, String parentId) {
Element habGroup = parent.addNonUniqueElement(AccountConstants.E_HAB_GROUP);
habGroup.addAttribute(AccountConstants.A_NAME, grp.getName());
for (Attr attr : grp.getAttrs()) {
if (!skipAttrs.contains(attr.getKey())) {
ToXML.encodeAttr(habGroup, attr.getKey(), attr.getValue());
}
}
if (parentId != null) {
habGroup.addAttribute(AccountConstants.A_PARENT_HAB_GROUP_ID, parentId);
}
habGroup.addAttribute(AdminConstants.A_ID, grp.getId());
habGroup.addAttribute(AccountConstants.A_HAB_SENIORITY_INDEX, grp.getSeniorityIndex());
for (HABGroup habGrp : grp.getChildGroups()) {
if (habGrp.getId() != null) {
encodeHabGroup(habGroup, habGrp, grp.getId());
}
}
}
use of com.zimbra.soap.account.type.HABGroup in project zm-mailbox by Zimbra.
the class TestHabGroupSort method testSort2.
@Test
public void testSort2() {
HABGroup grp = new HABGroup();
grp.setName("MyOrg");
grp.setId("1");
grp.setRootGroup(ZmBoolean.ONE);
List<HABGroup> childList1 = new ArrayList<HABGroup>();
grp.setChildGroups(childList1);
HABGroup grp1 = new HABGroup();
grp1.setName("Prod");
grp1.setId("2");
grp1.setSeniorityIndex(100);
childList1.add(grp1);
HABGroup grp2 = new HABGroup();
grp2.setName("Sales");
grp2.setId("3");
childList1.add(grp2);
HABGroup grp3 = new HABGroup();
grp3.setName("Market");
grp3.setId("4");
childList1.add(grp3);
HABGroup grp4 = new HABGroup();
grp4.setName("QA");
grp4.setSeniorityIndex(55);
grp4.setId("5");
childList1.add(grp4);
HABGroup grp5 = new HABGroup();
grp5.setName("Engg");
grp5.setSeniorityIndex(45);
grp5.setId("6");
childList1.add(grp5);
HABGroup grp7 = new HABGroup();
grp7.setId("7");
childList1.add(grp7);
HABGroup grp8 = new HABGroup();
grp8.setName("Dev");
grp8.setId("8");
childList1.add(grp8);
Collections.sort(childList1, new SortBySeniorityIndexThenName());
Assert.assertEquals("Prod", childList1.get(0).getName());
Assert.assertEquals("Engg", childList1.get(2).getName());
Assert.assertEquals("Sales", childList1.get(5).getName());
}