1
1
/*
2
- * Copyright 2002-2020 the original author or authors.
2
+ * Copyright 2002-2021 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
21
21
import static org .assertj .core .api .Assertions .assertThat ;
22
22
23
23
/**
24
+ * Unit tests for {@link SimpleAliasRegistry}.
25
+ *
24
26
* @author Juergen Hoeller
27
+ * @author Nha Vuong
28
+ * @author Sam Brannen
25
29
*/
26
30
class SimpleAliasRegistryTests {
27
31
32
+ private final SimpleAliasRegistry registry = new SimpleAliasRegistry ();
33
+
28
34
@ Test
29
35
void aliasChaining () {
30
- SimpleAliasRegistry registry = new SimpleAliasRegistry ();
31
36
registry .registerAlias ("test" , "testAlias" );
32
37
registry .registerAlias ("testAlias" , "testAlias2" );
33
38
registry .registerAlias ("testAlias2" , "testAlias3" );
@@ -42,7 +47,6 @@ void aliasChaining() {
42
47
43
48
@ Test // SPR-17191
44
49
void aliasChainingWithMultipleAliases () {
45
- SimpleAliasRegistry registry = new SimpleAliasRegistry ();
46
50
registry .registerAlias ("name" , "alias_a" );
47
51
registry .registerAlias ("name" , "alias_b" );
48
52
assertThat (registry .hasAlias ("name" , "alias_a" )).isTrue ();
@@ -61,27 +65,34 @@ void aliasChainingWithMultipleAliases() {
61
65
}
62
66
63
67
@ 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 ();
68
71
69
72
registry .removeAlias ("nickname" );
70
- assertThat (registry .hasAlias ("realname " , "nickname" )).isFalse ();
73
+ assertThat (registry .hasAlias ("real_name " , "nickname" )).isFalse ();
71
74
}
72
75
73
76
@ Test
74
- void isAliasTest () {
75
- SimpleAliasRegistry registry = new SimpleAliasRegistry ();
76
- registry .registerAlias ("realname" , "nickname" );
77
+ void isAlias () {
78
+ registry .registerAlias ("real_name" , "nickname" );
77
79
assertThat (registry .isAlias ("nickname" )).isTrue ();
80
+ assertThat (registry .isAlias ("real_name" )).isFalse ();
78
81
assertThat (registry .isAlias ("fake" )).isFalse ();
79
82
}
80
83
81
84
@ 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 ();
86
96
}
97
+
87
98
}
0 commit comments