org.assertj.db.api.SoftAssertions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of assertj-db Show documentation
Show all versions of assertj-db Show documentation
AssertJ-DB - Rich and fluent assertions for testing with database
/**
* 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.
*
* Copyright 2012-2016 the original author or authors.
*/
package org.assertj.db.api;
import org.assertj.core.api.SoftAssertionError;
import org.assertj.core.groups.Properties;
import org.assertj.db.type.Changes;
import org.assertj.db.type.Request;
import org.assertj.db.type.Table;
import java.util.List;
/**
* Implementation of AssertJ SoftAssertions for {@link Table}, {@link Request} and {@link Changes}.
*
* This implementation works like AssertJ SoftAssertions implementation by providing you with
* proxies of the AssertJ-DB assertion objects.
*
* For more details see AssertJ implementation : {@link org.assertj.core.api.SoftAssertions}
*
* @author Julien Roy
*/
public final class SoftAssertions extends AbstractSoftAssertions {
/**
* Creates a new instance of {@link TableAssert}.
*
* @param table The table to assert on.
* @return The created assertion object.
*/
public TableAssert assertThat(Table table) {
return proxy(TableAssert.class, Table.class, table);
}
/**
* Creates a new instance of {@link RequestAssert}.
*
* @param request The request to assert on.
* @return The created assertion object.
*/
public RequestAssert assertThat(Request request) {
return proxy(RequestAssert.class, Request.class, request);
}
/**
* Creates a new instance of {@link ChangesAssert}.
*
* @param changes The changes to assert on.
* @return The created assertion object.
*/
public ChangesAssert assertThat(Changes changes) {
return proxy(ChangesAssert.class, Changes.class, changes);
}
public void assertAll() {
List errors = this.errorsCollected();
if (!errors.isEmpty()) {
throw new SoftAssertionError(Properties.extractProperty("message", String.class).from(errors));
}
}
}