Example usage for java.util SortedMap put

List of usage examples for java.util SortedMap put

Introduction

In this page you can find the example usage for java.util SortedMap put.

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:monasca.log.api.app.LogSerializerTest.java

public void shouldSerializeValue() throws JSONException {
    String applicationType = "apache";
    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(applicationType, dimensions, message);
    final String json = this.serializer.toJson(log);
    final String expected = "{\"application_type\":\"apache\",\"dimensions\":{\"app_name\":\"WebService01\",\"environment\":\"production\"},"
            + "\"message\":\"Hello, world!\"}";

    JSONAssert.assertEquals(expected, json, true);
}

From source file:monasca.log.api.app.LogSerializerTest.java

public void shouldSerializeValueWithEmpty() throws JSONException {
    String applicationType = "";
    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(applicationType, 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);
}

From source file:monasca.log.api.app.LogSerializerTest.java

public void shouldSerializeValueWithEmpty_2() throws JSONException {
    String applicationType = "apache";
    SortedMap<String, String> dimensions = new TreeMap<String, String>();
    dimensions.put("app_name", "WebService01");
    dimensions.put("environment", "production");
    String message = "";

    final Log log = new Log(applicationType, dimensions, message);
    final String json = this.serializer.toJson(log);
    final String expected = "{\"application_type\":\"apache\",\"dimensions\":{\"app_name\":\"WebService01\",\"environment\":\"production\"},"
            + "\"message\":\"\"}";

    JSONAssert.assertEquals(expected, json, true);
}

From source file:monasca.log.api.app.LogSerializerTest.java

public void shouldSerializeValueWithEmpty_3() throws JSONException {
    String applicationType = "";
    SortedMap<String, String> dimensions = new TreeMap<String, String>();
    dimensions.put("app_name", "WebService01");
    dimensions.put("environment", "production");
    String message = "";

    final Log log = new Log(applicationType, dimensions, message);
    final String json = this.serializer.toJson(log);
    final String expected = "{\"dimensions\":{\"app_name\":\"WebService01\",\"environment\":\"production\"},"
            + "\"message\":\"\"}";

    JSONAssert.assertEquals(expected, json, true);
}

From source file:monasca.log.api.app.LogSerializerTest.java

public void shouldSerializeValueUTF() throws JSONException {
    String applicationType = "fobr";
    SortedMap<String, String> dimensions = new TreeMap<String, String>();
    dimensions.put("app_name", "fobr");
    dimensions.put("instance_id", "123");
    String message = "bobr";

    final Log log = new Log(applicationType, dimensions, message);
    final String json = this.serializer.toJson(log);
    final String expected = "{\"application_type\":\"fobr\",\"dimensions\":{\"app_name\":\"fobr\",\"instance_id\":\"123\"},"
            + "\"message\":\"bobr\"}";

    JSONAssert.assertEquals(expected, json, true);
}

From source file:monasca.log.api.app.LogSerializerTest.java

public void shouldSerializeAndDeserializeUTF8_3() throws UnsupportedEncodingException {
    String applicationType = "fo\u00f4b\u00e1r";
    String applicationType2 = "fobr";
    SortedMap<String, String> dimensions = new TreeMap<String, String>();
    dimensions.put("app_name", "fo\u00f4b\u00e1r");
    dimensions.put("environment", "production");
    dimensions.put("instance_id", "123");
    SortedMap<String, String> dimensions2 = new TreeMap<String, String>();
    dimensions2.put("app_name", "fobr");
    dimensions2.put("environment", "production");
    dimensions2.put("instance_id", "123");
    String message = "fo\u00f4b\u00e1r";
    String message2 = "fobr";
    Log expected_escaped = new Log(applicationType, dimensions, message);
    Log expected_nonescaped = new Log(applicationType2, dimensions2, message2);

    Log log = this.serializer.logFromJson(this.serializer.logToJson(expected_escaped).getBytes("UTF-8"));
    assertEquals(log, expected_nonescaped);
}

From source file:com.enonic.cms.core.RequestParameters.java

public SortedMap<String, String[]> getAsMapWithStringValues() {
    SortedMap<String, String[]> map = new TreeMap<String, String[]>();

    for (Param param : parameters.values()) {
        map.put(param.getName(), param.getValues());
    }//from  w w w  . j  a  v a 2  s .  c o  m

    return map;
}

From source file:com.tripit.auth.OAuthCredential.java

public boolean validateSignature(URI requestUri)
        throws URISyntaxException, UnsupportedEncodingException, InvalidKeyException, NoSuchAlgorithmException {
    List<NameValuePair> argList = URLEncodedUtils.parse(requestUri, "UTF-8");
    SortedMap<String, String> args = new TreeMap<String, String>();
    for (NameValuePair arg : argList) {
        args.put(arg.getName(), arg.getValue());
    }/*from  w ww.  ja v  a2s  .  c o m*/

    String signature = args.remove("oauth_signature");

    String baseUrl = new URI(requestUri.getScheme(), requestUri.getUserInfo(), requestUri.getAuthority(),
            requestUri.getPort(), requestUri.getPath(), null, requestUri.getFragment()).toString();

    return (signature != null && signature.equals(generateSignature(baseUrl, args)));
}

From source file:jenkins.metrics.util.NameRewriterMetricRegistry.java

private <T> SortedMap<String, T> rewrite(SortedMap<String, T> original) {
    if (StringUtils.isBlank(prefix) && StringUtils.isBlank(postfix)) {
        return original;
    }/*from w  w w  .  j  a  v a  2s  .c  om*/
    SortedMap<String, T> result = new TreeMap<String, T>(original.comparator());
    for (Map.Entry<String, T> entry : original.entrySet()) {
        result.put(name(prefix, entry.getKey(), postfix), entry.getValue());
    }
    return result;
}

From source file:com.orange.clara.cloud.servicedbdumper.filer.s3uploader.UploadS3StreamImpl.java

protected void prepareUploadPart(String container, String key, String uploadId, int numPart,
        Payload chunkedPart, SortedMap<Integer, String> etags) {
    String eTag = null;//w ww. j  a v a  2 s  . c o  m
    int i = 1;
    while (true) {
        try {
            eTag = s3Client.uploadPart(container, key, numPart, uploadId, chunkedPart);
            etags.put(numPart, eTag);
            break;
        } catch (Exception e) {
            logger.warn("Retry {}/{} to upload on S3 for container {}.", i, retry, container);
            if (i >= retry) {
                throw e;
            }
        }
        i++;
    }

}