@Test
void shouldBuildResultSummaryWithProfiledPlan()
{

    Value profile = value( parameters(
            "operatorType", "ProduceResult",
            "args", parameters( "a", 42 ),
            "identifiers", values( "a", "b" ),
            "rows", value( 424242 ),
            "dbHits", value( 242424 ),
            "time", value( 999 ),
            "children", values(
                    parameters(
                            "operatorType", "LabelScan",
                            "args", parameters( "x", 1 ),
                            "identifiers", values( "y", "z" ),
                            "rows", value( 2 ),
                            "dbHits", value( 4 )
                    )
            )
    ) );
    Map<String,Value> metadata = singletonMap( "profile", profile );
    ResultSummary summary = extractor.extractSummary( query(), connectionMock(), 42, metadata );
    assertTrue( summary.hasPlan() );
    assertTrue( summary.hasProfile() );
    assertEquals( "ProduceResult", summary.profile().operatorType() );
    assertEquals( singletonMap( "a", value( 42 ) ), summary.profile().arguments() );
    assertEquals( asList( "a", "b" ), summary.profile().identifiers() );
    assertEquals( 424242, summary.profile().records() );
    assertEquals( 242424, summary.profile().dbHits() );
    assertEquals( 999, summary.profile().time() );
    assertFalse( summary.profile().hasPageCacheStats() );
    assertEquals( 0, summary.profile().pageCacheHitRatio() );
    assertEquals( 0, summary.profile().pageCacheMisses() );
    assertEquals( 0, summary.profile().pageCacheHits() );
    List<ProfiledPlan> children = summary.profile().children();
    assertEquals( 1, children.size() );
    ProfiledPlan child = children.get( 0 );
    assertEquals( "LabelScan", child.operatorType() );
    assertEquals( singletonMap( "x", value( 1 ) ), child.arguments() );
    assertEquals( asList( "y", "z" ), child.identifiers() );
    assertEquals( 2, child.records() );
    assertEquals( 4, child.dbHits() );
}