File tree Expand file tree Collapse file tree 5 files changed +63
-5
lines changed
main/java/org/neo4j/driver
test/java/org/neo4j/driver/internal/util Expand file tree Collapse file tree 5 files changed +63
-5
lines changed Original file line number Diff line number Diff line change 18
18
*/
19
19
package org .neo4j .driver .internal .summary ;
20
20
21
- import org . neo4j . driver . summary . DatabaseInfo ;
21
+ import java . util . Objects ;
22
22
23
- import static org .neo4j .driver .internal . messaging . request . MultiDatabaseUtil . ABSENT_DB_NAME ;
23
+ import org .neo4j .driver .summary . DatabaseInfo ;
24
24
25
25
public class InternalDatabaseInfo implements DatabaseInfo
26
26
{
27
- public static DatabaseInfo DEFAULT_DATABASE_INFO = new InternalDatabaseInfo ( ABSENT_DB_NAME );
27
+ public static DatabaseInfo DEFAULT_DATABASE_INFO = new InternalDatabaseInfo ( null );
28
28
29
29
private final String name ;
30
30
@@ -38,4 +38,31 @@ public String name()
38
38
{
39
39
return this .name ;
40
40
}
41
+
42
+ @ Override
43
+ public boolean equals ( Object o )
44
+ {
45
+ if ( this == o )
46
+ {
47
+ return true ;
48
+ }
49
+ if ( o == null || getClass () != o .getClass () )
50
+ {
51
+ return false ;
52
+ }
53
+ InternalDatabaseInfo that = (InternalDatabaseInfo ) o ;
54
+ return Objects .equals ( name , that .name );
55
+ }
56
+
57
+ @ Override
58
+ public int hashCode ()
59
+ {
60
+ return Objects .hash ( name );
61
+ }
62
+
63
+ @ Override
64
+ public String toString ()
65
+ {
66
+ return "InternalDatabaseInfo{" + "name='" + name + '\'' + '}' ;
67
+ }
41
68
}
Original file line number Diff line number Diff line change @@ -171,6 +171,7 @@ public String toString()
171
171
return "InternalResultSummary{" +
172
172
"statement=" + statement +
173
173
", serverInfo=" + serverInfo +
174
+ ", databaseInfo=" + databaseInfo +
174
175
", statementType=" + statementType +
175
176
", counters=" + counters +
176
177
", plan=" + plan +
Original file line number Diff line number Diff line change 18
18
*/
19
19
package org .neo4j .driver .internal .summary ;
20
20
21
+ import java .util .Objects ;
22
+
21
23
import org .neo4j .driver .internal .BoltServerAddress ;
22
24
import org .neo4j .driver .internal .util .ServerVersion ;
23
25
import org .neo4j .driver .summary .ServerInfo ;
@@ -44,4 +46,31 @@ public String version()
44
46
{
45
47
return version ;
46
48
}
49
+
50
+ @ Override
51
+ public boolean equals ( Object o )
52
+ {
53
+ if ( this == o )
54
+ {
55
+ return true ;
56
+ }
57
+ if ( o == null || getClass () != o .getClass () )
58
+ {
59
+ return false ;
60
+ }
61
+ InternalServerInfo that = (InternalServerInfo ) o ;
62
+ return Objects .equals ( address , that .address ) && Objects .equals ( version , that .version );
63
+ }
64
+
65
+ @ Override
66
+ public int hashCode ()
67
+ {
68
+ return Objects .hash ( address , version );
69
+ }
70
+
71
+ @ Override
72
+ public String toString ()
73
+ {
74
+ return "InternalServerInfo{" + "address='" + address + '\'' + ", version='" + version + '\'' + '}' ;
75
+ }
47
76
}
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ public interface DatabaseInfo
25
25
{
26
26
/**
27
27
* The name of the database where a {@link ResultSummary} is obtained from.
28
+ * Default to {@code null} if servers does not support multi-databases.
28
29
* @return the name of the database where a {@link ResultSummary} is obtained from
29
30
*/
30
31
String name ();
Original file line number Diff line number Diff line change @@ -407,7 +407,7 @@ void shouldExtractDatabase()
407
407
}
408
408
409
409
@ Test
410
- void shouldDefaultToEmptyDatabaseName ()
410
+ void shouldDefaultToNullDatabaseName ()
411
411
{
412
412
// Given
413
413
Map <String ,Value > metadata = singletonMap ( "no_db" , value ( "no_db" ) );
@@ -416,7 +416,7 @@ void shouldDefaultToEmptyDatabaseName()
416
416
DatabaseInfo db = extractDatabaseInfo ( metadata );
417
417
418
418
// Then
419
- assertEquals ( "" , db .name () );
419
+ assertNull ( db .name () );
420
420
}
421
421
422
422
@ Test
You can’t perform that action at this time.
0 commit comments