Search in sources :

Example 11 with DefaultParameterValue

use of org.neo4j.internal.kernel.api.procs.DefaultParameterValue in project neo4j by neo4j.

the class MapConverterTest method shouldHandleNestedMaps.

@SuppressWarnings("unchecked")
@Test
void shouldHandleNestedMaps() {
    // Given
    String mapString = "{k1: 1337, k2: { k1 : 1337, k2: {k1: 1337}}}";
    // When
    DefaultParameterValue converted = converter.apply(mapString);
    // Then
    Map<String, Object> map1 = (Map<String, Object>) converted.value();
    Map<String, Object> map2 = (Map<String, Object>) map1.get("k2");
    Map<String, Object> map3 = (Map<String, Object>) map2.get("k2");
    assertThat(map1.get("k1")).isEqualTo(1337L);
    assertThat(map2.get("k1")).isEqualTo(1337L);
    assertThat(map3.get("k1")).isEqualTo(1337L);
}
Also used : DefaultParameterValue(org.neo4j.internal.kernel.api.procs.DefaultParameterValue) Collections.emptyMap(java.util.Collections.emptyMap) DefaultParameterValue.ntMap(org.neo4j.internal.kernel.api.procs.DefaultParameterValue.ntMap) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 12 with DefaultParameterValue

use of org.neo4j.internal.kernel.api.procs.DefaultParameterValue in project neo4j by neo4j.

the class MapConverterTest method shouldHandleEscapedDoubleQuotedInValue1.

@Test
void shouldHandleEscapedDoubleQuotedInValue1() {
    // Given
    String mapString = "{key: \"va\\\"lue\"}";
    // When
    DefaultParameterValue converted = converter.apply(mapString);
    // Then
    assertThat(converted).isEqualTo(ntMap(map("key", "va\"lue")));
}
Also used : DefaultParameterValue(org.neo4j.internal.kernel.api.procs.DefaultParameterValue) Test(org.junit.jupiter.api.Test)

Example 13 with DefaultParameterValue

use of org.neo4j.internal.kernel.api.procs.DefaultParameterValue in project neo4j by neo4j.

the class MapConverterTest method shouldHandleMapsWithLists.

@SuppressWarnings("unchecked")
@Test
void shouldHandleMapsWithLists() {
    // Given
    String mapString = "{k1: [1337, 42]}";
    // When
    DefaultParameterValue converted = converter.apply(mapString);
    // Then
    Map<String, Object> map1 = (Map<String, Object>) converted.value();
    assertThat(map1.get("k1")).isEqualTo(asList(1337L, 42L));
}
Also used : DefaultParameterValue(org.neo4j.internal.kernel.api.procs.DefaultParameterValue) Collections.emptyMap(java.util.Collections.emptyMap) DefaultParameterValue.ntMap(org.neo4j.internal.kernel.api.procs.DefaultParameterValue.ntMap) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 14 with DefaultParameterValue

use of org.neo4j.internal.kernel.api.procs.DefaultParameterValue in project neo4j by neo4j.

the class MapConverterTest method shouldHandleKeyWithEscapedSingleQuote.

@Test
void shouldHandleKeyWithEscapedSingleQuote() {
    // Given
    String mapString = "{`k\'ey`: \"value\"}";
    // When
    DefaultParameterValue converted = converter.apply(mapString);
    // Then
    assertThat(converted).isEqualTo(ntMap(map("k\'ey", "value")));
}
Also used : DefaultParameterValue(org.neo4j.internal.kernel.api.procs.DefaultParameterValue) Test(org.junit.jupiter.api.Test)

Example 15 with DefaultParameterValue

use of org.neo4j.internal.kernel.api.procs.DefaultParameterValue in project neo4j by neo4j.

the class MapConverterTest method shouldHandleEmptyMapWithSpaces.

@Test
void shouldHandleEmptyMapWithSpaces() {
    // Given
    String mapString = " {  }  ";
    // When
    DefaultParameterValue converted = converter.apply(mapString);
    // Then
    assertThat(converted).isEqualTo(ntMap(emptyMap()));
}
Also used : DefaultParameterValue(org.neo4j.internal.kernel.api.procs.DefaultParameterValue) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultParameterValue (org.neo4j.internal.kernel.api.procs.DefaultParameterValue)31 Test (org.junit.jupiter.api.Test)30 NTString (org.neo4j.internal.kernel.api.procs.Neo4jTypes.NTString)12 Arrays.asList (java.util.Arrays.asList)2 Collections.emptyList (java.util.Collections.emptyList)2 Collections.emptyMap (java.util.Collections.emptyMap)2 Collections.singletonList (java.util.Collections.singletonList)2 List (java.util.List)2 Map (java.util.Map)2 DefaultParameterValue.ntList (org.neo4j.internal.kernel.api.procs.DefaultParameterValue.ntList)2 DefaultParameterValue.ntMap (org.neo4j.internal.kernel.api.procs.DefaultParameterValue.ntMap)2 NTList (org.neo4j.internal.kernel.api.procs.Neo4jTypes.NTList)2 Parameter (java.lang.reflect.Parameter)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 ProcedureException (org.neo4j.internal.kernel.api.exceptions.ProcedureException)1 FieldSignature (org.neo4j.internal.kernel.api.procs.FieldSignature)1 Name (org.neo4j.procedure.Name)1 DefaultValueConverter (org.neo4j.procedure.impl.TypeCheckers.DefaultValueConverter)1