### Question:
GetHead implements Handler { @OpenApi( path = ROUTE, method = HttpMethod.GET, summary = "Get information about the chain head.", tags = {TAG_BEACON}, description = "Returns information about the head of the beacon chain from the node’s perspective.\n\n" + "To retrieve finalized and justified information, use " + GetChainHead.ROUTE + " instead.", responses = { @OpenApiResponse(status = RES_OK, content = @OpenApiContent(from = BeaconHead.class)), @OpenApiResponse(status = RES_NO_CONTENT, description = NO_CONTENT_PRE_GENESIS), @OpenApiResponse(status = RES_INTERNAL_ERROR) }) @Override public void handle(Context ctx) throws Exception { ctx.header(CACHE_CONTROL, CACHE_NONE); final Optional<BeaconHead> result = provider.getBeaconHead(); if (result.isPresent()) { ctx.result(jsonProvider.objectToJSON(result.get())); } else { ctx.status(SC_NO_CONTENT); } } GetHead(ChainDataProvider provider, JsonProvider jsonProvider); @OpenApi( path = ROUTE, method = HttpMethod.GET, summary = "Get information about the chain head.", tags = {TAG_BEACON}, description = "Returns information about the head of the beacon chain from the node’s perspective.\n\n" + "To retrieve finalized and justified information, use " + GetChainHead.ROUTE + " instead.", responses = { @OpenApiResponse(status = RES_OK, content = @OpenApiContent(from = BeaconHead.class)), @OpenApiResponse(status = RES_NO_CONTENT, description = NO_CONTENT_PRE_GENESIS), @OpenApiResponse(status = RES_INTERNAL_ERROR) }) @Override void handle(Context ctx); static final String ROUTE; }### Answer:
@Test public void shouldReturnBeaconHead() throws Exception { GetHead handler = new GetHead(provider, jsonProvider); Bytes32 blockRoot = Bytes32.random(); BeaconHead head = new BeaconHead(bestSlot, blockRoot, rootState.hash_tree_root()); when(provider.getBeaconHead()).thenReturn(Optional.of(head)); handler.handle(context); verify(context).header(Header.CACHE_CONTROL, CACHE_NONE); verify(context).result(jsonProvider.objectToJSON(head)); }