### Question:
SchemaMatch extends AbstractMatcher<EventSchema, EventSchema> { @Override public boolean match(EventSchema offer, EventSchema requirement, List<MatchingResultMessage> errorLog) { boolean matches = MatchingUtils.nullCheck(offer, requirement) || requirement.getEventProperties() .stream() .allMatch(req -> offer .getEventProperties() .stream() .anyMatch(of -> new PropertyMatch().match(of, req, errorLog))); return matches; } SchemaMatch(); @Override boolean match(EventSchema offer, EventSchema requirement, List<MatchingResultMessage> errorLog);  }### Answer:
@Test public void testPositiveSchemaMatch() { EventPropertyPrimitive offer1 = EpProperties.integerEp(Labels.empty(), "timestamp", Geo.lat); EventPropertyPrimitive offer2 = EpProperties.integerEp(Labels.empty(), "timestamp", Geo.lng); EventPropertyPrimitive requirement1 = EpRequirements.integerReq(); EventPropertyPrimitive requirement2 = EpRequirements.integerReq(); EventSchema offeredSchema = new EventSchema(Arrays.asList(offer1, offer2)); EventSchema requiredSchema = new EventSchema(Arrays.asList(requirement1, requirement2)); List<MatchingResultMessage> errorLog = new ArrayList<>(); boolean matches = new SchemaMatch().match(offeredSchema, requiredSchema, errorLog); assertTrue(matches); }
@Test public void testNegativeSchemaMatch() { EventPropertyPrimitive offer1 = EpProperties.integerEp(Labels.empty(), "timestamp", Geo.lat); EventPropertyPrimitive offer2 = EpProperties.integerEp(Labels.empty(), "timestamp", Geo.lng); EventPropertyPrimitive requirement1 = EpRequirements.integerReq(); EventPropertyPrimitive requirement2 = EpRequirements.stringReq(); EventSchema offeredSchema = new EventSchema(Arrays.asList(offer1, offer2)); EventSchema requiredSchema = new EventSchema(Arrays.asList(requirement1, requirement2)); List<MatchingResultMessage> errorLog = new ArrayList<>(); boolean matches = new SchemaMatch().match(offeredSchema, requiredSchema, errorLog); assertFalse(matches); }
@Test public void testNegativeSchemaMatchDomain() { EventPropertyPrimitive offer1 = EpProperties.integerEp(Labels.empty(), "timestamp", Geo.lat); EventPropertyPrimitive offer2 = EpProperties.integerEp(Labels.empty(), "timestamp", Geo.lng); EventPropertyPrimitive requirement1 = EpRequirements.domainPropertyReq(Geo.lat); EventPropertyPrimitive requirement2 = EpRequirements.stringReq(); EventSchema offeredSchema = new EventSchema(Arrays.asList(offer1, offer2)); EventSchema requiredSchema = new EventSchema(Arrays.asList(requirement1, requirement2)); List<MatchingResultMessage> errorLog = new ArrayList<>(); boolean matches = new SchemaMatch().match(offeredSchema, requiredSchema, errorLog); assertFalse(matches); }
@Test public void testPositiveSchemaMatchDomain() { EventPropertyPrimitive offer1 = EpProperties.integerEp(Labels.empty(), "timestamp", Geo.lat); EventPropertyPrimitive offer2 = EpProperties.integerEp(Labels.empty(), "timestamp", Geo.lng); EventPropertyPrimitive requirement1 = EpRequirements.domainPropertyReq(Geo.lat); EventPropertyPrimitive requirement2 = EpRequirements.integerReq(); EventSchema offeredSchema = new EventSchema(Arrays.asList(offer1, offer2)); EventSchema requiredSchema = new EventSchema(Arrays.asList(requirement1, requirement2)); List<MatchingResultMessage> errorLog = new ArrayList<>(); boolean matches = new SchemaMatch().match(offeredSchema, requiredSchema, errorLog); assertTrue(matches); }