@Test public void resend() { ResendRequest resendRequest = new ResendRequest(); resendRequest.setType(ResendRequestType.ALL); resendRequest.setPublicKey(Base64.getEncoder().encodeToString("JUNIT".getBytes())); EncodedPayload payload = mock(EncodedPayload.class); com.quorum.tessera.transaction.ResendResponse resendResponse = mock(com.quorum.tessera.transaction.ResendResponse.class); when(resendResponse.getPayload()).thenReturn(payload); when(transactionManager.resend(any(com.quorum.tessera.transaction.ResendRequest.class))) .thenReturn(resendResponse); when(payloadEncoder.encode(payload)).thenReturn("SUCCESS".getBytes()); Response result = transactionResource.resend(resendRequest); assertThat(result.getStatus()).isEqualTo(200); assertThat(result.getEntity()).isEqualTo("SUCCESS".getBytes()); verify(transactionManager).resend(any(com.quorum.tessera.transaction.ResendRequest.class)); verify(payloadEncoder).encode(payload); }
@ApiOperation("Resend transactions for given key or message hash/recipient") @ApiResponses({ @ApiResponse(code = 200, message = "Encoded payload when TYPE is INDIVIDUAL", response = String.class), @ApiResponse(code = 500, message = "General error") }) @POST @Path("resend") @Consumes(APPLICATION_JSON) @Produces(TEXT_PLAIN) public Response resend( @ApiParam(name = "resendRequest", required = true) @Valid @NotNull final ResendRequest resendRequest) { LOGGER.debug("Received resend request"); PublicKey recipient = Optional.of(resendRequest) .map(ResendRequest::getPublicKey) .map(Base64Codec.create()::decode) .map(PublicKey::from) .get(); MessageHash transactionHash = Optional.ofNullable(resendRequest) .map(ResendRequest::getKey) .map(Base64.getDecoder()::decode) .map(MessageHash::new) .orElse(null); com.quorum.tessera.transaction.ResendRequest request = com.quorum.tessera.transaction.ResendRequest.Builder.create() .withType( com.quorum.tessera.transaction.ResendRequest.ResendRequestType.valueOf( resendRequest.getType().name())) .withRecipient(recipient) .withHash(transactionHash) .build(); com.quorum.tessera.transaction.ResendResponse response = transactionManager.resend(request); Response.ResponseBuilder builder = Response.status(Status.OK); Optional.ofNullable(response.getPayload()).map(encoder::encode).ifPresent(builder::entity); return builder.build(); }
TransactionResource { @ApiOperation("Resend transactions for given key or message hash/recipient") @ApiResponses({ @ApiResponse(code = 200, message = "Encoded payload when TYPE is INDIVIDUAL", response = String.class), @ApiResponse(code = 500, message = "General error") }) @POST @Path("resend") @Consumes(APPLICATION_JSON) @Produces(TEXT_PLAIN) public Response resend( @ApiParam(name = "resendRequest", required = true) @Valid @NotNull final ResendRequest resendRequest) { LOGGER.debug("Received resend request"); PublicKey recipient = Optional.of(resendRequest) .map(ResendRequest::getPublicKey) .map(Base64Codec.create()::decode) .map(PublicKey::from) .get(); MessageHash transactionHash = Optional.ofNullable(resendRequest) .map(ResendRequest::getKey) .map(Base64.getDecoder()::decode) .map(MessageHash::new) .orElse(null); com.quorum.tessera.transaction.ResendRequest request = com.quorum.tessera.transaction.ResendRequest.Builder.create() .withType( com.quorum.tessera.transaction.ResendRequest.ResendRequestType.valueOf( resendRequest.getType().name())) .withRecipient(recipient) .withHash(transactionHash) .build(); com.quorum.tessera.transaction.ResendResponse response = transactionManager.resend(request); Response.ResponseBuilder builder = Response.status(Status.OK); Optional.ofNullable(response.getPayload()).map(encoder::encode).ifPresent(builder::entity); return builder.build(); } }
TransactionResource { @ApiOperation("Resend transactions for given key or message hash/recipient") @ApiResponses({ @ApiResponse(code = 200, message = "Encoded payload when TYPE is INDIVIDUAL", response = String.class), @ApiResponse(code = 500, message = "General error") }) @POST @Path("resend") @Consumes(APPLICATION_JSON) @Produces(TEXT_PLAIN) public Response resend( @ApiParam(name = "resendRequest", required = true) @Valid @NotNull final ResendRequest resendRequest) { LOGGER.debug("Received resend request"); PublicKey recipient = Optional.of(resendRequest) .map(ResendRequest::getPublicKey) .map(Base64Codec.create()::decode) .map(PublicKey::from) .get(); MessageHash transactionHash = Optional.ofNullable(resendRequest) .map(ResendRequest::getKey) .map(Base64.getDecoder()::decode) .map(MessageHash::new) .orElse(null); com.quorum.tessera.transaction.ResendRequest request = com.quorum.tessera.transaction.ResendRequest.Builder.create() .withType( com.quorum.tessera.transaction.ResendRequest.ResendRequestType.valueOf( resendRequest.getType().name())) .withRecipient(recipient) .withHash(transactionHash) .build(); com.quorum.tessera.transaction.ResendResponse response = transactionManager.resend(request); Response.ResponseBuilder builder = Response.status(Status.OK); Optional.ofNullable(response.getPayload()).map(encoder::encode).ifPresent(builder::entity); return builder.build(); } TransactionResource(final TransactionManager delegate, final PayloadEncoder payloadEncoder); }
TransactionResource { @ApiOperation("Resend transactions for given key or message hash/recipient") @ApiResponses({ @ApiResponse(code = 200, message = "Encoded payload when TYPE is INDIVIDUAL", response = String.class), @ApiResponse(code = 500, message = "General error") }) @POST @Path("resend") @Consumes(APPLICATION_JSON) @Produces(TEXT_PLAIN) public Response resend( @ApiParam(name = "resendRequest", required = true) @Valid @NotNull final ResendRequest resendRequest) { LOGGER.debug("Received resend request"); PublicKey recipient = Optional.of(resendRequest) .map(ResendRequest::getPublicKey) .map(Base64Codec.create()::decode) .map(PublicKey::from) .get(); MessageHash transactionHash = Optional.ofNullable(resendRequest) .map(ResendRequest::getKey) .map(Base64.getDecoder()::decode) .map(MessageHash::new) .orElse(null); com.quorum.tessera.transaction.ResendRequest request = com.quorum.tessera.transaction.ResendRequest.Builder.create() .withType( com.quorum.tessera.transaction.ResendRequest.ResendRequestType.valueOf( resendRequest.getType().name())) .withRecipient(recipient) .withHash(transactionHash) .build(); com.quorum.tessera.transaction.ResendResponse response = transactionManager.resend(request); Response.ResponseBuilder builder = Response.status(Status.OK); Optional.ofNullable(response.getPayload()).map(encoder::encode).ifPresent(builder::entity); return builder.build(); } TransactionResource(final TransactionManager delegate, final PayloadEncoder payloadEncoder); @ApiOperation("Resend transactions for given key or message hash/recipient") @ApiResponses({ @ApiResponse(code = 200, message = "Encoded payload when TYPE is INDIVIDUAL", response = String.class), @ApiResponse(code = 500, message = "General error") }) @POST @Path("resend") @Consumes(APPLICATION_JSON) @Produces(TEXT_PLAIN) Response resend(
            @ApiParam(name = "resendRequest", required = true) @Valid @NotNull final ResendRequest resendRequest); @ApiOperation(value = "Transmit encrypted payload between P2PRestApp Nodes") @ApiResponses({ @ApiResponse(code = 201, message = "Key created status"), @ApiResponse(code = 500, message = "General error") }) @POST @Path("push") @Consumes(APPLICATION_OCTET_STREAM) Response push(
            @ApiParam(name = "payload", required = true, value = "Key data to be stored.") final byte[] payload); }
TransactionResource { @ApiOperation("Resend transactions for given key or message hash/recipient") @ApiResponses({ @ApiResponse(code = 200, message = "Encoded payload when TYPE is INDIVIDUAL", response = String.class), @ApiResponse(code = 500, message = "General error") }) @POST @Path("resend") @Consumes(APPLICATION_JSON) @Produces(TEXT_PLAIN) public Response resend( @ApiParam(name = "resendRequest", required = true) @Valid @NotNull final ResendRequest resendRequest) { LOGGER.debug("Received resend request"); PublicKey recipient = Optional.of(resendRequest) .map(ResendRequest::getPublicKey) .map(Base64Codec.create()::decode) .map(PublicKey::from) .get(); MessageHash transactionHash = Optional.ofNullable(resendRequest) .map(ResendRequest::getKey) .map(Base64.getDecoder()::decode) .map(MessageHash::new) .orElse(null); com.quorum.tessera.transaction.ResendRequest request = com.quorum.tessera.transaction.ResendRequest.Builder.create() .withType( com.quorum.tessera.transaction.ResendRequest.ResendRequestType.valueOf( resendRequest.getType().name())) .withRecipient(recipient) .withHash(transactionHash) .build(); com.quorum.tessera.transaction.ResendResponse response = transactionManager.resend(request); Response.ResponseBuilder builder = Response.status(Status.OK); Optional.ofNullable(response.getPayload()).map(encoder::encode).ifPresent(builder::entity); return builder.build(); } TransactionResource(final TransactionManager delegate, final PayloadEncoder payloadEncoder); @ApiOperation("Resend transactions for given key or message hash/recipient") @ApiResponses({ @ApiResponse(code = 200, message = "Encoded payload when TYPE is INDIVIDUAL", response = String.class), @ApiResponse(code = 500, message = "General error") }) @POST @Path("resend") @Consumes(APPLICATION_JSON) @Produces(TEXT_PLAIN) Response resend(
            @ApiParam(name = "resendRequest", required = true) @Valid @NotNull final ResendRequest resendRequest); @ApiOperation(value = "Transmit encrypted payload between P2PRestApp Nodes") @ApiResponses({ @ApiResponse(code = 201, message = "Key created status"), @ApiResponse(code = 500, message = "General error") }) @POST @Path("push") @Consumes(APPLICATION_OCTET_STREAM) Response push(
            @ApiParam(name = "payload", required = true, value = "Key data to be stored.") final byte[] payload);  }