@Test public void coerceToEitherLeftOrRight() throws NoSuchFieldException, CoerceFailedException { Type type = TestFields.class.getField("eitherStringOrStringList").getGenericType(); TypeCoercer<?> coercer = typeCoercerFactory.typeCoercerForType(type); String inputString = "a_string"; ImmutableList<String> inputList = ImmutableList.of("a", "b"); assertEquals( Either.ofLeft(inputString), coercer.coerce(buildRuleResolver, filesystem, Paths.get(""), inputString)); assertEquals( Either.ofRight(inputList), coercer.coerce(buildRuleResolver, filesystem, Paths.get(""), inputList)); }
private Either<SourcePath, Pair<SourcePath, String>> newEntry(String path, String flags) { return Either.ofRight(new Pair<SourcePath, String>(new FileSourcePath(path), flags)); }