本文整理汇总了Java中jersey.repackaged.com.google.common.collect.Maps类的典型用法代码示例。如果您正苦于以下问题:Java Maps类的具体用法?Java Maps怎么用?Java Maps使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Maps类属于jersey.repackaged.com.google.common.collect包,在下文中一共展示了Maps类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSearchCenter
import jersey.repackaged.com.google.common.collect.Maps; //导入依赖的package包/类
@Test
public void testSearchCenter() {
when(amazonCloudSearch.describeDomains(any())).thenReturn(new DescribeDomainsResult()
.withDomainStatusList(Lists.newArrayList(new DomainStatus().withSearchService(new ServiceEndpoint().withEndpoint("http://localhost")))));
HashMap<String, List<String>> map = Maps.newHashMap();
map.put("property", Lists.newArrayList("value"));
SearchResult expected = new SearchResult().withHits(new Hits().withHit(new Hit().withFields(map)));
ArgumentCaptor<SearchRequest> requestCaptor = ArgumentCaptor.forClass(SearchRequest.class);
when(domain.search(requestCaptor.capture())).thenReturn(expected);
List<ObjectNode> result = getService(ModelIndexer.class).searchCenter("0,0");
SearchRequest request = requestCaptor.getValue();
assertEquals("value", result.get(0).get("property").asText());
assertEquals("latlon:['0.1,-0.1','-0.1,0.1']", request.getQuery());
assertEquals("{\"distance\":\"haversin(0.0,0.0,latlon.latitude,latlon.longitude)\"}", request.getExpr());
assertEquals("distance asc", request.getSort());
assertEquals(Long.valueOf(30L), request.getSize());
}
示例2: listUserProjects
import jersey.repackaged.com.google.common.collect.Maps; //导入依赖的package包/类
@Override
public CollectionWrapper<Project> listUserProjects(String userid) throws Exception {
Entry<String, String> entrys = Maps.immutableEntry("user_id", userid);
FilterProtectedAction<Project> command = new FilterProtectedDecorator<Project>(new ListUserProjectsAction(
assignmentApi, tokenProviderApi, policyApi, userid), tokenProviderApi, policyApi, entrys);
CollectionWrapper<Project> ret = command.execute(getRequest(), "enabled", "name");
return ret;
}
示例3: exportPropertyMap
import jersey.repackaged.com.google.common.collect.Maps; //导入依赖的package包/类
private static Map<String, String> exportPropertyMap(Iterable<String> lines) {
final Map<String, String> map = Maps.newHashMap();
lines.forEach(line -> {
Iterator<String> i = eqSp.split(line).iterator();
String k = i.next();
if (Strings.isNullOrEmpty(k))
return;
String v = eqJn.join(i);
map.put(k, v);
});
return map;
}
示例4: getDeploymentWithOutputSuccessfully
import jersey.repackaged.com.google.common.collect.Maps; //导入依赖的package包/类
@Test
public void getDeploymentWithOutputSuccessfully() throws Exception {
String deploymentId = "mmd34483-d937-4578-bfdb-ebe196bf82dd";
Deployment deployment = ControllerTestUtils.createDeployment(deploymentId);
Map<String, Object> outputs = Maps.newHashMap();
String key = "server_ip";
String value = "10.0.0.1";
outputs.put(key, value);
deployment.setOutputs(outputs);
deployment.setStatus(Status.CREATE_FAILED);
deployment.setStatusReason("Some reason");
Mockito.when(deploymentService.getDeployment(deploymentId)).thenReturn(deployment);
mockMvc
.perform(get("/deployments/" + deploymentId).header(HttpHeaders.AUTHORIZATION,
OAuth2AccessToken.BEARER_TYPE + " <access token>"))
.andExpect(status().isOk())
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.outputs", Matchers.hasEntry(key, value)))
.andDo(document("deployment", preprocessResponse(prettyPrint()),
responseFields(fieldWithPath("links[]").ignored(),
fieldWithPath("uuid").description("The unique identifier of a resource"),
fieldWithPath("creationTime").description(
"Creation date-time (http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14)"),
fieldWithPath("updateTime").description("Update date-time"),
fieldWithPath("status").description(
"The status of the deployment. (http://indigo-dc.github.io/orchestrator/apidocs/it/reply/orchestrator/enums/Status.html)"),
fieldWithPath("statusReason").description(
"Verbose explanation of reason that lead to the deployment status (Present only if the deploy is in some error status)"),
fieldWithPath("task").description(
"The current step of the deployment process. (http://indigo-dc.github.io/orchestrator/apidocs/it/reply/orchestrator/enums/Task.html)"),
fieldWithPath("callback").description(
"The endpoint used by the orchestrator to notify the progress of the deployment process."),
fieldWithPath("outputs").description("The outputs of the TOSCA document"),
fieldWithPath("links[]").ignored())));
}
示例5: resolveDashedProperties
import jersey.repackaged.com.google.common.collect.Maps; //导入依赖的package包/类
static Properties resolveDashedProperties(Properties properties, Map<String, String> envEntries) {
//stream over all known properties
properties.stringPropertyNames().parallelStream()
.filter(Objects::nonNull)
// sakuli.test.env -> SAKULI_TEST_ENV , sakuli.test.env
.map(propKey -> Maps.immutableEntry(propKey.toUpperCase().replaceAll("\\.", "_"), propKey))
// environment contains SAKULI_TEST_ENV ?
.filter(keyTupel -> envEntries.containsKey(keyTupel.getKey()))
// sakuli.test.env, <value from env>
.map(keyTupel -> mapEnvValueToPropKey(envEntries, keyTupel))
// update properties
.forEach(e -> properties.put(e.getKey(), e.getValue()));
return properties;
}
示例6: mapEnvValueToPropKey
import jersey.repackaged.com.google.common.collect.Maps; //导入依赖的package包/类
/**
* Resolves from the environment map, the fitting value of the Entry {@code <environment-key, property-key>} and logs the usage.
*/
private static Map.Entry<String, String> mapEnvValueToPropKey(Map<String, String> envEntries, Map.Entry<String, String> keyTupel) {
final String envKey = keyTupel.getKey();
final String propertyKey = keyTupel.getValue();
final String finalValue = envEntries.getOrDefault(envKey, "");
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("use environment variable '{}={}' value instead of property '{}'", envKey, finalValue, propertyKey);
} else {
LOGGER.info("use environment variable '{}' value instead of property '{}'", envKey, propertyKey);
}
return Maps.immutableEntry(propertyKey, finalValue);
}
示例7: setProjectEntryTextLayerBody
import jersey.repackaged.com.google.common.collect.Maps; //导入依赖的package包/类
public void setProjectEntryTextLayerBody(int projectId, int entryId, int transcriptionId, String newBody) {
Map<String, Object> transcription = Maps.newHashMap();
transcription.put("body", newBody);
Entity<?> entity = Entity.entity(transcription, MediaType.APPLICATION_JSON);
Response response = projectsTarget.path(String.valueOf(projectId))//
.path("entries").path(String.valueOf(entryId))//
.path("transcriptions").path(String.valueOf(transcriptionId))//
.request(MediaType.APPLICATION_JSON)//
.header("Authorization", "SimpleAuth " + token)//
.put(entity);
Log.info("response.status={}", response.getStatus());
}
示例8: addProject
import jersey.repackaged.com.google.common.collect.Maps; //导入依赖的package包/类
public Integer addProject(String projectTitle) {
Map<String, Object> payload = Maps.newHashMap();
payload.put("title", projectTitle);
Entity<?> entity = Entity.entity(payload, MediaType.APPLICATION_JSON);
Response response = projectsTarget//
.request(MediaType.APPLICATION_JSON)//
.header("Authorization", "SimpleAuth " + token)//
.post(entity);
Log.info("response = {}", response);
String location = response.getHeaderString("Location");
Integer projectId = Integer.valueOf(location.replaceFirst("^.*/", ""));
return projectId;
}
示例9: createRandomPartitionsAndStoredOffsets
import jersey.repackaged.com.google.common.collect.Maps; //导入依赖的package包/类
private static Map<TableRuntimeContext, Map<String, String>> createRandomPartitionsAndStoredOffsets(
boolean enablePartitioning
) {
Random random = RandomTestUtils.getRandom();
Map<TableRuntimeContext, Map<String, String>> partitions = new HashMap<>();
List<Integer> sqlTypes = new ArrayList<>(TableContextUtil.PARTITIONABLE_TYPES);
String schemaName = "schema";
String offsetColName = "OFFSET_COL";
int numTables = RandomTestUtils.nextInt(1, 8);
for (int t = 0; t < numTables; t++) {
String tableName = String.format("table%d", t);
int type = sqlTypes.get(RandomTestUtils.nextInt(0, sqlTypes.size()));
PartitioningMode partitioningMode = enablePartitioning && random.nextBoolean()
? PartitioningMode.BEST_EFFORT : PartitioningMode.DISABLED;
final boolean partitioned = partitioningMode == PartitioningMode.BEST_EFFORT;
int maxNumPartitions = partitioned ? RandomTestUtils.nextInt(1, 10) : 1;
// an integer should be compatible with all partitionable types
int partitionSize = RandomTestUtils.nextInt(1, 1000000);
TableContext table = new TableContext(
schemaName,
tableName,
Maps.newLinkedHashMap(Collections.singletonMap(offsetColName, type)),
Collections.singletonMap(offsetColName, null),
Collections.singletonMap(offsetColName, String.valueOf(partitionSize)),
Collections.singletonMap(offsetColName, "0"),
TableConfigBean.ENABLE_NON_INCREMENTAL_DEFAULT_VALUE,
partitioningMode,
maxNumPartitions,
null
);
for (int p = 0; p < maxNumPartitions; p++) {
if (partitioned && random.nextBoolean() && !(p == maxNumPartitions - 1 && partitions.isEmpty())) {
// only create some partitions
continue;
}
int startOffset = p * partitionSize;
int maxOffset = (p + 1) * partitionSize;
Map<String, String> partitionStoredOffsets = null;
if (random.nextBoolean()) {
// only simulate stored offsets sometimes
int storedOffset = RandomTestUtils.nextInt(startOffset + 1, maxOffset + 1);
partitionStoredOffsets = Collections.singletonMap(offsetColName, String.valueOf(storedOffset));
}
TableRuntimeContext partition = new TableRuntimeContext(
table,
false,
partitioned,
partitioned ? p + 1 : TableRuntimeContext.NON_PARTITIONED_SEQUENCE,
Collections.singletonMap(offsetColName, String.valueOf(startOffset)),
Collections.singletonMap(offsetColName, String.valueOf(maxOffset)),
partitionStoredOffsets
);
partitions.put(partition, partitionStoredOffsets);
}
}
return partitions;
}
示例10: ChunkedRequestAssembler
import jersey.repackaged.com.google.common.collect.Maps; //导入依赖的package包/类
public ChunkedRequestAssembler() {
this.chunkMap = Maps.newConcurrentMap();
this.initialRequests = Maps.newConcurrentMap();
}
示例11: main
import jersey.repackaged.com.google.common.collect.Maps; //导入依赖的package包/类
/**
* simple main class to run a thread connecting to a sample API using Streamdata.io service.
*
* @param args
*/
public static void main(String[] args) throws Exception {
// the sample API
String apiUrl = "http://stockmarket.streamdata.io/v2/prices";
String token = "[YOUR TOKEN HERE]";
// specific header map associated with the request
Map<String,String> headers = Maps.newHashMap();
// add this header if you wish to stream Json rather than Json-patch
// NOTE: no 'patch' event will be emitted.
// headers.put("Accept", "application/json");
String url = buildStreamdataUrl(apiUrl, token, headers);
// Start the event source as a Thread.
SampleEventSource eventSource = new SampleEventSource(url);
eventSource.setDaemon(true);
eventSource.start();
// let the sample app run for a few seconds.
Thread.sleep(30000);
// Close the eventSource
eventSource.close();
// then exit.
System.exit(0);
}