use of com.google.common.collect.FluentIterable in project buck by facebook.
the class ParsePipelineTest method speculativeDepsTraversalWhenGettingAllNodes.
@Test
public void speculativeDepsTraversalWhenGettingAllNodes() throws Exception {
final Fixture fixture = createMultiThreadedFixture("pipeline_test");
final Cell cell = fixture.getCell();
ImmutableSet<TargetNode<?, ?>> libTargetNodes = fixture.getTargetNodeParsePipeline().getAllNodes(cell, fixture.getCell().getFilesystem().resolve("BUCK"));
FluentIterable<BuildTarget> allDeps = FluentIterable.from(libTargetNodes).transformAndConcat(new Function<TargetNode<?, ?>, Iterable<BuildTarget>>() {
@Override
public Iterable<BuildTarget> apply(TargetNode<?, ?> input) {
return input.getDeps();
}
});
waitForAll(allDeps, dep -> fixture.getTargetNodeParsePipelineCache().lookupComputedNode(cell, dep) != null);
fixture.close();
}
use of com.google.common.collect.FluentIterable in project immutables by immutables.
the class BeanFriendlyTest method modifiableAsJavaBean.
@Test
public void modifiableAsJavaBean() throws Exception {
ImmutableSet<String> rwProperties = ImmutableSet.of("primary", "id", "description", "names", "options");
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"));
}
use of com.google.common.collect.FluentIterable in project gerrit by GerritCodeReview.
the class AccountIT method assertKeys.
private void assertKeys(Iterable<TestKey> expectedKeys) throws Exception {
// Check via API.
FluentIterable<TestKey> expected = FluentIterable.from(expectedKeys);
Map<String, GpgKeyInfo> keyMap = gApi.accounts().self().listGpgKeys();
assertThat(keyMap.keySet()).named("keys returned by listGpgKeys()").containsExactlyElementsIn(expected.transform(TestKey::getKeyIdString));
for (TestKey key : expected) {
assertKeyEquals(key, gApi.accounts().self().gpgKey(key.getKeyIdString()).get());
assertKeyEquals(key, gApi.accounts().self().gpgKey(Fingerprint.toString(key.getPublicKey().getFingerprint())).get());
assertKeyMapContains(key, keyMap);
}
// Check raw external IDs.
Account.Id currAccountId = atrScope.get().getUser().getAccountId();
Iterable<String> expectedFps = expected.transform(k -> BaseEncoding.base16().encode(k.getPublicKey().getFingerprint()));
Iterable<String> actualFps = externalIds.byAccount(currAccountId, SCHEME_GPGKEY).stream().map(e -> e.key().id()).collect(toSet());
assertThat(actualFps).named("external IDs in database").containsExactlyElementsIn(expectedFps);
// Check raw stored keys.
for (TestKey key : expected) {
getOnlyKeyFromStore(key);
}
}
use of com.google.common.collect.FluentIterable in project crate by crate.
the class ExecutionPhasesTask method executeBulk.
@Override
public List<CompletableFuture<Long>> executeBulk() {
FluentIterable<NodeOperation> nodeOperations = FluentIterable.from(nodeOperationTrees).transformAndConcat(new Function<NodeOperationTree, Iterable<? extends NodeOperation>>() {
@Nullable
@Override
public Iterable<? extends NodeOperation> apply(NodeOperationTree input) {
return input.nodeOperations();
}
});
Map<String, Collection<NodeOperation>> operationByServer = NodeOperationGrouper.groupByServer(nodeOperations);
List<ExecutionPhase> handlerPhases = new ArrayList<>(nodeOperationTrees.size());
List<BatchConsumer> handlerConsumers = new ArrayList<>(nodeOperationTrees.size());
List<CompletableFuture<Long>> results = new ArrayList<>(nodeOperationTrees.size());
for (NodeOperationTree nodeOperationTree : nodeOperationTrees) {
CollectingBatchConsumer<?, Long> consumer = new CollectingBatchConsumer<>(Collectors.collectingAndThen(Collectors.summingLong(r -> ((long) r.get(0))), sum -> sum));
handlerConsumers.add(consumer);
results.add(consumer.resultFuture());
handlerPhases.add(nodeOperationTree.leaf());
}
try {
setupContext(operationByServer, handlerPhases, handlerConsumers);
} catch (Throwable throwable) {
return Collections.singletonList(CompletableFutures.failedFuture(throwable));
}
return results;
}
use of com.google.common.collect.FluentIterable in project buck by facebook.
the class AppleBundleDescription method findDepsForTargetFromConstructorArgs.
/**
* Propagate the bundle's platform, debug symbol and strip flavors to its dependents
* which are other bundles (e.g. extensions)
*/
@Override
public ImmutableSet<BuildTarget> findDepsForTargetFromConstructorArgs(BuildTarget buildTarget, CellPathResolver cellRoots, AppleBundleDescription.Arg constructorArg) {
if (!cxxPlatformFlavorDomain.containsAnyOf(buildTarget.getFlavors())) {
buildTarget = BuildTarget.builder(buildTarget).addAllFlavors(ImmutableSet.of(defaultCxxPlatform.getFlavor())).build();
}
Optional<MultiarchFileInfo> fatBinaryInfo = MultiarchFileInfos.create(appleCxxPlatformsFlavorDomain, buildTarget);
CxxPlatform cxxPlatform;
if (fatBinaryInfo.isPresent()) {
AppleCxxPlatform appleCxxPlatform = fatBinaryInfo.get().getRepresentativePlatform();
cxxPlatform = appleCxxPlatform.getCxxPlatform();
} else {
cxxPlatform = ApplePlatforms.getCxxPlatformForBuildTarget(cxxPlatformFlavorDomain, defaultCxxPlatform, buildTarget);
}
String platformName = cxxPlatform.getFlavor().getName();
final Flavor actualWatchFlavor;
if (ApplePlatform.isSimulator(platformName)) {
actualWatchFlavor = WATCH_SIMULATOR_FLAVOR;
} else if (platformName.startsWith(ApplePlatform.IPHONEOS.getName()) || platformName.startsWith(ApplePlatform.WATCHOS.getName())) {
actualWatchFlavor = WATCH_OS_FLAVOR;
} else {
actualWatchFlavor = InternalFlavor.of(platformName);
}
FluentIterable<BuildTarget> depsExcludingBinary = FluentIterable.from(constructorArg.deps).filter(Predicates.not(constructorArg.binary::equals));
// Propagate platform flavors. Need special handling for watch to map the pseudo-flavor
// watch to the actual watch platform (simulator or device) so can't use
// BuildTargets.propagateFlavorsInDomainIfNotPresent()
{
FluentIterable<BuildTarget> targetsWithPlatformFlavors = depsExcludingBinary.filter(BuildTargets.containsFlavors(cxxPlatformFlavorDomain));
FluentIterable<BuildTarget> targetsWithoutPlatformFlavors = depsExcludingBinary.filter(Predicates.not(BuildTargets.containsFlavors(cxxPlatformFlavorDomain)));
FluentIterable<BuildTarget> watchTargets = targetsWithoutPlatformFlavors.filter(BuildTargets.containsFlavor(WATCH)).transform(input -> BuildTarget.builder(input.withoutFlavors(WATCH)).addFlavors(actualWatchFlavor).build());
targetsWithoutPlatformFlavors = targetsWithoutPlatformFlavors.filter(Predicates.not(BuildTargets.containsFlavor(WATCH)));
// Gather all the deps now that we've added platform flavors to everything.
depsExcludingBinary = targetsWithPlatformFlavors.append(watchTargets).append(BuildTargets.propagateFlavorDomains(buildTarget, ImmutableSet.of(cxxPlatformFlavorDomain), targetsWithoutPlatformFlavors));
}
// Propagate some flavors
depsExcludingBinary = BuildTargets.propagateFlavorsInDomainIfNotPresent(StripStyle.FLAVOR_DOMAIN, buildTarget, depsExcludingBinary);
depsExcludingBinary = BuildTargets.propagateFlavorsInDomainIfNotPresent(AppleDebugFormat.FLAVOR_DOMAIN, buildTarget, depsExcludingBinary);
depsExcludingBinary = BuildTargets.propagateFlavorsInDomainIfNotPresent(LinkerMapMode.FLAVOR_DOMAIN, buildTarget, depsExcludingBinary);
if (fatBinaryInfo.isPresent()) {
depsExcludingBinary = depsExcludingBinary.append(fatBinaryInfo.get().getRepresentativePlatform().getCodesignProvider().getParseTimeDeps());
} else {
depsExcludingBinary = depsExcludingBinary.append(appleCxxPlatformsFlavorDomain.getValue(buildTarget).map(platform -> platform.getCodesignProvider().getParseTimeDeps()).orElse(ImmutableSet.of()));
}
return ImmutableSet.copyOf(depsExcludingBinary);
}
Aggregations