Example usage for org.json.simple JSONArray containsAll

List of usage examples for org.json.simple JSONArray containsAll

Introduction

In this page you can find the example usage for org.json.simple JSONArray containsAll.

Prototype

boolean containsAll(Collection<?> c);

Source Link

Document

Returns true if this list contains all of the elements of the specified collection.

Usage

From source file:com.relayrides.pushy.apns.util.ApnsPayloadBuilderTest.java

@SuppressWarnings("unchecked")
@Test//  w  w  w .  j  a v a  2  s.  c om
public void testSetLocalizedAlertMessage() throws ParseException {
    final String alertKey = "test.alert";
    this.builder.setLocalizedAlertMessage(alertKey, null);

    {
        final JSONObject aps = this
                .extractApsObjectFromPayloadString(this.builder.buildWithDefaultMaximumLength());
        final JSONObject alert = (JSONObject) aps.get("alert");

        assertEquals(alertKey, alert.get("loc-key"));
        assertNull(alert.get("loc-args"));
    }

    final String[] alertArgs = new String[] { "Moose", "helicopter" };
    this.builder.setLocalizedAlertMessage(alertKey, alertArgs);

    {
        final JSONObject aps = this
                .extractApsObjectFromPayloadString(this.builder.buildWithDefaultMaximumLength());
        final JSONObject alert = (JSONObject) aps.get("alert");

        assertEquals(alertKey, alert.get("loc-key"));

        final JSONArray argsArray = (JSONArray) alert.get("loc-args");
        assertEquals(alertArgs.length, argsArray.size());
        assertTrue(argsArray.containsAll(java.util.Arrays.asList(alertArgs)));
    }
}