@Test public final void updateOrderBasedOnL4ClassifTest() throws Exception { final ParameterValue sourcePort = createIntParameterValue(L4ClassifierDefinition.SRC_PORT_PARAM, 4999L); final ParameterValue destPort = createIntParameterValue(L4ClassifierDefinition.DST_PORT_PARAM, 8080L); final ParameterValue sourceMiniRange = createRangeParameterValue(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM, 1000, 1000); final ParameterValue destinationMiniRange = createRangeParameterValue(L4ClassifierDefinition.DST_PORT_RANGE_PARAM, 2000, 2000); final ParameterValue sourcePortRange = createRangeParameterValue(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM, 3335, 3336); final ParameterValue destinationPortRange = createRangeParameterValue(L4ClassifierDefinition.DST_PORT_RANGE_PARAM, 9998, 9999); ClassifierInstance classifierInstance; classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, destinationPortRange); assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 180); classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourcePortRange); assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 180); classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourcePort); assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 170); classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourceMiniRange); assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 170); classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, destPort); assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 170); classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, destinationMiniRange); assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 170); classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourcePortRange, destinationPortRange); assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 160); classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourcePortRange, destPort); assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 150); classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, sourcePortRange, destinationMiniRange); assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 150); classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, destinationPortRange, sourcePort); assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 150); classifierInstance = createClassifierInstance(L4ClassifierDefinition.ID, destinationPortRange, sourceMiniRange); assertEquals(SingleClassifierRule.updateOrderBasedOn(classifierInstance, allow, 0), 150); }
@VisibleForTesting static int updateOrderBasedOn(ClassifierInstance ci, ActionChoice action, Integer baseOrder) { int delta = 0; if (ci.getClassifierDefinitionId().equals(EtherTypeClassifierDefinition.ID)) { delta = 350; } else if (ci.getClassifierDefinitionId().equals(IpProtoClassifierDefinition.ID)) { delta = 300; } else if (ci.getClassifierDefinitionId().equals(L4ClassifierDefinition.ID)) { delta = 200; List<ParameterValue> parameterValue = ci.getParameterValue(); for (ParameterValue pv : parameterValue) { if (isSrcOrDstPortParam(pv)) { delta -= 30; } else if (isRangePortParam(pv)) { delta -= pv.getRangeValue().getMin().equals(pv.getRangeValue().getMax()) ? 30 : 20; } } } if (action instanceof SfcActionCase) { delta -= 5; } return baseOrder + delta; }
SingleClassifierRule { @VisibleForTesting static int updateOrderBasedOn(ClassifierInstance ci, ActionChoice action, Integer baseOrder) { int delta = 0; if (ci.getClassifierDefinitionId().equals(EtherTypeClassifierDefinition.ID)) { delta = 350; } else if (ci.getClassifierDefinitionId().equals(IpProtoClassifierDefinition.ID)) { delta = 300; } else if (ci.getClassifierDefinitionId().equals(L4ClassifierDefinition.ID)) { delta = 200; List<ParameterValue> parameterValue = ci.getParameterValue(); for (ParameterValue pv : parameterValue) { if (isSrcOrDstPortParam(pv)) { delta -= 30; } else if (isRangePortParam(pv)) { delta -= pv.getRangeValue().getMin().equals(pv.getRangeValue().getMax()) ? 30 : 20; } } } if (action instanceof SfcActionCase) { delta -= 5; } return baseOrder + delta; } }
SingleClassifierRule { @VisibleForTesting static int updateOrderBasedOn(ClassifierInstance ci, ActionChoice action, Integer baseOrder) { int delta = 0; if (ci.getClassifierDefinitionId().equals(EtherTypeClassifierDefinition.ID)) { delta = 350; } else if (ci.getClassifierDefinitionId().equals(IpProtoClassifierDefinition.ID)) { delta = 300; } else if (ci.getClassifierDefinitionId().equals(L4ClassifierDefinition.ID)) { delta = 200; List<ParameterValue> parameterValue = ci.getParameterValue(); for (ParameterValue pv : parameterValue) { if (isSrcOrDstPortParam(pv)) { delta -= 30; } else if (isRangePortParam(pv)) { delta -= pv.getRangeValue().getMin().equals(pv.getRangeValue().getMax()) ? 30 : 20; } } } if (action instanceof SfcActionCase) { delta -= 5; } return baseOrder + delta; } SingleClassifierRule(SecurityRule secRule, int ruleBaseOrder, ActionChoice action); }
SingleClassifierRule { @VisibleForTesting static int updateOrderBasedOn(ClassifierInstance ci, ActionChoice action, Integer baseOrder) { int delta = 0; if (ci.getClassifierDefinitionId().equals(EtherTypeClassifierDefinition.ID)) { delta = 350; } else if (ci.getClassifierDefinitionId().equals(IpProtoClassifierDefinition.ID)) { delta = 300; } else if (ci.getClassifierDefinitionId().equals(L4ClassifierDefinition.ID)) { delta = 200; List<ParameterValue> parameterValue = ci.getParameterValue(); for (ParameterValue pv : parameterValue) { if (isSrcOrDstPortParam(pv)) { delta -= 30; } else if (isRangePortParam(pv)) { delta -= pv.getRangeValue().getMin().equals(pv.getRangeValue().getMax()) ? 30 : 20; } } } if (action instanceof SfcActionCase) { delta -= 5; } return baseOrder + delta; } SingleClassifierRule(SecurityRule secRule, int ruleBaseOrder, ActionChoice action); ClassifierInstance getClassifierInstance(); ClassifierRef getClassifierRef(); Rule getRule(); }
SingleClassifierRule { @VisibleForTesting static int updateOrderBasedOn(ClassifierInstance ci, ActionChoice action, Integer baseOrder) { int delta = 0; if (ci.getClassifierDefinitionId().equals(EtherTypeClassifierDefinition.ID)) { delta = 350; } else if (ci.getClassifierDefinitionId().equals(IpProtoClassifierDefinition.ID)) { delta = 300; } else if (ci.getClassifierDefinitionId().equals(L4ClassifierDefinition.ID)) { delta = 200; List<ParameterValue> parameterValue = ci.getParameterValue(); for (ParameterValue pv : parameterValue) { if (isSrcOrDstPortParam(pv)) { delta -= 30; } else if (isRangePortParam(pv)) { delta -= pv.getRangeValue().getMin().equals(pv.getRangeValue().getMax()) ? 30 : 20; } } } if (action instanceof SfcActionCase) { delta -= 5; } return baseOrder + delta; } SingleClassifierRule(SecurityRule secRule, int ruleBaseOrder, ActionChoice action); ClassifierInstance getClassifierInstance(); ClassifierRef getClassifierRef(); Rule getRule();  }