@Test public void shouldReturnExpectedObjectType() throws Exception { GetIdentity handler = new GetIdentity(network, jsonProvider); NodeId nodeid = mock(NodeId.class); when(eth2Network.getMetadata()).thenReturn(MetadataMessage.createDefault()); when(eth2Network.getNodeId()).thenReturn(nodeid); when(nodeid.toBase58()).thenReturn("aeiou"); when(eth2Network.getNodeAddress()).thenReturn("address"); handler.handle(context); verifyCacheStatus(CACHE_NONE); IdentityResponse response = getResponseObject(IdentityResponse.class); assertThat(response.data.peerId).isEqualTo("aeiou"); assertThat(response.data.p2pAddresses.get(0)).isEqualTo("address"); }
@OpenApi( path = ROUTE, method = HttpMethod.GET, summary = "Get node identity", description = "Retrieves data about the node's network presence.", tags = {TAG_V1_NODE}, responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = IdentityResponse.class), description = "The identifying information of the node."), @OpenApiResponse(status = RES_INTERNAL_ERROR) }) @Override public void handle(@NotNull final Context ctx) throws Exception { ctx.header(Header.CACHE_CONTROL, CACHE_NONE); final Identity networkIdentity = new Identity( network.getNodeIdAsBase58(), network.getEnr().orElse(""), network.getListeningAddresses(), network.getDiscoveryAddresses(), network.getMetadata()); ctx.result(jsonProvider.objectToJSON(new IdentityResponse(networkIdentity))); }
GetIdentity implements Handler { @OpenApi( path = ROUTE, method = HttpMethod.GET, summary = "Get node identity", description = "Retrieves data about the node's network presence.", tags = {TAG_V1_NODE}, responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = IdentityResponse.class), description = "The identifying information of the node."), @OpenApiResponse(status = RES_INTERNAL_ERROR) }) @Override public void handle(@NotNull final Context ctx) throws Exception { ctx.header(Header.CACHE_CONTROL, CACHE_NONE); final Identity networkIdentity = new Identity( network.getNodeIdAsBase58(), network.getEnr().orElse(""), network.getListeningAddresses(), network.getDiscoveryAddresses(), network.getMetadata()); ctx.result(jsonProvider.objectToJSON(new IdentityResponse(networkIdentity))); } }
GetIdentity implements Handler { @OpenApi( path = ROUTE, method = HttpMethod.GET, summary = "Get node identity", description = "Retrieves data about the node's network presence.", tags = {TAG_V1_NODE}, responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = IdentityResponse.class), description = "The identifying information of the node."), @OpenApiResponse(status = RES_INTERNAL_ERROR) }) @Override public void handle(@NotNull final Context ctx) throws Exception { ctx.header(Header.CACHE_CONTROL, CACHE_NONE); final Identity networkIdentity = new Identity( network.getNodeIdAsBase58(), network.getEnr().orElse(""), network.getListeningAddresses(), network.getDiscoveryAddresses(), network.getMetadata()); ctx.result(jsonProvider.objectToJSON(new IdentityResponse(networkIdentity))); } GetIdentity(final DataProvider provider, final JsonProvider jsonProvider);   GetIdentity(final NetworkDataProvider provider, final JsonProvider jsonProvider); }
GetIdentity implements Handler { @OpenApi( path = ROUTE, method = HttpMethod.GET, summary = "Get node identity", description = "Retrieves data about the node's network presence.", tags = {TAG_V1_NODE}, responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = IdentityResponse.class), description = "The identifying information of the node."), @OpenApiResponse(status = RES_INTERNAL_ERROR) }) @Override public void handle(@NotNull final Context ctx) throws Exception { ctx.header(Header.CACHE_CONTROL, CACHE_NONE); final Identity networkIdentity = new Identity( network.getNodeIdAsBase58(), network.getEnr().orElse(""), network.getListeningAddresses(), network.getDiscoveryAddresses(), network.getMetadata()); ctx.result(jsonProvider.objectToJSON(new IdentityResponse(networkIdentity))); } GetIdentity(final DataProvider provider, final JsonProvider jsonProvider);   GetIdentity(final NetworkDataProvider provider, final JsonProvider jsonProvider); @OpenApi( path = ROUTE, method = HttpMethod.GET, summary = "Get node identity", description = "Retrieves data about the node's network presence.", tags = {TAG_V1_NODE}, responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = IdentityResponse.class), description = "The identifying information of the node."), @OpenApiResponse(status = RES_INTERNAL_ERROR) }) @Override void handle(@NotNull final Context ctx); }
GetIdentity implements Handler { @OpenApi( path = ROUTE, method = HttpMethod.GET, summary = "Get node identity", description = "Retrieves data about the node's network presence.", tags = {TAG_V1_NODE}, responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = IdentityResponse.class), description = "The identifying information of the node."), @OpenApiResponse(status = RES_INTERNAL_ERROR) }) @Override public void handle(@NotNull final Context ctx) throws Exception { ctx.header(Header.CACHE_CONTROL, CACHE_NONE); final Identity networkIdentity = new Identity( network.getNodeIdAsBase58(), network.getEnr().orElse(""), network.getListeningAddresses(), network.getDiscoveryAddresses(), network.getMetadata()); ctx.result(jsonProvider.objectToJSON(new IdentityResponse(networkIdentity))); } GetIdentity(final DataProvider provider, final JsonProvider jsonProvider);   GetIdentity(final NetworkDataProvider provider, final JsonProvider jsonProvider); @OpenApi( path = ROUTE, method = HttpMethod.GET, summary = "Get node identity", description = "Retrieves data about the node's network presence.", tags = {TAG_V1_NODE}, responses = { @OpenApiResponse( status = RES_OK, content = @OpenApiContent(from = IdentityResponse.class), description = "The identifying information of the node."), @OpenApiResponse(status = RES_INTERNAL_ERROR) }) @Override void handle(@NotNull final Context ctx); static final String ROUTE; }