parent
345d8186d4
commit
432fdad7d0
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -21,13 +21,18 @@ import org.junit.jupiter.api.Test;
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Unit tests for {@link SimpleAliasRegistry}.
|
||||||
|
*
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
* @author Nha Vuong
|
||||||
|
* @author Sam Brannen
|
||||||
*/
|
*/
|
||||||
class SimpleAliasRegistryTests {
|
class SimpleAliasRegistryTests {
|
||||||
|
|
||||||
|
private final SimpleAliasRegistry registry = new SimpleAliasRegistry();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void aliasChaining() {
|
void aliasChaining() {
|
||||||
SimpleAliasRegistry registry = new SimpleAliasRegistry();
|
|
||||||
registry.registerAlias("test", "testAlias");
|
registry.registerAlias("test", "testAlias");
|
||||||
registry.registerAlias("testAlias", "testAlias2");
|
registry.registerAlias("testAlias", "testAlias2");
|
||||||
registry.registerAlias("testAlias2", "testAlias3");
|
registry.registerAlias("testAlias2", "testAlias3");
|
||||||
|
|
@ -42,7 +47,6 @@ class SimpleAliasRegistryTests {
|
||||||
|
|
||||||
@Test // SPR-17191
|
@Test // SPR-17191
|
||||||
void aliasChainingWithMultipleAliases() {
|
void aliasChainingWithMultipleAliases() {
|
||||||
SimpleAliasRegistry registry = new SimpleAliasRegistry();
|
|
||||||
registry.registerAlias("name", "alias_a");
|
registry.registerAlias("name", "alias_a");
|
||||||
registry.registerAlias("name", "alias_b");
|
registry.registerAlias("name", "alias_b");
|
||||||
assertThat(registry.hasAlias("name", "alias_a")).isTrue();
|
assertThat(registry.hasAlias("name", "alias_a")).isTrue();
|
||||||
|
|
@ -61,27 +65,34 @@ class SimpleAliasRegistryTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void removeAliasTest() {
|
void removeAlias() {
|
||||||
SimpleAliasRegistry registry = new SimpleAliasRegistry();
|
registry.registerAlias("real_name", "nickname");
|
||||||
registry.registerAlias("realname", "nickname");
|
assertThat(registry.hasAlias("real_name", "nickname")).isTrue();
|
||||||
assertThat(registry.hasAlias("realname", "nickname")).isTrue();
|
|
||||||
|
|
||||||
registry.removeAlias("nickname");
|
registry.removeAlias("nickname");
|
||||||
assertThat(registry.hasAlias("realname", "nickname")).isFalse();
|
assertThat(registry.hasAlias("real_name", "nickname")).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isAliasTest() {
|
void isAlias() {
|
||||||
SimpleAliasRegistry registry = new SimpleAliasRegistry();
|
registry.registerAlias("real_name", "nickname");
|
||||||
registry.registerAlias("realname", "nickname");
|
|
||||||
assertThat(registry.isAlias("nickname")).isTrue();
|
assertThat(registry.isAlias("nickname")).isTrue();
|
||||||
|
assertThat(registry.isAlias("real_name")).isFalse();
|
||||||
assertThat(registry.isAlias("fake")).isFalse();
|
assertThat(registry.isAlias("fake")).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getAliasesTest() {
|
void getAliases() {
|
||||||
SimpleAliasRegistry registry = new SimpleAliasRegistry();
|
registry.registerAlias("test", "testAlias1");
|
||||||
registry.registerAlias("realname", "nickname");
|
assertThat(registry.getAliases("test")).containsExactly("testAlias1");
|
||||||
assertThat(registry.getAliases("realname"));
|
|
||||||
|
registry.registerAlias("testAlias1", "testAlias2");
|
||||||
|
registry.registerAlias("testAlias2", "testAlias3");
|
||||||
|
assertThat(registry.getAliases("test")).containsExactlyInAnyOrder("testAlias1", "testAlias2", "testAlias3");
|
||||||
|
assertThat(registry.getAliases("testAlias1")).containsExactlyInAnyOrder("testAlias2", "testAlias3");
|
||||||
|
assertThat(registry.getAliases("testAlias2")).containsExactly("testAlias3");
|
||||||
|
|
||||||
|
assertThat(registry.getAliases("testAlias3")).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue