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

The following examples show how to use com.google.common.collect.ImmutableListMultimap#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: ClassPathResultTest.java    From cloud-opensource-java with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 2
Source File: ClassPathResultTest.java    From cloud-opensource-java with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 3
Source File: IniFileTest.java    From Strata with Apache License 2.0 5 votes vote down vote up
@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=[]}}");
}
 
Example 4
Source File: CreateTableStatement.java    From phoenix with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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;
}
 
Example 5
Source File: LookupValuesList.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 5 votes vote down vote up
/** Empty constructor */
private LookupValuesList()
{
	valuesById = ImmutableListMultimap.of();
	ordered = true;
	debugProperties = DebugProperties.EMPTY;
}
 
Example 6
Source File: LookupValuesList.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 7
Source File: CreateTableStatement.java    From phoenix with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 8
Source File: RdapNameserverSearchActionTest.java    From nomulus with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example 9
Source File: ResourceConfigTest.java    From Strata with Apache License 2.0 5 votes vote down vote up
@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));
}
 
Example 10
Source File: ClassPathResultTest.java    From cloud-opensource-java with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example 11
Source File: ClassPathResultTest.java    From cloud-opensource-java with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 12
Source File: ConsoleEventMonitorTest.java    From copybara with Apache License 2.0 5 votes vote down vote up
private Change<DummyRevision> newChange(String revision) {
  return new Change<>(
      new DummyRevision(revision),
      new Author("Foo", "Bar"),
      "Lorem Ipsum",
      ZonedDateTime.now(ZoneId.systemDefault()),
      ImmutableListMultimap.of());
}
 
Example 13
Source File: AWSSigningRequestInterceptor.java    From aws-signing-request-interceptor with MIT License 5 votes vote down vote up
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()));
}
 
Example 14
Source File: ResourceConfigTest.java    From Strata with Apache License 2.0 5 votes vote down vote up
@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));
}
 
Example 15
Source File: AWSSigningRequestInterceptorTest.java    From aws-signing-request-interceptor with MIT License 5 votes vote down vote up
@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));
}
 
Example 16
Source File: SingularityDeployStatistics.java    From Singularity with Apache License 2.0 4 votes vote down vote up
@Schema(description = "Timestamps of failed tasks by instance number")
@Deprecated
public ListMultimap<Integer, Long> getInstanceSequentialFailureTimestamps() {
  return ImmutableListMultimap.of();
}
 
Example 17
Source File: RdapDomainSearchActionTest.java    From nomulus with Apache License 2.0 4 votes vote down vote up
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());
}
 
Example 18
Source File: PickingSlotViewRepositoryTests.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 4 votes vote down vote up
@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);
}
 
Example 19
Source File: PropertiesFileTest.java    From Strata with Apache License 2.0 4 votes vote down vote up
@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));
}
 
Example 20
Source File: GitRevision.java    From copybara with Apache License 2.0 2 votes vote down vote up
/**
 * 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);
}