mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-22 16:18:32 +00:00
fix RegistryTest
This commit is contained in:
@@ -39,19 +39,19 @@ public class RegistryTest {
|
||||
public void openRegistry() {
|
||||
OpenRegistry<String> test = new OpenRegistryImpl<>(TypeKey.of(String.class));
|
||||
|
||||
test.register(RegistryKey.parse("test:test"), "bazinga");
|
||||
RegistryKey.parse("test:test").ifRight(r -> test.register(r, "bazinga"));
|
||||
|
||||
assertEquals(test.get(RegistryKey.parse("test:test")).orThrow(), "bazinga");
|
||||
assertEquals("bazinga", test.get(RegistryKey.parse("test:test").getRight().orThrow()).orThrow());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void openRegistryChecked() {
|
||||
OpenRegistry<String> test = new OpenRegistryImpl<>(TypeKey.of(String.class));
|
||||
|
||||
test.registerChecked(RegistryKey.parse("test:test"), "bazinga");
|
||||
RegistryKey.parse("test:test").ifRight(r -> test.registerChecked(r, "bazinga"));
|
||||
|
||||
try {
|
||||
test.registerChecked(RegistryKey.parse("test:test"), "bazinga2");
|
||||
RegistryKey.parse("test:test").ifRight(r -> test.registerChecked(r, "bazinga2"));
|
||||
fail("Shouldn't be able to re-register with #registerChecked!");
|
||||
} catch(DuplicateEntryException ignore) {
|
||||
|
||||
@@ -62,12 +62,12 @@ public class RegistryTest {
|
||||
public void checkedRegistry() {
|
||||
CheckedRegistry<String> test = new CheckedRegistryImpl<>(new OpenRegistryImpl<>(TypeKey.of(String.class)));
|
||||
|
||||
test.register(RegistryKey.parse("test:test"), "bazinga");
|
||||
RegistryKey.parse("test:test").ifRight(r -> test.register(r, "bazinga"));
|
||||
|
||||
assertEquals(test.get(RegistryKey.parse("test:test")).orThrow(), "bazinga");
|
||||
assertEquals("bazinga", test.get(RegistryKey.parse("test:test").getRight().orThrow()).orThrow());
|
||||
|
||||
try {
|
||||
test.register(RegistryKey.parse("test:test"), "bazinga2");
|
||||
RegistryKey.parse("test:test").ifRight(r -> test.register(r, "bazinga2"));
|
||||
fail("Shouldn't be able to re-register in CheckedRegistry!");
|
||||
} catch(DuplicateEntryException ignore) {
|
||||
|
||||
@@ -78,7 +78,7 @@ public class RegistryTest {
|
||||
public void getID() {
|
||||
OpenRegistry<String> test = new OpenRegistryImpl<>(TypeKey.of(String.class));
|
||||
|
||||
test.register(RegistryKey.parse("test:test"), "bazinga");
|
||||
RegistryKey.parse("test:test").ifRight(r -> test.register(r, "bazinga"));
|
||||
|
||||
assertEquals(test.getByID("test").collectThrow(Invalid::toIllegal), "bazinga");
|
||||
}
|
||||
@@ -87,10 +87,10 @@ public class RegistryTest {
|
||||
public void getIDAmbiguous() {
|
||||
OpenRegistry<String> test = new OpenRegistryImpl<>(TypeKey.of(String.class));
|
||||
|
||||
test.registerChecked(RegistryKey.parse("test:test"), "bazinga");
|
||||
test.registerChecked(RegistryKey.parse("test2:test"), "bazinga");
|
||||
RegistryKey.parse("test:test").ifRight(r -> test.register(r, "bazinga"));
|
||||
RegistryKey.parse("test3:test").ifRight(r -> test.register(r, "bazinga"));
|
||||
|
||||
Either<InvalidLookup, String> result = test.getByID("test");
|
||||
Either<Invalid, String> result = test.getByID("test");
|
||||
assertTrue(result.isLeft());
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user