Exemple #1
0
  @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));
  }
Exemple #2
0
 private Either<SourcePath, Pair<SourcePath, String>> newEntry(String path) {
   return Either.ofLeft((SourcePath) new FileSourcePath(path));
 }