Search in sources :

Example 96 with EnumSource

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

the class SingleInstanceGetRoutingTableProcedureTest method shouldThrowIfClientProvidedPortIsNotANumber.

@ParameterizedTest
@EnumSource(value = RoutingMode.class)
void shouldThrowIfClientProvidedPortIsNotANumber(RoutingMode routingMode) {
    // given
    var advertisedBoldPort = 8776;
    var clientProvidedPort = "bolt";
    var advertisedBoltAddress = new SocketAddress("neo4j.com", advertisedBoldPort);
    var clientProvidedHostPortStr = String.format("%s:%s", "my.neo4j-service.com", clientProvidedPort);
    var ctxContents = new MapValueBuilder();
    ctxContents.add(ADDRESS_CONTEXT_KEY, Values.stringValue(clientProvidedHostPortStr));
    var ctx = ctxContents.build();
    var portRegister = mock(ConnectorPortRegister.class);
    when(portRegister.getLocalAddress(BoltConnector.NAME)).thenReturn(new HostnamePort("neo4j.com", advertisedBoldPort));
    var config = newConfig(Config.defaults(SERVER_DEFAULTS), Duration.ofSeconds(100), advertisedBoltAddress);
    config.set(routing_default_router, routingMode);
    var databaseManager = databaseManagerMock(config, true);
    var logProvider = new AssertableLogProvider();
    var procedure = newProcedure(databaseManager, portRegister, config, logProvider);
    var expectedMessage = "An address key is included in the query string provided to the GetRoutingTableProcedure, but its value could not be parsed.";
    // when
    assertThrows(ProcedureException.class, () -> invoke(procedure, ID, ctx), expectedMessage);
}
Also used : MapValueBuilder(org.neo4j.values.virtual.MapValueBuilder) HostnamePort(org.neo4j.internal.helpers.HostnamePort) SocketAddress(org.neo4j.configuration.helpers.SocketAddress) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 97 with EnumSource

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

the class TestRecoveryScenarios method shouldRecoverTransactionWhereNodeIsDeletedInTheFuture.

@ParameterizedTest
@EnumSource(FlushStrategy.class)
void shouldRecoverTransactionWhereNodeIsDeletedInTheFuture(FlushStrategy strategy) throws Exception {
    // GIVEN
    Node node = createNodeWithProperty("key", "value", label);
    checkPoint();
    setProperty(node, "other-key", 1);
    deleteNode(node);
    strategy.flush(db);
    // WHEN
    crashAndRestart();
    // -- really the problem was that recovery threw exception, so mostly assert that.
    try (Transaction tx = db.beginTx()) {
        node = tx.getNodeById(node.getId());
        tx.commit();
        fail("Should not exist");
    } catch (NotFoundException e) {
        assertEquals("Node " + node.getId() + " not found", e.getMessage());
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) Node(org.neo4j.graphdb.Node) NotFoundException(org.neo4j.graphdb.NotFoundException) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 98 with EnumSource

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

the class TokenIndexAccessorTest method readerShouldFindManyWithOtherTokens.

@ParameterizedTest
@EnumSource(IndexOrder.class)
void readerShouldFindManyWithOtherTokens(IndexOrder indexOrder) throws Exception {
    // Given
    int tokenId = 1;
    long[] entityIds = new long[] { 1, 2, 3, 64, 65, 1000, 2001 };
    long[] otherEntityIds = new long[] { 1, 2, 4, 64, 66, 1000, 2000 };
    addToIndex(tokenId, entityIds);
    addToIndex(2, otherEntityIds);
    LongList expectedIds = LongLists.immutable.of(entityIds);
    // When
    assertReaderFindsExpected(indexOrder, tokenId, expectedIds);
}
Also used : MutableLongList(org.eclipse.collections.api.list.primitive.MutableLongList) LongList(org.eclipse.collections.api.list.primitive.LongList) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 99 with EnumSource

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

the class EntityCommandGrouperTest method shouldSeeSingleGroupOfPropertiesWithoutEntity.

@ParameterizedTest
@EnumSource(Factory.class)
void shouldSeeSingleGroupOfPropertiesWithoutEntity(Factory factory) {
    // given
    EntityCommandGrouper grouper = new EntityCommandGrouper<>(factory.command(0).getClass(), 8);
    long entityId = 1;
    BaseCommand<? extends PrimitiveRecord> entity = factory.command(entityId);
    PropertyCommand property1 = property(entity.getAfter());
    PropertyCommand property2 = property(entity.getAfter());
    // intentionally DO NOT add the entity command
    grouper.add(property1);
    grouper.add(property2);
    EntityCommandGrouper.Cursor cursor = grouper.sortAndAccessGroups();
    // when/then
    assertGroups(cursor, group(entityId, null, property1, property2));
}
Also used : PropertyCommand(org.neo4j.internal.recordstorage.Command.PropertyCommand) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 100 with EnumSource

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

the class EntityCommandGrouperTest method shouldSeeMultipleGroupsSomeOfThemWithEntity.

@ParameterizedTest
@EnumSource(Factory.class)
void shouldSeeMultipleGroupsSomeOfThemWithEntity(Factory factory) {
    // given
    EntityCommandGrouper grouper = new EntityCommandGrouper<>(factory.command(0).getClass(), 64);
    Group[] groups = new Group[random.nextInt(10, 30)];
    for (int entityId = 0; entityId < groups.length; entityId++) {
        BaseCommand entityCommand = random.nextBoolean() ? factory.command(entityId) : null;
        groups[entityId] = new Group(entityId, entityCommand);
        if (entityCommand != null) {
            // <-- storage transaction logs are sorted such that entity commands comes before property commands
            grouper.add(entityCommand);
        }
    }
    int totalNumberOfProperties = random.nextInt(10, 100);
    for (int i = 0; i < totalNumberOfProperties; i++) {
        int entityId = random.nextInt(groups.length);
        PropertyCommand property = property(factory.command(entityId).getAfter());
        groups[entityId].addProperty(property);
        grouper.add(property);
    }
    // ^^^ OK so we've generated property commands for random entities in random order, let's sort them
    EntityCommandGrouper.Cursor cursor = grouper.sortAndAccessGroups();
    // then
    assertGroups(cursor, groups);
}
Also used : BaseCommand(org.neo4j.internal.recordstorage.Command.BaseCommand) PropertyCommand(org.neo4j.internal.recordstorage.Command.PropertyCommand) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

EnumSource (org.junit.jupiter.params.provider.EnumSource)382 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)378 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