### Question:
SchemaFilter implements Predicate<Schema> { @Override public boolean test(Schema schema) { return matchesSchemaKey(schema.getKey(), keyQuery) && matchesSpecification(schema.getSpecification(), specQuery); } SchemaFilter(SchemaKeyQuery schemaKeyQuery, SpecificationQuery specificationQuery); @Override boolean test(Schema schema);  }### Answer:
@Test public void filterBySchemaKey() { SchemaKeyQuery schemaKeyQuery = builder().domainRegex(REGEX).nameRegex(REGEX).build(); SchemaFilter schemaFilter = new SchemaFilter(schemaKeyQuery, null); Schema schema = matchingSchema(); assertTrue(schemaFilter.test(schema)); schema = matchingSchema(); schema.getKey().setDomain(FAIL); assertFalse(schemaFilter.test(schema)); schema = matchingSchema(); schema.getKey().setName(FAIL); assertFalse(schemaFilter.test(schema)); }
@Test public void filterBySpecificationQuery() { TagQuery tagQuery = TagQuery.builder().nameRegex(REGEX).valueRegex(REGEX).build(); SpecificationQuery specificationQuery = SpecificationQuery.builder() .typeRegex(REGEX) .descriptionRegex(REGEX) .tags(Collections.singletonList(tagQuery)) .build(); SchemaFilter schemaFilter = new SchemaFilter(null, specificationQuery); Schema schema = matchingSchema(); assertTrue(schemaFilter.test(schema)); schema = matchingSchema(); schema.getSpecification().setType(FAIL); assertFalse(schemaFilter.test(schema)); schema = matchingSchema(); schema.getSpecification().setDescription(FAIL); assertFalse(schemaFilter.test(schema)); schema = matchingSchema(); schema.getSpecification().getTags().get(0).setName(FAIL); assertFalse(schemaFilter.test(schema)); schema = matchingSchema(); schema.getSpecification().getTags().get(0).setValue(FAIL); assertFalse(schemaFilter.test(schema)); schema = matchingSchema(); schema.getSpecification().setType(null); assertFalse(schemaFilter.test(schema)); schema = matchingSchema(); schema.getSpecification().setDescription(null); assertFalse(schemaFilter.test(schema)); schema = matchingSchema(); schema.getSpecification().getTags().get(0).setName(null); assertFalse(schemaFilter.test(schema)); schema = matchingSchema(); schema.getSpecification().getTags().get(0).setValue(null); assertFalse(schemaFilter.test(schema)); schema = matchingSchema(); schema.getSpecification().setTags(null); assertFalse(schemaFilter.test(schema)); }