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

The following examples show how to use com.google.common.collect.ImmutableSet#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: RangerSystemAccessControlTest.java    From ranger with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("PMD")
public void testTableOperations()
{
  Set<SchemaTableName> aliceTables = ImmutableSet.of(new SchemaTableName("schema", "table"));
  assertEquals(accessControlManager.filterTables(context(alice), aliceCatalog, aliceTables), aliceTables);
  assertEquals(accessControlManager.filterTables(context(bob), "alice-catalog", aliceTables), ImmutableSet.of());

  accessControlManager.checkCanCreateTable(context(alice), aliceTable);
  accessControlManager.checkCanDropTable(context(alice), aliceTable);
  accessControlManager.checkCanSelectFromColumns(context(alice), aliceTable, ImmutableSet.of());
  accessControlManager.checkCanInsertIntoTable(context(alice), aliceTable);
  accessControlManager.checkCanDeleteFromTable(context(alice), aliceTable);
  accessControlManager.checkCanRenameColumn(context(alice), aliceTable);


  try {
    accessControlManager.checkCanCreateTable(context(bob), aliceTable);
  } catch (AccessDeniedException expected) {
  }
}
 
Example 2
Source File: TestRubixCaching.java    From presto with Apache License 2.0 6 votes vote down vote up
private FileSystem getCachingFileSystem(HdfsContext context, Path path)
        throws IOException
{
    HdfsConfigurationInitializer configurationInitializer = new HdfsConfigurationInitializer(config, ImmutableSet.of());
    HiveHdfsConfiguration configuration = new HiveHdfsConfiguration(
            configurationInitializer,
            ImmutableSet.of(
                    rubixConfigInitializer,
                    (dynamicConfig, ignoredContext, ignoredUri) -> {
                        dynamicConfig.set("fs.file.impl", CachingLocalFileSystem.class.getName());
                        dynamicConfig.setBoolean("fs.gs.lazy.init.enable", true);
                        dynamicConfig.set("fs.azure.account.key", "Zm9vCg==");
                        dynamicConfig.set("fs.adl.oauth2.client.id", "test");
                        dynamicConfig.set("fs.adl.oauth2.refresh.url", "http://localhost");
                        dynamicConfig.set("fs.adl.oauth2.credential", "password");
                    }));
    HdfsEnvironment environment = new HdfsEnvironment(configuration, config, new NoHdfsAuthentication());
    return environment.getFileSystem(context, path);
}
 
Example 3
Source File: ProcessComponentsTest.java    From closure-stylesheets with Apache License 2.0 6 votes vote down vote up
protected void testTreeConstructionWithResolve(
    ImmutableMap<String, String> fileNameToGss,
    String expectedOutput) {

  parseAndBuildTree(fileNameToGss);
  runPass();
  ResolveCustomFunctionNodesForChunks<String> resolveFunctions =
      new ResolveCustomFunctionNodesForChunks<String>(
          tree.getMutatingVisitController(), errorManager,
          ImmutableMap.of("someColorFunction", SOME_COLOR_FUNCTION),
          false /* allowUnknownFunctions */,
          ImmutableSet.<String>of() /* allowedNonStandardFunctions */,
          new UniqueSuffixFunction());
  resolveFunctions.runPass();
  checkTreeDebugString(expectedOutput);
}
 
Example 4
Source File: AppleDeviceControllerTest.java    From buck with Apache License 2.0 6 votes vote down vote up
@Test
public void getPhysicalDevicesTest() throws IOException {
  ImmutableSet<AppleDevice> physicalDevices;
  try (OutputStream stdin = new ByteArrayOutputStream();
      InputStream stdout = getClass().getResourceAsStream("testdata/idb-list.txt");
      InputStream stderr = new ByteArrayInputStream(new byte[0])) {
    FakeProcess fakeIdbList = new FakeProcess(0, stdin, stdout, stderr);
    ProcessExecutorParams processExecutorParams =
        ProcessExecutorParams.builder()
            .setCommand(ImmutableList.of(IDB_PATH.toString(), "list-targets", "--json"))
            .build();
    FakeProcessExecutor fakeProcessExecutor =
        new FakeProcessExecutor(ImmutableMap.of(processExecutorParams, fakeIdbList));
    AppleDeviceController deviceController =
        new AppleDeviceController(fakeProcessExecutor, IDB_PATH);
    physicalDevices = deviceController.getPhysicalDevices();
  }

  ImmutableSet<ImmutableAppleDevice> expected =
      ImmutableSet.of(
          ImmutableAppleDevice.of("iPhone", "", "Booted", "device", "iOS 12.4", "arm64"));

  assertEquals(physicalDevices, expected);
}
 
Example 5
Source File: AnalysisEventRequirementTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test event requirements on a trace with no pre-defined events. They
 * should all pass
 */
@Test
public void testNoPreDefinedEvents() {
    /* A simple trace with no pre-defined events */
    TmfTrace traceNoEvents = new TmfTraceStub();

    TmfAbstractAnalysisRequirement req = new TmfAnalysisEventRequirement(ImmutableSet.of(EVENT1, EVENT3), PriorityLevel.MANDATORY);
    assertTrue(req.test(traceNoEvents));

    req = new TmfAnalysisEventRequirement(ImmutableSet.of(EVENT1, EVENT2), PriorityLevel.OPTIONAL);
    assertTrue(req.test(traceNoEvents));

    traceNoEvents.dispose();
}
 
Example 6
Source File: OspfProcess.java    From batfish with Apache License 2.0 5 votes vote down vote up
private Builder(@Nullable Supplier<String> processIdGenerator) {
  // Default to Cisco IOS values
  _adminCosts = computeDefaultAdminCosts(ConfigurationFormat.CISCO_IOS);
  _areas = ImmutableMap.of();
  _exportPolicySources = ImmutableSet.of();
  _neighborConfigs = ImmutableMap.of();
  _processIdGenerator = processIdGenerator;
  // Default to Cisco IOS value
  _summaryAdminCost =
      RoutingProtocol.OSPF_IA.getSummaryAdministrativeCost(ConfigurationFormat.CISCO_IOS);
  _generatedRoutes = ImmutableSet.of();
}
 
Example 7
Source File: TestDirectedGraph.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddVertices() throws Exception {
  Set<String> toBeAddedVertices = ImmutableSet.of("a", "b", "c");

  DirectedGraph<String> directedGraph = new DirectedGraph<>();
  Assert.assertTrue(directedGraph.addVertex("a"));
  Assert.assertTrue(directedGraph.addVertex("b"));
  Assert.assertTrue(directedGraph.addVertex("c"));

  Assert.assertEquals(3, directedGraph.vertices().size());
  Assert.assertTrue(toBeAddedVertices.containsAll(directedGraph.vertices()));
  Assert.assertTrue(directedGraph.vertices().containsAll(toBeAddedVertices));
}
 
Example 8
Source File: SystemTableRulesFactory.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Override
public Set<RelOptRule> getRules(OptimizerRulesContext optimizerContext, PlannerPhase phase, SourceType pluginType) {
  switch(phase) {
  case LOGICAL:
    return ImmutableSet.<RelOptRule>of(new SystemScanDrule(pluginType));

  case PHYSICAL:
    return ImmutableSet.of(SystemScanPrule.INSTANCE);

  default:
    return ImmutableSet.of();
  }
}
 
Example 9
Source File: Odin.java    From baleen with Apache License 2.0 5 votes vote down vote up
@Override
public AnalysisEngineAction getAction() {
  return new AnalysisEngineAction(
      ImmutableSet.of(
          Entity.class, Sentence.class, Paragraph.class, Temporal.class, Location.class),
      ImmutableSet.of(Event.class));
}
 
Example 10
Source File: OCamlIntegrationTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompilerFlagsDependency() throws IOException, InterruptedException {
  ProjectWorkspace workspace =
      TestDataHelper.createProjectWorkspaceForScenario(
          this, "compiler_flag_macros", tmp.newFolder());
  workspace.setUp();

  String ocamlVersion = this.getOcamlVersion(workspace);
  assumeTrue("Installed ocaml is too old for this test", "4.02.0".compareTo(ocamlVersion) <= 0);

  BuildTarget binary = BuildTargetFactory.newInstance("//:main");
  BuildTarget lib = BuildTargetFactory.newInstance("//:lib");
  BuildTarget helper = BuildTargetFactory.newInstance("//:test");
  ImmutableSet<BuildTarget> targets = ImmutableSet.of(binary, lib, helper);

  // Build the binary.
  workspace.runBuckCommand("build", binary.toString()).assertSuccess();

  // Make sure the helper target is built as well.
  BuckBuildLog buildLog = workspace.getBuildLog();
  assertTrue(buildLog.getAllTargets().containsAll(targets));
  buildLog.assertTargetBuiltLocally(binary);

  // Make sure the ppx flag worked
  String out = workspace.runBuckCommand("run", binary.toString()).getStdout();
  assertEquals("42!\n", out);
}
 
Example 11
Source File: CorsFilterTest.java    From vics with MIT License 5 votes vote down vote up
@Test
public void allowsTheHostIfDefined() throws Exception {
    given(req.getHeader("Origin")).willReturn("http://135.31.22.221");
    CorsConfig allowedHosts = new CorsConfig(ImmutableSet.of("http://135.31.22.221"), "");
    CorsFilter underTest = new CorsFilter(allowedHosts);

    underTest.doFilter(req, res, chain);

    verify(res, times(1)).setHeader("Access-Control-Allow-Origin", "http://135.31.22.221");
}
 
Example 12
Source File: NullLocationSpecifier.java    From batfish with Apache License 2.0 4 votes vote down vote up
@Override
public Set<Location> resolve(SpecifierContext ctxt) {
  return ImmutableSet.of();
}
 
Example 13
Source File: HashSetStateTest.java    From Rails with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void testView() {
    ImmutableSet<Item> list = ImmutableSet.of(oneItem);
    assertEquals(list, stateInit.view());
}
 
Example 14
Source File: ToLowerCamelCaseFunction.java    From js-dossier with Apache License 2.0 4 votes vote down vote up
@Override
public Set<Integer> getValidArgsSizes() {
  return ImmutableSet.of(1);
}
 
Example 15
Source File: ThreadNumTaskFactory.java    From bistoury with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Set<Integer> codes() {
    return ImmutableSet.of(CommandCode.REQ_TYPE_CPU_THREAD_NUM.getCode());
}
 
Example 16
Source File: TestWindowNode.java    From presto with Apache License 2.0 4 votes vote down vote up
@Test
public void testSerializationRoundtrip()
        throws Exception
{
    Symbol windowSymbol = symbolAllocator.newSymbol("sum", BIGINT);
    ResolvedFunction resolvedFunction = metadata.resolveFunction(QualifiedName.of("sum"), fromTypes(BIGINT));
    WindowNode.Frame frame = new WindowNode.Frame(
            WindowFrame.Type.RANGE,
            FrameBound.Type.UNBOUNDED_PRECEDING,
            Optional.empty(),
            FrameBound.Type.UNBOUNDED_FOLLOWING,
            Optional.empty(),
            Optional.empty(),
            Optional.empty());

    PlanNodeId id = newId();
    WindowNode.Specification specification = new WindowNode.Specification(
            ImmutableList.of(columnA),
            Optional.of(new OrderingScheme(
                    ImmutableList.of(columnB),
                    ImmutableMap.of(columnB, SortOrder.ASC_NULLS_FIRST))));
    Map<Symbol, WindowNode.Function> functions = ImmutableMap.of(windowSymbol, new WindowNode.Function(resolvedFunction, ImmutableList.of(columnC.toSymbolReference()), frame, false));
    Optional<Symbol> hashSymbol = Optional.of(columnB);
    Set<Symbol> prePartitionedInputs = ImmutableSet.of(columnA);
    WindowNode windowNode = new WindowNode(
            id,
            sourceNode,
            specification,
            functions,
            hashSymbol,
            prePartitionedInputs,
            0);

    String json = objectMapper.writeValueAsString(windowNode);

    WindowNode actualNode = objectMapper.readValue(json, WindowNode.class);

    assertEquals(actualNode.getId(), windowNode.getId());
    assertEquals(actualNode.getSpecification(), windowNode.getSpecification());
    assertEquals(actualNode.getWindowFunctions(), windowNode.getWindowFunctions());
    assertEquals(actualNode.getFrames(), windowNode.getFrames());
    assertEquals(actualNode.getHashSymbol(), windowNode.getHashSymbol());
    assertEquals(actualNode.getPrePartitionedInputs(), windowNode.getPrePartitionedInputs());
    assertEquals(actualNode.getPreSortedOrderPrefix(), windowNode.getPreSortedOrderPrefix());
}
 
Example 17
Source File: Boosting.java    From incubator-samoa with Apache License 2.0 4 votes vote down vote up
@Override
public Set<Stream> getResultStreams() {
  return ImmutableSet.of(this.resultStream);
}
 
Example 18
Source File: TestShardCleaner.java    From presto with Apache License 2.0 4 votes vote down vote up
@Test
public void testCleanLocalShardsImmediately()
        throws Exception
{
    assertEquals(cleaner.getLocalShardsCleaned().getTotalCount(), 0);
    TestingShardDao shardDao = dbi.onDemand(TestingShardDao.class);
    MetadataDao metadataDao = dbi.onDemand(MetadataDao.class);

    long tableId = metadataDao.insertTable("test", "test", false, false, null, 0);

    UUID shard1 = randomUUID();
    UUID shard2 = randomUUID();
    UUID shard3 = randomUUID();

    Set<UUID> shards = ImmutableSet.of(shard1, shard2, shard3);

    for (UUID shard : shards) {
        shardDao.insertShard(shard, tableId, null, 0, 0, 0, 0);
        createShardFile(shard);
        assertTrue(shardFileExists(shard));
    }

    int node1 = shardDao.insertNode("node1");
    int node2 = shardDao.insertNode("node2");

    // shard 1: referenced by this node
    // shard 2: not referenced
    // shard 3: referenced by other node

    shardDao.insertShardNode(shard1, node1);
    shardDao.insertShardNode(shard3, node2);

    // clean shards immediately
    Set<UUID> local = cleaner.getLocalShards();
    cleaner.cleanLocalShardsImmediately(local);

    assertEquals(cleaner.getLocalShardsCleaned().getTotalCount(), 2);

    // shards 2 and 3 should be deleted
    // shard 1 is referenced by this node
    assertTrue(shardFileExists(shard1));
    assertFalse(shardFileExists(shard2));
    assertFalse(shardFileExists(shard3));
}
 
Example 19
Source File: SpawnIncludeScanner.java    From bazel with Apache License 2.0 4 votes vote down vote up
@Override
public Iterable<String> getClientEnvironmentVariables() {
  return ImmutableSet.of();
}
 
Example 20
Source File: FileTreeComputation.java    From buck with Apache License 2.0 4 votes vote down vote up
@Override
public ImmutableSet<? extends ComputeKey<? extends ComputeResult>> discoverPreliminaryDeps(
    FileTreeKey key) {
  return ImmutableSet.of(ImmutableDirectoryListKey.of(key.getPath()));
}