use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.
the class TokenRegistry method allInternalTokens.
public Collection<NamedToken> allInternalTokens() {
// Likely only a small fraction of all tokens are returned here.
Registries reg = this.registries;
List<NamedToken> list = new ArrayList<>();
for (NamedToken token : reg.idToToken) {
if (token.isInternal()) {
list.add(token);
}
}
return unmodifiableCollection(list);
}
use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.
the class DelegatingTokenHolderTest method assertTokens.
private static void assertTokens(Iterable<NamedToken> allTokens, NamedToken... expectedTokens) {
Map<String, NamedToken> existing = new HashMap<>();
for (NamedToken token : allTokens) {
existing.put(token.name(), token);
}
Map<String, NamedToken> expected = new HashMap<>();
for (NamedToken token : expectedTokens) {
expected.put(token.name(), token);
}
assertEquals(expected, existing);
}
use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.
the class TokenRegistryTest method puttingPublicTokenBySameNameAsInternalTokenMustNotConflict.
@Test
void puttingPublicTokenBySameNameAsInternalTokenMustNotConflict() {
registry.put(new NamedToken(INBOUND1_TYPE, 1, true));
// This mustn't throw:
registry.put(new NamedToken(INBOUND1_TYPE, 2));
}
use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.
the class TokenRegistryTest method mustKeepOriginalPublicTokenWhenAddDuplicate.
@Test
void mustKeepOriginalPublicTokenWhenAddDuplicate() {
registry.put(new NamedToken(INBOUND1_TYPE, 1));
registry.put(new NamedToken(INBOUND2_TYPE, 2));
assertThrows(NonUniqueTokenException.class, () -> registry.put(new NamedToken(INBOUND1_TYPE, 3)));
assertEquals(1, registry.getId(INBOUND1_TYPE).intValue());
assertEquals(2, registry.getId(INBOUND2_TYPE).intValue());
assertNull(registry.getToken(3));
assertNull(registry.getTokenInternal(3));
}
use of org.neo4j.token.api.NamedToken in project neo4j by neo4j.
the class TokenRegistryTest method allInternalTokensMustIncludeInternalTokensButNotIncludePublicTokens.
@Test
void allInternalTokensMustIncludeInternalTokensButNotIncludePublicTokens() {
registry.putAll(asList(new NamedToken(INBOUND1_TYPE, 1), new NamedToken(INBOUND1_TYPE, 2, true), new NamedToken(INBOUND2_TYPE, 3), new NamedToken(INBOUND2_TYPE, 4, true)));
Collection<NamedToken> tokens = registry.allInternalTokens();
assertThat(tokens).contains(new NamedToken(INBOUND1_TYPE, 2, true), new NamedToken(INBOUND2_TYPE, 4, true));
}
Aggregations