use of org.neo4j.values.storable.TextValue in project neo4j by neo4j.
the class DatabaseStateProcedure method extractDatabaseId.
protected NamedDatabaseId extractDatabaseId(AnyValue[] input) throws ProcedureException {
if (input.length != 1) {
throw new IllegalArgumentException("Illegal input:" + Arrays.toString(input));
}
var rawName = input[0];
if (!(rawName instanceof TextValue)) {
throw new IllegalArgumentException(format("Parameter '%s' value should have a string representation. Instead: %s", PARAMETER_NAME, rawName));
}
var name = new NormalizedDatabaseName(((TextValue) rawName).stringValue());
return idRepository.getByName(name).orElseThrow(() -> new ProcedureException(DatabaseNotFound, format("Unable to retrieve the status " + "for database with name %s because no database with this name exists!", name)));
}
use of org.neo4j.values.storable.TextValue in project neo4j by neo4j.
the class DuplicateCheckStrategyTest method duplicateFoundAmongUniqueStringSingleProperty.
@ParameterizedTest
@MethodSource("duplicateCheckStrategies")
void duplicateFoundAmongUniqueStringSingleProperty(DuplicateCheckStrategy checkStrategy) throws IndexEntryConflictException {
for (int i = 0; i < randomNumberOfEntries(); i++) {
String propertyValue = String.valueOf(i);
TextValue stringValue = Values.stringValue(propertyValue);
checkStrategy.checkForDuplicate(stringValue, i);
}
int duplicateTarget = BUCKET_STRATEGY_ENTRIES_THRESHOLD - 2;
String duplicate = String.valueOf(duplicateTarget);
TextValue duplicatedValue = Values.stringValue(duplicate);
var e = assertThrows(IndexEntryConflictException.class, () -> checkStrategy.checkForDuplicate(duplicatedValue, 3));
assertEquals(format("Both node %d and node 3 share the property value %s", duplicateTarget, ValueTuple.of(duplicatedValue)), e.getMessage());
}
use of org.neo4j.values.storable.TextValue in project neo4j by neo4j.
the class PrettyPrinterTest method shouldBeAbleToUseAnyQuoteMark.
@Test
void shouldBeAbleToUseAnyQuoteMark() {
// Given
TextValue hello = stringValue("(ツ)");
PrettyPrinter printer = new PrettyPrinter("__", FULL);
// When
hello.writeTo(printer);
// Then
assertThat(printer.value()).isEqualTo("__(ツ)__");
}
use of org.neo4j.values.storable.TextValue in project neo4j by neo4j.
the class SchemaComplianceCheckerTest method shouldReportNotUniquelyIndexed.
@Test
void shouldReportNotUniquelyIndexed() throws Exception {
// given
LabelSchemaDescriptor descriptor = forLabel(label1, propertyKey1);
long indexId = uniqueIndex(descriptor);
long nodeId;
try (AutoCloseable ignored = tx()) {
TextValue value = stringValue("a");
// (N1) indexed w/ property A
{
long propId = propertyStore.nextId(CursorContext.NULL);
nodeId = node(nodeStore.nextId(CursorContext.NULL), propId, NULL, label1);
property(propId, NULL, NULL, propertyValue(propertyKey1, value));
indexValue(descriptor, indexId, nodeId, value);
}
// (N2) indexed w/ property A
{
long propId = propertyStore.nextId(CursorContext.NULL);
long nodeId2 = node(nodeStore.nextId(CursorContext.NULL), propId, NULL, label1);
property(propId, NULL, NULL, propertyValue(propertyKey1, value));
indexValue(descriptor, indexId, nodeId2, value);
}
}
// when
checkIndexed(nodeId);
// then
expect(ConsistencyReport.NodeConsistencyReport.class, report -> report.uniqueIndexNotUnique(any(), any(), anyLong()));
}
use of org.neo4j.values.storable.TextValue in project neo4j by neo4j.
the class DbIndexesFailureMessageIT method listAllIndexesWithFailedIndex.
@Test
void listAllIndexesWithFailedIndex() throws Throwable {
// Given
KernelTransaction dataTransaction = newTransaction(AUTH_DISABLED);
String labelName = "Fail";
String propertyKey = "foo";
int failedLabel = dataTransaction.tokenWrite().labelGetOrCreateForName(labelName);
int propertyKeyId1 = dataTransaction.tokenWrite().propertyKeyGetOrCreateForName(propertyKey);
this.transaction.createNode(Label.label(labelName)).setProperty(propertyKey, "some value");
commit();
KernelTransaction transaction = newTransaction(AUTH_DISABLED);
LabelSchemaDescriptor schema = forLabel(failedLabel, propertyKeyId1);
IndexDescriptor index = transaction.schemaWrite().indexCreate(schema, "fail foo index");
commit();
try (org.neo4j.graphdb.Transaction tx = db.beginTx()) {
assertThrows(IllegalStateException.class, () -> tx.schema().awaitIndexesOnline(2, MINUTES));
}
// When
RawIterator<AnyValue[], ProcedureException> stream = procs().procedureCallRead(procs().procedureGet(procedureName("db", "indexDetails")).id(), new TextValue[] { stringValue(index.getName()) }, ProcedureCallContext.EMPTY);
assertTrue(stream.hasNext());
AnyValue[] result = stream.next();
assertFalse(stream.hasNext());
// Commit procedure transaction
commit();
// Then
assertEquals(longValue(index.getId()), result[0]);
assertEquals(stringValue("fail foo index"), result[1]);
assertEquals(stringValue("FAILED"), result[2]);
assertEquals(doubleValue(0.0), result[3]);
assertEquals(stringValue("NONUNIQUE"), result[4]);
assertEquals(stringValue("BTREE"), result[5]);
assertEquals(stringValue("NODE"), result[6]);
assertEquals(VirtualValues.list(stringValue(labelName)), result[7]);
assertEquals(VirtualValues.list(stringValue(propertyKey)), result[8]);
assertEquals(stringValue(NATIVE_BTREE10.providerName()), result[9]);
assertMapsEqual(index.getIndexConfig().asMap(), (MapValue) result[10]);
assertThat(((TextValue) result[11]).stringValue()).contains("java.lang.RuntimeException: Fail on update during population");
assertEquals(12, result.length);
}
Aggregations