Search in sources :

Example 1 with StringValue

use of org.neo4j.values.storable.StringValue in project neo4j by neo4j.

the class CommunityProcedureITBase method listProcedures.

@Test
void listProcedures() throws Throwable {
    // When
    ProcedureHandle procedures = procs().procedureGet(procedureName("dbms", "procedures"));
    RawIterator<AnyValue[], ProcedureException> stream = procs().procedureCallRead(procedures.id(), new AnyValue[0], ProcedureCallContext.EMPTY);
    // Then
    List<AnyValue[]> actual = asList(stream);
    List<Object[]> expected = getExpectedCommunityProcs();
    Map<String, AnyValue[]> resultMap = actual.stream().collect(toMap(row -> ((StringValue) row[0]).stringValue(), Function.identity()));
    Map<String, Object[]> expectedMap = expected.stream().collect(toMap(row -> ((StringValue) row[0]).stringValue(), Function.identity()));
    assertThat(resultMap.keySet(), containsInAnyOrder(expectedMap.keySet().toArray()));
    for (String procName : resultMap.keySet()) {
        AnyValue[] actualArray = resultMap.get(procName);
        Object[] expectedArray = expectedMap.get(procName);
        assertNotNull(expectedArray, "Got an unexpected entry for " + procName + " =>\n" + printElementsOfArray(actualArray));
        assertEquals(expectedArray.length, actualArray.length, "Count of columns for " + procName + " does not match");
        for (int i = 1; i < actualArray.length; i++) {
            Matcher matcher;
            if (expectedArray[i] instanceof TextArray) {
                // this has to be a list of roles, we ignore those in community and expect a null here
                matcher = equalTo(NO_VALUE);
            } else if (expectedArray[i] instanceof Matcher) {
                matcher = (Matcher) expectedArray[i];
            } else {
                matcher = equalTo(expectedArray[i]);
            }
            assertThat("Column " + i + " for " + procName + " does not match", actualArray[i], matcher);
        }
    }
    commit();
}
Also used : AnyValue(org.neo4j.values.AnyValue) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) NO_VALUE(org.neo4j.values.storable.Values.NO_VALUE) Arrays(java.util.Arrays) TextArray(org.neo4j.values.storable.TextArray) RawIterator(org.neo4j.collection.RawIterator) Iterators.asList(org.neo4j.internal.helpers.collection.Iterators.asList) IsEqual.equalTo(org.hamcrest.core.IsEqual.equalTo) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) ProcedureSignature.procedureName(org.neo4j.internal.kernel.api.procs.ProcedureSignature.procedureName) Function(java.util.function.Function) Collectors.joining(java.util.stream.Collectors.joining) Test(org.junit.jupiter.api.Test) List(java.util.List) ProcedureCallContext(org.neo4j.internal.kernel.api.procs.ProcedureCallContext) StringValue(org.neo4j.values.storable.StringValue) Collectors.toMap(java.util.stream.Collectors.toMap) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) ProcedureHandle(org.neo4j.internal.kernel.api.procs.ProcedureHandle) Matcher(org.hamcrest.Matcher) Map(java.util.Map) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Matcher(org.hamcrest.Matcher) ProcedureHandle(org.neo4j.internal.kernel.api.procs.ProcedureHandle) AnyValue(org.neo4j.values.AnyValue) ProcedureException(org.neo4j.internal.kernel.api.exceptions.ProcedureException) StringValue(org.neo4j.values.storable.StringValue) TextArray(org.neo4j.values.storable.TextArray) Test(org.junit.jupiter.api.Test)

Example 2 with StringValue

use of org.neo4j.values.storable.StringValue in project neo4j by neo4j.

the class IndexSettingUtilTest method assertString.

private static void assertString(IndexSetting setting, Object object, String expectedResult) {
    Value result = IndexSettingUtil.asIndexSettingValue(setting, object);
    assertTrue(result instanceof StringValue);
    assertEquals(expectedResult, ((StringValue) result).stringValue());
}
Also used : StringValue(org.neo4j.values.storable.StringValue) BooleanValue(org.neo4j.values.storable.BooleanValue) Value(org.neo4j.values.storable.Value) StringValue(org.neo4j.values.storable.StringValue)

Aggregations

StringValue (org.neo4j.values.storable.StringValue)2 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 Function (java.util.function.Function)1 Collectors.joining (java.util.stream.Collectors.joining)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 Matcher (org.hamcrest.Matcher)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)1 IsEqual.equalTo (org.hamcrest.core.IsEqual.equalTo)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)1 Test (org.junit.jupiter.api.Test)1 RawIterator (org.neo4j.collection.RawIterator)1 Iterators.asList (org.neo4j.internal.helpers.collection.Iterators.asList)1 ProcedureException (org.neo4j.internal.kernel.api.exceptions.ProcedureException)1 ProcedureCallContext (org.neo4j.internal.kernel.api.procs.ProcedureCallContext)1 ProcedureHandle (org.neo4j.internal.kernel.api.procs.ProcedureHandle)1 ProcedureSignature.procedureName (org.neo4j.internal.kernel.api.procs.ProcedureSignature.procedureName)1