本文整理汇总了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();
}
示例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();
}
示例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();
}
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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));
}
示例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;
}
示例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");
}
示例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);
}
示例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");
}
示例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);
}
示例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);
}
示例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());
}