Java Code Examples for org.json.simple.JSONObject.put()

The following are Jave code examples for showing how to use put() of the org.json.simple.JSONObject class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: alfresco-repository   File: TagPropertyDecorator.java   View Source Code Vote up 6 votes
/**
 * @see org.alfresco.repo.jscript.app.PropertyDecorator#decorate(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable)
 */
@SuppressWarnings("unchecked")
public JSONAware decorate(QName propertyName, NodeRef nodeRef, Serializable value)
{
    Collection<NodeRef> collection = (Collection<NodeRef>)value;
    JSONArray array = new JSONArray();

    for (NodeRef obj : collection)
    {
        try
        {
            JSONObject jsonObj = new JSONObject();
            jsonObj.put("name", this.nodeService.getProperty(obj, ContentModel.PROP_NAME));
            jsonObj.put("nodeRef", obj.toString());
            array.add(jsonObj);
        }
        catch (InvalidNodeRefException e)
        {
            logger.warn("Tag with nodeRef " + obj.toString() + " does not exist.");
        }
    }

    return array;
}
 
Example 2
Project: mongodb-gremlin   File: MongoDBQueryStep.java   View Source Code Vote up 6 votes
@Override
public JSONObject projectTraverser(final Traverser.Admin<Path> traverser) {
    final JSONObject root = new JSONObject();
    JSONObject currentNode = root;
    for (final Object object : traverser.get()) {
        if (object instanceof Map) {
            for(final Map.Entry entry : (Set<Map.Entry>)((Map)object).entrySet()) {
                if(entry.getKey().equals(T.id))
                    currentNode.put(T.id.getAccessor(),entry.getValue());
                else if(entry.getKey().equals(T.label))
                    currentNode.put(T.label.getAccessor(),entry.getValue());
                else
                    currentNode.put(entry.getKey(),entry.getValue());
            }
        }
        else if (object instanceof String)
            currentNode.put(object, currentNode = new JSONObject());
    }
    return root;
}
 
Example 3
Project: personium-core   File: UserDataComplexPropertyDateTimeTest.java   View Source Code Vote up 6 votes
/**
 * ComplexPropertyのTypeがEdmDateTimeの場合ユーザデータに最小値より小さい値を指定して400エラーとなること.
 */
@SuppressWarnings("unchecked")
@Test
public final void ComplexPropertyのTypeがEdmDateTimeの場合ユーザデータに最小値より小さい値を指定して400エラーとなること() {
    // リクエストボディを設定
    JSONObject complexBody = new JSONObject();
    complexBody.put(PROP_NAME, "/Date(" + (ODataUtils.DATETIME_MIN - 1) + ")/");
    JSONObject body = new JSONObject();
    body.put("__id", USERDATA_ID);
    body.put(PROP_NAME, complexBody);

    try {
        createEntities(EdmSimpleType.DATETIME.getFullyQualifiedTypeName());

        // ユーザデータ作成
        TResponse response = createUserData(body, HttpStatus.SC_BAD_REQUEST,
                cellName, boxName, COL_NAME, ENTITY_TYPE_NAME);

        JSONObject json = response.bodyAsJson();
        String code = json.get("code").toString();
        assertEquals("PR400-OD-0006", code);
    } finally {
        deleteEntities();
    }
}
 
Example 4
Project: incubator-netbeans   File: CSS.java   View Source Code Vote up 6 votes
/**
 * Sets a new text of the specified property.
 *
 * @param styleId ID of the style to modify.
 * @param propertyIndex index of the property in the style.
 * @param propertyText text of the property in the form {@code name:value;}.
 * @param overwrite if {@code true} then the property at the given position
 * is overwritten, otherwise it is inserted.
 * @return the resulting style after the property text modification.
 */
public Style setPropertyText(StyleId styleId, int propertyIndex, String propertyText, boolean overwrite) {
    Style resultingStyle = null;
    JSONObject params = new JSONObject();
    params.put("styleId", styleId.toJSONObject()); // NOI18N
    params.put("propertyIndex", propertyIndex); // NOI18N
    params.put("text", propertyText); // NOI18N
    params.put("overwrite", overwrite); // NOI18N
    Response response = transport.sendBlockingCommand(new Command("CSS.setPropertyText", params)); // NOI18N
    if (response != null) {
        JSONObject result = response.getResult();
        if (result != null) {
            JSONObject style = (JSONObject)result.get("style"); // NOI18N
            resultingStyle = new Style(style);
        }
    }
    return resultingStyle;
}
 
Example 5
Project: burstcoin   File: GetBlocks.java   View Source Code Vote up 6 votes
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {

    int firstIndex = ParameterParser.getFirstIndex(req);
    int lastIndex = ParameterParser.getLastIndex(req);
    if (lastIndex < 0 || lastIndex - firstIndex > 99) {
        lastIndex = firstIndex + 99;
    }

    boolean includeTransactions = "true".equalsIgnoreCase(req.getParameter("includeTransactions"));

    JSONArray blocks = new JSONArray();
    try (DbIterator<? extends Block> iterator = Nxt.getBlockchain().getBlocks(firstIndex, lastIndex)) {
        while (iterator.hasNext()) {
            Block block = iterator.next();
            blocks.add(JSONData.block(block, includeTransactions));
        }
    }

    JSONObject response = new JSONObject();
    response.put("blocks", blocks);

    return response;
}
 
Example 6
Project: personium-core   File: UserDataListTest.java   View Source Code Vote up 6 votes
/**
 * ユーザデータの一覧を作成.
 */
@SuppressWarnings("unchecked")
public void createUserDataList() {
    // リクエストボディを設定
    JSONObject body = new JSONObject();
    body.put("__id", userDataId201);
    body.put("dynamicProperty1", "dynamicPropertyValue1");
    body.put("dynamicProperty2", "dynamicPropertyValue2");
    body.put("dynamicProperty3", "dynamicPropertyValue3");

    JSONObject body2 = new JSONObject();
    body2.put("__id", userDataId202);
    body2.put("dynamicProperty1", "dynamicPropertyValueA");
    body2.put("dynamicProperty2", "dynamicPropertyValueB");
    body2.put("dynamicProperty3", "dynamicPropertyValueC");

    // ユーザデータ作成
    createUserData(body, HttpStatus.SC_CREATED);
    createUserData(body2, HttpStatus.SC_CREATED);
}
 
Example 7
Project: bskyblock   File: Metrics.java   View Source Code Vote up 6 votes
protected JSONObject getRequestJsonObject() {
    JSONObject chart = new JSONObject();
    chart.put("chartId", chartId);
    try {
        JSONObject data = getChartData();
        if (data == null) {
            // If the data is null we don't send the chart.
            return null;
        }
        chart.put("data", data);
    } catch (Throwable t) {
        if (logFailedRequests) {
            Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
        }
        return null;
    }
    return chart;
}
 
Example 8
Project: bskyblock   File: Metrics.java   View Source Code Vote up 6 votes
@Override
protected JSONObject getChartData() {
    JSONObject data = new JSONObject();
    JSONObject values = new JSONObject();
    HashMap<Country, Integer> map = getValues(new HashMap<Country, Integer>());
    if (map == null || map.isEmpty()) {
        // Null = skip the chart
        return null;
    }
    boolean allSkipped = true;
    for (Map.Entry<Country, Integer> entry : map.entrySet()) {
        if (entry.getValue() == 0) {
            continue; // Skip this invalid
        }
        allSkipped = false;
        values.put(entry.getKey().getCountryIsoTag(), entry.getValue());
    }
    if (allSkipped) {
        // Null = skip the chart
        return null;
    }
    data.put("values", values);
    return data;
}
 
Example 9
Project: ShowPolicyPackage   File: ObjectsInUse.java   View Source Code Vote up 5 votes
/**
 * Util function.
 * Creates a json object that represent the class.
 *
 * @return The {@link JSONObject} that represent the class
 */
public JSONObject toJson(){

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("types", allTypes);
    jsonObject.put("htmlObjectsFileName",htmlObjectsFileName );

    return jsonObject;
}
 
Example 10
Project: burstcoin   File: Attachment.java   View Source Code Vote up 5 votes
@Override
void putMyJSON(JSONObject attachment) {
    attachment.put("purchase", Convert.toUnsignedLong(purchaseId));
    attachment.put("goodsData", Convert.toHexString(goods.getData()));
    attachment.put("goodsNonce", Convert.toHexString(goods.getNonce()));
    attachment.put("discountNQT", discountNQT);
    attachment.put("goodsIsText", goodsIsText);
}
 
Example 11
Project: CaulCrafting   File: Metrics.java   View Source Code Vote up 5 votes
@Override
protected JSONObject getChartData() throws Exception {
    JSONObject data = new JSONObject();
    int value = callable.call();
    if (value == 0) {
        // Null = skip the chart
        return null;
    }
    data.put("value", value);
    return data;
}
 
Example 12
Project: personium-core   File: UserDataListSelectTest.java   View Source Code Vote up 5 votes
@SuppressWarnings("unchecked")
private void createMultiUserDataList() {
    JSONObject body = new JSONObject();
    body.put("__id", userDataId201);
    body.put("dynamicProperty", "dynamicPropertyValue");
    body.put("secondDynamicProperty", "secondDynamicPropertyValue");
    body.put("nullProp", null);
    body.put("intProperty", 123);
    body.put("floatProperty", 123.123);
    body.put("trueProperty", true);
    body.put("falseProperty", false);
    body.put("nullStringProperty", "null");
    body.put("intStringProperty", "123");
    body.put("floatStringProperty", "123.123");
    body.put("trueStringProperty", "true");
    body.put("falseStringProperty", "false");
    body.put("onlyExistProperty201", "exist201");

    JSONObject body2 = new JSONObject();
    body2.put("__id", userDataId202);
    body2.put("dynamicProperty", "dynamicPropertyValue2");
    body2.put("secondDynamicProperty", "secondDynamicPropertyValue2");
    body2.put("nullProp", "nullString2");
    body2.put("intProperty", 1234);
    body2.put("floatProperty", 123.1234);
    body2.put("trueProperty", true);
    body2.put("falseProperty", false);
    body2.put("nullStringProperty", "null");
    body2.put("intStringProperty", "1234");
    body2.put("floatStringProperty", "123.1234");
    body2.put("trueStringProperty", "true");
    body2.put("falseStringProperty", "false");
    body.put("onlyExistProperty202", "exist202");

    // ユーザデータ作成
    createUserData(body, HttpStatus.SC_CREATED);
    createUserData(body2, HttpStatus.SC_CREATED);
}
 
Example 13
Project: personium-core   File: UserDataDeclaredDoubleComplexTypePropertyTest.java   View Source Code Vote up 5 votes
/**
 * Double型配列のデータに最大制限値より大きい値が含まれている場合に登録できないこと.
 * @throws ParseException パース例外.
 */
@SuppressWarnings("unchecked")
@Test
public final void Double型配列のデータに最大制限値より大きい値が含まれている場合に登録できないこと() throws ParseException {
    String userdataId1 = "doubleTest1";

    try {
        createEntities(EdmSimpleType.DOUBLE.getFullyQualifiedTypeName(), "1.79E308");
        // complexTypeProperty作成
        UserDataUtils.createComplexTypeProperty(cellName, boxName, COL_NAME, "listDoubleProperty",
                COMPLEX_TYPE_NAME,
                EdmSimpleType.DOUBLE.getFullyQualifiedTypeName(), true, null, "List");

        // Double型で登録・取得可能なこと
        JSONArray reqBody = (JSONArray) new JSONParser().parse("[123.456,-567.89,1,\"9.123456789\",1.791E308]");
        JSONObject complexBody = new JSONObject();
        complexBody.put("listDoubleProperty", reqBody);
        JSONObject body = new JSONObject();
        body.put("__id", userdataId1);
        body.put(PROP_NAME, complexBody);

        // ユーザデータ作成
        UserDataUtils.create(AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_BAD_REQUEST, body,
                cellName, boxName, COL_NAME, ENTITY_TYPE_NAME);

        // ユーザデータ一件取得
        getUserData(cellName, boxName, COL_NAME, ENTITY_TYPE_NAME, userdataId1,
                Setup.MASTER_TOKEN_NAME, HttpStatus.SC_NOT_FOUND);
    } finally {
        // ユーザデータ削除
        deleteUserData(userdataId1);

        String ctplocationUrl = UrlUtils.complexTypeProperty(cellName, boxName, COL_NAME, "listDoubleProperty",
                COMPLEX_TYPE_NAME);
        ODataCommon.deleteOdataResource(ctplocationUrl);
        deleteEntities();
    }
}
 
Example 14
Project: ArchersBattle   File: Metrics.java   View Source Code Vote up 5 votes
@Override
protected JSONObject getChartData() {
    JSONObject data = new JSONObject();
    Country value = getValue();

    if (value == null) {
        // Null = skip the chart
        return null;
    }
    data.put("value", value.getCountryIsoTag());
    return data;
}
 
Example 15
Project: bStats-Metrics   File: MetricsLite.java   View Source Code Vote up 5 votes
/**
 * Gets the plugin specific data.
 * This method is called using Reflection.
 *
 * @return The plugin specific data.
 */
public JSONObject getPluginData() {
    JSONObject data = new JSONObject();

    String pluginName = plugin.getDescription().getName();
    String pluginVersion = plugin.getDescription().getVersion();

    data.put("pluginName", pluginName); // Append the name of the plugin
    data.put("pluginVersion", pluginVersion); // Append the version of the plugin
    JSONArray customCharts = new JSONArray();
    data.put("customCharts", customCharts);

    return data;
}
 
Example 16
Project: alfresco-remote-api   File: GroupMember.java   View Source Code Vote up 5 votes
public JSONObject toJSON()
{
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("id", getId());
    jsonObject.put("displayName", getDisplayName());
    jsonObject.put("memberType", getMemberType());

    return jsonObject;
}
 
Example 17
Project: personium-core   File: MessageSentTest.java   View Source Code Vote up 5 votes
/**
 * 送信メッセージの削除ができること.
 */
@SuppressWarnings("unchecked")
@Test
public final void 送信メッセージの削除ができること() {
    // 送信先CellUrl
    String targetCell = Setup.TEST_CELL2;

    // リクエストボディ作成
    JSONObject body = new JSONObject();
    body.put("BoxBound", false);
    body.put("InReplyTo", null);
    body.put("To", UrlUtils.cellRoot(targetCell));
    body.put("ToRelation", null);
    body.put("Type", TYPE_MESSAGE);
    body.put("Title", "title");
    body.put("Body", "body");
    body.put("Priority", 3);
    body.put("RequestRelation", null);
    body.put("RequestRelationTarget", null);

    TResponse response = null;
    String id = null;
    try {
        // メッセージ送信
        response = SentMessageUtils.sent(MASTER_TOKEN_NAME, TEST_CELL1,
                body.toJSONString(), HttpStatus.SC_CREATED);

        // __idの取得
        JSONObject results = (JSONObject) ((JSONObject) response.bodyAsJson().get("d")).get("results");
        id = (String) results.get("__id");
    } finally {
        if (response != null) {
            // メッセージの削除
            SentMessageUtils.delete(MASTER_TOKEN_NAME, TEST_CELL1, HttpStatus.SC_NO_CONTENT, id);
        }
        // 自動生成された受信メッセージの削除
        deleteReceivedMessage(targetCell, UrlUtils.cellRoot(Setup.TEST_CELL1), TYPE_MESSAGE, "title", "body");
    }

}
 
Example 18
Project: personium-core   File: UserDataLinkTest.java   View Source Code Vote up 4 votes
/**
 * link済みのユーザデータを削除できないこと_AssociationEndがアスタ対1.
 */
@SuppressWarnings("unchecked")
@Test
public final void link済みのユーザデータを削除できないこと_AssociationEndがアスタ対1() {
    String srcEntityType = "SalesDetail";
    String targetEntityType = "Sales";
    String srcUserDataId = "src-Id";
    String targetUserDataId = "target-Id";

    JSONObject body = new JSONObject();
    try {
        body.put("__id", srcUserDataId);
        createUserData(body, HttpStatus.SC_CREATED, Setup.TEST_CELL1, Setup.TEST_BOX1, Setup.TEST_ODATA,
                srcEntityType);
        body.put("__id", targetUserDataId);
        createUserData(body, HttpStatus.SC_CREATED, Setup.TEST_CELL1, Setup.TEST_BOX1, Setup.TEST_ODATA,
                targetEntityType);

        // $links登録
        ResourceUtils.linksUserData(srcEntityType, srcUserDataId, targetEntityType, targetUserDataId,
                HttpStatus.SC_NO_CONTENT);

        // $links先のユーザデータ削除
        deleteUserData(Setup.TEST_CELL1, Setup.TEST_BOX1, Setup.TEST_ODATA,
                targetEntityType, targetUserDataId, PersoniumUnitConfig.getMasterToken(), HttpStatus.SC_CONFLICT);

        // $links一覧取得
        TResponse resList = Http.request("box/odatacol/list-link.txt")
                .with("cellPath", Setup.TEST_CELL1)
                .with("boxPath", Setup.TEST_BOX1)
                .with("colPath", Setup.TEST_ODATA)
                .with("srcPath", srcEntityType + "('" + srcUserDataId + "')")
                .with("trgPath", targetEntityType)
                .with("token", PersoniumUnitConfig.getMasterToken())
                .with("accept", MediaType.APPLICATION_JSON)
                .returns()
                .statusCode(HttpStatus.SC_OK)
                .debug();
        ArrayList<String> expectedUriList = new ArrayList<String>();
        expectedUriList.add(UrlUtils.userdata(Setup.TEST_CELL1, Setup.TEST_BOX1,
                Setup.TEST_ODATA, targetEntityType, targetUserDataId));
        // レスポンスボディのチェック
        ODataCommon.checkLinResponseBody(resList.bodyAsJson(), expectedUriList);
    } finally {
        ResourceUtils.deleteUserDataLinks(srcUserDataId, targetUserDataId, targetEntityType, Setup.TEST_CELL1,
                Setup.TEST_BOX1, Setup.TEST_ODATA, srcEntityType, -1);
        deleteUserData(Setup.TEST_CELL1, Setup.TEST_BOX1, Setup.TEST_ODATA,
                srcEntityType, srcUserDataId, PersoniumUnitConfig.getMasterToken(), HttpStatus.SC_NO_CONTENT);
        deleteUserData(Setup.TEST_CELL1, Setup.TEST_BOX1, Setup.TEST_ODATA,
                targetEntityType, targetUserDataId, PersoniumUnitConfig.getMasterToken(), HttpStatus.SC_NO_CONTENT);
    }
}
 
Example 19
Project: personium-core   File: MessageApproveTest.java   View Source Code Vote up 4 votes
/**
 * Error test.
 * Approve build message with RelationClassURL.
 * Box corresponding to the RelationClassURL can not be found.
 */
@SuppressWarnings("unchecked")
@Test
public final void error_approve_build_message_not_found_box_corresponding_to_RelationClassURL() {
    String relationName = "messageTestRelation";
    String boxName = Setup.TEST_BOX2;

    // Request body of message
    JSONObject body = new JSONObject();
    body.put("__id", "12345678901234567890123456789012");
    body.put("From", UrlUtils.cellRoot(Setup.TEST_CELL2));
    body.put("Type", TYPE_REQ_RELATION_BUILD);
    body.put("Title", "Title");
    body.put("Body", "Body");
    body.put("InReplyTo", "d3330643f57a42fd854558fb0a96a96a");
    body.put("Priority", 3);
    body.put("Status", STATUS_NONE);
    body.put("RequestRelation", UrlUtils.relationClassUrl(Setup.TEST_CELL_SCHEMA2, relationName));
    body.put("RequestRelationTarget", UrlUtils.cellRoot("targetCell"));

    TResponse response = null;
    try {
        // ---------------
        // Preparation
        // ---------------
        // ReceivedMessage
        String requestUrl = UrlUtils.cellRoot(Setup.TEST_CELL1);
        response = ReceivedMessageUtils.receive(getCellIssueToken(requestUrl), Setup.TEST_CELL1,
                body.toJSONString(), HttpStatus.SC_CREATED);
        String messageId = (String) body.get("__id");

        // ---------------
        // Execution
        // ---------------
        // execute approved message
        PersoniumRestAdapter rest = new PersoniumRestAdapter();
        HashMap<String, String> requestheaders = new HashMap<String, String>();
        requestheaders.put(HttpHeaders.AUTHORIZATION, BEARER_MASTER_TOKEN);
        requestUrl = UrlUtils.approvedMessage(Setup.TEST_CELL1, messageId);
        PersoniumResponse res = rest.post(requestUrl, "{\"Command\":\"" + STATUS_APPROVED + "\" }", requestheaders);

        // ---------------
        // Verification
        // ---------------
        PersoniumCoreException exception = PersoniumCoreException.ReceivedMessage
                .BOX_THAT_MATCHES_RELATION_CLASS_URL_NOT_EXISTS.params(body.get("RequestRelation"));
        assertEquals(HttpStatus.SC_BAD_REQUEST, res.getStatusCode());
        checkErrorResponse(res.bodyAsJson(), exception.getCode(), exception.getMessage());
        // Check relation not exists
        RelationUtils.get(Setup.TEST_CELL1, MASTER_TOKEN_NAME, relationName, boxName, HttpStatus.SC_NOT_FOUND);
        // Check extcell not exists
        ExtCellUtils.get(MASTER_TOKEN_NAME, Setup.TEST_CELL1,
                UrlUtils.cellRoot("targetCell"), HttpStatus.SC_NOT_FOUND);
        // Check status
        checkMessageStatus(messageId, STATUS_NONE);
    } catch (PersoniumException e) {
        fail(e.getStackTrace().toString());
    } finally {
        // Delete Received message
        if (response != null) {
            deleteOdataResource(response.getLocationHeader());
        }
        // Delete Relation-ExtCell $links
        LinksUtils.deleteLinksExtCell(Setup.TEST_CELL1,
                PersoniumCoreUtils.encodeUrlComp(UrlUtils.cellRoot("targetCell")),
                Relation.EDM_TYPE_NAME, relationName, boxName, MASTER_TOKEN_NAME, -1);
        // Delete Relation
        RelationUtils.delete(Setup.TEST_CELL1, MASTER_TOKEN_NAME, relationName, boxName, -1);
        // Delete ExtCell
        ExtCellUtils.delete(MASTER_TOKEN_NAME, Setup.TEST_CELL1, UrlUtils.cellRoot("targetCell"));
    }
}
 
Example 20
Project: personium-core   File: MessageSentTest.java   View Source Code Vote up 4 votes
/**
 * ToとtoRelationに同じCellの値を使用して1件だけMessage送信されること.
 */
@SuppressWarnings("unchecked")
@Test
public final void ToとtoRelationに同じCellの値を使用して1件だけMessage送信されること() {
    // 送信先CellUrl
    String targetCell = Setup.TEST_CELL2;

    // リクエストボディ作成
    JSONObject body = new JSONObject();
    body.put("BoxBound", false);
    body.put("InReplyTo", null);
    body.put("To", UrlUtils.cellRoot(targetCell));
    body.put("ToRelation", "cellrelation");
    body.put("Type", TYPE_MESSAGE);
    body.put("Title", "title");
    body.put("Body", "body");
    body.put("Priority", 3);
    body.put("RequestRelation", null);
    body.put("RequestRelationTarget", null);

    TResponse response = null;
    try {
        // メッセージ送信
        response = SentMessageUtils.sent(MASTER_TOKEN_NAME, TEST_CELL1,
                body.toJSONString(), HttpStatus.SC_CREATED);

        // レスポンスボディのチェック
        JSONObject expectedResult = new JSONObject();
        expectedResult.put("To", UrlUtils.cellRoot(targetCell));
        expectedResult.put("Code", Integer.toString(HttpStatus.SC_CREATED));
        expectedResult.put("Reason", "Created.");
        JSONArray expectedResults = new JSONArray();
        expectedResults.add(expectedResult);
        JSONObject expected = new JSONObject();
        expected.put("_Box.Name", null);
        expected.put("InReplyTo", null);
        expected.put("To", UrlUtils.cellRoot(targetCell));
        expected.put("ToRelation", "cellrelation");
        expected.put("Type", TYPE_MESSAGE);
        expected.put("Title", "title");
        expected.put("Body", "body");
        expected.put("Priority", 3);
        expected.put("RequestRelation", null);
        expected.put("RequestRelationTarget", null);
        expected.put("Result", expectedResults);

        ODataCommon.checkResponseBody(response.bodyAsJson(), response.getLocationHeader(),
                SENT_MESSAGE_TYPE, expected);

        // __idの取得
        JSONObject result = (JSONObject) ((JSONObject) response.bodyAsJson().get("d")).get("results");
        String id = (String) result.get("__id");

        // 送信メッセージを一件取得してボディをチェック
        TResponse getSMResponse = SentMessageUtils.get(MASTER_TOKEN_NAME, TEST_CELL1, HttpStatus.SC_OK,
                id);
        ODataCommon.checkResponseBody(getSMResponse.bodyAsJson(), response.getLocationHeader(),
                SENT_MESSAGE_TYPE, expected);
    } finally {
        // 送信メッセージの削除
        if (response != null) {
            deleteOdataResource(response.getLocationHeader());
        }
        // 自動生成された受信メッセージの削除
        deleteReceivedMessage(targetCell, UrlUtils.cellRoot(Setup.TEST_CELL1), TYPE_MESSAGE, "title", "body");
    }
}