### Question:
EtherTypeClassifier extends Classifier { @Override protected List<MatchBuilder> update(List<MatchBuilder> matches, Map<String, ParameterValue> params) { Long type = params.get(EtherTypeClassifierDefinition.ETHERTYPE_PARAM).getIntValue(); for (MatchBuilder match : matches) { EthernetMatchBuilder em; if (match.getEthernetMatch() != null) { equalOrNotSetValidation(match.getEthernetMatch().getEthernetType(), type); continue; } else { em = new EthernetMatchBuilder(); } em.setEthernetType(new EthernetTypeBuilder().setType(new EtherType(type)).build()); match.setEthernetMatch(em.build()); } return matches; } protected  EtherTypeClassifier(Classifier parent); @Override ClassifierDefinitionId getId(); @Override ClassifierDefinition getClassifierDefinition(); @Override List<SupportedParameterValues> getSupportedParameterValues();  }### Answer:
@Test public void testUpdate() { List<MatchBuilder> matches = new ArrayList<>(); Map<String, ParameterValue> params = new HashMap<>(); matches.add( new MatchBuilder().setIpMatch(ClassifierTestUtils.createIpMatch(ClassifierTestUtils.TCP.shortValue()))); params.putAll( ClassifierTestUtils.createIntValueParam(EtherTypeClassifierDefinition.ETHERTYPE_PARAM, FlowUtils.IPv4)); List<MatchBuilder> updated = Classifier.ETHER_TYPE_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(EtherTypeClassifierDefinition.ETHERTYPE_PARAM, FlowUtils.IPv6)); List<MatchBuilder> updated = Classifier.ETHER_TYPE_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(EtherTypeClassifierDefinition.ETHERTYPE_PARAM, FlowUtils.IPv6)); thrown.expect(IllegalArgumentException.class); thrown.expectMessage(Classifier.MSG_CLASSIFICATION_CONFLICT_DETECTED); Classifier.ETHER_TYPE_CL.update(matches, params); }