Java Code Examples for com.google.common.collect.FluentIterable#of()

The following examples show how to use com.google.common.collect.FluentIterable#of() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XcodeNativeTargetGeneratorTest.java    From buck with Apache License 2.0 6 votes vote down vote up
@Test
public void testSwapWithSharedBundes() {
  BuildTarget sharedLibrary = BuildTargetFactory.newInstance("//foo:shared#shared");
  BuildTarget bundleTarget = BuildTargetFactory.newInstance("//foo", "sharedFramework");

  TargetNode<?> bundleNode =
      AppleBundleBuilder.createBuilder(bundleTarget)
          .setBinary(sharedLibrary)
          .setExtension(Either.ofLeft(AppleBundleExtension.FRAMEWORK))
          .setInfoPlist(FakeSourcePath.of("Info.plist"))
          .setProductName(Optional.of("shared"))
          .build();

  TargetNode<?> sharedNode = AppleLibraryBuilder.createBuilder(sharedLibrary).build();

  ImmutableMap<BuildTarget, TargetNode<?>> sharedLibraryToBundle =
      ImmutableMap.of(sharedLibrary, bundleNode);

  FluentIterable<TargetNode<?>> input = FluentIterable.of(sharedNode);
  FluentIterable<TargetNode<?>> output =
      XcodeNativeTargetGenerator.swapSharedLibrariesForBundles(input, sharedLibraryToBundle);
  assertTrue(output.contains(bundleNode));
  assertFalse(output.contains(sharedNode));
  assertEquals(output.size(), 1);
}
 
Example 2
Source File: GivenMembersTest.java    From ArchUnit with Apache License 2.0 5 votes vote down vote up
@SafeVarargs
private static <T> Set<T> union(Set<T>... sets) {
    FluentIterable<T> result = FluentIterable.of();
    for (Set<T> set : sets) {
        result = result.append(set);
    }
    return result.toSet();
}
 
Example 3
Source File: FluentIterableUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void whenCreatingFluentIterableFromArray_shouldContainAllUsers() throws Exception {
    User[] usersArray = {new User(1L, "John", 45), new User(2L, "Max", 15)};
    FluentIterable<User> users = FluentIterable.of(usersArray);

    Assert.assertThat(users.size(), equalTo(2));
}
 
Example 4
Source File: FluentIterableUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void whenJoiningFluentIterableElements_shouldOutputAllUsers() throws Exception {
    User[] usersArray = {new User(1L, "John", 45), new User(2L, "Max", 15)};

    FluentIterable<User> users = FluentIterable.of(usersArray);

    Assert.assertThat(users.join(Joiner.on("; ")),
            equalTo("User{id=1, name=John, age=45}; User{id=2, name=Max, age=15}"));
}
 
Example 5
Source File: BeanFriendlyTest.java    From immutables with Apache License 2.0 5 votes vote down vote up
@Test
public void modifiableAsJavaBean() throws Exception {
  ImmutableSet<String> rwProperties =
      ImmutableSet.of("primary", "id", "description", "names", "options", "extra");

  FluentIterable<PropertyDescriptor> propertyDescriptors =
      FluentIterable.of(
          Introspector.getBeanInfo(ModifiableBeanFriendly.class)
              .getPropertyDescriptors());

  check(propertyDescriptors.transform(p -> p.getName()).toSet().containsAll(rwProperties));

  for (PropertyDescriptor pd : propertyDescriptors) {
    check(pd.getReadMethod()).notNull();
    if (rwProperties.contains(pd.getName())) {
      check(pd.getWriteMethod()).notNull();
    }
  }

  ModifiableBeanFriendly bean = new ModifiableBeanFriendly();
  bean.setPrimary(true);
  bean.setDescription("description");
  bean.setId(1000);
  bean.setNames(ImmutableList.of("name"));
  bean.addNames("name2");
  bean.putOptions("foo", "bar");

  // This bean can become immutable.
  BeanFriendly immutableBean = bean.toImmutable();
  check(immutableBean.isPrimary());
  check(immutableBean.getDescription()).is("description");
  check(immutableBean.getId()).is(1000);
  check(immutableBean.getNames()).isOf("name", "name2");
  check(immutableBean.getOptions()).is(ImmutableMap.of("foo", "bar"));
}