Search in sources :

Example 41 with SendResponse

use of com.quorum.tessera.api.SendResponse in project tessera by ConsenSys.

the class DeleteIT method deleteTransactionThatExists.

@Test
public void deleteTransactionThatExists() throws Exception {
    // setup (sending in a tx)
    Party sender = partyHelper.getParties().findAny().get();
    Party recipient = partyHelper.getParties().filter(p -> !p.getPublicKey().equals(sender.getPublicKey())).findAny().get();
    RestUtils utils = new RestUtils();
    byte[] txnData = utils.createTransactionData();
    Response response = utils.send(sender, txnData, Collections.singleton(recipient));
    assertThat(response.getStatus()).isEqualTo(201);
    final SendResponse sendResponse = response.readEntity(SendResponse.class);
    final String encodedHash = URLEncoder.encode(sendResponse.getKey(), UTF_8.toString());
    try (PreparedStatement statement = sender.getDatabaseConnection().prepareStatement(COUNT_ALL)) {
        statement.setBytes(1, Base64.getDecoder().decode(sendResponse.getKey()));
        try (ResultSet rs = statement.executeQuery()) {
            assertThat(rs.next()).isTrue();
            assertThat(rs.getLong(1)).isEqualTo(1);
        }
    }
    // delete it
    final Response resp = sender.getRestClientWebTarget().path("transaction").path(encodedHash).request().delete();
    // validate result
    assertThat(resp).isNotNull();
    assertThat(resp.getStatus()).isEqualTo(204);
}
Also used : Response(jakarta.ws.rs.core.Response) SendResponse(com.quorum.tessera.api.SendResponse) SendResponse(com.quorum.tessera.api.SendResponse) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) Test(org.junit.Test)

Aggregations

SendResponse (com.quorum.tessera.api.SendResponse)41 Response (jakarta.ws.rs.core.Response)38 SendRequest (com.quorum.tessera.api.SendRequest)32 Test (org.junit.Test)29 Party (com.quorum.tessera.test.Party)20 ReceiveResponse (com.quorum.tessera.api.ReceiveResponse)19 MessageHash (com.quorum.tessera.data.MessageHash)16 PublicKey (com.quorum.tessera.encryption.PublicKey)16 URI (java.net.URI)15 ReceiveResponse (com.quorum.tessera.transaction.ReceiveResponse)10 SendSignedRequest (com.quorum.tessera.api.SendSignedRequest)9 PrivacyGroup (com.quorum.tessera.enclave.PrivacyGroup)6 PrivacyMode (com.quorum.tessera.enclave.PrivacyMode)4 PartyHelper (com.quorum.tessera.test.PartyHelper)4 URLEncoder (java.net.URLEncoder)4 StandardCharsets (java.nio.charset.StandardCharsets)4 Stream (java.util.stream.Stream)4 RestUtils (com.quorum.tessera.test.rest.RestUtils)3 MIME_TYPE_JSON_2_1 (com.quorum.tessera.version.MultiTenancyVersion.MIME_TYPE_JSON_2_1)3 Operation (io.swagger.v3.oas.annotations.Operation)3