Reactivate test that wasn't executing at all due to logical error.
Refactored to use execution context
@@ -3,7 +3,6 @@ package com.quorum.tessera.test.rest;
import com.quorum.tessera.api.model.ReceiveResponse;
import com.quorum.tessera.api.model.SendResponse;
import com.quorum.tessera.test.Party;
-import com.quorum.tessera.test.RestPartyHelper;
import org.junit.Test;
import javax.ws.rs.client.Client;
@@ -12,13 +11,15 @@ import javax.ws.rs.core.Response;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
-import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.quorum.tessera.test.PartyHelper;
+import com.quorum.tessera.test.RestPartyHelper;
+import java.util.Arrays;
+
/**
* This tests that a node that hosts multiple sets of keys can send/receive
@@ -27,67 +28,66 @@ import com.quorum.tessera.test.PartyHelper;
@RunWith(Parameterized.class)
public class MultipleKeyNodeIT {
-
-
- private static PartyHelper partyHelper = new RestPartyHelper();
+ private PartyHelper partyHelper = new RestPartyHelper();
private final Client client = ClientBuilder.newClient();
- private final Party recipient;
+ private final String recipientAlias;
private String txHash;
private RestUtils restUtils = new RestUtils();
- public MultipleKeyNodeIT(Party recipient) {
- this.recipient = recipient;
+ public MultipleKeyNodeIT(String recipientAlias) {
+ this.recipientAlias = recipientAlias;
}
-
@Before
public void onSetUp() {
Party sender = partyHelper.findByAlias("A");
+ Party recipient = partyHelper.findByAlias(recipientAlias);
byte[] transactionData = restUtils.createTransactionData();
final SendResponse result = restUtils.sendRequestAssertSuccess(sender, transactionData, recipient);
assertThat(result.getKey()).isNotBlank();
this.txHash = result.getKey();
-
}
+
+
@Test
public void thenTransactionHasBeenPersistedOnOtherNode() throws UnsupportedEncodingException {
final byte[] transactionData = RestUtils.generateTransactionData();
- Party sender = partyHelper.findByAlias("A");
-
+ Party recipient = partyHelper.findByAlias(recipientAlias);
//retrieve the transaction
- final Response retrieveResponse = this.client.target(sender.getPublicKey())
+ final Response retrieveResponse = this.client.target(recipient.getQ2TUri())
.path("transaction")
.path(URLEncoder.encode(txHash, "UTF-8"))
- .request().get();
+ .queryParam("to", recipient.getPublicKey())
+ .request()
+ .get();
assertThat(retrieveResponse).isNotNull();
- assertThat(retrieveResponse.getStatus()).isEqualTo(200);
+ assertThat(retrieveResponse.getStatus())
+ .describedAs(txHash + " should be present on other node")
+ .isEqualTo(200);
final ReceiveResponse result = retrieveResponse.readEntity(ReceiveResponse.class);
+ //TODO: Verify payload
+ assertThat(result).isNotNull();
- assertThat(result.getPayload()).isEqualTo(transactionData);
}
@Parameterized.Parameters
- public static List<Party> recipients() {
- return partyHelper.getParties()
- .filter(p -> p.getAlias().equals("D"))
- .filter(p -> p.getAlias().equals("C")).collect(Collectors.toList());
- }
-
-
+ public static List<String> recipients() {
+ return Arrays.asList("C","D");
+ }
}
