当前位置: 首页>>代码示例>>Java>>正文


Java ImmutableMap.of方法代码示例

本文整理汇总了Java中com.google.common.collect.ImmutableMap.of方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableMap.of方法的具体用法?Java ImmutableMap.of怎么用?Java ImmutableMap.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.ImmutableMap的用法示例。


在下文中一共展示了ImmutableMap.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleException

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Override
public Response handleException(SessionAlreadyExistingException exception) {
    UUID errorId = UUID.randomUUID();
    LOG.error(MessageFormat.format("{0} - Exception while processing request.", errorId), exception);

    Map<EventDetailsKey, String> details = ImmutableMap.of(
            message, exception.getMessage(),
            error_id, errorId.toString());

    eventSinkProxy.logHubEvent(new EventSinkHubEvent(
            serviceInfo,
            exception.getSessionId(),
            EventSinkHubEventConstants.EventTypes.ERROR_EVENT,
            details));

    return Response.status(Response.Status.BAD_REQUEST)
            .type(MediaType.APPLICATION_JSON_TYPE)
            .entity(createAuditedErrorStatus(errorId, DUPLICATE_SESSION))
            .build();
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:21,代码来源:SessionAlreadyExistingExceptionMapper.java

示例2: setUp

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Setup(Level.Trial)
@Override
public void setUp() throws Exception {
    ListeningExecutorService dsExec = MoreExecutors.newDirectExecutorService();
    executor = MoreExecutors.listeningDecorator(
            MoreExecutors.getExitingExecutorService((ThreadPoolExecutor) Executors.newFixedThreadPool(1), 1L,
                    TimeUnit.SECONDS));

    InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", dsExec);
    InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", dsExec);
    Map<LogicalDatastoreType, DOMStore> datastores = ImmutableMap.of(
        LogicalDatastoreType.OPERATIONAL, (DOMStore)operStore,
        LogicalDatastoreType.CONFIGURATION, configStore);

    domBroker = new SerializedDOMDataBroker(datastores, executor);
    schemaContext = BenchmarkModel.createTestContext();
    configStore.onGlobalContextUpdated(schemaContext);
    operStore.onGlobalContextUpdated(schemaContext);
    initTestNode();
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:21,代码来源:InMemoryBrokerWriteTransactionBenchmark.java

示例3: testEmptyTransactionSubmitSucceeds

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Test
public void testEmptyTransactionSubmitSucceeds() throws ExecutionException, InterruptedException {
    DOMStore domStore = mock(DOMStore.class);
    try (ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(
            LogicalDatastoreType.OPERATIONAL, domStore, LogicalDatastoreType.CONFIGURATION, domStore),
            futureExecutor)) {

        CheckedFuture<Void, TransactionCommitFailedException> submit1 =
                dataBroker.newWriteOnlyTransaction().submit();

        assertNotNull(submit1);

        submit1.get();

        CheckedFuture<Void, TransactionCommitFailedException> submit2 =
                dataBroker.newReadWriteTransaction().submit();

        assertNotNull(submit2);

        submit2.get();
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:23,代码来源:ConcurrentDOMDataBrokerTest.java

示例4: testFromGauges_Ungrouped

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Test
public void testFromGauges_Ungrouped() {
  final DropwizardMeasurementParser parser = mock(DropwizardMeasurementParser.class);
  final DropwizardTransformer transformer = transformerWithParser(parser, false);

  final Map<String, Gauge> gauges = ImmutableMap.of(
    "some.stuff.queued", () -> 12,
    "some.stuff.processed", () -> 15
  );

  when(parser.parse("some.stuff.queued")).thenReturn(
    DropwizardMeasurement.create("some.stuff.queued", MEASUREMENT_TAGS, Optional.empty())
  );

  when(parser.parse("some.stuff.processed")).thenReturn(
    DropwizardMeasurement.create("some.stuff.processed", MEASUREMENT_TAGS, Optional.empty())
  );

  final List<InfluxDbMeasurement> expected = ImmutableList.of(
    InfluxDbMeasurement.create("some.stuff.queued", ALL_TAGS, ImmutableMap.of("value", "12i"), 90210L),
    InfluxDbMeasurement.create("some.stuff.processed", ALL_TAGS, ImmutableMap.of("value", "15i"), 90210L)
  );

  final List<InfluxDbMeasurement> measurements = transformer.fromGauges(gauges, 90210L);
  assertEquals("should not group gauge measurements", expected, measurements);
}
 
开发者ID:kickstarter,项目名称:dropwizard-influxdb-reporter,代码行数:27,代码来源:DropwizardTransformerTest.java

示例5: decodeHeaders

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
private static Map<String, String> decodeHeaders(int expectedHeadersType, ByteBuf messageHeader)
{
    if (messageHeader.readableBytes() == 0) {
        return ImmutableMap.of();
    }

    byte headersType = messageHeader.readByte();
    if (headersType != expectedHeadersType) {
        return ImmutableMap.of();
    }

    ImmutableMap.Builder<String, String> headers = ImmutableMap.builder();
    int headerCount = readVarint(messageHeader);
    for (int i = 0; i < headerCount; i++) {
        String key = readString(messageHeader);
        String value = readString(messageHeader);
        headers.put(key, value);
    }
    return headers.build();
}
 
开发者ID:airlift,项目名称:drift,代码行数:21,代码来源:HeaderMessageEncoding.java

示例6: shouldHandleEmptyInMergedMaps

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Test
public void shouldHandleEmptyInMergedMaps() throws Exception {

    final Observable<Integer> a = Observable.empty();

    final Observable<Integer> b = Observable.create(s -> {
        s.onNext(1);
        s.onNext(2);
        s.onNext(3);
        s.onComplete();
    });

    final ImmutableMap<String, Observable<Integer>> map = ImmutableMap.of(
        "a", a,
        "b", b
    );

    final Observable<ImmutableMap<String, Integer>> observableMap =
        MoreObservables.mergeMaps(map);

    final int error = observableMap
        .reduce(1, (x, y) -> 0)
        .blockingGet();

    assertEquals(0, error);
}
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:27,代码来源:MoreObservablesTest.java

示例7: setup

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Before
public void setup() throws Exception {
  final ElasticsearchCluster.ColumnData[] justMapping = new ElasticsearchCluster.ColumnData[]{
      new ElasticsearchCluster.ColumnData("full_address", STRING, null),
      new ElasticsearchCluster.ColumnData("city", STRING, ImmutableMap.of("index", "not_analyzed"), null),
      new ElasticsearchCluster.ColumnData("review_count", INTEGER, null),
      new ElasticsearchCluster.ColumnData("stars", FLOAT, null)
  };

  elastic.load(schema, table, justMapping);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:12,代码来源:TestEmptyIndexType.java

示例8: empty

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Test
public void empty() throws Exception {
    ImmutableWeightedRandomChooser<?, ?> chooser = new ImmutableWeightedRandomChooser<>(ImmutableMap.of());
    assertTrue(chooser.isEmpty());
    assertTotalWeight(0, chooser);
    assertThrows(NoSuchElementException.class, () -> chooser.choose(entropy));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:8,代码来源:WeightedRandomChooserTest.java

示例9: shouldVisitCatalog

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
protected boolean shouldVisitCatalog() {
  if (filter == null) {
    return true;
  }

  final Map<String, String> recordValues = ImmutableMap.of(CATS_COL_CATALOG_NAME, catalogName);

  // If the filter evaluates to false then we don't need to visit the catalog.
  // For other two results (TRUE, INCONCLUSIVE) continue to visit the catalog.
  return filter.evaluate(recordValues) != Result.FALSE;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:12,代码来源:InfoSchemaRecordGenerator.java

示例10: testExecutePrivate

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Test(timeOut = 60 * 1000L)
public void testExecutePrivate() throws Exception {

    conf.addProperty(
            "com.after_sunrise.cryptocurrency.cryptotrader.service.coincheck.CoincheckContext.api.id",
            "my_id"
    );
    conf.addProperty(
            "com.after_sunrise.cryptocurrency.cryptotrader.service.coincheck.CoincheckContext.api.secret",
            "my_secret"
    );
    doReturn(Instant.ofEpochMilli(1234567890)).when(target).getNow();

    String path = "http://localhost:80/test";
    Map<String, String> params = ImmutableMap.of("foo", "bar");
    String data = "hoge";

    Map<String, String> headers = new LinkedHashMap<>();
    headers.put("Content-Type", "application/json");
    headers.put("ACCESS-KEY", "my_id");
    headers.put("ACCESS-NONCE", "1234567890");
    headers.put("ACCESS-SIGNATURE", "c1882128a3b8bcf13cec68d2dabf0ab867064f97afc90162624d32273a05b65a");
    doReturn("test").when(target).request(GET, path + "?foo=bar", headers, data);

    assertEquals(target.executePrivate(GET, path, params, data), "test");

}
 
开发者ID:after-the-sunrise,项目名称:cryptotrader,代码行数:28,代码来源:CoincheckContextTest.java

示例11: OFSwitch

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
public OFSwitch(IOFConnectionBackend connection, @Nonnull OFFactory factory, @Nonnull IOFSwitchManager switchManager,
		@Nonnull DatapathId datapathId) {
	if(connection == null)
		throw new NullPointerException("connection must not be null");
	if(!connection.getAuxId().equals(OFAuxId.MAIN))
		throw new IllegalArgumentException("connection must be the main connection");
	if(factory == null)
		throw new NullPointerException("factory must not be null");
	if(switchManager == null)
		throw new NullPointerException("switchManager must not be null");

	this.connected = true;
	this.factory = factory;
	this.switchManager = switchManager;
	this.datapathId = datapathId;
	this.attributes = new ConcurrentHashMap<Object, Object>();
	this.role = null;
	this.description = new SwitchDescription();
	this.portManager = new PortManager();
	this.status = SwitchStatus.HANDSHAKE;

	// Connections
	this.connections = new ConcurrentHashMap<OFAuxId, IOFConnectionBackend>();
	this.connections.put(connection.getAuxId(), connection);

	// Switch's controller connection
	this.controllerConnections = ImmutableMap.of();

	// Defaults properties for an ideal switch
	this.setAttribute(PROP_FASTWILDCARDS, EnumSet.allOf(OFFlowWildcards.class));
	this.setAttribute(PROP_SUPPORTS_OFPP_FLOOD, Boolean.TRUE);
	this.setAttribute(PROP_SUPPORTS_OFPP_TABLE, Boolean.TRUE);
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:34,代码来源:OFSwitch.java

示例12: createIncompatiblePairsOfTransactionsAndIDPs

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Test
public void createIncompatiblePairsOfTransactionsAndIDPs() throws Exception {
    Map<TransactionConfigEntityData, List<IdentityProviderConfigEntityData>> incompatiblePairs = ImmutableMap.of(aTransactionConfigData().build(), asList(anIdentityProviderConfigData().build()));
    ConfigValidationException exception = ConfigValidationException.createIncompatiblePairsOfTransactionsAndIDPs(incompatiblePairs);
    assertThat(exception.getMessage()).isEqualTo("Transaction unsupported by IDP(s).\n" +
            "Transaction: default-transaction-entity-id\n" +
            "IDP(s): [default-idp-entity-id]\n");
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:9,代码来源:ConfigValidationExceptionTest.java

示例13: sourceOffsets

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Test
public void sourceOffsets() throws InterruptedException {
  final String SEQUENCE_NUMBER = "asdfasdfddsa";
  Map<String, Object> sourceOffset = ImmutableMap.of(RecordConverter.FIELD_SEQUENCE_NUMBER, SEQUENCE_NUMBER);
  when(this.offsetStorageReader.offset(anyMap())).thenReturn(sourceOffset);
  when(this.kinesisClient.getShardIterator(any())).thenReturn(
      new GetShardIteratorResult().withShardIterator("dfasdfsadfasdf")
  );
  this.task.start(settings);

  GetRecordsResult recordsResult = new GetRecordsResult()
      .withNextShardIterator("dsfargadsfasdfasda")
      .withRecords(TestData.record())
      .withMillisBehindLatest(0L);

  when(this.kinesisClient.getRecords(any())).thenReturn(recordsResult);

  List<SourceRecord> records = this.task.poll();

  assertNotNull(records, "records should not be null.");
  assertFalse(records.isEmpty(), "records should not be empty.");

  verify(this.offsetStorageReader, atLeastOnce()).offset(anyMap());

  GetShardIteratorRequest expectedIteratorRequest = new GetShardIteratorRequest()
      .withShardIteratorType(ShardIteratorType.AFTER_SEQUENCE_NUMBER)
      .withShardId(this.config.kinesisShardId)
      .withStreamName(this.config.kinesisStreamName)
      .withStartingSequenceNumber(SEQUENCE_NUMBER);

  verify(this.kinesisClient, atLeastOnce()).getShardIterator(expectedIteratorRequest);
}
 
开发者ID:jcustenborder,项目名称:kafka-connect-kinesis,代码行数:33,代码来源:KinesisSourceTaskTest.java

示例14: markAccountEventAsRead

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Override
public void markAccountEventAsRead(final int accountEventId) {
    val url = ACCOUNT_EVENT_READ.replace("{account_id}", String.valueOf(accountEventId));
    val emptyMap = ImmutableMap.of();
    val jsonReq = Json.toJson(emptyMap);
    log.trace("JSON request {}", jsonReq);
    val reqBody = RequestBody.create(JSON, jsonReq);

    executeReq(url, HttpMethod.POST, Void.TYPE, reqBody);
}
 
开发者ID:ankushs92,项目名称:linode4j,代码行数:11,代码来源:LinodeApiClient.java

示例15: toMap

import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Override
public Map<String, String> toMap() {
    return ImmutableMap.of(TAG_CONVERGE, Boolean.toString(converge),
                           TAG_CRITERIA1, criteria1.toString(),
                           TAG_CRITERIA2, criteria2.toString(),
                           TAG_CRITERIA3, criteria3.toString());
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:8,代码来源:MultiCriteriaVoltageStabilityIndex2.java


注:本文中的com.google.common.collect.ImmutableMap.of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。