Search in sources :

Example 56 with JsonObject

use of com.eclipsesource.json.JsonObject in project box-android-sdk by box.

the class BoxRequestUpdateSharedItem method setUnsharedAt.

/**
     * Sets the date that this shared link will be deactivated. If this is set to null it will remove the
     * unshared at date that is set on this item.
     * Note: the date will be rounded to the day as the API does not support hours, minutes, or seconds
     *
     * @param unsharedAt the date that this shared link will be deactivated.
     * @return  the updated request
     * @throws ParseException thrown if date provided cannot be properly parsed.
     */
public R setUnsharedAt(Date unsharedAt) throws ParseException {
    JsonObject jsonObject = getSharedLinkJsonObject();
    if (unsharedAt == null) {
        jsonObject.add(BoxSharedLink.FIELD_UNSHARED_AT, JsonValue.NULL);
    } else {
        jsonObject.add(BoxSharedLink.FIELD_UNSHARED_AT, BoxDateFormat.format(BoxDateFormat.convertToDay(unsharedAt)));
    }
    BoxSharedLink sharedLink = new BoxSharedLink(jsonObject);
    mBodyMap.put(BoxItem.FIELD_SHARED_LINK, sharedLink);
    return (R) this;
}
Also used : JsonObject(com.eclipsesource.json.JsonObject) BoxSharedLink(com.box.androidsdk.content.models.BoxSharedLink)

Example 57 with JsonObject

use of com.eclipsesource.json.JsonObject in project box-android-sdk by box.

the class BoxFolder method createFromIdAndName.

/**
     * A convenience method to create an empty folder with just the id and type fields set. This allows
     * the ability to interact with the content sdk in a more descriptive and type safe manner
     *
     * @param folderId the id of folder to create
     * @param name the name of the folder to create
     * @return an empty BoxFolder object that only contains id and type information
     */
public static BoxFolder createFromIdAndName(String folderId, String name) {
    JsonObject object = new JsonObject();
    object.add(BoxItem.FIELD_ID, folderId);
    object.add(BoxItem.FIELD_TYPE, BoxFolder.TYPE);
    if (!TextUtils.isEmpty(name)) {
        object.add(BoxItem.FIELD_NAME, name);
    }
    return new BoxFolder(object);
}
Also used : JsonObject(com.eclipsesource.json.JsonObject)

Example 58 with JsonObject

use of com.eclipsesource.json.JsonObject in project box-android-sdk by box.

the class BoxGroup method createFromId.

/**
     * A convenience method to create an empty group with just the id and type fields set. This allows
     * the ability to interact with the content sdk in a more descriptive and type safe manner
     *
     * @param groupId  the id of group to create
     * @return an empty BoxGroup object that only contains id and type information
     */
public static BoxGroup createFromId(String groupId) {
    JsonObject object = new JsonObject();
    object.add(BoxCollaborator.FIELD_ID, groupId);
    object.add(BoxCollaborator.FIELD_TYPE, BoxUser.TYPE);
    return new BoxGroup(object);
}
Also used : JsonObject(com.eclipsesource.json.JsonObject)

Example 59 with JsonObject

use of com.eclipsesource.json.JsonObject in project bytecode-viewer by Konloch.

the class DecompilerSettings method saveTo.

public void saveTo(JsonObject rootSettings) {
    if (rootSettings.get("decompilers") == null) {
        rootSettings.add("decompilers", new JsonObject());
    }
    JsonObject decompilerSection = rootSettings.get("decompilers").asObject();
    if (decompilerSection.get(decompiler.getName()) == null) {
        decompilerSection.add(decompiler.getName(), new JsonObject());
    }
    JsonObject thisDecompiler = decompilerSection.get(decompiler.getName()).asObject();
    for (Map.Entry<Setting, JCheckBoxMenuItem> entry : menuItems.entrySet()) {
        thisDecompiler.add(entry.getKey().getParam(), entry.getValue().isSelected());
    }
}
Also used : JsonObject(com.eclipsesource.json.JsonObject) Map(java.util.Map) HashMap(java.util.HashMap)

Example 60 with JsonObject

use of com.eclipsesource.json.JsonObject in project hazelcast by hazelcast.

the class SlowOperationDetector_JsonTest method testJSON_multipleEntryProcessorClasses.

@Test
public void testJSON_multipleEntryProcessorClasses() throws InterruptedException {
    for (int i = 0; i < 2; i++) {
        map.executeOnEntries(getSlowEntryProcessor(3));
    }
    SlowEntryProcessorChild entryProcessorChild = new SlowEntryProcessorChild(3);
    map.executeOnEntries(entryProcessorChild);
    map.executeOnEntries(getSlowEntryProcessor(4));
    awaitSlowEntryProcessors();
    entryProcessorChild.await();
    logger.finest(getOperationStats(instance).toString());
    JsonArray slowOperationLogsJsonArray = getSlowOperationLogsJsonArray(instance);
    JsonObject firstLogJsonObject = slowOperationLogsJsonArray.get(0).asObject();
    JsonObject secondLogJsonObject = slowOperationLogsJsonArray.get(1).asObject();
    assertJSONContainsClassNameJustOnce(firstLogJsonObject, secondLogJsonObject, "SlowEntryProcessor");
    assertJSONContainsClassNameJustOnce(firstLogJsonObject, secondLogJsonObject, "SlowEntryProcessorChild");
    int firstSize = firstLogJsonObject.get("invocations").asArray().size();
    int secondSize = secondLogJsonObject.get("invocations").asArray().size();
    assertTrue(format("Expected to find 1 and 3 invocations in logs, but was %d and %d", firstSize, secondSize), (firstSize == 1 ^ secondSize == 1) && (firstSize == 3 ^ secondSize == 3));
}
Also used : JsonArray(com.eclipsesource.json.JsonArray) JsonObject(com.eclipsesource.json.JsonObject) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Aggregations

JsonObject (com.eclipsesource.json.JsonObject)126 Test (org.junit.Test)41 ParallelTest (com.hazelcast.test.annotation.ParallelTest)38 QuickTest (com.hazelcast.test.annotation.QuickTest)38 JsonArray (com.eclipsesource.json.JsonArray)14 JsonUtil.getString (com.hazelcast.util.JsonUtil.getString)12 HashMap (java.util.HashMap)12 Map (java.util.Map)9 JsonValue (com.eclipsesource.json.JsonValue)5 ExecuteScriptRequest (com.hazelcast.internal.management.request.ExecuteScriptRequest)5 BoxSharedLink (com.box.androidsdk.content.models.BoxSharedLink)4 WanPublisherConfig (com.hazelcast.config.WanPublisherConfig)4 ChangeClusterStateRequest (com.hazelcast.internal.management.request.ChangeClusterStateRequest)3 ChangeWanStateRequest (com.hazelcast.internal.management.request.ChangeWanStateRequest)3 ILogger (com.hazelcast.logging.ILogger)3 IOException (java.io.IOException)3 BoxEntity (com.box.androidsdk.content.models.BoxEntity)2 ParseException (com.eclipsesource.json.ParseException)2 ClusterState (com.hazelcast.cluster.ClusterState)2 MapConfig (com.hazelcast.config.MapConfig)2