本文整理汇总了Java中jersey.repackaged.com.google.common.collect.Maps.newHashMap方法的典型用法代码示例。如果您正苦于以下问题:Java Maps.newHashMap方法的具体用法?Java Maps.newHashMap怎么用?Java Maps.newHashMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jersey.repackaged.com.google.common.collect.Maps
的用法示例。
在下文中一共展示了Maps.newHashMap方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: 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())));
}
示例4: 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());
}
示例5: 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;
}
示例6: 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);
}