### Question:
IpProtoClassifier extends Classifier { @Override protected List<MatchBuilder> update(List<MatchBuilder> matches, Map<String, ParameterValue> params) { Long proto = params.get(IpProtoClassifierDefinition.PROTO_PARAM).getIntValue(); for (MatchBuilder match : matches) { IpMatchBuilder imb; if (match.getIpMatch() != null) { equalOrNotSetValidation(match.getIpMatch().getIpProtocol(), proto); continue; } else { imb = new IpMatchBuilder(); } imb.setIpProtocol(proto.shortValue()); match.setIpMatch(imb.build()); } return matches; } protected  IpProtoClassifier(Classifier parent); @Override ClassifierDefinitionId getId(); @Override ClassifierDefinition getClassifierDefinition(); @Override List<SupportedParameterValues> getSupportedParameterValues(); static Long getIpProtoValue(Map<String, ParameterValue> params);  }### Answer:
@Test public void testUpdate() { List<MatchBuilder> matches = new ArrayList<>(); Map<String, ParameterValue> params = new HashMap<>(); matches.add(new MatchBuilder() .setEthernetMatch(ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE))); params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM, ClassifierTestUtils.TCP)); List<MatchBuilder> updated = Classifier.IP_PROTO_CL.update(matches, params); assertEquals(1, updated.size()); MatchBuilder first = updated.get(0); assertEquals(ClassifierTestUtils.IPV4_ETH_TYPE, first.getEthernetMatch().getEthernetType()); assertSame(ClassifierTestUtils.TCP, first.getIpMatch().getIpProtocol().longValue()); }
@Test public void testUpdate_overrideBySameValue() { List<MatchBuilder> matches = new ArrayList<>(); Map<String, ParameterValue> params = new HashMap<>(); matches.add(new MatchBuilder() .setEthernetMatch(ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV6_ETH_TYPE)) .setIpMatch(ClassifierTestUtils.createIpMatch(ClassifierTestUtils.UDP.shortValue()))); params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM, ClassifierTestUtils.UDP)); List<MatchBuilder> updated = Classifier.IP_PROTO_CL.update(matches, params); assertEquals(1, updated.size()); MatchBuilder first = updated.get(0); assertEquals(ClassifierTestUtils.IPV6_ETH_TYPE, first.getEthernetMatch().getEthernetType()); assertSame(ClassifierTestUtils.UDP, first.getIpMatch().getIpProtocol().longValue()); }
@Test public void testUpdate_overrideByDifferentValue() { List<MatchBuilder> matches = new ArrayList<>(); Map<String, ParameterValue> params = new HashMap<>(); matches.add(new MatchBuilder() .setEthernetMatch(ClassifierTestUtils.createEthernetMatch(ClassifierTestUtils.IPV4_ETH_TYPE)) .setIpMatch(ClassifierTestUtils.createIpMatch(ClassifierTestUtils.SCTP.shortValue()))); params.putAll(ClassifierTestUtils.createIntValueParam(IpProtoClassifierDefinition.PROTO_PARAM, ClassifierTestUtils.TCP)); thrown.expect(IllegalArgumentException.class); thrown.expectMessage(Classifier.MSG_CLASSIFICATION_CONFLICT_DETECTED); Classifier.IP_PROTO_CL.update(matches, params); }