Skip to content

Commit 41b0d56

Browse files
authored
Update to using the local variable type inference in tests (#1448)
1 parent cde775c commit 41b0d56

File tree

285 files changed

+5527
-6083
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

285 files changed

+5527
-6083
lines changed

driver/src/test/java/org/neo4j/driver/AuthTokensTest.java

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
class AuthTokensTest {
3939
@Test
4040
void basicAuthWithoutRealm() {
41-
InternalAuthToken basic = (InternalAuthToken) basic("foo", "bar");
41+
var basic = (InternalAuthToken) basic("foo", "bar");
4242

43-
Map<String, Value> map = basic.toMap();
43+
var map = basic.toMap();
4444

4545
assertThat(map.size(), equalTo(3));
4646
assertThat(map.get("scheme"), equalTo((Value) new StringValue("basic")));
@@ -50,9 +50,9 @@ void basicAuthWithoutRealm() {
5050

5151
@Test
5252
void basicAuthWithRealm() {
53-
InternalAuthToken basic = (InternalAuthToken) basic("foo", "bar", "baz");
53+
var basic = (InternalAuthToken) basic("foo", "bar", "baz");
5454

55-
Map<String, Value> map = basic.toMap();
55+
var map = basic.toMap();
5656

5757
assertThat(map.size(), equalTo(4));
5858
assertThat(map.get("scheme"), equalTo((Value) new StringValue("basic")));
@@ -63,9 +63,9 @@ void basicAuthWithRealm() {
6363

6464
@Test
6565
void customAuthWithoutParameters() {
66-
InternalAuthToken basic = (InternalAuthToken) custom("foo", "bar", "baz", "my_scheme");
66+
var basic = (InternalAuthToken) custom("foo", "bar", "baz", "my_scheme");
6767

68-
Map<String, Value> map = basic.toMap();
68+
var map = basic.toMap();
6969

7070
assertThat(map.size(), equalTo(4));
7171
assertThat(map.get("scheme"), equalTo((Value) new StringValue("my_scheme")));
@@ -76,13 +76,13 @@ void customAuthWithoutParameters() {
7676

7777
@Test
7878
void customAuthParameters() {
79-
HashMap<String, Object> parameters = new HashMap<>();
79+
var parameters = new HashMap<String, Object>();
8080
parameters.put("list", asList(1, 2, 3));
81-
InternalAuthToken basic = (InternalAuthToken) custom("foo", "bar", "baz", "my_scheme", parameters);
81+
var basic = (InternalAuthToken) custom("foo", "bar", "baz", "my_scheme", parameters);
8282

8383
Map<String, Value> expectedParameters = new HashMap<>();
8484
expectedParameters.put("list", new ListValue(values(1, 2, 3)));
85-
Map<String, Value> map = basic.toMap();
85+
var map = basic.toMap();
8686

8787
assertThat(map.size(), equalTo(5));
8888
assertThat(map.get("scheme"), equalTo((Value) new StringValue("my_scheme")));
@@ -95,22 +95,22 @@ void customAuthParameters() {
9595
@Test
9696
void shouldSupportBearerAuth() {
9797
// GIVEN
98-
String tokenStr = "token";
98+
var tokenStr = "token";
9999

100100
// WHEN
101-
InternalAuthToken token = (InternalAuthToken) AuthTokens.bearer(tokenStr);
101+
var token = (InternalAuthToken) AuthTokens.bearer(tokenStr);
102102

103103
// THEN
104-
Map<String, Value> map = token.toMap();
104+
var map = token.toMap();
105105
assertThat(map.size(), equalTo(2));
106106
assertThat(map.get("scheme"), equalTo(new StringValue("bearer")));
107107
assertThat(map.get("credentials"), equalTo(new StringValue(tokenStr)));
108108
}
109109

110110
@Test
111111
void basicKerberosAuthWithRealm() {
112-
InternalAuthToken token = (InternalAuthToken) AuthTokens.kerberos("base64");
113-
Map<String, Value> map = token.toMap();
112+
var token = (InternalAuthToken) AuthTokens.kerberos("base64");
113+
var map = token.toMap();
114114

115115
assertThat(map.size(), equalTo(3));
116116
assertThat(map.get("scheme"), equalTo((Value) new StringValue("kerberos")));
@@ -120,20 +120,20 @@ void basicKerberosAuthWithRealm() {
120120

121121
@Test
122122
void shouldNotAllowBasicAuthTokenWithNullUsername() {
123-
NullPointerException e = assertThrows(NullPointerException.class, () -> AuthTokens.basic(null, "password"));
123+
var e = assertThrows(NullPointerException.class, () -> AuthTokens.basic(null, "password"));
124124
assertEquals("Username can't be null", e.getMessage());
125125
}
126126

127127
@Test
128128
void shouldNotAllowBasicAuthTokenWithNullPassword() {
129-
NullPointerException e = assertThrows(NullPointerException.class, () -> AuthTokens.basic("username", null));
129+
var e = assertThrows(NullPointerException.class, () -> AuthTokens.basic("username", null));
130130
assertEquals("Password can't be null", e.getMessage());
131131
}
132132

133133
@Test
134134
void shouldAllowBasicAuthTokenWithNullRealm() {
135-
AuthToken token = AuthTokens.basic("username", "password", null);
136-
Map<String, Value> map = ((InternalAuthToken) token).toMap();
135+
var token = AuthTokens.basic("username", "password", null);
136+
var map = ((InternalAuthToken) token).toMap();
137137

138138
assertEquals(3, map.size());
139139
assertEquals("basic", map.get("scheme").asString());
@@ -143,34 +143,33 @@ void shouldAllowBasicAuthTokenWithNullRealm() {
143143

144144
@Test
145145
void shouldNotAllowBearerAuthTokenWithNullToken() {
146-
NullPointerException e = assertThrows(NullPointerException.class, () -> AuthTokens.bearer(null));
146+
var e = assertThrows(NullPointerException.class, () -> AuthTokens.bearer(null));
147147
assertEquals("Token can't be null", e.getMessage());
148148
}
149149

150150
@Test
151151
void shouldNotAllowKerberosAuthTokenWithNullTicket() {
152-
NullPointerException e = assertThrows(NullPointerException.class, () -> AuthTokens.kerberos(null));
152+
var e = assertThrows(NullPointerException.class, () -> AuthTokens.kerberos(null));
153153
assertEquals("Ticket can't be null", e.getMessage());
154154
}
155155

156156
@Test
157157
void shouldNotAllowCustomAuthTokenWithNullPrincipal() {
158-
NullPointerException e = assertThrows(
158+
var e = assertThrows(
159159
NullPointerException.class, () -> AuthTokens.custom(null, "credentials", "realm", "scheme"));
160160
assertEquals("Principal can't be null", e.getMessage());
161161
}
162162

163163
@Test
164164
void shouldNotAllowCustomAuthTokenWithNullCredentials() {
165-
NullPointerException e =
166-
assertThrows(NullPointerException.class, () -> AuthTokens.custom("principal", null, "realm", "scheme"));
165+
var e = assertThrows(NullPointerException.class, () -> AuthTokens.custom("principal", null, "realm", "scheme"));
167166
assertEquals("Credentials can't be null", e.getMessage());
168167
}
169168

170169
@Test
171170
void shouldAllowCustomAuthTokenWithNullRealm() {
172-
AuthToken token = AuthTokens.custom("principal", "credentials", null, "scheme");
173-
Map<String, Value> map = ((InternalAuthToken) token).toMap();
171+
var token = AuthTokens.custom("principal", "credentials", null, "scheme");
172+
var map = ((InternalAuthToken) token).toMap();
174173

175174
assertEquals(3, map.size());
176175
assertEquals("scheme", map.get("scheme").asString());
@@ -180,7 +179,7 @@ void shouldAllowCustomAuthTokenWithNullRealm() {
180179

181180
@Test
182181
void shouldNotAllowCustomAuthTokenWithNullScheme() {
183-
NullPointerException e = assertThrows(
182+
var e = assertThrows(
184183
NullPointerException.class, () -> AuthTokens.custom("principal", "credentials", "realm", null));
185184
assertEquals("Scheme can't be null", e.getMessage());
186185
}

0 commit comments

Comments
 (0)