/**
* Copyright (C) 2015 Orion Health (Orchestral Development Ltd)
*
* 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 xbdd.report.assertions;
import static org.assertj.core.util.Objects.areEqual;
import org.assertj.core.api.AbstractAssert;
import org.assertj.core.internal.Iterables;
import xbdd.report.ScenarioSummary;
import xbdd.report.StepSummary;
/**
* {@link ScenarioSummary} specific assertions - Generated by CustomAssertionGenerator.
*/
public class ScenarioSummaryAssert extends AbstractAssert<ScenarioSummaryAssert, ScenarioSummary> {
/**
* Creates a new <code>{@link ScenarioSummaryAssert}</code> to make assertions on actual ScenarioSummary.
*
* @param actual the ScenarioSummary we want to make assertions on.
*/
public ScenarioSummaryAssert(final ScenarioSummary actual) {
super(actual, ScenarioSummaryAssert.class);
}
/**
* An entry point for ScenarioSummaryAssert to follow AssertJ standard <code>assertThat()</code> statements.<br>
* With a static import, one can write directly: <code>assertThat(myScenarioSummary)</code> and get specific assertion with code
* completion.
*
* @param actual the ScenarioSummary we want to make assertions on.
* @return a new <code>{@link ScenarioSummaryAssert}</code>
*/
public static ScenarioSummaryAssert assertThat(final ScenarioSummary actual) {
return new ScenarioSummaryAssert(actual);
}
/**
* Verifies that the actual ScenarioSummary's background contains the given StepSummary elements.
*
* @param background the given elements that should be contained in actual ScenarioSummary's background.
* @return this assertion object.
* @throws AssertionError if the actual ScenarioSummary's background does not contain all given StepSummary elements.
*/
public ScenarioSummaryAssert hasBackground(final StepSummary... background) {
// check that actual ScenarioSummary we want to make assertions on is not null.
isNotNull();
// check that given StepSummary varargs is not null.
if (background == null) {
throw new AssertionError("Expecting background parameter not to be null.");
}
// check with standard error message, to set another message call: info.overridingErrorMessage("my error message");
Iterables.instance().assertContains(this.info, this.actual.getBackground(), background);
// return the current assertion for method chaining
return this;
}
/**
* Verifies that the actual ScenarioSummary has no background.
*
* @return this assertion object.
* @throws AssertionError if the actual ScenarioSummary's background is not empty.
*/
public ScenarioSummaryAssert hasNoBackground() {
// check that actual ScenarioSummary we want to make assertions on is not null.
isNotNull();
// we override the default error message with a more explicit one
final String assertjErrorMessage = "\nExpected :\n <%s>\nnot to have background but had :\n <%s>";
// check
if (this.actual.getBackground().iterator().hasNext()) {
failWithMessage(assertjErrorMessage, this.actual, this.actual.getBackground());
}
// return the current assertion for method chaining
return this;
}
/**
* Verifies that the actual ScenarioSummary's description is equal to the given one.
*
* @param description the given description to compare the actual ScenarioSummary's description to.
* @return this assertion object.
* @throws AssertionError - if the actual ScenarioSummary's description is not equal to the given one.
*/
public ScenarioSummaryAssert hasDescription(final String description) {
// check that actual ScenarioSummary we want to make assertions on is not null.
isNotNull();
// overrides the default error message with a more explicit one
final String assertjErrorMessage = "\nExpected description of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>";
// null safe check
final String actualDescription = this.actual.getDescription();
if (!areEqual(actualDescription, description)) {
failWithMessage(assertjErrorMessage, this.actual, description, actualDescription);
}
// return the current assertion for method chaining
return this;
}
/**
* Verifies that the actual ScenarioSummary's environment is equal to the given one.
*
* @param environment the given environment to compare the actual ScenarioSummary's environment to.
* @return this assertion object.
* @throws AssertionError - if the actual ScenarioSummary's environment is not equal to the given one.
*/
public ScenarioSummaryAssert hasEnvironment(final String environment) {
// check that actual ScenarioSummary we want to make assertions on is not null.
isNotNull();
// overrides the default error message with a more explicit one
final String assertjErrorMessage = "\nExpected environment of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>";
// null safe check
final String actualEnvironment = this.actual.getEnvironment();
if (!areEqual(actualEnvironment, environment)) {
failWithMessage(assertjErrorMessage, this.actual, environment, actualEnvironment);
}
// return the current assertion for method chaining
return this;
}
/**
* Verifies that the actual ScenarioSummary's executionNotes is equal to the given one.
*
* @param executionNotes the given executionNotes to compare the actual ScenarioSummary's executionNotes to.
* @return this assertion object.
* @throws AssertionError - if the actual ScenarioSummary's executionNotes is not equal to the given one.
*/
public ScenarioSummaryAssert hasExecutionNotes(final String executionNotes) {
// check that actual ScenarioSummary we want to make assertions on is not null.
isNotNull();
// overrides the default error message with a more explicit one
final String assertjErrorMessage = "\nExpected executionNotes of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>";
// null safe check
final String actualExecutionNotes = this.actual.getExecutionNotes();
if (!areEqual(actualExecutionNotes, executionNotes)) {
failWithMessage(assertjErrorMessage, this.actual, executionNotes, actualExecutionNotes);
}
// return the current assertion for method chaining
return this;
}
/**
* Verifies that the actual ScenarioSummary's name is equal to the given one.
*
* @param name the given name to compare the actual ScenarioSummary's name to.
* @return this assertion object.
* @throws AssertionError - if the actual ScenarioSummary's name is not equal to the given one.
*/
public ScenarioSummaryAssert hasName(final String name) {
// check that actual ScenarioSummary we want to make assertions on is not null.
isNotNull();
// overrides the default error message with a more explicit one
final String assertjErrorMessage = "\nExpected name of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>";
// null safe check
final String actualName = this.actual.getName();
if (!areEqual(actualName, name)) {
failWithMessage(assertjErrorMessage, this.actual, name, actualName);
}
// return the current assertion for method chaining
return this;
}
/**
* Verifies that the actual ScenarioSummary's result is equal to the given one.
*
* @param result the given result to compare the actual ScenarioSummary's result to.
* @return this assertion object.
* @throws AssertionError - if the actual ScenarioSummary's result is not equal to the given one.
*/
public ScenarioSummaryAssert hasResult(final String result) {
// check that actual ScenarioSummary we want to make assertions on is not null.
isNotNull();
// overrides the default error message with a more explicit one
final String assertjErrorMessage = "\nExpected result of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>";
// null safe check
final String actualResult = this.actual.getResult();
if (!areEqual(actualResult, result)) {
failWithMessage(assertjErrorMessage, this.actual, result, actualResult);
}
// return the current assertion for method chaining
return this;
}
/**
* Verifies that the actual ScenarioSummary's steps are the same as the given one.
*
* @param scenarioSummary the given ScenarioSummary.
* @return this assertion object.
* @throws AssertionError if the actual ScenarioSummary's steps does not contain all given ScenarioSummary steps.
*/
public ScenarioSummaryAssert hasSameStepsAs(final ScenarioSummary scenarioSummary) {
// check that actual ScenarioSummary we want to make assertions on is not null.
isNotNull();
if (scenarioSummary == null) {
throw new AssertionError("Expecting scenarioSummary parameter not to be null.");
}
if (scenarioSummary.getSteps() == null) {
throw new AssertionError("Expecting steps parameter not to be null.");
}
// check with standard error message, to set another message call: info.overridingErrorMessage("my error message");
Iterables.instance().assertContainsAll(this.info, this.actual.getSteps(), scenarioSummary.getSteps());
// return the current assertion for method chaining
return this;
}
/**
* Verifies that the actual ScenarioSummary has no steps.
*
* @return this assertion object.
* @throws AssertionError if the actual ScenarioSummary's steps is not empty.
*/
public ScenarioSummaryAssert hasNoSteps() {
// check that actual ScenarioSummary we want to make assertions on is not null.
isNotNull();
// we override the default error message with a more explicit one
final String assertjErrorMessage = "\nExpected :\n <%s>\nnot to have steps but had :\n <%s>";
// check
if (this.actual.getSteps().iterator().hasNext()) {
failWithMessage(assertjErrorMessage, this.actual, this.actual.getSteps());
}
// return the current assertion for method chaining
return this;
}
/**
* Verifies that the actual ScenarioSummary's tags contains the given String elements.
*
* @param tags the given elements that should be contained in actual ScenarioSummary's tags.
* @return this assertion object.
* @throws AssertionError if the actual ScenarioSummary's tags does not contain all given String elements.
*/
public ScenarioSummaryAssert hasTags(final String... tags) {
// check that actual ScenarioSummary we want to make assertions on is not null.
isNotNull();
// check that given String varargs is not null.
if (tags == null) {
throw new AssertionError("Expecting tags parameter not to be null.");
}
// check with standard error message, to set another message call: info.overridingErrorMessage("my error message");
Iterables.instance().assertContains(this.info, this.actual.getTags(), tags);
// return the current assertion for method chaining
return this;
}
/**
* Verifies that the actual ScenarioSummary has no tags.
*
* @return this assertion object.
* @throws AssertionError if the actual ScenarioSummary's tags is not empty.
*/
public ScenarioSummaryAssert hasNoTags() {
// check that actual ScenarioSummary we want to make assertions on is not null.
isNotNull();
// we override the default error message with a more explicit one
final String assertjErrorMessage = "\nExpected :\n <%s>\nnot to have tags but had :\n <%s>";
// check
if (this.actual.getTags().iterator().hasNext()) {
failWithMessage(assertjErrorMessage, this.actual, this.actual.getTags());
}
// return the current assertion for method chaining
return this;
}
/**
* Verifies that the actual ScenarioSummary's testingTips is equal to the given one.
*
* @param testingTips the given testingTips to compare the actual ScenarioSummary's testingTips to.
* @return this assertion object.
* @throws AssertionError - if the actual ScenarioSummary's testingTips is not equal to the given one.
*/
public ScenarioSummaryAssert hasTestingTips(final String testingTips) {
// check that actual ScenarioSummary we want to make assertions on is not null.
isNotNull();
// overrides the default error message with a more explicit one
final String assertjErrorMessage = "\nExpected testingTips of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>";
// null safe check
final String actualTestingTips = this.actual.getTestingTips();
if (!areEqual(actualTestingTips, testingTips)) {
failWithMessage(assertjErrorMessage, this.actual, testingTips, actualTestingTips);
}
// return the current assertion for method chaining
return this;
}
}