List of usage examples for java.util SortedMap put
V put(K key, V value);
From source file:com.tripit.auth.OAuthCredential.java
public String getSessionParameters(String redirectUrl, String action) throws UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException { SortedMap<String, String> params = new TreeMap<String, String>(); params.put("redirect_url", redirectUrl); params = generateOAuthParameters(action, params); params.put("redirect_url", redirectUrl); params.put("action", action); StringBuilder sb = new StringBuilder(); sb.append('{'); boolean isFirst = true; for (Map.Entry<String, String> param : params.entrySet()) { if (isFirst) { isFirst = false;/*from ww w. j a va 2 s. c om*/ } else { sb.append(","); } jsonEncodeString(param.getKey(), sb); sb.append(": "); jsonEncodeString(param.getValue(), sb); } sb.append('}'); return sb.toString(); }
From source file:monasca.log.api.app.LogSerializerTest.java
public void shouldSerializeAndDeserializeWithNull() { SortedMap<String, String> dimensions = new TreeMap<String, String>(); dimensions.put("app_name", "WebService01"); dimensions.put("environment", "production"); dimensions.put("instance_id", "123"); String message = "Hello, world!"; Log expected = new Log(null, dimensions, message); Log log = this.serializer.logFromJson(this.serializer.logToJson(expected).getBytes()); assertEquals(log, expected);//from w w w . ja v a 2 s .co m }
From source file:controllers.api.ExtractorsApiController.java
@BodyParser.Of(BodyParser.Json.class) public Result order(String inputId) { final JsonNode json = request().body().asJson(); final SortedMap<Integer, String> positions = Maps.newTreeMap(); final Iterator<JsonNode> order = json.get("order").elements(); int i = 0;/*ww w. j a va 2s . c o m*/ while (order.hasNext()) { final String extractorId = order.next().asText(); positions.put(i, extractorId); i++; } try { extractorService.order(inputId, positions); } catch (IOException e) { Logger.error("Could not update extractor order.", e); return internalServerError(); } catch (APIException e) { Logger.error("Could not update extractor order.", e); return internalServerError(); } return ok(); }
From source file:monasca.log.api.app.LogSerializerTest.java
public void shouldSerializeAndDeserialize() { String applicationType = "apache"; SortedMap<String, String> dimensions = new TreeMap<String, String>(); dimensions.put("app_name", "WebService01"); dimensions.put("environment", "production"); dimensions.put("instance_id", "123"); String message = "Hello, world!"; Log expected = new Log(applicationType, dimensions, message); Log log = this.serializer.logFromJson(this.serializer.logToJson(expected).getBytes()); assertEquals(log, expected);//from w ww . jav a 2 s . com }
From source file:monasca.log.api.app.LogSerializerTest.java
public void shouldSerializeAndDeserializeWithEmpty() { String applicationType = ""; SortedMap<String, String> dimensions = new TreeMap<String, String>(); dimensions.put("app_name", "WebService01"); dimensions.put("environment", "production"); dimensions.put("instance_id", "123"); String message = "Hello, world!"; Log expected = new Log(applicationType, dimensions, message); Log log = this.serializer.logFromJson(this.serializer.logToJson(expected).getBytes()); assertEquals(log, expected);/* w w w. java 2s.c o m*/ }
From source file:monasca.log.api.app.LogSerializerTest.java
public void shouldSerializeAndDeserializeWithEmpty_2() { String applicationType = "apache"; SortedMap<String, String> dimensions = new TreeMap<String, String>(); dimensions.put("app_name", "WebService01"); dimensions.put("environment", "production"); dimensions.put("instance_id", "123"); String message = ""; Log expected = new Log(applicationType, dimensions, message); Log log = this.serializer.logFromJson(this.serializer.logToJson(expected).getBytes()); assertEquals(log, expected);//w ww . j a va 2 s .c o m }
From source file:monasca.log.api.app.LogSerializerTest.java
public void shouldSerializeAndDeserializeWithEmpty_3() { String applicationType = ""; SortedMap<String, String> dimensions = new TreeMap<String, String>(); dimensions.put("app_name", "WebService01"); dimensions.put("environment", "production"); dimensions.put("instance_id", "123"); String message = ""; Log expected = new Log(applicationType, dimensions, message); Log log = this.serializer.logFromJson(this.serializer.logToJson(expected).getBytes()); assertEquals(log, expected);/*from ww w. j a v a 2 s . co m*/ }
From source file:monasca.log.api.app.LogSerializerTest.java
public void shouldSerializeAndDeserializeUTF8() throws UnsupportedEncodingException { String applicationType = "fobr"; SortedMap<String, String> dimensions = new TreeMap<String, String>(); dimensions.put("app_name", "fobr"); dimensions.put("environment", "production"); dimensions.put("instance_id", "123"); String message = "fobr"; Log expected = new Log(applicationType, dimensions, message); Log log = this.serializer.logFromJson(this.serializer.logToJson(expected).getBytes("UTF-8")); assertEquals(log, expected);//from w w w .j av a 2 s .c o m }
From source file:monasca.log.api.app.LogSerializerTest.java
public void shouldSerializeAndDeserializeUTF8_2() throws UnsupportedEncodingException { String applicationType = "fo\u00f4b\u00e1r"; SortedMap<String, String> dimensions = new TreeMap<String, String>(); dimensions.put("app_name", "fo\u00f4b\u00e1r"); dimensions.put("environment", "production"); dimensions.put("instance_id", "123"); String message = "fo\u00f4b\u00e1r"; Log expected = new Log(applicationType, dimensions, message); Log log = this.serializer.logFromJson(this.serializer.logToJson(expected).getBytes("UTF-8")); assertEquals(log, expected);/*from w w w. j a v a 2s. c o m*/ }
From source file:monasca.log.api.app.LogSerializerTest.java
public void shouldSerializeValueWithNull() throws JSONException { SortedMap<String, String> dimensions = new TreeMap<String, String>(); dimensions.put("app_name", "WebService01"); dimensions.put("environment", "production"); String message = "Hello, world!"; final Log log = new Log(null, dimensions, message); final String json = this.serializer.toJson(log); final String expected = "{\"dimensions\":{\"app_name\":\"WebService01\",\"environment\":\"production\"}," + "\"message\":\"Hello, world!\"}"; JSONAssert.assertEquals(expected, json, true); }