SetNetworkACLCommand extends NetworkElementCommand { protected void orderNetworkAclRulesByRuleNumber(List<NetworkACLTO> aclList) { Collections.sort(aclList, new Comparator<NetworkACLTO>() { @Override public int compare(final NetworkACLTO acl1, final NetworkACLTO acl2) { return acl1.getNumber() > acl2.getNumber() ? 1 : -1; } }); } protected  SetNetworkACLCommand();  SetNetworkACLCommand(final List<NetworkACLTO> rules, final NicTO nic); NetworkACLTO[] getRules(); String[][] generateFwRules(); NicTO getNic(); @Override int getAnswersCount();  }
@Test public void testNetworkAclRuleOrdering(){ List<NetworkACLTO> aclList = Lists.newArrayList(); aclList.add(new NetworkACLTO(3, null, null, null, null, false, false, null, null, null, null, false, 3)); aclList.add(new NetworkACLTO(1, null, null, null, null, false, false, null, null, null, null, false, 1)); aclList.add(new NetworkACLTO(2, null, null, null, null, false, false, null, null, null, null, false, 2)); SetNetworkACLCommand cmd = new SetNetworkACLCommand(aclList, null); cmd.orderNetworkAclRulesByRuleNumber(aclList); for(int i=0; i< aclList.size();i++){ assertEquals(aclList.get(i).getNumber(), i+1); } }