@Test public void testUpdateMatch() { Long dstRangeStart = 8079L; Long dstRangeEnd = 8081L; Long singlePort = 80L; params.putAll( ClassifierTestUtils.createIntValueParam(EtherTypeClassifierDefinition.ETHERTYPE_PARAM, FlowUtils.IPv4)); params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM, ClassifierTestUtils.TCP)); params.putAll(ClassifierTestUtils.createIntValueParam(L4ClassifierDefinition.SRC_PORT_PARAM, singlePort)); params.putAll(ClassifierTestUtils.createRangeValueParam(L4ClassifierDefinition.DST_PORT_RANGE_PARAM, dstRangeStart, dstRangeEnd)); ClassificationResult result = Classifier.L4_CL.updateMatch(matches, params); assertEquals(true, result.isSuccessfull()); assertEquals(3, result.getMatchBuilders().size()); Set<Long> dstPorts = new HashSet<>(); for (MatchBuilder match : result.getMatchBuilders()) { assertEquals(ClassifierTestUtils.IPV4_ETH_TYPE, match.getEthernetMatch().getEthernetType()); assertSame(singlePort.intValue(), new TcpMatchBuilder((TcpMatch) match.getLayer4Match()).getTcpSourcePort().getValue()); dstPorts.add(new TcpMatchBuilder((TcpMatch) match.getLayer4Match()).getTcpDestinationPort() .getValue() .longValue()); } for (Long dstPort = dstRangeStart; dstPort <= dstRangeEnd; dstPort++) { assertTrue(dstPorts.contains(dstPort)); } }
public final ClassificationResult updateMatch(List<MatchBuilder> matches, Map<String, ParameterValue> params) { if (params == null) { return new ClassificationResult( "Classifier-instance with classifier-definition-id: " + this.getId() + ". No parameters present."); } List<MatchBuilder> matchBuilders = matches; try { checkPresenceOfRequiredParams(params); matchBuilders = this.update(matchBuilders, params); Classifier parent = this.getParent(); List<Classifier> updatedClassifiers = new ArrayList<>(); updatedClassifiers.add(this); while (parent != null) { boolean hasReqParams = true; try { parent.checkPresenceOfRequiredParams(params); } catch (IllegalArgumentException e) { hasReqParams = false; } if (hasReqParams) { matchBuilders = parent.update(matchBuilders, params); updatedClassifiers.add(parent); } parent = parent.getParent(); } for (Classifier updatedClassifier : updatedClassifiers) { updatedClassifier.checkPrereqs(matchBuilders); } } catch (IllegalArgumentException e) { if (!Strings.isNullOrEmpty(e.getMessage())) { return new ClassificationResult(e.getMessage()); } else return new ClassificationResult("Classifier-instance with classifier-definition-id: " + this.getId() + ". Classification was not successful."); } return new ClassificationResult(matchBuilders); }
Classifier { public final ClassificationResult updateMatch(List<MatchBuilder> matches, Map<String, ParameterValue> params) { if (params == null) { return new ClassificationResult( "Classifier-instance with classifier-definition-id: " + this.getId() + ". No parameters present."); } List<MatchBuilder> matchBuilders = matches; try { checkPresenceOfRequiredParams(params); matchBuilders = this.update(matchBuilders, params); Classifier parent = this.getParent(); List<Classifier> updatedClassifiers = new ArrayList<>(); updatedClassifiers.add(this); while (parent != null) { boolean hasReqParams = true; try { parent.checkPresenceOfRequiredParams(params); } catch (IllegalArgumentException e) { hasReqParams = false; } if (hasReqParams) { matchBuilders = parent.update(matchBuilders, params); updatedClassifiers.add(parent); } parent = parent.getParent(); } for (Classifier updatedClassifier : updatedClassifiers) { updatedClassifier.checkPrereqs(matchBuilders); } } catch (IllegalArgumentException e) { if (!Strings.isNullOrEmpty(e.getMessage())) { return new ClassificationResult(e.getMessage()); } else return new ClassificationResult("Classifier-instance with classifier-definition-id: " + this.getId() + ". Classification was not successful."); } return new ClassificationResult(matchBuilders); } }
Classifier { public final ClassificationResult updateMatch(List<MatchBuilder> matches, Map<String, ParameterValue> params) { if (params == null) { return new ClassificationResult( "Classifier-instance with classifier-definition-id: " + this.getId() + ". No parameters present."); } List<MatchBuilder> matchBuilders = matches; try { checkPresenceOfRequiredParams(params); matchBuilders = this.update(matchBuilders, params); Classifier parent = this.getParent(); List<Classifier> updatedClassifiers = new ArrayList<>(); updatedClassifiers.add(this); while (parent != null) { boolean hasReqParams = true; try { parent.checkPresenceOfRequiredParams(params); } catch (IllegalArgumentException e) { hasReqParams = false; } if (hasReqParams) { matchBuilders = parent.update(matchBuilders, params); updatedClassifiers.add(parent); } parent = parent.getParent(); } for (Classifier updatedClassifier : updatedClassifiers) { updatedClassifier.checkPrereqs(matchBuilders); } } catch (IllegalArgumentException e) { if (!Strings.isNullOrEmpty(e.getMessage())) { return new ClassificationResult(e.getMessage()); } else return new ClassificationResult("Classifier-instance with classifier-definition-id: " + this.getId() + ". Classification was not successful."); } return new ClassificationResult(matchBuilders); } protected  Classifier(Classifier parent); }
Classifier { public final ClassificationResult updateMatch(List<MatchBuilder> matches, Map<String, ParameterValue> params) { if (params == null) { return new ClassificationResult( "Classifier-instance with classifier-definition-id: " + this.getId() + ". No parameters present."); } List<MatchBuilder> matchBuilders = matches; try { checkPresenceOfRequiredParams(params); matchBuilders = this.update(matchBuilders, params); Classifier parent = this.getParent(); List<Classifier> updatedClassifiers = new ArrayList<>(); updatedClassifiers.add(this); while (parent != null) { boolean hasReqParams = true; try { parent.checkPresenceOfRequiredParams(params); } catch (IllegalArgumentException e) { hasReqParams = false; } if (hasReqParams) { matchBuilders = parent.update(matchBuilders, params); updatedClassifiers.add(parent); } parent = parent.getParent(); } for (Classifier updatedClassifier : updatedClassifiers) { updatedClassifier.checkPrereqs(matchBuilders); } } catch (IllegalArgumentException e) { if (!Strings.isNullOrEmpty(e.getMessage())) { return new ClassificationResult(e.getMessage()); } else return new ClassificationResult("Classifier-instance with classifier-definition-id: " + this.getId() + ". Classification was not successful."); } return new ClassificationResult(matchBuilders); } protected  Classifier(Classifier parent); abstract ClassifierDefinitionId getId(); abstract ClassifierDefinition getClassifierDefinition(); final Classifier getParent(); abstract List<SupportedParameterValues> getSupportedParameterValues(); final ClassificationResult updateMatch(List<MatchBuilder> matches, Map<String, ParameterValue> params); }
Classifier { public final ClassificationResult updateMatch(List<MatchBuilder> matches, Map<String, ParameterValue> params) { if (params == null) { return new ClassificationResult( "Classifier-instance with classifier-definition-id: " + this.getId() + ". No parameters present."); } List<MatchBuilder> matchBuilders = matches; try { checkPresenceOfRequiredParams(params); matchBuilders = this.update(matchBuilders, params); Classifier parent = this.getParent(); List<Classifier> updatedClassifiers = new ArrayList<>(); updatedClassifiers.add(this); while (parent != null) { boolean hasReqParams = true; try { parent.checkPresenceOfRequiredParams(params); } catch (IllegalArgumentException e) { hasReqParams = false; } if (hasReqParams) { matchBuilders = parent.update(matchBuilders, params); updatedClassifiers.add(parent); } parent = parent.getParent(); } for (Classifier updatedClassifier : updatedClassifiers) { updatedClassifier.checkPrereqs(matchBuilders); } } catch (IllegalArgumentException e) { if (!Strings.isNullOrEmpty(e.getMessage())) { return new ClassificationResult(e.getMessage()); } else return new ClassificationResult("Classifier-instance with classifier-definition-id: " + this.getId() + ". Classification was not successful."); } return new ClassificationResult(matchBuilders); } protected  Classifier(Classifier parent); abstract ClassifierDefinitionId getId(); abstract ClassifierDefinition getClassifierDefinition(); final Classifier getParent(); abstract List<SupportedParameterValues> getSupportedParameterValues(); final ClassificationResult updateMatch(List<MatchBuilder> matches, Map<String, ParameterValue> params); static final String MSG_CLASSIFICATION_CONFLICT_DETECTED; static final String MSG_NOT_SPECIFIED; static final String MSG_PARAMETER_IS_NOT_PRESENT; static final String MSG_MUTUALLY_EXCLUSIVE; static final String MSG_RANGE_VALUE_MISMATCH; static final String MSG_NOT_SUPPORTED; static final String MSG_IS_MISSING; static final String MSG_NOT_PRESENT; static final EtherTypeClassifier ETHER_TYPE_CL; static final IpProtoClassifier IP_PROTO_CL; static final L4Classifier L4_CL; }