### Question:
DefaultQuery implements Query { @Override public Boolean belongsToComponent(String component) { return handlers.entrySet().stream().anyMatch( entry -> component.equals(entry.getKey()) && entry.getValue() != null && !entry.getValue().isEmpty() ); } DefaultQuery(QueryDefinition definition,
                        Map<String, Set<QueryHandler<?>>> handlers, Set<String> responseTypes); @Override Boolean belongsToComponent(String component); @Override boolean belongsToContext(String context); @Override void printOn(Media media);  }### Answer:
@Test public void belongsToComponent() { assertTrue(query.belongsToComponent("componentA")); }
@Test public void notBelongsToMissingComponent() { assertFalse(query.belongsToComponent("componentD")); }
@Test public void notBelongsToComponentWithoutHandlers() { assertFalse(query.belongsToComponent("componentB")); assertFalse(query.belongsToComponent("componentC")); }