### Question:
QueryRestController { @GetMapping("components/{component}/queries") public Iterable<Query> getByComponent(@PathVariable("component") String component, @RequestParam("context") String context){ return new ComponentItems<>(component, context, new DefaultQueries(registrationCache)); } QueryRestController(QueryRegistrationCache registrationCache,
                               QueryDispatcher queryDispatcher); @GetMapping("components/{component}/queries") Iterable<Query> getByComponent(@PathVariable("component") String component, @RequestParam("context") String context); @GetMapping("queries") List<JsonQueryMapping> get(); @PostMapping("queries/run") @ApiImplicitParams({ @ApiImplicitParam(name = TOKEN_PARAM, value = "Access Token", required = false, dataType = "string", paramType = "header") }) SseEmitter execute(
            @RequestHeader(value = CONTEXT_PARAM, defaultValue = Topology.DEFAULT_CONTEXT, required = false) String context,
            @RequestBody @Valid QueryRequestJson query);  }### Answer:
@Test public void getByComponent(){ Iterator<Query> iterator = testSubject.getByComponent("Component", Topology.DEFAULT_CONTEXT).iterator(); assertTrue(iterator.hasNext()); GsonMedia media = new GsonMedia(); iterator.next().printOn(media); assertEquals("{\"name\":\"Request\",\"responseTypes\":[\"Response\"]}", media.toString()); assertFalse(iterator.hasNext()); }
@Test public void getByNotExistingComponent(){ Iterator iterator = testSubject.getByComponent("otherComponent", Topology.DEFAULT_CONTEXT).iterator(); assertFalse(iterator.hasNext()); }
@Test public void getByNotExistingContext(){ Iterator iterator = testSubject.getByComponent("Component", "Dummy").iterator(); assertFalse(iterator.hasNext()); }