Search in sources :

Example 51 with NamedToken

use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.

the class TokenRegistryTest method getTokenInternalMustNotFindPublicTokens.

@Test
void getTokenInternalMustNotFindPublicTokens() {
    registry.put(new NamedToken(INBOUND1_TYPE, 1));
    assertThat(registry.getTokenInternal(1)).isNull();
}
Also used : NamedToken(org.neo4j.token.api.NamedToken) Test(org.junit.jupiter.api.Test)

Example 52 with NamedToken

use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.

the class TokenRegistryTest method putAllMustNotThrowWhenPublicTokenDuplicatesNameOfInternalToken.

@Test
void putAllMustNotThrowWhenPublicTokenDuplicatesNameOfInternalToken() {
    registry.put(new NamedToken(INBOUND1_TYPE, 1, true));
    registry.putAll(singletonList(new NamedToken(INBOUND1_TYPE, 2)));
}
Also used : NamedToken(org.neo4j.token.api.NamedToken) Test(org.junit.jupiter.api.Test)

Example 53 with NamedToken

use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.

the class EntityValueUpdatesTest method propertyLoader.

private static StorageReader propertyLoader(StorageProperty... properties) {
    StubStorageCursors stub = new StubStorageCursors();
    for (StorageProperty property : properties) {
        stub.propertyKeyTokenHolder().addToken(new NamedToken(String.valueOf(property.propertyKeyId()), property.propertyKeyId()));
    }
    Map<String, Value> propertyMap = new HashMap<>();
    for (StorageProperty p : properties) {
        propertyMap.put(String.valueOf(p.propertyKeyId()), p.value());
    }
    stub.withNode(ENTITY_ID).properties(propertyMap);
    stub.withRelationship(ENTITY_ID, 1, 1, 2).properties(propertyMap);
    return stub;
}
Also used : HashMap(java.util.HashMap) Value(org.neo4j.values.storable.Value) PropertyKeyValue(org.neo4j.storageengine.api.PropertyKeyValue) StorageProperty(org.neo4j.storageengine.api.StorageProperty) StubStorageCursors(org.neo4j.storageengine.api.StubStorageCursors) NamedToken(org.neo4j.token.api.NamedToken)

Example 54 with NamedToken

use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.

the class SchemaStore method insertPropertyIntoMap.

private static void insertPropertyIntoMap(PropertyKeyValue propertyKeyValue, Map<String, Value> props, TokenHolders tokenHolders) throws MalformedSchemaRuleException {
    try {
        NamedToken propertyKeyTokenName = tokenHolders.propertyKeyTokens().getInternalTokenById(propertyKeyValue.propertyKeyId());
        props.put(propertyKeyTokenName.name(), propertyKeyValue.value());
    } catch (TokenNotFoundException | InvalidRecordException e) {
        int id = propertyKeyValue.propertyKeyId();
        throw new MalformedSchemaRuleException("Cannot read schema rule because it is referring to a property key token (id " + id + ") that does not exist.", e);
    }
}
Also used : MalformedSchemaRuleException(org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException) NamedToken(org.neo4j.token.api.NamedToken) TokenNotFoundException(org.neo4j.token.api.TokenNotFoundException)

Example 55 with NamedToken

use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.

the class RelationshipTest method shouldBeAbleToReferToIdsBeyondMaxInt.

@Test
void shouldBeAbleToReferToIdsBeyondMaxInt() {
    // GIVEN
    var transaction = mock(InternalTransaction.class, RETURNS_DEEP_STUBS);
    when(transaction.newNodeEntity(anyLong())).then(invocation -> nodeWithId(invocation.getArgument(0)));
    when(transaction.getRelationshipTypeById(anyInt())).then(invocation -> new NamedToken("whatever", invocation.getArgument(0)));
    long[] ids = new long[] { 1437589437, 2047587483, 2147496246L, 2147342921, 3276473721L, 4762746373L, 57587348738L, 59892898932L };
    int[] types = new int[] { 0, 10, 101, 3024, 20123, 45008 };
    // WHEN/THEN
    for (int i = 0; i < ids.length - 2; i++) {
        long id = ids[i];
        long nodeId1 = ids[i + 1];
        long nodeId2 = ids[i + 2];
        int type = types[i];
        verifyIds(transaction, id, nodeId1, type, nodeId2);
        verifyIds(transaction, id, nodeId2, type, nodeId1);
    }
}
Also used : NamedToken(org.neo4j.token.api.NamedToken) Test(org.junit.jupiter.api.Test)

Aggregations

NamedToken (org.neo4j.token.api.NamedToken)63 Test (org.junit.jupiter.api.Test)41 ArrayList (java.util.ArrayList)6 TokenNotFoundException (org.neo4j.token.api.TokenNotFoundException)6 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)5 SchemaRule (org.neo4j.internal.schema.SchemaRule)5 NonUniqueTokenException (org.neo4j.token.api.NonUniqueTokenException)5 TokenHolder (org.neo4j.token.api.TokenHolder)5 AlreadyConstrainedException (org.neo4j.kernel.api.exceptions.schema.AlreadyConstrainedException)4 HashMap (java.util.HashMap)3 Iterator (java.util.Iterator)3 IntSupplier (java.util.function.IntSupplier)3 KernelException (org.neo4j.exceptions.KernelException)3 Iterators (org.neo4j.internal.helpers.collection.Iterators)3 IdCapacityExceededException (org.neo4j.internal.id.IdCapacityExceededException)3 Token (org.neo4j.internal.kernel.api.Token)3 TokenWrite.checkValidTokenName (org.neo4j.internal.kernel.api.TokenWrite.checkValidTokenName)3 LabelNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.LabelNotFoundKernelException)3 PropertyKeyIdNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)3 RelationshipTypeIdNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.RelationshipTypeIdNotFoundKernelException)3