Search in sources :

Example 76 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.

the class AccountRepositoryIntegrationTest method getTransactionById.

@ParameterizedTest
@EnumSource(RepositoryType.class)
void getTransactionById(RepositoryType type) {
    TransactionRepository transactionRepository = getRepositoryFactory(type).createTransactionRepository();
    Account account = config().getDefaultAccount();
    List<Transaction> transactions = get(transactionRepository.search(new TransactionSearchCriteria(TransactionGroup.CONFIRMED).signerPublicKey(account.getPublicAccount().getPublicKey()).pageSize(10))).getData();
    Assertions.assertTrue(transactions.size() > 0);
    String id = transactions.get(1).getTransactionInfo().get().getId().get();
    List<Transaction> transactions2 = get(transactionRepository.getTransactions(TransactionGroup.CONFIRMED, Arrays.asList(id)));
    Assertions.assertEquals(1, transactions2.size());
    transactions2.forEach(t -> Assertions.assertEquals(id, t.getTransactionInfo().get().getId().get()));
}
Also used : Account(io.nem.symbol.sdk.model.account.Account) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) Transaction(io.nem.symbol.sdk.model.transaction.Transaction) TransferTransaction(io.nem.symbol.sdk.model.transaction.TransferTransaction) TransactionRepository(io.nem.symbol.sdk.api.TransactionRepository) TransactionSearchCriteria(io.nem.symbol.sdk.api.TransactionSearchCriteria) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 77 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project nem2-sdk-java by nemtech.

the class AccountMetadataIntegrationTest method addMetadataToAccount.

@ParameterizedTest
@EnumSource(RepositoryType.class)
public void addMetadataToAccount(RepositoryType type) {
    BigInteger key = SerializationUtils.toUnsignedBigInteger(RandomUtils.generateRandomInt(100000) + Long.MAX_VALUE);
    Assertions.assertTrue(key.compareTo(BigInteger.ZERO) > 0);
    System.out.println("Key: " + key);
    String message = "This is the message for this account! 汉字" + key;
    System.out.println("Storing message '" + message + "' in account metadata " + testAccount.getAddress().plain());
    AccountMetadataTransaction transaction = AccountMetadataTransactionFactory.create(getNetworkType(), getDeadline(), testAccount.getAddress(), key, StringEncoder.getBytes(message)).maxFee(maxFee).build();
    AccountMetadataTransaction processedTransaction = announceAggregateAndValidate(type, transaction, testAccount).getLeft();
    Assertions.assertEquals(transaction.getValueSizeDelta(), processedTransaction.getValueSizeDelta());
    Assertions.assertEquals(transaction.getScopedMetadataKey(), processedTransaction.getScopedMetadataKey());
    sleep(1000);
    Metadata metadata = assertMetadata(transaction, get(getRepositoryFactory(type).createMetadataRepository().search(new MetadataSearchCriteria().metadataType(MetadataType.ACCOUNT).sourceAddress(testAccount.getAddress()))).getData());
    assertMetadata(transaction, get(getRepositoryFactory(type).createMetadataRepository().search(new MetadataSearchCriteria().metadataType(MetadataType.ACCOUNT).sourceAddress(testAccount.getAddress()).scopedMetadataKey(metadata.getScopedMetadataKey()))).getData());
    assertMetadata(transaction, get(getRepositoryFactory(type).createMetadataRepository().search(new MetadataSearchCriteria().metadataType(MetadataType.ACCOUNT).sourceAddress(testAccount.getAddress()).targetAddress(testAccount.getAddress()).scopedMetadataKey(metadata.getScopedMetadataKey()))).getData());
    Assertions.assertArrayEquals(StringEncoder.getBytes(message), processedTransaction.getValue());
}
Also used : MetadataSearchCriteria(io.nem.symbol.sdk.api.MetadataSearchCriteria) AccountMetadataTransaction(io.nem.symbol.sdk.model.transaction.AccountMetadataTransaction) Metadata(io.nem.symbol.sdk.model.metadata.Metadata) BigInteger(java.math.BigInteger) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 78 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project litiengine by gurkenlabs.

the class EnvironmentTests method testEntityByRenderType.

@ParameterizedTest
@EnumSource(RenderType.class)
void testEntityByRenderType(RenderType renderType) {
    ICombatEntity entity = mock(ICombatEntity.class);
    when(entity.getMapId()).thenReturn(123);
    when(entity.getName()).thenReturn("test");
    when(entity.getRenderType()).thenReturn(renderType);
    when(entity.getCollisionType()).thenReturn(Collision.DYNAMIC);
    this.testEnvironment.add(entity);
    assertNotNull(this.testEnvironment.get(123));
    assertNotNull(this.testEnvironment.get("test"));
    assertEquals(1, this.testEnvironment.getEntities(renderType).size());
    this.testEnvironment.remove(entity);
    assertNull(this.testEnvironment.get(123));
    assertNull(this.testEnvironment.get("test"));
    assertEquals(0, this.testEnvironment.getEntities(renderType).size());
}
Also used : ICombatEntity(de.gurkenlabs.litiengine.entities.ICombatEntity) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 79 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project reactor-core by reactor.

the class FluxCreateTest method secondOnCancelHandlerIsDisposedImmediately.

@ParameterizedTestWithName
@EnumSource(OverflowStrategy.class)
void secondOnCancelHandlerIsDisposedImmediately(OverflowStrategy overflowStrategy) {
    AtomicInteger firstDisposed = new AtomicInteger();
    AtomicInteger secondDisposed = new AtomicInteger();
    Flux.create(sink -> sink.onCancel(firstDisposed::incrementAndGet).onCancel(secondDisposed::incrementAndGet), overflowStrategy).subscribe();
    assertThat(firstDisposed).as("first handler for %s", overflowStrategy).hasValue(0);
    assertThat(secondDisposed).as("second handler for %s", overflowStrategy).hasValue(1);
}
Also used : IntStream(java.util.stream.IntStream) StepVerifier(reactor.test.StepVerifier) Scannable(reactor.core.Scannable) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SerializedFluxSink(reactor.core.publisher.FluxCreate.SerializedFluxSink) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) OverflowStrategy(reactor.core.publisher.FluxSink.OverflowStrategy) EnumSource(org.junit.jupiter.params.provider.EnumSource) Scheduler(reactor.core.scheduler.Scheduler) AtomicReference(java.util.concurrent.atomic.AtomicReference) BufferAsyncSink(reactor.core.publisher.FluxCreate.BufferAsyncSink) CoreSubscriber(reactor.core.CoreSubscriber) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LatestAsyncSink(reactor.core.publisher.FluxCreate.LatestAsyncSink) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Schedulers(reactor.core.scheduler.Schedulers) RaceTestUtils(reactor.test.util.RaceTestUtils) Subscriber(org.reactivestreams.Subscriber) ParameterizedTestWithName(reactor.test.ParameterizedTestWithName) Semaphore(java.util.concurrent.Semaphore) Step(reactor.test.StepVerifier.Step) Context(reactor.util.context.Context) Executors(java.util.concurrent.Executors) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) Assertions.fail(org.assertj.core.api.Assertions.fail) Subscription(org.reactivestreams.Subscription) AssertSubscriber(reactor.test.subscriber.AssertSubscriber) Exceptions(reactor.core.Exceptions) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTestWithName(reactor.test.ParameterizedTestWithName)

Example 80 with EnumSource

use of org.junit.jupiter.params.provider.EnumSource in project aeron by real-logic.

the class ArchiveTest method replayBufferReturnsDataBufferIfThreadingModeIsNotDEDICATED.

@ParameterizedTest
@EnumSource(value = ArchiveThreadingMode.class, mode = EXCLUDE, names = "DEDICATED")
void replayBufferReturnsDataBufferIfThreadingModeIsNotDEDICATED(final ArchiveThreadingMode threadingMode) {
    final Archive.Context context = new Archive.Context().threadingMode(threadingMode);
    final UnsafeBuffer buffer = context.replayBuffer();
    assertSame(context.dataBuffer(), buffer);
}
Also used : AeronArchive(io.aeron.archive.client.AeronArchive) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) Context(io.aeron.archive.Archive.Context) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

EnumSource (org.junit.jupiter.params.provider.EnumSource)397 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)393 Account (io.nem.symbol.sdk.model.account.Account)40 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)38 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)34 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)34 Address (io.nem.symbol.sdk.model.account.Address)30 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)27 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)26 TransactionSearchCriteria (io.nem.symbol.sdk.api.TransactionSearchCriteria)26 BigInteger (java.math.BigInteger)25 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)23 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)23 EntityUpdates (org.neo4j.storageengine.api.EntityUpdates)21 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)19 Path (java.nio.file.Path)18 ArrayList (java.util.ArrayList)16 Listener (io.nem.symbol.sdk.api.Listener)15 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)15 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)14