类com.google.common.collect.HashMultimap源码实例Demo

下面列出了怎么用com.google.common.collect.HashMultimap的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: dremio-oss   文件: ScanResult.java
@JsonCreator public ScanResult(
    @JsonProperty("scannedPackages") Collection<String> scannedPackages,
    @JsonProperty("scannedClasses") Collection<String> scannedClasses,
    @JsonProperty("scannedAnnotations") Collection<String> scannedAnnotations,
    @JsonProperty("annotatedClasses") Collection<AnnotatedClassDescriptor> annotatedClasses,
    @JsonProperty("implementations") Collection<ParentClassDescriptor> implementations) {
  this.scannedPackages = unmodifiableList(new ArrayList<>(checkNotNull(scannedPackages)));
  this.scannedClasses = unmodifiableSet(new HashSet<>(checkNotNull(scannedClasses)));
  this.scannedAnnotations = unmodifiableSet(new HashSet<>(checkNotNull(scannedAnnotations)));
  this.annotatedClasses = unmodifiableList(new ArrayList<>(checkNotNull(annotatedClasses)));
  this.implementations = unmodifiableList(new ArrayList<>(checkNotNull(implementations)));
  this.parentClassByName = new HashMap<>();
  for (ParentClassDescriptor parentClassDescriptor : implementations) {
    this.parentClassByName.put(parentClassDescriptor.getName(), parentClassDescriptor);
  }
  this.annotationsByName = HashMultimap.create();
  for (AnnotatedClassDescriptor annotated : annotatedClasses) {
    for (AnnotationDescriptor annotationDescriptor : annotated.getAnnotations()) {
      if (scannedAnnotations.contains(annotationDescriptor.getAnnotationType())) {
        this.annotationsByName.put(annotationDescriptor.getAnnotationType(), annotated);
      }
    }
  }
}
 
源代码2 项目: twill   文件: ZKDiscoveryService.java
/**
 * Constructs ZKDiscoveryService using the provided zookeeper client for storing service registry under namespace.
 * @param zkClient of zookeeper quorum
 * @param namespace under which the service registered would be stored in zookeeper.
 *                  If namespace is {@code null}, no namespace will be used.
 */
public ZKDiscoveryService(ZKClient zkClient, String namespace) {
  this.closed = new AtomicBoolean();
  this.discoverables = HashMultimap.create();
  this.lock = new ReentrantLock();
  this.retryExecutor = Executors.newSingleThreadScheduledExecutor(
    Threads.createDaemonThreadFactory("zk-discovery-retry"));
  this.zkClient = namespace == null ? zkClient : ZKClients.namespace(zkClient, namespace);
  this.services = CacheBuilder.newBuilder()
    .removalListener(new RemovalListener<String, ServiceDiscoveredCacheEntry>() {
      @Override
      public void onRemoval(RemovalNotification<String, ServiceDiscoveredCacheEntry> notification) {
        ServiceDiscoveredCacheEntry entry = notification.getValue();
        if (entry != null) {
          entry.cancel();
        }
      }
    })
    .build(createServiceLoader());
  this.watcherCancellable = this.zkClient.addConnectionWatcher(createConnectionWatcher());
}
 
源代码3 项目: onos   文件: SegmentRoutingManager.java
/**
 * Returns vlan port map of given device.
 *
 * @param deviceId device id
 * @return vlan-port multimap
 */
public Multimap<VlanId, PortNumber> getVlanPortMap(DeviceId deviceId) {
    HashMultimap<VlanId, PortNumber> vlanPortMap = HashMultimap.create();

    interfaceService.getInterfaces().stream()
            .filter(intf -> intf.connectPoint().deviceId().equals(deviceId))
            .forEach(intf -> {
                vlanPortMap.put(intf.vlanUntagged(), intf.connectPoint().port());
                intf.vlanTagged().forEach(vlanTagged ->
                    vlanPortMap.put(vlanTagged, intf.connectPoint().port())
                );
                vlanPortMap.put(intf.vlanNative(), intf.connectPoint().port());
            });
    vlanPortMap.removeAll(VlanId.NONE);

    return vlanPortMap;
}
 
源代码4 项目: bazel-buildfarm   文件: WorkerQueuesTest.java
@Test
public void cpuGpuConfig_invalidProvisionEnqueued() {

  // Arrange
  WorkerQueues queues = WorkerQueueConfigurations.gpuAndFallback();

  // Act
  Operation operation = Operation.newBuilder().build();
  SetMultimap<String, String> provisions = HashMultimap.create();
  provisions.put("invalid_key", "invalid_value");
  boolean success = queues.enqueueOperation(operation, provisions);

  // Assert
  assertThat(success).isTrue();
  assertThat(queues.queueSize("GPU")).isEqualTo(0);
  assertThat(queues.queueSize("Other")).isEqualTo(1);
}
 
源代码5 项目: log-synth   文件: VinSampler.java
private static SetMultimap<String, String> multiMapResource(String name) throws IOException {
    final Splitter onTab = Splitter.on("\t");

    //noinspection UnstableApiUsage
    return Resources.readLines(Resources.getResource(name), Charsets.UTF_8, new LineProcessor<SetMultimap<String, String>>() {
        final SetMultimap<String, String> r = HashMultimap.create();

        @Override
        public boolean processLine(String line) {
            Iterator<String> pieces = onTab.split(line).iterator();
            String key = pieces.next();
            r.put(key, pieces.next());
            return true;
        }

        @Override
        public SetMultimap<String, String> getResult() {
            return r;
        }
    });
}
 
private Multimap<ArtifactCoordinates, ArtifactCoordinates> getSnapshots(Profile profile,
    PomPropertyResolver propertyResolver) {
  this.log.debug("\t\tChecking direct plugin references of profile '" + profile.getId() + "'");
  Multimap<ArtifactCoordinates, ArtifactCoordinates> result = HashMultimap.create();
  BuildBase build = profile.getBuild();
  if (build != null) {
    for (Plugin plugin : build.getPlugins()) {
      Collection<Dependency> snapshots = Collections2.filter(plugin.getDependencies(),
          new IsSnapshotDependency(propertyResolver));
      if (!snapshots.isEmpty()) {
        result.putAll(PluginToCoordinates.INSTANCE.apply(plugin),
            Collections2.transform(snapshots, DependencyToCoordinates.INSTANCE));
      }
    }
  }
  return result;
}
 
源代码7 项目: incubator-tez   文件: TestTaskExecution.java
private TezTaskRunner createTaskRunner(ApplicationId appId, TezTaskUmbilicalForTest umbilical,
    TaskReporter taskReporter, ListeningExecutorService executor, byte[] processorConf)
    throws IOException {
  TezConfiguration tezConf = new TezConfiguration(defaultConf);
  UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
  Path testDir = new Path(workDir, UUID.randomUUID().toString());
  String[] localDirs = new String[] { testDir.toString() };

  TezDAGID dagId = TezDAGID.getInstance(appId, 1);
  TezVertexID vertexId = TezVertexID.getInstance(dagId, 1);
  TezTaskID taskId = TezTaskID.getInstance(vertexId, 1);
  TezTaskAttemptID taskAttemptId = TezTaskAttemptID.getInstance(taskId, 1);
  ProcessorDescriptor processorDescriptor = new ProcessorDescriptor(TestProcessor.class.getName())
      .setUserPayload(processorConf);
  TaskSpec taskSpec = new TaskSpec(taskAttemptId, "dagName", "vertexName", processorDescriptor,
      new ArrayList<InputSpec>(), new ArrayList<OutputSpec>(), null);

  TezTaskRunner taskRunner = new TezTaskRunner(tezConf, ugi, localDirs, taskSpec, umbilical, 1,
      new HashMap<String, ByteBuffer>(), HashMultimap.<String, String> create(), taskReporter,
      executor);
  return taskRunner;
}
 
源代码8 项目: datawave   文件: IndexInfo.java
protected Set<IndexMatch> buildNodeList(HashMultimap<String,JexlNode> ids, IndexMatchType type, boolean allowsDelayed, List<JexlNode> delayedNodes) {
    Set<IndexMatch> matches = Sets.newHashSet();
    for (String uid : ids.keySet()) {
        
        Set<JexlNode> nodes = ids.get(uid);
        // make sure that we have nodes, otherwise we are pruned to nothing
        if (nodes.size() > 1 || (allowsDelayed && (nodes.size() + delayedNodes.size()) > 1)) {
            JexlNodeSet nodeSet = new JexlNodeSet();
            nodeSet.addAll(nodes);
            nodeSet.addAll(delayedNodes);
            
            IndexMatch currentMatch = new IndexMatch(Sets.newHashSet(nodeSet.getNodes()), uid, type);
            matches.add(currentMatch);
        }
    }
    return matches;
}
 
源代码9 项目: datawave   文件: CardinalityConfiguration.java
private Set<String> getStoredProjectionFields() {
    Set<String> initialProjectionFields = new HashSet<>();
    Set<String> finalProjectionFields = new HashSet<>();
    initialProjectionFields.addAll(getAllFieldNames());
    if (cardinalityUidField != null) {
        initialProjectionFields.add(cardinalityUidField);
    }
    
    // remove fields that will not be stored with the event
    initialProjectionFields.removeAll(Arrays.asList(nonDocumentFields));
    
    // map local model names to the stored names that the tserver will find
    Multimap<String,String> forwardMap = HashMultimap.create();
    for (Map.Entry<String,String> entry : cardinalityFieldReverseMapping.entrySet()) {
        forwardMap.put(entry.getValue(), entry.getKey());
    }
    for (String f : initialProjectionFields) {
        if (forwardMap.containsKey(f)) {
            finalProjectionFields.addAll(forwardMap.get(f));
        } else {
            finalProjectionFields.add(f);
        }
    }
    return finalProjectionFields;
}
 
源代码10 项目: OSRS-Deobfuscator   文件: Frame.java
public Frame(Execution execution, Method method)
{
	this.execution = execution;
	this.method = method;

	Code code = method.getCode();

	stack = new Stack(code.getMaxStack());
	variables = new Variables(code.getMaxLocals());
	ctx = new MethodContext(execution, method);
	nonStatic = method;

	exceptions = HashMultimap.create();
	Exceptions codeExceptions = code.getExceptions();
	for (Exception ex : codeExceptions.getExceptions())
	{
		Instruction i = ex.getStart().next();
		exceptions.put(i, ex);
	}
}
 
源代码11 项目: similarity   文件: ConceptTest.java
@Test
public void test() throws Exception {
    Multimap<String, Concept> CONCEPTS = HashMultimap.create();
    CONCEPTS.put("打", new Concept("打", "V", "TakeOutOfWater|捞起"));
    CONCEPTS.put("打", new Concept("打", "V", "TakeOutOfWater|捞起"));
    CONCEPTS.put("打", new Concept("打", "V", "TakeOutOfWater|捞起"));
    CONCEPTS.put("打", new Concept("打", "V", "TakeOutOfWater|捞起"));

    Collection<Concept> collection = CONCEPTS.get("打");
    for (Concept c : collection) {
        System.out.println(c);

    }

    Multimap<String, Integer> map = HashMultimap.create();
    map.put("打", 1);
    map.put("打", 1);
    map.put("打", 1);
    map.put("打", 2);

    Collection<Integer> cc = map.get("打");
    for (Integer i : cc) {
        System.out.println(i);
    }
}
 
源代码12 项目: xio   文件: Http1FilterUnitTest.java
@Test
public void testDeniedRule() throws UnknownHostException {
  List<Http1DeterministicRuleEngineConfig.Rule> blacklist = new ArrayList<>();
  HashMultimap<String, String> headers = HashMultimap.create();
  headers.put("User-Agent", "Bad-actor: 1.0");
  Http1DeterministicRuleEngineConfig.Rule bad =
      new Http1DeterministicRuleEngineConfig.Rule(
          HttpMethod.GET, "/path/to/failure", HttpVersion.HTTP_1_0, headers);
  blacklist.add(bad);
  Http1Filter http1Filter =
      new Http1Filter(new Http1FilterConfig(ImmutableList.copyOf(blacklist)));
  EmbeddedChannel chDeny = new EmbeddedChannel(http1Filter);
  DefaultHttpRequest request =
      new DefaultHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.GET, "/path/to/failure");
  request.headers().set("User-Agent", "Bad-actor: 1.0");
  chDeny.writeInbound(request);
  chDeny.runPendingTasks();
  assertFalse(chDeny.isActive());
  assertFalse(chDeny.isOpen());
}
 
源代码13 项目: dsl-devkit   文件: GraphTest.java
@Test
public void testTopologicalSorting() {
  Multimap<String, String> graph = HashMultimap.create();
  graph.put("7", "11");
  graph.put("7", "8");
  graph.put("3", "8");
  graph.put("3", "10");
  graph.put("11", "2");
  graph.put("11", "9");
  graph.put("11", "10");
  graph.put("8", "8");
  graph.put("8", "9");
  graph.put("8", "10");

  List<String> sorted = Graph.create(graph).sort();
  assertSorting(graph, sorted);
}
 
源代码14 项目: pacbot   文件: AnnotationPublisher.java
/**
 * Populate existing issues for type.
 *
 * @param ruleParam the rule param
 * @throws Exception the exception
 */
public void populateExistingIssuesForType(Map<String, String> ruleParam) throws Exception {

    String esUrl = ESUtils.getEsUrl();
    String ruleId = ruleParam.get(PacmanSdkConstants.RULE_ID);
    String indexName = CommonUtils.getIndexNameFromRuleParam(ruleParam);
    Map<String, Object> mustFilter = new HashMap<>();
    String attributeToQuery = ESUtils.convertAttributetoKeyword(PacmanSdkConstants.RULE_ID); //actual attribute will be  tokenized hence querying on keyword
    mustFilter.put(attributeToQuery, ruleId);
    List<String> fields = new ArrayList<String>();
    Map<String, Object> mustNotFilter = new HashMap<>();
    mustNotFilter.put("issueStatus.keyword", "closed");
    HashMultimap<String, Object> shouldFilter = HashMultimap.create();
    shouldFilter.put("type.keyword", "recommendation");
    shouldFilter.put("type.keyword", "issue");
    Long totalDocs = ESUtils.getTotalDocumentCountForIndexAndType(esUrl, indexName, null, mustFilter, mustNotFilter,
            shouldFilter);
    // get all the issues for this ruleId
    List<Map<String, String>> existingIssues = ESUtils.getDataFromES(esUrl, indexName.toLowerCase(), null,
            mustFilter, mustNotFilter, shouldFilter, fields, 0, totalDocs);
    existingIssues.stream().forEach(obj -> {
        existingIssuesMapWithAnnotationIdAsKey.put(obj.get(PacmanSdkConstants.ES_DOC_ID_KEY), obj);
    });
}
 
源代码15 项目: datawave   文件: AbstractNormalizer.java
@Override
public Multimap<String,NormalizedContentInterface> normalizeMap(Multimap<String,NormalizedContentInterface> fields) {
    Multimap<String,NormalizedContentInterface> results = HashMultimap.create();
    // if handling all fields, then we need to navigate the entire list
    for (Entry<String,NormalizedContentInterface> field : fields.entries()) {
        if (field.getValue() != null) {
            NormalizedContentInterface normalizedContent = field.getValue();
            try {
                normalizedContent = normalize(field.getValue());
            } catch (Exception e) {
                log.error("Failed to normalize " + field.getValue().getIndexedFieldName() + '=' + field.getValue().getIndexedFieldValue(), e);
                normalizedContent.setError(e);
            }
            results.put(normalizedContent.getIndexedFieldName(), normalizedContent);
        }
    }
    return results;
}
 
@Override
public Object transform(Object o) {
    
    if (o instanceof EventBase) {
        EventBase e = (EventBase) o;
        List<? extends FieldBase> fields = e.getFields();
        Multimap<String,FieldBase> fieldMap = HashMultimap.create();
        for (FieldBase f : fields) {
            fieldMap.put(f.getName(), f);
        }
        
        for (String d : requestedDecorators) {
            
            EventQueryDataDecorator decorator = dataDecorators.get(d);
            if (decorator != null) {
                decorator.decorateData(fieldMap);
            }
        }
        e.setFields(new ArrayList<>(fieldMap.values()));
        return e;
    } else {
        return o;
    }
}
 
源代码17 项目: incubator-pinot   文件: ThirdEyeUtils.java
/**
 * Returns or modifies a filter that can be for querying the results corresponding to the given dimension map.
 *
 * For example, if a dimension map = {country=IN,page_name=front_page}, then the two entries will be added or
 * over-written to the given filter.
 *
 * Note that if the given filter contains an entry: country=["IN", "US", "TW",...], then this entry is replaced by
 * country=IN.
 *
 * @param dimensionMap the dimension map to add to the filter
 * @param filterToDecorate if it is null, a new filter will be created; otherwise, it is modified.
 * @return a filter that is modified according to the given dimension map.
 */
public static Multimap<String, String> getFilterSetFromDimensionMap(DimensionMap dimensionMap,
    Multimap<String, String> filterToDecorate) {
  if (filterToDecorate == null) {
    filterToDecorate = HashMultimap.create();
  }

  for (Map.Entry<String, String> entry : dimensionMap.entrySet()) {
    String dimensionName = entry.getKey();
    String dimensionValue = entry.getValue();
    // If dimension value is "OTHER", then we need to get all data and calculate "OTHER" part.
    // In order to reproduce the data for "OTHER", the filter should remain as is.
    if ( !dimensionValue.equalsIgnoreCase("OTHER") ) {
      // Only add the specific dimension value to the filter because other dimension values will not be used
      filterToDecorate.removeAll(dimensionName);
      filterToDecorate.put(dimensionName, dimensionValue);
    }
  }

  return filterToDecorate;
}
 
源代码18 项目: xtext-xtend   文件: UIResourceChangeRegistry.java
public void readState(final InputStream in) {
  try {
    final DataInputStream reader = new DataInputStream(in);
    for (final HashMultimap<String, URI> map : Collections.<HashMultimap<String, URI>>unmodifiableList(CollectionLiterals.<HashMultimap<String, URI>>newArrayList(this.existsListeners, this.charsetListeners, this.childrenListeners, this.contentsListeners))) {
      {
        final int urisForExists = reader.readInt();
        for (int i = 0; (i < urisForExists); i++) {
          {
            final String path = reader.readUTF();
            final String uri = reader.readUTF();
            map.put(path, URI.createURI(uri));
          }
        }
      }
    }
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
private Multimap<String, IProject> initProjectLocation() {
	final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	final IProject[] projects = root.getProjects();
	final Multimap<String, IProject> locations = HashMultimap.create();

	// initialize the repository paths
	repositoryPaths = repositoriesProvider.getWorkspaceRepositories().stream()
			.map(r -> r.getDirectory().getParentFile().toPath()).collect(Collectors.toSet());

	for (final IProject project : projects) {
		if (isRemoteEditNature(project)) {
			continue;
		}
		final String pair = getWorkingSetId(project);
		locations.put(pair, project);
	}

	return locations;
}
 
源代码20 项目: docker-java   文件: DefaultDockerCmdExecFactory.java
@Override
public DefaultWebTarget queryParamsSet(String name, Set<?> values) {
    SetMultimap<String, String> newQueryParams = HashMultimap.create(queryParams);
    newQueryParams.replaceValues(name, values.stream().filter(Objects::nonNull).map(Object::toString).collect(Collectors.toSet()));

    return new DefaultWebTarget(path, newQueryParams);
}
 
源代码21 项目: dockerfile-image-update   文件: GitHubTest.java
@Test
public void testShouldNotProcessBecauseDidNotFindDockerfiles() {
    gitHubRepository = mock(GHRepository.class);
    when(gitHubRepository.getFullName()).thenReturn(repoName);
    Multimap<String, String> multimap = HashMultimap.create();
    assertTrue(GitHub.shouldNotProcessDockerfilesInRepo(multimap, gitHubRepository));
}
 
源代码22 项目: Elasticsearch   文件: Literal.java
public static Literal fromObject(Object value) {
    Literal literal = null;
    if (value == null) {
        literal = new NullLiteral();
    } else if (value instanceof String) {
        literal = new StringLiteral((String) value);
    } else if (value instanceof Number) {
        if (value instanceof Float || value instanceof Double) {
            literal = new DoubleLiteral(value.toString());
        } else if (value instanceof Short || value instanceof Integer || value instanceof Long){
            literal = new LongLiteral(value.toString());
        }
    } else if (value instanceof Boolean) {
        literal = (Boolean) value ? BooleanLiteral.TRUE_LITERAL : BooleanLiteral.FALSE_LITERAL;
    } else if (value instanceof Object[]) {
        List<Expression> expressions = new ArrayList<>();
        for (Object o : (Object[]) value) {
            expressions.add(fromObject(o));
        }
        literal = new ArrayLiteral(expressions);
    } else if (value instanceof Map) {
        Multimap<String, Expression> map = HashMultimap.create();
        @SuppressWarnings("unchecked") Map<String, Object> valueMap = (Map<String, Object>) value;
        for (Map.Entry<String, Object> entry : valueMap.entrySet()) {
            map.put(entry.getKey(), fromObject(entry.getValue()));
        }
        literal = new ObjectLiteral(map);
    }
    return literal;
}
 
源代码23 项目: presto   文件: TestRaptorIntegrationSmokeTest.java
@Test
public void testShardingByTemporalDateColumn()
{
    // Make sure we have at least 2 different orderdate.
    assertEquals(computeActual("SELECT count(DISTINCT orderdate) >= 2 FROM orders WHERE orderdate < date '1992-02-08'").getOnlyValue(), true);

    assertUpdate("CREATE TABLE test_shard_temporal_date " +
                    "WITH (temporal_column = 'orderdate') AS " +
                    "SELECT orderdate, orderkey " +
                    "FROM orders " +
                    "WHERE orderdate < date '1992-02-08'",
            "SELECT count(*) " +
                    "FROM orders " +
                    "WHERE orderdate < date '1992-02-08'");

    MaterializedResult results = computeActual("SELECT orderdate, \"$shard_uuid\" FROM test_shard_temporal_date");

    // Each shard will only contain data of one date.
    SetMultimap<String, LocalDate> shardDateMap = HashMultimap.create();
    for (MaterializedRow row : results.getMaterializedRows()) {
        shardDateMap.put((String) row.getField(1), (LocalDate) row.getField(0));
    }

    for (Collection<LocalDate> dates : shardDateMap.asMap().values()) {
        assertEquals(dates.size(), 1);
    }

    // Make sure we have all the rows
    assertQuery("SELECT orderdate, orderkey FROM test_shard_temporal_date",
            "SELECT orderdate, orderkey FROM orders WHERE orderdate < date '1992-02-08'");
}
 
源代码24 项目: dockerfile-image-update   文件: ParentTest.java
@Test
public void testChangeDockerfiles_pullRequestCreation() throws Exception {
    Map<String, Object> nsMap = ImmutableMap.of(Constants.IMG, "image", Constants.TAG, "tag", Constants.STORE, "store");
    Namespace ns = new Namespace(nsMap);

    GHRepository forkedRepo = mock(GHRepository.class);
    when(forkedRepo.isFork()).thenReturn(true);
    when(forkedRepo.getFullName()).thenReturn("forkedrepo");

    GHRepository parentRepo = mock(GHRepository.class);
    when(parentRepo.getFullName()).thenReturn("repo2");
    when(forkedRepo.getParent()).thenReturn(parentRepo);

    Multimap<String, GitHubContentToProcess> pathToDockerfilesInParentRepo = HashMultimap.create();
    pathToDockerfilesInParentRepo.put("repo1", new GitHubContentToProcess(null, null, "df1"));
    pathToDockerfilesInParentRepo.put("repo2", new GitHubContentToProcess(null, null, "df2"));
    pathToDockerfilesInParentRepo.put("repo3", new GitHubContentToProcess(null, null, "df3"));
    pathToDockerfilesInParentRepo.put("repo4", new GitHubContentToProcess(null, null, "df4"));

    GHContent content = mock(GHContent.class);

    DockerfileGitHubUtil dockerfileGitHubUtil = mock(DockerfileGitHubUtil.class);

    when(dockerfileGitHubUtil.getPullRequestForImageBranch(eq(forkedRepo), any())).thenReturn(Optional.empty());

    when(dockerfileGitHubUtil.tryRetrievingContent(forkedRepo, "df2",
            "image-tag")).thenReturn(content);

    Parent parent = new Parent();
    parent.loadDockerfileGithubUtil(dockerfileGitHubUtil);
    parent.changeDockerfiles(ns, pathToDockerfilesInParentRepo, new GitHubContentToProcess(forkedRepo, parentRepo, ""), new ArrayList<>());

    Mockito.verify(dockerfileGitHubUtil, times(1))
            .tryRetrievingContent(eq(forkedRepo), eq("df2"), eq("image-tag"));
    Mockito.verify(dockerfileGitHubUtil, times(1))
            .modifyOnGithub(eq(content), eq("image-tag"), eq("image"), eq("tag"), anyString());
    Mockito.verify(dockerfileGitHubUtil, times(1))
            .createPullReq(eq(parentRepo), eq("image-tag"), eq(forkedRepo), anyString());
}
 
@Inject
public MemoryPerUserWaveViewHandlerImpl(final WaveMap waveMap) {
  // Let the view expire if it not accessed for some time.
  explicitPerUserWaveViews =
      CacheBuilder.newBuilder().expireAfterAccess(PER_USER_WAVES_VIEW_CACHE_MINUTES, TimeUnit.MINUTES)
          .<ParticipantId, Multimap<WaveId, WaveletId>>build(new CacheLoader<ParticipantId, Multimap<WaveId, WaveletId>>() {

            @Override
            public Multimap<WaveId, WaveletId> load(final ParticipantId user) {
              Multimap<WaveId, WaveletId> userView = HashMultimap.create();

              // Create initial per user waves view by looping over all waves
              // in the waves store.
              Map<WaveId, Wave> waves = waveMap.getWaves();
              for (Map.Entry<WaveId, Wave> entry : waves.entrySet()) {
                Wave wave = entry.getValue();
                for (WaveletContainer c : wave) {
                  WaveletId waveletId = c.getWaveletName().waveletId;
                  try {
                    if (!c.hasParticipant(user)) {
                      continue;
                    }
                    // Add this wave to the user view.
                    userView.put(entry.getKey(), waveletId);
                  } catch (WaveletStateException e) {
                    LOG.warning("Failed to access wavelet " + c.getWaveletName(), e);
                  }
                }
              }
              LOG.info("Initalized waves view for user: " + user.getAddress()
                  + ", number of waves in view: " + userView.size());
              return userView;
            }
          });
}
 
源代码26 项目: api-mining   文件: AbstractNameBindingsExtractor.java
protected Multimap<String, TokenNameBinding> getBindingsForName(
		final List<TokenNameBinding> bindings) {
	final Multimap<String, TokenNameBinding> toks = HashMultimap.create();
	for (final TokenNameBinding binding : bindings) {
		toks.put(binding.getName(), binding);
	}
	return toks;
}
 
源代码27 项目: gef   文件: GeometricShapePart.java
@Override
protected SetMultimap<? extends Object, String> doGetContentAnchorages() {
	SetMultimap<Object, String> anchorages = HashMultimap.create();
	for (AbstractGeometricElement<? extends IGeometry> anchorage : getContent().getAnchorages()) {
		anchorages.put(anchorage, "link");
	}
	return anchorages;
}
 
源代码28 项目: tez   文件: TestMROutput.java
public static LogicalIOProcessorRuntimeTask createLogicalTask(
    Configuration conf,
    TezUmbilical umbilical, String dagName,
    String vertexName, TezExecutors sharedExecutor) throws Exception {
  ProcessorDescriptor procDesc = ProcessorDescriptor.create(TestProcessor.class.getName());
  List<InputSpec> inputSpecs = Lists.newLinkedList();
  List<OutputSpec> outputSpecs = Lists.newLinkedList();
  outputSpecs.add(new OutputSpec("Null",
      MROutput.createConfigBuilder(conf, TestOutputFormat.class).build().getOutputDescriptor(), 1));
  
  TaskSpec taskSpec = new TaskSpec(
      TezTestUtils.getMockTaskAttemptId(0, 0, 0, 0),
      dagName, vertexName, -1,
      procDesc,
      inputSpecs,
      outputSpecs, null, null);

  FileSystem fs = FileSystem.getLocal(conf);
  Path workDir =
      new Path(new Path(System.getProperty("test.build.data", "/tmp")),
               "TestMapOutput").makeQualified(fs.getUri(), fs.getWorkingDirectory());

  return new LogicalIOProcessorRuntimeTask(
      taskSpec,
      0,
      conf,
      new String[] {workDir.toString()},
      umbilical,
      null,
      new HashMap<String, String>(),
      HashMultimap.<String, String>create(), null, "", new ExecutionContextImpl("localhost"),
      Runtime.getRuntime().maxMemory(), true, new DefaultHadoopShim(), sharedExecutor);
}
 
源代码29 项目: timely   文件: TimelyAuthenticationToken.java
public TimelyAuthenticationToken(String subjectDn, Object clientCert, Multimap<String, String> httpHeaders) {
    super(subjectDn, clientCert);
    if (httpHeaders == null) {
        this.httpHeaders = HashMultimap.create();
    } else {
        this.httpHeaders = httpHeaders;
    }
    if (clientCert instanceof X509Certificate) {
        this.clientCert = (X509Certificate) clientCert;
    }
    String issuerDn = clientCert == null ? null : this.clientCert.getIssuerDN().getName();
    String proxiedEntities;
    String proxiedIssuers;
    try {
        proxiedEntities = HttpHeaderUtils.getSingleHeader(httpHeaders, PROXIED_ENTITIES_HEADER, true);
        proxiedIssuers = HttpHeaderUtils.getSingleHeader(httpHeaders, PROXIED_ISSUERS_HEADER, true);
    } catch (IllegalArgumentException e) {
        LOG.error(e.getMessage(), e);
        throw e;
    }
    if (proxiedEntities != null && proxiedIssuers == null) {
        LOG.error(PROXIED_ENTITIES_HEADER + " supplied, but missing " + PROXIED_ISSUERS_HEADER);
        throw new IllegalArgumentException(
                PROXIED_ENTITIES_HEADER + " supplied, but missing " + PROXIED_ISSUERS_HEADER);
    }
    List<SubjectIssuerDNPair> entities = extractEntities(subjectDn, issuerDn, proxiedEntities, proxiedIssuers);
    long now = System.currentTimeMillis();
    List<TimelyUser> timelyUsers = new ArrayList<>();
    for (SubjectIssuerDNPair ent : entities) {
        TimelyUser.UserType userType = DnUtils.isServerDN(ent.subjectDN()) ? TimelyUser.UserType.SERVER
                : TimelyUser.UserType.USER;
        timelyUsers.add(new TimelyUser(ent, userType, null, null, null, now));
    }
    timelyPrincipal = new TimelyPrincipal(timelyUsers);
    LOG.trace("Created TimelyAuthenticationToken: {}", timelyPrincipal.getName());
}
 
源代码30 项目: gef   文件: ContentBehavior.java
@SuppressWarnings("unchecked")
private void detachAll(IVisualPart<? extends Node> parent,
		final Set<? extends Object> contentChildren,
		List<IContentPart<? extends Node>> toRemove,
		Map<IVisualPart<? extends Node>, List<IContentPart<? extends Node>>> removalsPerParent) {
	// only synchronize IContentPart children
	// find all content parts for which no content element exists in
	// contentChildren, and therefore have to be removed

	List<IContentPart<? extends Node>> childrenToRemove = new ArrayList<>();
	for (IContentPart<? extends Node> contentPart : (List<IContentPart<? extends Node>>) PartUtils
			.filterParts(parent.getChildrenUnmodifiable(),
					IContentPart.class)) {
		// mark for removal
		if (!contentChildren.contains(contentPart.getContent())) {
			detachAll(contentPart, Collections.emptySet(), toRemove,
					removalsPerParent);
			childrenToRemove.add(contentPart);
			toRemove.add(contentPart);
			synchronizeContentPartAnchorages(contentPart,
					HashMultimap.create());
		}
	}
	if (!childrenToRemove.isEmpty()) {
		removalsPerParent.put(parent, childrenToRemove);
	}
}
 
 同包方法