Skip to content

Commit

Permalink
LPS-195040 SF
Browse files Browse the repository at this point in the history
  • Loading branch information
brianchandotcom committed Sep 20, 2023
1 parent f2582a5 commit 513ee48
Showing 1 changed file with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public void setUp() throws PortalException {
_LIST_TYPE_ENTRY_KEY_1,
Collections.singletonMap(
LocaleUtil.US, RandomTestUtil.randomString()));

_listTypeEntryLocalService.addListTypeEntry(
null, TestPropsValues.getUserId(),
listTypeDefinition.getListTypeDefinitionId(),
Expand Down Expand Up @@ -98,30 +97,29 @@ public void setUp() throws PortalException {

@Test
public void testPostMultiselectPicklistAsArrayOfMaps() throws Exception {
JSONObject jsonObject = HTTPTestUtil.invokeToJSONObject(
JSONUtil.put(
_OBJECT_FIELD_NAME,
JSONUtil.putAll(
JSONUtil.put("key", _LIST_TYPE_ENTRY_KEY_1),
JSONUtil.put("key", _LIST_TYPE_ENTRY_KEY_2))
).toString(),
_objectDefinition.getRESTContextPath(), Http.Method.POST);

JSONArray multiselectJSONArray = jsonObject.getJSONArray(
_OBJECT_FIELD_NAME);

Assert.assertEquals(2, multiselectJSONArray.length());

JSONObject picklistItemJSONObject = multiselectJSONArray.getJSONObject(
JSONArray jsonArray = JSONUtil.getValueAsJSONArray(
HTTPTestUtil.invokeToJSONObject(
JSONUtil.put(
_OBJECT_FIELD_NAME,
JSONUtil.putAll(
JSONUtil.put("key", _LIST_TYPE_ENTRY_KEY_1),
JSONUtil.put("key", _LIST_TYPE_ENTRY_KEY_2))
).toString(),
_objectDefinition.getRESTContextPath(), Http.Method.POST),
"JSONArray/" + _OBJECT_FIELD_NAME);

Assert.assertEquals(2, jsonArray.length());

JSONObject jsonObject = jsonArray.getJSONObject(
0);

Assert.assertEquals(
picklistItemJSONObject.getString("key"), _LIST_TYPE_ENTRY_KEY_1);
jsonObject.getString("key"), _LIST_TYPE_ENTRY_KEY_1);

picklistItemJSONObject = multiselectJSONArray.getJSONObject(1);
jsonObject = jsonArray.getJSONObject(1);

Assert.assertEquals(
picklistItemJSONObject.getString("key"), _LIST_TYPE_ENTRY_KEY_2);
jsonObject.getString("key"), _LIST_TYPE_ENTRY_KEY_2);
}

private static final String _LIST_TYPE_ENTRY_KEY_1 =
Expand Down

0 comments on commit 513ee48

Please sign in to comment.