All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springframework.boot.test.json.ObjectContentAssert Maven / Gradle / Ivy

There is a newer version: 3.2.5
Show newest version
/*
 * Copyright 2012-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.boot.test.json;

import java.util.Map;

import org.assertj.core.api.AbstractMapAssert;
import org.assertj.core.api.AbstractObjectArrayAssert;
import org.assertj.core.api.AbstractObjectAssert;
import org.assertj.core.api.Assert;
import org.assertj.core.api.Assertions;
import org.assertj.core.internal.Objects;

/**
 * AssertJ {@link Assert} for {@link ObjectContent}.
 *
 * @param  the actual type
 * @author Phillip Webb
 * @since 1.4.0
 */
public class ObjectContentAssert
		extends AbstractObjectAssert, A> {

	protected ObjectContentAssert(A actual) {
		super(actual, ObjectContentAssert.class);
	}

	/**
	 * Verifies that the actual value is an array, and returns an array assertion, to
	 * allow chaining of array-specific assertions from this call.
	 * @return an array assertion object
	 */
	public AbstractObjectArrayAssert asArray() {
		Objects.instance().assertIsInstanceOf(this.info, this.actual, Object[].class);
		return Assertions.assertThat((Object[]) this.actual);
	}

	/**
	 * Verifies that the actual value is a map, and returns a map assertion, to allow
	 * chaining of map-specific assertions from this call.
	 * @return a map assertion object
	 */
	@SuppressWarnings("unchecked")
	public AbstractMapAssert asMap() {
		Objects.instance().assertIsInstanceOf(this.info, this.actual, Map.class);
		return Assertions.assertThat((Map) this.actual);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy