### Question:
GroundingMatch extends AbstractMatcher<EventGrounding, EventGrounding> { @Override public boolean match(EventGrounding offer, EventGrounding requirement, List<MatchingResultMessage> errorLog) { return MatchingUtils.nullCheckRightNullDisallowed(offer, requirement) || (matchProtocols(offer.getTransportProtocols(), requirement.getTransportProtocols(), errorLog) && matchFormats(offer.getTransportFormats(), requirement.getTransportFormats(), errorLog)); } GroundingMatch(); @Override boolean match(EventGrounding offer, EventGrounding requirement, List<MatchingResultMessage> errorLog);  }### Answer:
@Test public void testPositiveGroundingMatch() { TransportProtocol offerProtocol = TestUtils.kafkaProtocol(); TransportProtocol requirementProtocol = TestUtils.kafkaProtocol(); TransportFormat offerFormat = TestUtils.jsonFormat(); TransportFormat requirementFormat = TestUtils.jsonFormat(); EventGrounding offeredGrounding = new EventGrounding(offerProtocol, offerFormat); EventGrounding requiredGrounding = new EventGrounding(requirementProtocol, requirementFormat); List<MatchingResultMessage> errorLog = new ArrayList<>(); boolean matches = new GroundingMatch().match(offeredGrounding, requiredGrounding, errorLog); assertTrue(matches); }
@Test public void testNegativeGroundingMatchProtocol() { TransportProtocol offerProtocol = TestUtils.kafkaProtocol(); TransportProtocol requirementProtocol = TestUtils.jmsProtocol(); TransportFormat offerFormat = TestUtils.jsonFormat(); TransportFormat requirementFormat = TestUtils.jsonFormat(); EventGrounding offeredGrounding = new EventGrounding(offerProtocol, offerFormat); EventGrounding requiredGrounding = new EventGrounding(requirementProtocol, requirementFormat); List<MatchingResultMessage> errorLog = new ArrayList<>(); boolean matches = new GroundingMatch().match(offeredGrounding, requiredGrounding, errorLog); assertFalse(matches); }
@Test public void testNegativeGroundingMatchFormat() { TransportProtocol offerProtocol = TestUtils.kafkaProtocol(); TransportProtocol requirementProtocol = TestUtils.kafkaProtocol(); TransportFormat offerFormat = TestUtils.jsonFormat(); TransportFormat requirementFormat = TestUtils.thriftFormat(); EventGrounding offeredGrounding = new EventGrounding(offerProtocol, offerFormat); EventGrounding requiredGrounding = new EventGrounding(requirementProtocol, requirementFormat); List<MatchingResultMessage> errorLog = new ArrayList<>(); boolean matches = new GroundingMatch().match(offeredGrounding, requiredGrounding, errorLog); assertFalse(matches); }
@Test public void testNegativeGroundingMatchBoth() { TransportProtocol offerProtocol = TestUtils.kafkaProtocol(); TransportProtocol requirementProtocol = TestUtils.jmsProtocol(); TransportFormat offerFormat = TestUtils.jsonFormat(); TransportFormat requirementFormat = TestUtils.thriftFormat(); EventGrounding offeredGrounding = new EventGrounding(offerProtocol, offerFormat); EventGrounding requiredGrounding = new EventGrounding(requirementProtocol, requirementFormat); List<MatchingResultMessage> errorLog = new ArrayList<>(); boolean matches = new GroundingMatch().match(offeredGrounding, requiredGrounding, errorLog); assertFalse(matches); }