Search in sources :

Example 1 with StringValue

use of org.neo4j.driver.internal.value.StringValue in project neo4j by neo4j.

the class TablePlanFormatterTest method withEmptyDetails.

@Test
public void withEmptyDetails() {
    Plan plan = mock(Plan.class);
    Map<String, Value> args = new HashMap<String, Value>(2) {

        {
            put("EstimatedRows", new FloatValue(55));
            put("Details", new StringValue(""));
        }
    };
    when(plan.arguments()).thenReturn(args);
    when(plan.operatorType()).thenReturn("Projection");
    assertThat(tablePlanFormatter.formatPlan(plan), is(String.join(NEWLINE, "+-------------+---------+----------------+", "| Operator    | Details | Estimated Rows |", "+-------------+---------+----------------+", "| +Projection |         |             55 |", "+-------------+---------+----------------+", "")));
}
Also used : HashMap(java.util.HashMap) StringValue(org.neo4j.driver.internal.value.StringValue) Value(org.neo4j.driver.Value) FloatValue(org.neo4j.driver.internal.value.FloatValue) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) FloatValue(org.neo4j.driver.internal.value.FloatValue) Plan(org.neo4j.driver.summary.Plan) StringValue(org.neo4j.driver.internal.value.StringValue) Test(org.junit.Test)

Example 2 with StringValue

use of org.neo4j.driver.internal.value.StringValue in project neo4j by neo4j.

the class TablePlanFormatterTest method renderShortDetails.

@Test
public void renderShortDetails() {
    Plan plan = mock(Plan.class);
    Map<String, Value> args = Collections.singletonMap("Details", new StringValue("x.prop AS prop"));
    when(plan.arguments()).thenReturn(args);
    when(plan.operatorType()).thenReturn("Projection");
    assertThat(tablePlanFormatter.formatPlan(plan), is(String.join(NEWLINE, "+-------------+----------------+", "| Operator    | Details        |", "+-------------+----------------+", "| +Projection | x.prop AS prop |", "+-------------+----------------+", "")));
}
Also used : StringValue(org.neo4j.driver.internal.value.StringValue) Value(org.neo4j.driver.Value) FloatValue(org.neo4j.driver.internal.value.FloatValue) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Plan(org.neo4j.driver.summary.Plan) StringValue(org.neo4j.driver.internal.value.StringValue) Test(org.junit.Test)

Example 3 with StringValue

use of org.neo4j.driver.internal.value.StringValue in project neo4j by neo4j.

the class TablePlanFormatterTest method renderExactMaxLengthDetails.

@Test
public void renderExactMaxLengthDetails() {
    Plan plan = mock(Plan.class);
    String details = stringOfLength(TablePlanFormatter.MAX_DETAILS_COLUMN_WIDTH);
    Map<String, Value> args = Collections.singletonMap("Details", new StringValue(details));
    when(plan.arguments()).thenReturn(args);
    when(plan.operatorType()).thenReturn("Projection");
    assertThat(tablePlanFormatter.formatPlan(plan), containsString("| +Projection | " + details + " |"));
}
Also used : StringValue(org.neo4j.driver.internal.value.StringValue) Value(org.neo4j.driver.Value) FloatValue(org.neo4j.driver.internal.value.FloatValue) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Plan(org.neo4j.driver.summary.Plan) StringValue(org.neo4j.driver.internal.value.StringValue) Test(org.junit.Test)

Example 4 with StringValue

use of org.neo4j.driver.internal.value.StringValue in project neo4j by neo4j.

the class TablePlanFormatterTest method multiLineDetails.

@Test
public void multiLineDetails() {
    Plan argumentPlan = mock(Plan.class);
    when(argumentPlan.arguments()).thenReturn(Collections.emptyMap());
    when(argumentPlan.operatorType()).thenReturn("Argument");
    Plan childPlan = mock(Plan.class);
    Map<String, Value> args = Collections.singletonMap("Details", new StringValue(stringOfLength(TablePlanFormatter.MAX_DETAILS_COLUMN_WIDTH + 5)));
    when(childPlan.arguments()).thenReturn(args);
    when(childPlan.operatorType()).thenReturn("Expand");
    doReturn(new ArrayList<Plan>() {

        {
            add(argumentPlan);
            add(argumentPlan);
        }
    }).when(childPlan).children();
    Plan plan = mock(Plan.class);
    String details = stringOfLength(TablePlanFormatter.MAX_DETAILS_COLUMN_WIDTH + 1);
    args = Collections.singletonMap("Details", new StringValue(details));
    when(plan.arguments()).thenReturn(args);
    when(plan.operatorType()).thenReturn("Projection");
    doReturn(new ArrayList<Plan>() {

        {
            add(childPlan);
            add(childPlan);
        }
    }).when(plan).children();
    assertThat(tablePlanFormatter.formatPlan(plan), is(String.join(NEWLINE, "+---------------+------------------------------------------------------------------------------------------------------+", "| Operator      | Details                                                                                              |", "+---------------+------------------------------------------------------------------------------------------------------+", "| +Projection   | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |", "| |             | a                                                                                                    |", "| |\\            +------------------------------------------------------------------------------------------------------+", "| | +Expand     | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |", "| | |           | aaaaa                                                                                                |", "| | |\\          +------------------------------------------------------------------------------------------------------+", "| | | +Argument |                                                                                                      |", "| | |           +------------------------------------------------------------------------------------------------------+", "| | +Argument   |                                                                                                      |", "| |             +------------------------------------------------------------------------------------------------------+", "| +Expand       | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |", "| |             | aaaaa                                                                                                |", "| |\\            +------------------------------------------------------------------------------------------------------+", "| | +Argument   |                                                                                                      |", "| |             +------------------------------------------------------------------------------------------------------+", "| +Argument     |                                                                                                      |", "+---------------+------------------------------------------------------------------------------------------------------+", "")));
}
Also used : StringValue(org.neo4j.driver.internal.value.StringValue) Value(org.neo4j.driver.Value) FloatValue(org.neo4j.driver.internal.value.FloatValue) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Plan(org.neo4j.driver.summary.Plan) StringValue(org.neo4j.driver.internal.value.StringValue) Test(org.junit.Test)

Aggregations

CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 Test (org.junit.Test)4 Value (org.neo4j.driver.Value)4 FloatValue (org.neo4j.driver.internal.value.FloatValue)4 StringValue (org.neo4j.driver.internal.value.StringValue)4 Plan (org.neo4j.driver.summary.Plan)4 HashMap (java.util.HashMap)1