/**
   * Test the casting of a JSON object array.
   *
   * <p>This test asserts that a the class of a elements of the cast JSON object matches the class
   * provided to the cast element method.
   */
  @Test
  public void testCastElement() {
    JsonObjectArray<JsonObject> testJsonObjectArray =
        this.createJsonObjectArray(this.createUnderlyingJsonArray());
    JsonObjectArray<CastJsonObject> testCastJsonObjectArray =
        testJsonObjectArray.castElement(CastJsonObject.class);

    assertEquals(testJsonObjectArray, testCastJsonObjectArray);

    testJsonObjectArray.set(0, this.createJsonObject(this.createUnderlyingJsonObject()));

    assertTrue(
        "testCastJsonObjectArray[0] !instanceof " + CastJsonObject.class.getName(),
        testCastJsonObjectArray.get(0) instanceof CastJsonObject);
  }
  /**
   * Test the setting of an element of the array.
   *
   * <p>This test asserts that setting the elements changes the elements at the corresponding index
   * of the underlying array.
   */
  @Test
  public void testSet() {
    JsonObject[] jsonObjects = this.createJsonObjects(5);

    J array = this.createUnderlyingJsonArray();

    JsonObjectArray<JsonObject> testJsonObjectArray = this.createJsonObjectArray(array);

    for (int i = 0; i < 5; i++) {
      testJsonObjectArray.set(i, jsonObjects[i]);
    }

    assertEquals("array.length", 5, this.getArrayLength(array));
    for (int i = 0; i < 5; i++) {
      assertEquals("array[" + i + "]", jsonObjects[i].getObject(), this.getObjectElement(array, i));
    }
  }