當前位置: 首頁>>代碼示例>>Java>>正文


Java MultivaluedMapImpl類代碼示例

本文整理匯總了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");
}
 
開發者ID:mrisney,項目名稱:twitter-java-ads-sdk,代碼行數:20,代碼來源:Tweet.java

示例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);
}
 
開發者ID:mrisney,項目名稱:twitter-java-ads-sdk,代碼行數:22,代碼來源:Tweet.java

示例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"));
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:27,代碼來源:WorstRatedItemsTest.java

示例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"));
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:27,代碼來源:BestRatedItemsTest.java

示例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"));
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:19,代碼來源:RateTest.java

示例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"));
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:19,代碼來源:ItemTypesTest.java

示例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"));
    }
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:25,代碼來源:RecommendationsForUserTest.java

示例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"));
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:17,代碼來源:RateTest.java

示例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")));
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:18,代碼來源:ItemsRatedGoodByOtherUsersTest.java

示例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"));
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:18,代碼來源:BuyTest.java

示例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"));
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:17,代碼來源:FieldStoreAPITest.java

示例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"));
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:27,代碼來源:ItemsOfClusterTest.java

示例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"));
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:19,代碼來源:RateTest.java

示例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"));
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:25,代碼來源:RateTest.java

示例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")));
}
 
開發者ID:major2015,項目名稱:easyrec_major,代碼行數:18,代碼來源:OtherUsersAlsoBoughtTest.java


注:本文中的com.sun.jersey.core.util.MultivaluedMapImpl類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。