com.google.common.collect.ImmutableListMultimap#of ( )源码实例Demo

下面列出了com.google.common.collect.ImmutableListMultimap#of ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Test
public void testFormatDependencyPaths_path_A_B() {
  ImmutableListMultimap<ClassPathEntry, DependencyPath> tree =
      ImmutableListMultimap.of(jarA, dependencyPath_A, jarB, dependencyPath_B);

  ClassPathResult classPathResult = new ClassPathResult(tree, ImmutableSet.of());

  String actual = classPathResult.formatDependencyPaths(ImmutableList.of(jarA, jarB));

  assertEquals(
      "com.google:a:1 is at:\n"
          + "  com.google:a:1 (compile)\n"
          + "com.google:b:1 is at:\n"
          + "  com.google:b:1 (compile)\n",
      actual);
}
 
@Test
public void testFormatDependencyPaths_threePathsForA() {
  ImmutableListMultimap<ClassPathEntry, DependencyPath> tree =
      ImmutableListMultimap.of(
          jarA, dependencyPath_A, jarA, dependencyPath_B_A, jarA, dependencyPath_A_B_A);

  ClassPathResult classPathResult = new ClassPathResult(tree, ImmutableSet.of());

  String actual = classPathResult.formatDependencyPaths(ImmutableList.of(jarA));

  assertEquals(
      "com.google:a:1 is at:\n"
          + "  com.google:a:1 (compile)\n"
          + "  and 2 other dependency paths.\n",
      actual);
}
 
@Test
public void queryParamsSupportValuesWithoutEquals() throws Exception {
    final String key = "scroll_id";
    final String url = "http://someurl.com?" + key;
    final Multimap<String, String> queryParams = ImmutableListMultimap.of(key, "");

    when(signer.getSignedHeaders(anyString(), anyString(), eq(queryParams), anyMapOf(String.class, Object.class), any(com.google.common.base.Optional.class))).thenReturn(ImmutableMap.of());
    mockRequest(url);

    interceptor.process(request, context);

    verify(request).setHeaders(new Header[]{});
    verify(signer).getSignedHeaders(anyString(), anyString(), eq(queryParams), anyMapOf(String.class, Object.class), any(com.google.common.base.Optional.class));
}
 
源代码4 项目: Strata   文件: IniFileTest.java
@Test
public void test_of_propertyNoEquals() {
  IniFile test = IniFile.of(CharSource.wrap("[section]\na\n"));
  Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a", "");
  assertThat(test.asMap()).isEqualTo(ImmutableMap.of("section", PropertySet.of(keyValues1)));

  assertThat(test.section("section")).isEqualTo(PropertySet.of(keyValues1));
  assertThat(test.section("section").contains("a")).isEqualTo(true);
  assertThat(test.section("section").valueList("a")).isEqualTo(ImmutableList.of(""));
  assertThat(test.section("section").contains("b")).isEqualTo(false);
  assertThat(test.section("section").keys()).isEqualTo(ImmutableSet.of("a"));
  assertThat(test.section("section").asMultimap()).isEqualTo(ImmutableListMultimap.of("a", ""));
  assertThat(test.toString()).isEqualTo("{section={a=[]}}");
}
 
源代码5 项目: Strata   文件: ResourceConfigTest.java
@Test
public void test_ofChained_chainNextFileFalse() {
  IniFile test = ResourceConfig.combinedIniFile("TestChain2.ini");
  Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a", "z");
  Multimap<String, String> keyValues2 = ImmutableListMultimap.of("m", "n");
  assertThat(test.asMap())
      .hasSize(2)
      .containsEntry("one", PropertySet.of(keyValues1))
      .containsEntry("two", PropertySet.of(keyValues2));
}
 
private Multimap<String, String> params(HttpRequest request) throws IOException {
    final String rawQuery = ((HttpRequestWrapper) request).getURI().getRawQuery();
    if (Strings.isNullOrEmpty(rawQuery))
        return ImmutableListMultimap.of();

    return params(URLDecoder.decode(rawQuery, StandardCharsets.UTF_8.name()));
}
 
源代码7 项目: copybara   文件: ConsoleEventMonitorTest.java
private Change<DummyRevision> newChange(String revision) {
  return new Change<>(
      new DummyRevision(revision),
      new Author("Foo", "Bar"),
      "Lorem Ipsum",
      ZonedDateTime.now(ZoneId.systemDefault()),
      ImmutableListMultimap.of());
}
 
@Test
public void testFormatDependencyPaths_onePath() {
  ImmutableListMultimap<ClassPathEntry, DependencyPath> tree =
      ImmutableListMultimap.of(jarA, dependencyPath_A, jarB, dependencyPath_B);

  ClassPathResult classPathResult = new ClassPathResult(tree, ImmutableSet.of());

  String actual = classPathResult.formatDependencyPaths(ImmutableList.of(jarA));

  assertEquals("com.google:a:1 is at:\n" + "  com.google:a:1 (compile)\n", actual);
}
 
@Test
public void testGetClassPathEntries() {
  ImmutableListMultimap<ClassPathEntry, DependencyPath> tree =
      ImmutableListMultimap.of(
          jarA, dependencyPath_A,
          jarB, dependencyPath_B,
          jarA, dependencyPath_A_B_A);

  ClassPathResult result = new ClassPathResult(tree, ImmutableSet.of());

  ImmutableSet<ClassPathEntry> classPathEntries = result.getClassPathEntries("com.google:a:1");
  assertEquals(1, classPathEntries.size());
  UnmodifiableIterator<ClassPathEntry> iterator = classPathEntries.iterator();
  assertEquals(Paths.get("a.jar"), iterator.next().getJar());
}
 
源代码10 项目: Strata   文件: ResourceConfigTest.java
@Test
public void test_ofChained_chainRemoveSections() {
  IniFile test = ResourceConfig.combinedIniFile("TestChain5.ini");
  Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a", "a");
  Multimap<String, String> keyValues2 = ImmutableListMultimap.of("m", "n", "o", "z");
  assertThat(test.asMap())
      .hasSize(2)
      .containsEntry("one", PropertySet.of(keyValues1))
      .containsEntry("two", PropertySet.of(keyValues2));
}
 
源代码11 项目: nomulus   文件: RdapNameserverSearchActionTest.java
private JsonObject generateActualJsonWithName(String name, String cursor) {
  metricSearchType = SearchType.BY_NAMESERVER_NAME;
  rememberWildcardType(name);
  action.nameParam = Optional.of(name);
  if (cursor == null) {
    action.parameterMap = ImmutableListMultimap.of("name", name);
    action.cursorTokenParam = Optional.empty();
  } else {
    action.parameterMap = ImmutableListMultimap.of("name", name, "cursor", cursor);
    action.cursorTokenParam = Optional.of(cursor);
  }
  action.run();
  return parseJsonObject(response.getPayload());
}
 
源代码12 项目: phoenix   文件: CreateTableStatement.java
protected CreateTableStatement(TableName tableName, ListMultimap<String,Pair<String,Object>> props, List<ColumnDef> columns, PrimaryKeyConstraint pkConstraint,
        List<ParseNode> splitNodes, PTableType tableType, boolean ifNotExists, 
        TableName baseTableName, ParseNode whereClause, int bindCount, Boolean immutableRows) {
    this.tableName = tableName;
    this.props = props == null ? ImmutableListMultimap.<String,Pair<String,Object>>of() : props;
    this.tableType = PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA.equals(tableName.getSchemaName()) ? PTableType.SYSTEM : tableType;
    this.columns = columns == null ? ImmutableList.<ColumnDef>of() : ImmutableList.<ColumnDef>copyOf(columns);
    this.pkConstraint = pkConstraint == null ? PrimaryKeyConstraint.EMPTY : pkConstraint;
    this.splitNodes = splitNodes == null ? Collections.<ParseNode>emptyList() : ImmutableList.copyOf(splitNodes);
    this.bindCount = bindCount;
    this.ifNotExists = ifNotExists;
    this.baseTableName = baseTableName;
    this.whereClause = whereClause;
    this.immutableRows = immutableRows;
}
 
public static LookupValuesList fromNullable(final LookupValue lookupValue)
{
	if (lookupValue == null)
	{
		return EMPTY;
	}

	final ImmutableListMultimap<Object, LookupValue> valuesById = ImmutableListMultimap.of(lookupValue.getId(), lookupValue);
	final boolean ordered = true;
	return new LookupValuesList(valuesById, ordered, DebugProperties.EMPTY);
}
 
/** Empty constructor */
private LookupValuesList()
{
	valuesById = ImmutableListMultimap.of();
	ordered = true;
	debugProperties = DebugProperties.EMPTY;
}
 
源代码15 项目: phoenix   文件: CreateTableStatement.java
protected CreateTableStatement(TableName tableName, ListMultimap<String,Pair<String,Object>> props, List<ColumnDef> columns, PrimaryKeyConstraint pkConstraint,
        List<ParseNode> splitNodes, PTableType tableType, boolean ifNotExists, 
        TableName baseTableName, ParseNode whereClause, int bindCount) {
    this.tableName = tableName;
    this.props = props == null ? ImmutableListMultimap.<String,Pair<String,Object>>of() : props;
    this.tableType = PhoenixDatabaseMetaData.TYPE_SCHEMA.equals(tableName.getSchemaName()) ? PTableType.SYSTEM : tableType;
    this.columns = columns == null ? ImmutableList.<ColumnDef>of() : ImmutableList.<ColumnDef>copyOf(columns);
    this.pkConstraint = pkConstraint == null ? PrimaryKeyConstraint.EMPTY : pkConstraint;
    this.splitNodes = splitNodes == null ? Collections.<ParseNode>emptyList() : ImmutableList.copyOf(splitNodes);
    this.bindCount = bindCount;
    this.ifNotExists = ifNotExists;
    this.baseTableName = baseTableName;
    this.whereClause = whereClause;
}
 
源代码16 项目: nomulus   文件: RdapDomainSearchActionTest.java
private JsonObject generateActualJson(RequestType requestType, String paramValue, String cursor) {
  action.requestPath = actionPath;
  action.requestMethod = POST;
  String requestTypeParam = null;
  switch (requestType) {
    case NAME:
      action.nameParam = Optional.of(paramValue);
      action.nsLdhNameParam = Optional.empty();
      action.nsIpParam = Optional.empty();
      requestTypeParam = "name";
      break;
    case NS_LDH_NAME:
      action.nameParam = Optional.empty();
      action.nsLdhNameParam = Optional.of(paramValue);
      action.nsIpParam = Optional.empty();
      requestTypeParam = "nsLdhName";
      break;
    case NS_IP:
      action.nameParam = Optional.empty();
      action.nsLdhNameParam = Optional.empty();
      action.nsIpParam = Optional.of(paramValue);
      requestTypeParam = "nsIp";
      break;
    default:
      action.nameParam = Optional.empty();
      action.nsLdhNameParam = Optional.empty();
      action.nsIpParam = Optional.empty();
      requestTypeParam = "";
      break;
  }
  if (paramValue != null) {
    if (cursor == null) {
      action.parameterMap = ImmutableListMultimap.of(requestTypeParam, paramValue);
      action.cursorTokenParam = Optional.empty();
    } else {
      action.parameterMap =
          ImmutableListMultimap.of(requestTypeParam, paramValue, "cursor", cursor);
      action.cursorTokenParam = Optional.of(cursor);
    }
  }
  action.run();
  return parseJsonObject(response.getPayload());
}
 
源代码17 项目: Singularity   文件: SingularityDeployStatistics.java
@Schema(description = "Timestamps of failed tasks by instance number")
@Deprecated
public ListMultimap<Integer, Long> getInstanceSequentialFailureTimestamps() {
  return ImmutableListMultimap.of();
}
 
@Test
public void testRetrievePickingSlotRows_One_TU_with_CU()
{
	final ShipmentScheduleId shipmentScheduleId = createShipmentSchedule();

	final PickingSlotId pickingSlotId = createPickingSlot();

	final boolean pickingSlotRowProcessed = false;

	// set up a picked TU with a CU to be returned by the pickingHUsRepo.
	{
		final ListMultimap<PickingSlotId, PickedHUEditorRow> husIndexedByPickingSlotId = ImmutableListMultimap.of(
				pickingSlotId,
				new PickedHUEditorRow(
						HUEditorRow
								.builder(WindowId.of(423))
								.setRowId(HUEditorRowId.ofTopLevelHU(HuId.ofRepoId(100)))
								.setType(HUEditorRowType.TU)
								.setTopLevel(true)
								.addIncludedRow(HUEditorRow
										.builder(WindowId.of(423))
										.setRowId(HUEditorRowId.ofHU(HuId.ofRepoId(101), HuId.ofRepoId(100)))
										.setType(HUEditorRowType.VHU)
										.setTopLevel(false)
										.build())
								.build(),
						pickingSlotRowProcessed));

		Mockito.when(pickingHUsRepo.retrievePickedHUsIndexedByPickingSlotId(
				PickingCandidatesQuery.builder()
						.shipmentScheduleId(shipmentScheduleId)
						.onlyNotClosedOrNotRackSystem(true)
						.build()))
				.thenReturn(husIndexedByPickingSlotId);
	}

	final PickingSlotViewRepository pickingSlotViewRepository = createPickingSlotViewRepository();
	final PickingSlotRepoQuery query = PickingSlotRepoQuery.of(shipmentScheduleId);
	final List<PickingSlotRow> rowsByShipmentScheduleId = pickingSlotViewRepository.retrievePickingSlotRows(query);

	assertThat(rowsByShipmentScheduleId).hasSize(1);
	final PickingSlotRow pickingSlotRow = rowsByShipmentScheduleId.get(0);
	assertThat(pickingSlotRow.isPickingSlotRow()).isTrue();
	assertThat(pickingSlotRow.isPickedHURow()).isFalse();
	assertThat(pickingSlotRow.isProcessed()).isEqualTo(pickingSlotRowProcessed);

	assertThat(pickingSlotRow.getIncludedRows()).hasSize(1);
	final PickingSlotRow tuRow = pickingSlotRow.getIncludedRows().get(0);
	assertThat(tuRow.isPickingSlotRow()).isFalse();
	assertThat(tuRow.isPickedHURow()).isTrue();
	assertThat(tuRow.getHuId().getRepoId()).isEqualTo(100);

	assertThat(tuRow.getIncludedRows()).hasSize(1);
	final PickingSlotRow whuRow = tuRow.getIncludedRows().get(0);
	assertThat(whuRow.isPickingSlotRow()).isFalse();
	assertThat(whuRow.isPickedHURow()).isTrue();
	assertThat(whuRow.getHuId().getRepoId()).isEqualTo(101);
}
 
源代码19 项目: Strata   文件: PropertiesFileTest.java
@Test
public void test_of_escaping() {
  PropertiesFile test = PropertiesFile.of(CharSource.wrap(FILE3));
  Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a=d=", "x");
  assertThat(test.getProperties()).isEqualTo(PropertySet.of(keyValues1));
}
 
源代码20 项目: copybara   文件: GitRevision.java
/**
 * Create a git revision from a complete (40 characters) git SHA-1 string.
 *
 * @param repository git repository that should contain the {@code sha1}
 * @param sha1 a 40 characters SHA-1
 */
GitRevision(GitRepository repository, String sha1) {
  this(repository, sha1, /*reviewReference=*/ null, /*reference=*/ null,
      ImmutableListMultimap.of(), /*url=*/null);
}