summaryrefslogtreecommitdiff
path: root/src/test/java/sevenUnits/utils/NameSymbolTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/sevenUnits/utils/NameSymbolTest.java')
-rw-r--r--src/test/java/sevenUnits/utils/NameSymbolTest.java76
1 files changed, 45 insertions, 31 deletions
diff --git a/src/test/java/sevenUnits/utils/NameSymbolTest.java b/src/test/java/sevenUnits/utils/NameSymbolTest.java
index 3ae2448..f8843e0 100644
--- a/src/test/java/sevenUnits/utils/NameSymbolTest.java
+++ b/src/test/java/sevenUnits/utils/NameSymbolTest.java
@@ -33,37 +33,65 @@ import org.junit.jupiter.params.provider.MethodSource;
/**
* Tests for the {@link NameSymbol} class.
- *
+ *
* @since v1.0.0
*/
class NameSymbolTest {
private static Stream<Arguments> testEqualsHashCode() {
return Stream.of(
- Arguments.of(NameSymbol.ofName("test"), NameSymbol.ofName("test"), true),
+ Arguments.of(NameSymbol.ofName("test"), NameSymbol.ofName("test"),
+ true),
Arguments.of(NameSymbol.ofName("a"), NameSymbol.ofName("b"), false),
- Arguments.of(NameSymbol.ofSymbol("test"), NameSymbol.ofSymbol("test"), true),
- Arguments.of(NameSymbol.ofSymbol("a"), NameSymbol.ofSymbol("b"), false),
- Arguments.of(NameSymbol.ofName("test"), NameSymbol.ofSymbol("test"), false),
- Arguments.of(NameSymbol.of("main", "s"), NameSymbol.of("main", "s"), true),
- Arguments.of(NameSymbol.of("main", "s"), NameSymbol.of("main", "s", "m"), false),
+ Arguments.of(NameSymbol.ofSymbol("test"),
+ NameSymbol.ofSymbol("test"), true),
+ Arguments.of(NameSymbol.ofSymbol("a"), NameSymbol.ofSymbol("b"),
+ false),
+ Arguments.of(NameSymbol.ofName("test"), NameSymbol.ofSymbol("test"),
+ false),
+ Arguments.of(NameSymbol.of("main", "s"), NameSymbol.of("main", "s"),
+ true),
+ Arguments.of(NameSymbol.of("main", "s"),
+ NameSymbol.of("main", "s", "m"), false),
Arguments.of(new NameSymbol(null, null, new HashSet<>()),
new NameSymbol(null, null, new HashSet<>()), true),
- Arguments.of(new NameSymbol(
- Optional.of("main"), Optional.of("s"), new HashSet<>()),
+ Arguments.of(
+ new NameSymbol(Optional.of("main"), Optional.of("s"),
+ new HashSet<>()),
new NameSymbol(null, null, new HashSet<>()), false),
Arguments.of(new NameSymbol(null, null, new HashSet<>()),
new NameSymbol(Optional.of("main"), Optional.of("s"),
- new HashSet<>()), false),
- Arguments.of(new NameSymbol(Optional.of("main"), null, new HashSet<>()),
+ new HashSet<>()),
+ false),
+ Arguments.of(
+ new NameSymbol(Optional.of("main"), null, new HashSet<>()),
new NameSymbol(Optional.of("main"), Optional.of("s"),
- new HashSet<>()), false));
+ new HashSet<>()),
+ false));
+ }
+
+ @Test
+ public void testCreate() {
+ final Set<String> names = Set.of("a", "b", "c");
+ final var ns = NameSymbol.ofNullable(null, null, names);
+ assertTrue(ns.getPrimaryName().isPresent(),
+ "NameSymbol created without primary name.");
+ assertTrue(names.contains(ns.getPrimaryName().orElseThrow()),
+ String.format("Primary name (%s) was not obtained from names set.",
+ ns.getPrimaryName()));
+ assertFalse(
+ ns.getOtherNames().contains(ns.getPrimaryName().orElseThrow()),
+ String.format("Primary name (%s) was included in other names set.",
+ ns.getPrimaryName()));
+ assertEquals(Set.of("a", "b", "c"), names,
+ "names input was changed by ofNullable()");
}
-
+
/**
- * Tests that two NameSymbols are or are not equal.
- * If they are equal, also ensures they have the same hash code.
- * @param a first NameSymbol to test
- * @param b second NameSymbol to test
+ * Tests that two NameSymbols are or are not equal. If they are equal, also
+ * ensures they have the same hash code.
+ *
+ * @param a first NameSymbol to test
+ * @param b second NameSymbol to test
* @param equal true iff a should be equal to be, otherwise false
*/
@ParameterizedTest
@@ -77,18 +105,4 @@ class NameSymbolTest {
assertFalse(Objects.equals(a, b));
}
}
-
- @Test
- public void testCreate() {
- Set<String> names = Set.of("a", "b", "c");
- NameSymbol ns = NameSymbol.ofNullable(null, null, names);
- assertTrue(ns.getPrimaryName().isPresent(), "NameSymbol created without primary name.");
- assertTrue(names.contains(ns.getPrimaryName().orElseThrow()),
- String.format("Primary name (%s) was not obtained from names set.",
- ns.getPrimaryName()));
- assertFalse(ns.getOtherNames().contains(ns.getPrimaryName().orElseThrow()),
- String.format("Primary name (%s) was included in other names set.",
- ns.getPrimaryName()));
- assertEquals(Set.of("a", "b", "c"), names, "names input was changed by ofNullable()");
- }
}