use of org.assertj.core.api.InstanceOfAssertFactories.list in project today-framework by TAKETODAY.
the class StreamConverterTests method convertFromListToStream.
@Test
@SuppressWarnings("resource")
void convertFromListToStream() throws NoSuchFieldException {
this.conversionService.addConverterFactory(new StringToNumberConverterFactory());
List<String> list = Arrays.asList("1", "2", "3");
TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("streamOfIntegers"));
Object result = this.conversionService.convert(list, streamOfInteger);
assertThat(result).as("Converted object must be a stream").isInstanceOf(Stream.class);
@SuppressWarnings("unchecked") Stream<Integer> content = (Stream<Integer>) result;
assertThat(content.mapToInt(x -> x).sum()).isEqualTo(6);
}
use of org.assertj.core.api.InstanceOfAssertFactories.list in project hedera-mirror-node by hashgraph.
the class TokenMintTransactionSupplierTest method createWithCustomNonFungibleDataMessageSize.
@Test
void createWithCustomNonFungibleDataMessageSize() {
TokenMintTransactionSupplier tokenMintTransactionSupplier = new TokenMintTransactionSupplier();
tokenMintTransactionSupplier.setAmount(2);
tokenMintTransactionSupplier.setMaxTransactionFee(1);
tokenMintTransactionSupplier.setMetadataSize(14);
tokenMintTransactionSupplier.setTokenId(TOKEN_ID.toString());
tokenMintTransactionSupplier.setType(TokenType.NON_FUNGIBLE_UNIQUE);
TokenMintTransaction actual = tokenMintTransactionSupplier.get();
assertThat(actual).returns(0L, TokenMintTransaction::getAmount).returns(ONE_TINYBAR, TokenMintTransaction::getMaxTransactionFee).returns(TOKEN_ID, TokenMintTransaction::getTokenId).extracting(TokenMintTransaction::getMetadata).returns(2, List::size).returns(14, metadataList -> metadataList.get(0).length).returns(14, metadataList -> metadataList.get(1).length);
}
use of org.assertj.core.api.InstanceOfAssertFactories.list in project hedera-mirror-node by hashgraph.
the class CryptoTransferTransactionSupplierTest method createWithCustomAllTransfer.
@Test
void createWithCustomAllTransfer() {
TokenId nftTokenId = TokenId.fromString("0.0.21");
Hbar transferAmount = Hbar.fromTinybars(2);
CryptoTransferTransactionSupplier cryptoTransferTransactionSupplier = new CryptoTransferTransactionSupplier();
cryptoTransferTransactionSupplier.setAmount(2);
cryptoTransferTransactionSupplier.setMaxTransactionFee(1);
cryptoTransferTransactionSupplier.setNftTokenId(nftTokenId.toString());
cryptoTransferTransactionSupplier.setRecipientAccountId(ACCOUNT_ID_2.toString());
cryptoTransferTransactionSupplier.setSenderAccountId(ACCOUNT_ID.toString());
cryptoTransferTransactionSupplier.setSerialNumber(new AtomicLong(10));
cryptoTransferTransactionSupplier.setTokenId(TOKEN_ID.toString());
cryptoTransferTransactionSupplier.setTransferTypes(Set.of(CRYPTO, NFT, TOKEN));
TransferTransaction actual = cryptoTransferTransactionSupplier.get();
assertThat(actual).returns(ONE_TINYBAR, TransferTransaction::getMaxTransactionFee).satisfies(a -> assertThat(a.getHbarTransfers()).containsEntry(ACCOUNT_ID, transferAmount.negated()).containsEntry(ACCOUNT_ID_2, transferAmount)).satisfies(a -> assertThat(a).extracting(TransferTransaction::getTokenNftTransfers, MAP).hasSize(1).extractingByKey(nftTokenId, LIST).extracting("serial", "sender", "receiver").containsExactlyInAnyOrder(tuple(10L, ACCOUNT_ID, ACCOUNT_ID_2), tuple(11L, ACCOUNT_ID, ACCOUNT_ID_2))).extracting(TransferTransaction::getHbarTransfers, MAP).hasSize(2).containsEntry(ACCOUNT_ID, transferAmount.negated()).containsEntry(ACCOUNT_ID_2, transferAmount);
}
use of org.assertj.core.api.InstanceOfAssertFactories.list in project today-infrastructure by TAKETODAY.
the class StreamConverterTests method convertFromListToStream.
@Test
@SuppressWarnings("resource")
void convertFromListToStream() throws NoSuchFieldException {
this.conversionService.addConverterFactory(new StringToNumberConverterFactory());
List<String> list = Arrays.asList("1", "2", "3");
TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("streamOfIntegers"));
Object result = this.conversionService.convert(list, streamOfInteger);
assertThat(result).as("Converted object must be a stream").isInstanceOf(Stream.class);
@SuppressWarnings("unchecked") Stream<Integer> content = (Stream<Integer>) result;
assertThat(content.mapToInt(x -> x).sum()).isEqualTo(6);
}
use of org.assertj.core.api.InstanceOfAssertFactories.list in project spring-framework by spring-projects.
the class StreamConverterTests method convertFromListToStream.
@Test
@SuppressWarnings("resource")
void convertFromListToStream() throws NoSuchFieldException {
this.conversionService.addConverterFactory(new StringToNumberConverterFactory());
List<String> list = Arrays.asList("1", "2", "3");
TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("streamOfIntegers"));
Object result = this.conversionService.convert(list, streamOfInteger);
assertThat(result).as("Converted object must be a stream").isInstanceOf(Stream.class);
@SuppressWarnings("unchecked") Stream<Integer> content = (Stream<Integer>) result;
assertThat(content.mapToInt(x -> x).sum()).isEqualTo(6);
}
Aggregations