Skip to content

Commit 432fdad

Browse files
committed
Polish contribution
See gh-26982
1 parent 345d818 commit 432fdad

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

spring-core/src/test/java/org/springframework/core/SimpleAliasRegistryTests.java

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,13 +21,18 @@
2121
import static org.assertj.core.api.Assertions.assertThat;
2222

2323
/**
24+
* Unit tests for {@link SimpleAliasRegistry}.
25+
*
2426
* @author Juergen Hoeller
27+
* @author Nha Vuong
28+
* @author Sam Brannen
2529
*/
2630
class SimpleAliasRegistryTests {
2731

32+
private final SimpleAliasRegistry registry = new SimpleAliasRegistry();
33+
2834
@Test
2935
void aliasChaining() {
30-
SimpleAliasRegistry registry = new SimpleAliasRegistry();
3136
registry.registerAlias("test", "testAlias");
3237
registry.registerAlias("testAlias", "testAlias2");
3338
registry.registerAlias("testAlias2", "testAlias3");
@@ -42,7 +47,6 @@ void aliasChaining() {
4247

4348
@Test // SPR-17191
4449
void aliasChainingWithMultipleAliases() {
45-
SimpleAliasRegistry registry = new SimpleAliasRegistry();
4650
registry.registerAlias("name", "alias_a");
4751
registry.registerAlias("name", "alias_b");
4852
assertThat(registry.hasAlias("name", "alias_a")).isTrue();
@@ -61,27 +65,34 @@ void aliasChainingWithMultipleAliases() {
6165
}
6266

6367
@Test
64-
void removeAliasTest() {
65-
SimpleAliasRegistry registry = new SimpleAliasRegistry();
66-
registry.registerAlias("realname", "nickname");
67-
assertThat(registry.hasAlias("realname", "nickname")).isTrue();
68+
void removeAlias() {
69+
registry.registerAlias("real_name", "nickname");
70+
assertThat(registry.hasAlias("real_name", "nickname")).isTrue();
6871

6972
registry.removeAlias("nickname");
70-
assertThat(registry.hasAlias("realname", "nickname")).isFalse();
73+
assertThat(registry.hasAlias("real_name", "nickname")).isFalse();
7174
}
7275

7376
@Test
74-
void isAliasTest() {
75-
SimpleAliasRegistry registry = new SimpleAliasRegistry();
76-
registry.registerAlias("realname", "nickname");
77+
void isAlias() {
78+
registry.registerAlias("real_name", "nickname");
7779
assertThat(registry.isAlias("nickname")).isTrue();
80+
assertThat(registry.isAlias("real_name")).isFalse();
7881
assertThat(registry.isAlias("fake")).isFalse();
7982
}
8083

8184
@Test
82-
void getAliasesTest() {
83-
SimpleAliasRegistry registry = new SimpleAliasRegistry();
84-
registry.registerAlias("realname", "nickname");
85-
assertThat(registry.getAliases("realname"));
85+
void getAliases() {
86+
registry.registerAlias("test", "testAlias1");
87+
assertThat(registry.getAliases("test")).containsExactly("testAlias1");
88+
89+
registry.registerAlias("testAlias1", "testAlias2");
90+
registry.registerAlias("testAlias2", "testAlias3");
91+
assertThat(registry.getAliases("test")).containsExactlyInAnyOrder("testAlias1", "testAlias2", "testAlias3");
92+
assertThat(registry.getAliases("testAlias1")).containsExactlyInAnyOrder("testAlias2", "testAlias3");
93+
assertThat(registry.getAliases("testAlias2")).containsExactly("testAlias3");
94+
95+
assertThat(registry.getAliases("testAlias3")).isEmpty();
8696
}
97+
8798
}

0 commit comments

Comments
 (0)