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);
}
Aggregations