
com.foursoft.vecmodel.vec120.AbstractVecDoubleValuePropertyAssert Maven / Gradle / Ivy
Show all versions of vec120-assertions Show documentation
package com.foursoft.vecmodel.vec120;
import org.assertj.core.api.Assertions;
/**
* Abstract base class for {@link VecDoubleValueProperty} specific assertions - Generated by CustomAssertionGenerator.
*/
@javax.annotation.Generated(value="assertj-assertions-generator")
public abstract class AbstractVecDoubleValuePropertyAssert, A extends VecDoubleValueProperty> extends AbstractVecCustomPropertyAssert {
/**
* Creates a new {@link AbstractVecDoubleValuePropertyAssert}
to make assertions on actual VecDoubleValueProperty.
* @param actual the VecDoubleValueProperty we want to make assertions on.
*/
protected AbstractVecDoubleValuePropertyAssert(A actual, Class selfType) {
super(actual, selfType);
}
/**
* Verifies that the actual VecDoubleValueProperty's value is equal to the given one.
* @param value the given value to compare the actual VecDoubleValueProperty's value to.
* @return this assertion object.
* @throws AssertionError - if the actual VecDoubleValueProperty's value is not equal to the given one.
*/
public S hasValue(double value) {
// check that actual VecDoubleValueProperty we want to make assertions on is not null.
isNotNull();
// overrides the default error message with a more explicit one
String assertjErrorMessage = "\nExpecting value of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>";
// check value for value
double actualValue = actual.getValue();
if (actualValue != value) {
failWithMessage(assertjErrorMessage, actual, value, actualValue);
}
// return the current assertion for method chaining
return myself;
}
/**
* Verifies that the actual VecDoubleValueProperty's value is close to the given value by less than the given offset.
*
* If difference is equal to the offset value, assertion is considered successful.
* @param value the value to compare the actual VecDoubleValueProperty's value to.
* @param assertjOffset the given offset.
* @return this assertion object.
* @throws AssertionError - if the actual VecDoubleValueProperty's value is not close enough to the given value.
*/
public S hasValueCloseTo(double value, double assertjOffset) {
// check that actual VecDoubleValueProperty we want to make assertions on is not null.
isNotNull();
double actualValue = actual.getValue();
// overrides the default error message with a more explicit one
String assertjErrorMessage = String.format("\nExpecting value:\n <%s>\nto be close to:\n <%s>\nby less than <%s> but difference was <%s>",
actualValue, value, assertjOffset, Math.abs(value - actualValue));
// check
Assertions.assertThat(actualValue).overridingErrorMessage(assertjErrorMessage).isCloseTo(value, Assertions.within(assertjOffset));
// return the current assertion for method chaining
return myself;
}
}