MetadataExtractor { public static Bookmark extractBookmarks( Map<String,Value> metadata ) { Value bookmarkValue = metadata.get( "bookmark" ); if ( bookmarkValue != null && !bookmarkValue.isNull() && bookmarkValue.hasType( TYPE_SYSTEM.STRING() ) ) { return InternalBookmark.parse( bookmarkValue.asString() ); } return InternalBookmark.empty(); } MetadataExtractor( String resultAvailableAfterMetadataKey, String resultConsumedAfterMetadataKey ); QueryKeys extractQueryKeys( Map<String,Value> metadata ); long extractQueryId( Map<String,Value> metadata ); long extractResultAvailableAfter( Map<String,Value> metadata ); ResultSummary extractSummary(Query query, Connection connection, long resultAvailableAfter, Map<String,Value> metadata ); static DatabaseInfo extractDatabaseInfo( Map<String,Value> metadata ); static Bookmark extractBookmarks( Map<String,Value> metadata ); static ServerVersion extractNeo4jServerVersion( Map<String,Value> metadata ); static final int ABSENT_QUERY_ID; }
@Test void shouldExtractBookmark() { String bookmarkValue = "neo4j:bookmark:v1:tx123456"; Bookmark bookmark = extractor.extractBookmarks( singletonMap( "bookmark", value( bookmarkValue ) ) ); assertEquals( InternalBookmark.parse( bookmarkValue ), bookmark ); }
@Test void shouldExtractNoBookmarkWhenMetadataContainsNull() { Bookmark bookmark = extractor.extractBookmarks( singletonMap( "bookmark", null ) ); assertEquals( InternalBookmark.empty(), bookmark ); }
@Test void shouldExtractNoBookmarkWhenMetadataContainsNullValue() { Bookmark bookmark = extractor.extractBookmarks( singletonMap( "bookmark", Values.NULL ) ); assertEquals( InternalBookmark.empty(), bookmark ); }
@Test void shouldExtractNoBookmarkWhenMetadataContainsValueOfIncorrectType() { Bookmark bookmark = extractor.extractBookmarks( singletonMap( "bookmark", value( 42 ) ) ); assertEquals( InternalBookmark.empty(), bookmark ); }