Example #1
0
  @Test
  public void coercingAppleSourcePaths() throws NoSuchFieldException, CoerceFailedException {
    Type type = TestFields.class.getField("listOfAppleSources").getGenericType();
    TypeCoercer<?> coercer = typeCoercerFactory.typeCoercerForType(type);

    ImmutableList<String> input = ImmutableList.of("foo.m", "bar.m");
    Object result = coercer.coerce(buildRuleResolver, filesystem, Paths.get(""), input);
    ImmutableList<AppleSource> expectedResult =
        ImmutableList.of(
            AppleSource.ofSourcePath(new TestSourcePath("foo.m")),
            AppleSource.ofSourcePath(new TestSourcePath("bar.m")));
    assertEquals(expectedResult, result);
  }
Example #2
0
  @Test
  public void coercingHeterogeneousAppleSourceGroups()
      throws NoSuchFieldException, CoerceFailedException {
    Type type = TestFields.class.getField("listOfAppleSources").getGenericType();
    TypeCoercer<?> coercer = typeCoercerFactory.typeCoercerForType(type);

    ImmutableList<?> input =
        ImmutableList.of(
            ImmutableList.of(
                "Group1", ImmutableList.of("foo.m", ImmutableList.of("bar.m", "-Wall"))),
            ImmutableList.of(
                "Group2", ImmutableList.of("baz.m", ImmutableList.of("blech.m", "-fobjc-arc"))));
    Object result = coercer.coerce(buildRuleResolver, filesystem, Paths.get(""), input);
    ImmutableList<AppleSource> expectedResult =
        ImmutableList.of(
            AppleSource.ofSourceGroup(
                new Pair<>(
                    "Group1",
                    ImmutableList.of(
                        AppleSource.ofSourcePath(new TestSourcePath("foo.m")),
                        AppleSource.ofSourcePathWithFlags(
                            new Pair<SourcePath, String>(new TestSourcePath("bar.m"), "-Wall"))))),
            AppleSource.ofSourceGroup(
                new Pair<>(
                    "Group2",
                    ImmutableList.of(
                        AppleSource.ofSourcePath(new TestSourcePath("baz.m")),
                        AppleSource.ofSourcePathWithFlags(
                            new Pair<SourcePath, String>(
                                new TestSourcePath("blech.m"), "-fobjc-arc"))))));
    assertEquals(expectedResult, result);
  }