ServerVersion { public static ServerVersion version( Driver driver ) { try ( Session session = driver.session() ) { String versionString = session.readTransaction( tx -> tx.run( "RETURN 1" ).consume().server().version() ); return version( versionString ); } } private  ServerVersion( String product, int major, int minor, int patch ); String product(); static ServerVersion version( Driver driver ); static ServerVersion version( String server ); @Override boolean equals( Object o ); @Override int hashCode(); boolean greaterThan(ServerVersion other); boolean greaterThanOrEqual(ServerVersion other); boolean lessThan(ServerVersion other); boolean lessThanOrEqual(ServerVersion other); @Override String toString(); static ServerVersion fromBoltProtocolVersion( BoltProtocolVersion protocolVersion ); static final String NEO4J_PRODUCT; static final ServerVersion v4_2_0; static final ServerVersion v4_1_0; static final ServerVersion v4_0_0; static final ServerVersion v3_5_0; static final ServerVersion v3_4_0; static final ServerVersion vInDev; }
@Test void shouldFailToParseIllegalVersions() { assertThrows( IllegalArgumentException.class, () -> ServerVersion.version( "" ) ); assertThrows( IllegalArgumentException.class, () -> ServerVersion.version( "/1.2.3" ) ); assertThrows( IllegalArgumentException.class, () -> ServerVersion.version( "Neo4j1.2.3" ) ); assertThrows( IllegalArgumentException.class, () -> ServerVersion.version( "Neo4j" ) ); }
@Test void version() { assertThat( ServerVersion.version( "Neo4j/dev" ), is( ServerVersion.vInDev ) ); assertThat( ServerVersion.version( "Neo4j/4.0.0" ), is( ServerVersion.v4_0_0 ) ); }