@Test public void shouldReturnUnavailableWhenStoreNotAvailable() throws Exception { final GetGenesis handler = new GetGenesis(chainDataProvider, jsonProvider); when(chainDataProvider.isStoreAvailable()).thenReturn(false); handler.handle(context); verifyStatusCode(SC_NOT_FOUND); }
@OpenApi( path = ROUTE, method = HttpMethod.GET, summary = "Get chain genesis details", tags = {TAG_V1_BEACON, TAG_VALIDATOR_REQUIRED}, description = "Retrieve details of the chain's genesis which can be used to identify chain.", responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = GetGenesisResponse.class)), @OpenApiResponse( status = RES_NOT_FOUND, description = "Chain genesis info is not yet known"), @OpenApiResponse(status = RES_INTERNAL_ERROR), }) @Override public void handle(@NotNull final Context ctx) throws Exception { final Optional<GenesisData> maybeData = getGenesisData(); if (maybeData.isEmpty()) { ctx.status(SC_NOT_FOUND); return; } ctx.result(jsonProvider.objectToJSON(new GetGenesisResponse(maybeData.get()))); }
GetGenesis extends AbstractHandler implements Handler { @OpenApi( path = ROUTE, method = HttpMethod.GET, summary = "Get chain genesis details", tags = {TAG_V1_BEACON, TAG_VALIDATOR_REQUIRED}, description = "Retrieve details of the chain's genesis which can be used to identify chain.", responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = GetGenesisResponse.class)), @OpenApiResponse( status = RES_NOT_FOUND, description = "Chain genesis info is not yet known"), @OpenApiResponse(status = RES_INTERNAL_ERROR), }) @Override public void handle(@NotNull final Context ctx) throws Exception { final Optional<GenesisData> maybeData = getGenesisData(); if (maybeData.isEmpty()) { ctx.status(SC_NOT_FOUND); return; } ctx.result(jsonProvider.objectToJSON(new GetGenesisResponse(maybeData.get()))); } }
GetGenesis extends AbstractHandler implements Handler { @OpenApi( path = ROUTE, method = HttpMethod.GET, summary = "Get chain genesis details", tags = {TAG_V1_BEACON, TAG_VALIDATOR_REQUIRED}, description = "Retrieve details of the chain's genesis which can be used to identify chain.", responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = GetGenesisResponse.class)), @OpenApiResponse( status = RES_NOT_FOUND, description = "Chain genesis info is not yet known"), @OpenApiResponse(status = RES_INTERNAL_ERROR), }) @Override public void handle(@NotNull final Context ctx) throws Exception { final Optional<GenesisData> maybeData = getGenesisData(); if (maybeData.isEmpty()) { ctx.status(SC_NOT_FOUND); return; } ctx.result(jsonProvider.objectToJSON(new GetGenesisResponse(maybeData.get()))); } GetGenesis(final DataProvider dataProvider, final JsonProvider jsonProvider);   GetGenesis(final ChainDataProvider chainDataProvider, final JsonProvider jsonProvider); }
GetGenesis extends AbstractHandler implements Handler { @OpenApi( path = ROUTE, method = HttpMethod.GET, summary = "Get chain genesis details", tags = {TAG_V1_BEACON, TAG_VALIDATOR_REQUIRED}, description = "Retrieve details of the chain's genesis which can be used to identify chain.", responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = GetGenesisResponse.class)), @OpenApiResponse( status = RES_NOT_FOUND, description = "Chain genesis info is not yet known"), @OpenApiResponse(status = RES_INTERNAL_ERROR), }) @Override public void handle(@NotNull final Context ctx) throws Exception { final Optional<GenesisData> maybeData = getGenesisData(); if (maybeData.isEmpty()) { ctx.status(SC_NOT_FOUND); return; } ctx.result(jsonProvider.objectToJSON(new GetGenesisResponse(maybeData.get()))); } GetGenesis(final DataProvider dataProvider, final JsonProvider jsonProvider);   GetGenesis(final ChainDataProvider chainDataProvider, final JsonProvider jsonProvider); @OpenApi( path = ROUTE, method = HttpMethod.GET, summary = "Get chain genesis details", tags = {TAG_V1_BEACON, TAG_VALIDATOR_REQUIRED}, description = "Retrieve details of the chain's genesis which can be used to identify chain.", responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = GetGenesisResponse.class)), @OpenApiResponse( status = RES_NOT_FOUND, description = "Chain genesis info is not yet known"), @OpenApiResponse(status = RES_INTERNAL_ERROR), }) @Override void handle(@NotNull final Context ctx); }
GetGenesis extends AbstractHandler implements Handler { @OpenApi( path = ROUTE, method = HttpMethod.GET, summary = "Get chain genesis details", tags = {TAG_V1_BEACON, TAG_VALIDATOR_REQUIRED}, description = "Retrieve details of the chain's genesis which can be used to identify chain.", responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = GetGenesisResponse.class)), @OpenApiResponse( status = RES_NOT_FOUND, description = "Chain genesis info is not yet known"), @OpenApiResponse(status = RES_INTERNAL_ERROR), }) @Override public void handle(@NotNull final Context ctx) throws Exception { final Optional<GenesisData> maybeData = getGenesisData(); if (maybeData.isEmpty()) { ctx.status(SC_NOT_FOUND); return; } ctx.result(jsonProvider.objectToJSON(new GetGenesisResponse(maybeData.get()))); } GetGenesis(final DataProvider dataProvider, final JsonProvider jsonProvider);   GetGenesis(final ChainDataProvider chainDataProvider, final JsonProvider jsonProvider); @OpenApi( path = ROUTE, method = HttpMethod.GET, summary = "Get chain genesis details", tags = {TAG_V1_BEACON, TAG_VALIDATOR_REQUIRED}, description = "Retrieve details of the chain's genesis which can be used to identify chain.", responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = GetGenesisResponse.class)), @OpenApiResponse( status = RES_NOT_FOUND, description = "Chain genesis info is not yet known"), @OpenApiResponse(status = RES_INTERNAL_ERROR), }) @Override void handle(@NotNull final Context ctx); static final String ROUTE; }