use of io.nem.symbol.sdk.model.transaction.TransactionStatusError in project nem2-sdk-java by nemtech.
the class ListenerBase method toStatus.
private TransactionStatusError toStatus(Object message, String channelParams) {
UnresolvedAddress unresolvedAddress = getUnresolvedAddress(channelParams);
String hash = jsonHelper.getString(message, "hash");
String code = jsonHelper.getString(message, "code");
Deadline deadline = new Deadline(new BigInteger(jsonHelper.getString(message, "deadline")));
return (new TransactionStatusError(unresolvedAddress, hash, code, deadline));
}
use of io.nem.symbol.sdk.model.transaction.TransactionStatusError in project nem2-sdk-java by nemtech.
the class ListenerVertxTest method shouldFilterOutHandleStatus.
@Test
public void shouldFilterOutHandleStatus() throws InterruptedException, ExecutionException, TimeoutException {
Account account1 = Account.generateNewAccount(NETWORK_TYPE);
Account account2 = Account.generateNewAccount(NETWORK_TYPE);
AtomicReference<TransactionStatusError> reference = new AtomicReference<>();
simulateWebSocketStartup();
Assertions.assertNotNull(listener.status(account2.getAddress()).subscribe(reference::set));
Map<String, Object> message = new HashMap<>();
message.put("hash", "1234hash");
message.put("address", account1.getAddress().encoded());
message.put("code", "some error");
message.put("deadline", 5555);
handle(message, "status/" + account1.getAddress().plain());
Assertions.assertNull(reference.get());
Mockito.verify(webSocketMock).handler(Mockito.any());
Mockito.verify(webSocketMock).writeTextMessage(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, "status" + "/" + account2.getAddress().plain())));
}
use of io.nem.symbol.sdk.model.transaction.TransactionStatusError in project nem2-sdk-java by nemtech.
the class ListenerOkHttpTest method shouldFilterOutHandleStatus.
@Test
public void shouldFilterOutHandleStatus() throws InterruptedException, ExecutionException, TimeoutException {
Account account1 = Account.generateNewAccount(networkType);
Account account2 = Account.generateNewAccount(networkType);
AtomicReference<TransactionStatusError> reference = new AtomicReference<>();
simulateWebSocketStartup();
Assertions.assertNotNull(listener.status(account2.getAddress()).subscribe(reference::set));
Map<String, Object> message = new HashMap<>();
message.put("hash", "1234hash");
message.put("address", account1.getAddress().encoded());
message.put("code", "some error");
message.put("deadline", 5555);
handle(message, "status/" + account1.getAddress().plain());
Assertions.assertNull(reference.get());
Mockito.verify(webSocketMock).send(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, "status" + "/" + account2.getAddress().plain())));
}
use of io.nem.symbol.sdk.model.transaction.TransactionStatusError in project nem2-sdk-java by nemtech.
the class ListenerVertxTest method shouldHandleStatus.
@Test
public void shouldHandleStatus() throws InterruptedException, ExecutionException, TimeoutException {
Account account1 = Account.generateNewAccount(NETWORK_TYPE);
AtomicReference<TransactionStatusError> reference = new AtomicReference<>();
simulateWebSocketStartup();
Assertions.assertNotNull(listener.status(account1.getAddress()).subscribe(reference::set));
Map<String, Object> message = new HashMap<>();
message.put("hash", "1234hash");
message.put("address", account1.getAddress().encoded());
message.put("code", "some error");
message.put("deadline", 5555);
handle(message, "status/" + account1.getAddress().plain());
Assertions.assertNotNull(reference.get());
Assertions.assertEquals(message.get("hash"), reference.get().getHash());
Assertions.assertEquals(message.get("code"), reference.get().getStatus());
Assertions.assertEquals(account1.getAddress(), reference.get().getAddress());
Mockito.verify(webSocketMock).handler(Mockito.any());
Mockito.verify(webSocketMock).writeTextMessage(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, "status" + "/" + account1.getAddress().plain())));
}
use of io.nem.symbol.sdk.model.transaction.TransactionStatusError in project nem2-sdk-java by nemtech.
the class ListenerOkHttpTest method shouldHandleStatus.
@Test
public void shouldHandleStatus() throws InterruptedException, ExecutionException, TimeoutException {
Account account1 = Account.generateNewAccount(networkType);
AtomicReference<TransactionStatusError> reference = new AtomicReference<>();
simulateWebSocketStartup();
Assertions.assertNotNull(listener.status(account1.getAddress()).subscribe(reference::set));
Map<String, Object> message = new HashMap<>();
message.put("hash", "1234hash");
message.put("address", account1.getAddress().encoded());
message.put("code", "some error");
message.put("deadline", 5555);
handle(message, "status/" + account1.getAddress().plain());
Assertions.assertNotNull(reference.get());
Assertions.assertEquals(message.get("hash"), reference.get().getHash());
Assertions.assertEquals(message.get("code"), reference.get().getStatus());
Assertions.assertEquals(account1.getAddress(), reference.get().getAddress());
Mockito.verify(webSocketMock).send(jsonHelper.print(new ListenerSubscribeMessage(this.wsId, "status" + "/" + account1.getAddress().plain())));
}
Aggregations