本文整理汇总了Java中com.sun.jersey.core.util.MultivaluedMapImpl类的典型用法代码示例。如果您正苦于以下问题:Java MultivaluedMapImpl类的具体用法?Java MultivaluedMapImpl怎么用?Java MultivaluedMapImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MultivaluedMapImpl类属于com.sun.jersey.core.util包,在下文中一共展示了MultivaluedMapImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import com.sun.jersey.core.util.MultivaluedMapImpl; //导入依赖的package包/类
public String create() throws Exception {
String resource = TWEET_CREATE.replace("{account_id}", account_id);
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("status", status);
if (null != media_ids) {
params.add("media_ids", Joiner.on(',').join(media_ids));
}
if (null != as_user_id) {
params.add("as_user_id", as_user_id);
}
log.debug("calling twitter endpoint : " + getResource().path(resource).toString());
Map map = getResource().path(resource).type(MediaType.APPLICATION_FORM_URLENCODED)
.accept(MediaType.APPLICATION_JSON_TYPE).post(Map.class, params);
log.debug(map.toString());
return (String) map.get("id_str");
}
示例2: destroy
import com.sun.jersey.core.util.MultivaluedMapImpl; //导入依赖的package包/类
public static void destroy(Long tweetId) {
Client client = ClientServiceFactory.getInstance().getClient();
String domain = "https://api.twitter.com/";
String resourcePath = "/1.1/statuses/destroy/" + tweetId.toString() + ".json";
WebResource webResource = client.resource(domain);
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("id", tweetId.toString());
ClientResponse response = webResource
.path(resourcePath)
.type(MediaType.APPLICATION_FORM_URLENCODED)
.accept(MediaType.APPLICATION_JSON_TYPE)
.post(ClientResponse.class, params);
String output = response.getEntity(String.class);
log.info(output);
}
示例3: worstRatedItems_requestedItemType_shouldFilterResults
import com.sun.jersey.core.util.MultivaluedMapImpl; //导入依赖的package包/类
@Test
public void worstRatedItems_requestedItemType_shouldFilterResults() {
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("tenantid", TENANT_ID);
params.add("apikey", API_KEY);
params.add("requesteditemtype", "OTHER_ITEM");
JSONObject json = makeAPIRequest(params);
assertThat(json, not(is(nullValue())));
assertThat(json.getString("tenantid"), is(TENANT_ID));
assertThat(json.getString("action"), is("worstrateditems"));
JSONArray items = getSafeJSONArray(json, "recommendeditems", "item");
assertThat(items.size(), is(1));
JSONObject item = items.getJSONObject(0);
assertThat(item.getString("creationDate"), is("2011-06-22 12:05:00.0"));
assertThat(item.getString("description"), is("Other B"));
assertThat(item.getString("imageUrl"), is("http://testtenant.com/test/other/b/img.png"));
assertThat(item.getString("id"), is("OTHER_B"));
assertThat(item.getString("itemType"), is("OTHER_ITEM"));
assertThat(item.getString("url"), is("http://testtenant.com/test/other/b"));
assertThat(item.getString("value"), is("3.0"));
}
示例4: bestRatedItems_requestedItemType_shouldFilterResults
import com.sun.jersey.core.util.MultivaluedMapImpl; //导入依赖的package包/类
@Test
public void bestRatedItems_requestedItemType_shouldFilterResults() {
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("tenantid", TENANT_ID);
params.add("apikey", API_KEY);
params.add("requesteditemtype", "OTHER_ITEM");
JSONObject json = makeAPIRequest(params);
assertThat(json, not(is(nullValue())));
assertThat(json.getString("tenantid"), is(TENANT_ID));
assertThat(json.getString("action"), is("bestrateditems"));
JSONArray items = getSafeJSONArray(json, "recommendeditems", "item");
assertThat(items.size(), is(1));
JSONObject item = items.getJSONObject(0);
assertThat(item.getString("creationDate"), is("2011-06-22 12:04:00.0"));
assertThat(item.getString("description"), is("Other A"));
assertThat(item.getString("imageUrl"), is("http://testtenant.com/test/other/a/img.png"));
assertThat(item.getString("id"), is("OTHER_A"));
assertThat(item.getString("itemType"), is("OTHER_ITEM"));
assertThat(item.getString("url"), is("http://testtenant.com/test/other/a"));
assertThat(item.getString("value"), is("9.0"));
}
示例5: rate_wrongApiKey_shouldReturnError
import com.sun.jersey.core.util.MultivaluedMapImpl; //导入依赖的package包/类
@Test
public void rate_wrongApiKey_shouldReturnError() {
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("tenantid", TENANT_ID);
params.add("apikey", "0123456789abcdefedcba98765432100");
params.add("sessionid", "TEST_SESSION");
params.add("itemid", "TEST_A");
params.add("itemdescription", "Test A");
params.add("itemurl", "http://testtenant.com/test/test/a");
params.add("ratingvalue", "5");
JSONObject json = makeAPIRequest(params);
assertThat(json, not(is(nullValue())));
assertThat(json.getJSONObject("error").getString("@code"), is("299"));
assertThat(json.getJSONObject("error").getString("@message"),
containsString("Wrong APIKey/Tenant combination"));
}
示例6: itemTypes_apiKeyTenant_shouldReturnItemTypes
import com.sun.jersey.core.util.MultivaluedMapImpl; //导入依赖的package包/类
@Test
public void itemTypes_apiKeyTenant_shouldReturnItemTypes() {
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("tenantid", TENANT_ID);
params.add("apikey", API_KEY);
JSONObject json = makeAPIRequest(params);
assertThat(json, not(is(nullValue())));
assertThat(json.getString("tenantId"), is(TENANT_ID));
JSONArray itemTypes = getSafeJSONArray(json, "itemTypes", "itemType");
// itemtypes where visible=0 are not shown
assertThat(itemTypes.size(), is(2));
assertThat(itemTypes.getString(0), is("ITEM_TYPE"));
assertThat(itemTypes.getString(1), is("OTHER_ITEM"));
}
示例7: recommendationsForUser_wrongUser_shouldReturnError
import com.sun.jersey.core.util.MultivaluedMapImpl; //导入依赖的package包/类
@Test
public void recommendationsForUser_wrongUser_shouldReturnError() {
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("tenantid", TENANT_ID);
params.add("apikey", API_KEY);
params.add("userid", "WRONG_USER");
params.add("itemtype", "ITEM");
JSONObject json = makeAPIRequest(params);
assertThat(json, not(is(nullValue())));
assertThat(json.getString("action"), is("recommendationsforuser"));
assertThat(json.getString("tenantid"), is(TENANT_ID));
assertThat(json.getString("userid"), is("WRONG_USER"));
JSONArray items = getSafeJSONArray(json, "recommendeditems", "item");
assertThat(items.size(), is(0));
// TODO in the future this test case should return an error (ie when users are explicitly modelled)
// assertThat(json, not(is(nullValue())));
// assertThat(json.getJSONObject("error").getString("@code"), is("402"));
// assertThat(json.getJSONObject("error").getString("@message"), containsString("User id not valid"));
}
示例8: rate_noSessionId_shouldReturnError
import com.sun.jersey.core.util.MultivaluedMapImpl; //导入依赖的package包/类
@Test
public void rate_noSessionId_shouldReturnError() {
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("tenantid", TENANT_ID);
params.add("apikey", API_KEY);
params.add("itemid", "TEST_A");
params.add("itemdescription", "Test A");
params.add("itemurl", "http://testtenant.com/test/test/a");
params.add("ratingvalue", "5");
JSONObject json = makeAPIRequest(params);
assertThat(json, not(is(nullValue())));
assertThat(json.getJSONObject("error").getString("@code"), is("401"));
assertThat(json.getJSONObject("error").getString("@message"), containsString("session id required"));
}
示例9: itemsRatedGoodByOtherUsers_wrongItemType_shouldReturnError
import com.sun.jersey.core.util.MultivaluedMapImpl; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
@Test
public void itemsRatedGoodByOtherUsers_wrongItemType_shouldReturnError() {
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("tenantid", TENANT_ID);
params.add("apikey", API_KEY);
params.add("itemid", "ITEM_A");
params.add("itemtype", "WRONG_ITEMTYPE");
JSONObject json = makeAPIRequest(params);
assertThat(json, not(is(nullValue())));
assertThat(json.getJSONObject("error").getString("@code"), is("912"));
assertThat(json.getJSONObject("error").getString("@message"),
allOf(containsString("Operation failed"), containsString("itemType"), containsString("WRONG_ITEMTYPE"),
containsString("not found")));
}
示例10: buy_wrongApiKey_shouldReturnError
import com.sun.jersey.core.util.MultivaluedMapImpl; //导入依赖的package包/类
@Test
public void buy_wrongApiKey_shouldReturnError() {
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("tenantid", TENANT_ID);
params.add("apikey", "0123456789abcdefedcba98765432100");
params.add("sessionid", "TEST_SESSION");
params.add("itemid", "TEST_A");
params.add("itemdescription", "Test A");
params.add("itemurl", "http://testtenant.com/test/test/a");
JSONObject json = makeAPIRequest(params);
assertThat(json, not(is(nullValue())));
assertThat(json.getJSONObject("error").getString("@code"), is("299"));
assertThat(json.getJSONObject("error").getString("@message"),
containsString("Wrong APIKey/Tenant combination"));
}
示例11: storeFieldItemTypeNotFound
import com.sun.jersey.core.util.MultivaluedMapImpl; //导入依赖的package包/类
@Test
public void storeFieldItemTypeNotFound() {
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("tenantid", TENANT_ID);
params.add("apikey", API_KEY);
params.add("itemid", "PROFILE_TEST_ITEM_1");
params.add("itemtype", "I_DO_NOT_EXIST");
params.add("field", "/profile/weight");
params.add("value", "70");
JSONObject json = makeAPIRequest(params);
assertThat(json, not(is(nullValue())));
assertThat(json.getJSONObject("error").getString("@code"), is("912"));
}
示例12: itemsOfCluster_requestedItemType_shouldFilter
import com.sun.jersey.core.util.MultivaluedMapImpl; //导入依赖的package包/类
@Test
public void itemsOfCluster_requestedItemType_shouldFilter() {
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("tenantid", TENANT_ID);
params.add("apikey", API_KEY);
params.add("clusterid", "CLUSTER_A_1");
params.add("requesteditemtype", "OTHER_ITEM");
JSONObject json = makeAPIRequest(params);
assertThat(json, not(is(nullValue())));
assertThat(json.getString("tenantid"), is(TENANT_ID));
assertThat(json.getString("action"), is("itemsofcluster"));
JSONArray items = getSafeJSONArray(json, "recommendeditems", "item");
assertThat(items.size(), is(1));
JSONObject item = items.getJSONObject(0);
assertThat(item.getString("creationDate"), is("2011-06-22 12:04:00.0"));
assertThat(item.getString("description"), is("Other A"));
assertThat(item.getString("imageUrl"), is("http://testtenant.com/test/other/a/img.png"));
assertThat(item.getString("id"), is("OTHER_A"));
assertThat(item.getString("itemType"), is("OTHER_ITEM"));
assertThat(item.getString("url"), is("http://testtenant.com/test/other/a"));
}
示例13: rate_tooLittleRatingValue_shouldReturnError
import com.sun.jersey.core.util.MultivaluedMapImpl; //导入依赖的package包/类
@Test
public void rate_tooLittleRatingValue_shouldReturnError() {
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("tenantid", TENANT_ID);
params.add("apikey", API_KEY);
params.add("sessionid", "TEST_SESSION");
params.add("itemid", "TEST_A");
params.add("itemdescription", "Test A");
params.add("itemurl", "http://testtenant.com/test/test/a");
params.add("ratingvalue", "-1");
JSONObject json = makeAPIRequest(params);
assertThat(json, not(is(nullValue())));
assertThat(json.getJSONObject("error").getString("@code"), is("305"));
assertThat(json.getJSONObject("error").getString("@message"),
containsString("Rating Value must be a valid Integer"));
}
示例14: rate_withRequiredParameters_shouldCreateViewActionAndItem
import com.sun.jersey.core.util.MultivaluedMapImpl; //导入依赖的package包/类
@Test
@ExpectedDataSet("/dbunit/web/rest/expected_rate_1.xml")
public void rate_withRequiredParameters_shouldCreateViewActionAndItem() {
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("tenantid", TENANT_ID);
params.add("apikey", API_KEY);
params.add("sessionid", "TEST_SESSION");
params.add("itemid", "TEST_A");
params.add("itemdescription", "Test A");
params.add("itemurl", "http://testtenant.com/test/test/a");
params.add("ratingvalue", "5");
JSONObject json = makeAPIRequest(params);
assertThat(json, not(is(nullValue())));
assertThat(json.getString("action"), is("rate"));
assertThat(json.getString("tenantid"), is(TENANT_ID));
assertThat(json.getString("sessionid"), is("TEST_SESSION"));
assertThat(json.getString("ratingValue"), is("5"));
assertThat(json.getJSONObject("item").getString("id"), is("TEST_A"));
assertThat(json.getJSONObject("item").getString("itemType"), is("ITEM"));
assertThat(json.getJSONObject("item").getString("description"), is("Test A"));
assertThat(json.getJSONObject("item").getString("url"), is("http://testtenant.com/test/test/a"));
}
示例15: otherUsersAlsoBought_wrongItemType_shouldReturnError
import com.sun.jersey.core.util.MultivaluedMapImpl; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
@Test
public void otherUsersAlsoBought_wrongItemType_shouldReturnError() {
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("tenantid", TENANT_ID);
params.add("apikey", API_KEY);
params.add("itemid", "ITEM_A");
params.add("itemtype", "WRONG_ITEMTYPE");
JSONObject json = makeAPIRequest(params);
assertThat(json, not(is(nullValue())));
assertThat(json.getJSONObject("error").getString("@code"), is("912"));
assertThat(json.getJSONObject("error").getString("@message"),
allOf(containsString("Operation failed"), containsString("itemType"), containsString("WRONG_ITEMTYPE"),
containsString("not found")));
}