org.assertj.vavr.api.VavrAssertions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of assertj-vavr Show documentation
Show all versions of assertj-vavr Show documentation
Rich and fluent assertions for testing Vavr tools
/*
* 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 2017-2020 the original author or authors.
*/
package org.assertj.vavr.api;
import io.vavr.Lazy;
import io.vavr.collection.*;
import io.vavr.control.Either;
import io.vavr.control.Option;
import io.vavr.control.Try;
import io.vavr.control.Validation;
import org.assertj.core.util.CheckReturnValue;
/**
* Entry point for assertion methods for different Vavr types. Each method in this class is a static factory for a
* type-specific assertion object.
*
* @author Grzegorz Piwowarek
*/
@CheckReturnValue
public final class VavrAssertions {
private VavrAssertions() {
}
/**
* Creates assertion for {@link io.vavr.control.Either}.
*
* @param the type of a value contained on left by actual {@link Either}
.
* @param the type of a value contained on right by actual {@link Either}
.
* @param actual the actual value.
* @return the created assertion object.
*/
@CheckReturnValue
public static EitherAssert assertThat(Either actual) {
return new EitherAssert<>(actual);
}
/**
* Creates assertion for {@link Lazy}.
*
* @param the type of a value contained by actual {@link Lazy}
.
* @param actual the actual value.
* @return the created assertion object.
*/
@CheckReturnValue
public static LazyAssert assertThat(Lazy actual) {
return new LazyAssert<>(actual);
}
/**
* Creates assertion for {@link io.vavr.control.Option}.
*
* @param the type of a value contained by actual {@link Option}
.
* @param actual the actual value.
* @return the created assertion object.
*/
@CheckReturnValue
public static OptionAssert assertThat(Option actual) {
return new OptionAssert<>(actual);
}
/**
* Creates assertion for {@link io.vavr.control.Try}.
*
* @param the type of a value contained by actual {@link Try}
.
* @param actual the actual value.
* @return the created assertion object.
*/
@CheckReturnValue
public static TryAssert assertThat(Try actual) {
return new TryAssert<>(actual);
}
/**
* Creates assertion for {@link io.vavr.collection.List}.
*
* @param the type of elements contained by actual {@link List}
.
* @param actual the actual value.
* @return the created assertion object.
*/
@CheckReturnValue
public static SeqAssert assertThat(Seq actual) {
return new SeqAssert<>(actual);
}
/**
* Creates assertion for {@link io.vavr.control.Validation}.
*
* @param type of the value in the case of the invalid {@link Validation}.
* @param type of the value in the case of the valid {@link Validation}.
* @param actual the actual value.
* @return the created assertion object.
*/
@CheckReturnValue
public static ValidationAssert assertThat(Validation actual) {
return new ValidationAssert<>(actual);
}
/**
* Creates assertion for {@link io.vavr.collection.Set}.
*
* @param the type of elements contained by actual {@link Set}
.
* @param actual the actual value.
* @return the created assertion object.
*/
@CheckReturnValue
public static SetAssert assertThat(Set actual) {
return new SetAssert<>(actual);
}
/**
* Creates assertion for {@link io.vavr.collection.Map}.
*
* @param key type of the {@link Map}.
* @param value type of the {@link Map}.
* @param actual the actual value.
* @return the created assertion object.
*/
@CheckReturnValue
public static MapAssert assertThat(Map actual) {
return new MapAssert<>(actual);
}
/**
* Creates assertion for {@link io.vavr.collection.Multimap}.
*
* @param key type of the {@link Multimap}.
* @param value type of the {@link Multimap}.
* @param actual the actual value.
* @return the created assertion object.
*/
@CheckReturnValue
public static MultimapAssert assertThat(Multimap actual) {
return new MultimapAssert<>(actual);
}
}