/* * Copyright (c) 2024 John Ahlroos * * Creative Commons Attribution-NoDerivatives 4.0 International Public License * * By exercising the Licensed Rights (defined below), You accept and agree * to be bound by the terms and conditions of this Creative Commons * Attribution-NoDerivatives 4.0 International Public License ("Public * License"). To the extent this Public License may be interpreted as a * contract, You are granted the Licensed Rights in consideration of Your * acceptance of these terms and conditions, and the Licensor grants You * such rights in consideration of benefits the Licensor receives from * making the Licensed Material available under these terms and * conditions. * * Refer to LICENSE file or https://creativecommons.org/licenses/by-nd/4.0 for full license. * */ package com.devsoap.json; import jakarta.json.JsonArray; import jakarta.json.JsonValue; import org.assertj.core.api.AbstractListAssert; import java.util.List; import static java.util.Objects.requireNonNull; /** * JSON Array Assertions * * @author John Ahlroos */ public class JsonArrayAssert extends AbstractListAssert, List, VALUE_TYPE, JsonValueAssert> { private final String fieldName; /** * Create a new JSON array assert * @param fieldName the field the array refers to or null if the root element * @param value The array value */ public JsonArrayAssert(String fieldName, VALUE_TYPE value) { super(List.of(requireNonNull(value, "type cannot be null")), JsonArrayAssert.class); this.fieldName = fieldName; } @SuppressWarnings("unchecked") protected JsonArrayAssert(String fieldName, JsonArray array) { super(requireNonNull(array, "Array cannot be null").getValuesAs(jsonValue -> (VALUE_TYPE) jsonValue), JsonArrayAssert.class); this.fieldName = fieldName; } @Override protected JsonValueAssert toAssert(VALUE_TYPE value, String description) { return new JsonValueAssert<>(fieldName, (JsonValue) value, value); } @Override protected JsonArrayAssert newAbstractIterableAssert(Iterable iterable) { //TODO return null; } }