package org.bonitasoft.console.common.server.page;
import static java.lang.String.format;
import java.io.Serializable;
import java.util.Map;
import javax.servlet.http.Cookie;
import org.assertj.core.api.AbstractAssert;
import org.assertj.core.api.Assertions;
/**
* {@link RestApiResponse} specific assertions - Generated by CustomAssertionGenerator.
*/
public class RestApiResponseAssert extends AbstractAssert<RestApiResponseAssert, RestApiResponse> {
/**
* Creates a new </code>{@link RestApiResponseAssert}</code> to make assertions on actual RestApiResponse.
* @param actual the RestApiResponse we want to make assertions on.
*/
public RestApiResponseAssert(RestApiResponse actual) {
super(actual, RestApiResponseAssert.class);
}
/**
* An entry point for RestApiResponseAssert to follow AssertJ standard <code>assertThat()</code> statements.<br>
* With a static import, one's can write directly : <code>assertThat(myRestApiResponse)</code> and get specific assertion with code completion.
* @param actual the RestApiResponse we want to make assertions on.
* @return a new </code>{@link RestApiResponseAssert}</code>
*/
public static RestApiResponseAssert assertThat(RestApiResponse actual) {
return new RestApiResponseAssert(actual);
}
/**
* Verifies that the actual RestApiResponse's additionalCookies contains the given Cookie elements.
* @param additionalCookies the given elements that should be contained in actual RestApiResponse's additionalCookies.
* @return this assertion object.
* @throws AssertionError if the actual RestApiResponse's additionalCookies does not contain all given Cookie elements.
*/
public RestApiResponseAssert hasAdditionalCookies(Cookie... additionalCookies) {
// check that actual RestApiResponse we want to make assertions on is not null.
isNotNull();
// check that given Cookie varargs is not null.
if (additionalCookies == null)
throw new AssertionError("Expecting additionalCookies parameter not to be null.");
// check with standard error message (see commented below to set your own message).
Assertions.assertThat(actual.getAdditionalCookies()).contains(additionalCookies);
// uncomment the 4 lines below if you want to build your own error message :
// WritableAssertionInfo assertionInfo = new WritableAssertionInfo();
// String errorMessage = "my error message";
// assertionInfo.overridingErrorMessage(errorMessage);
// Iterables.instance().assertContains(assertionInfo, actual.getTeamMates(), teamMates);
// return the current assertion for method chaining
return this;
}
/**
* Verifies that the actual RestApiResponse has no additionalCookies.
* @return this assertion object.
* @throws AssertionError if the actual RestApiResponse's additionalCookies is not empty.
*/
public RestApiResponseAssert hasNoAdditionalCookies() {
// check that actual RestApiResponse we want to make assertions on is not null.
isNotNull();
// we overrides the default error message with a more explicit one
String errorMessage = format("\nExpected :\n <%s>\nnot to have additionalCookies but had :\n <%s>", actual, actual.getAdditionalCookies());
// check
if (!actual.getAdditionalCookies().isEmpty())
throw new AssertionError(errorMessage);
// return the current assertion for method chaining
return this;
}
/**
* Verifies that the actual RestApiResponse's additionalHeaders is equal to the given one.
* @param additionalHeaders the given additionalHeaders to compare the actual RestApiResponse's additionalHeaders to.
* @return this assertion object.
* @throws AssertionError - if the actual RestApiResponse's additionalHeaders is not equal to the given one.
*/
public RestApiResponseAssert hasAdditionalHeaders(Map additionalHeaders) {
// check that actual RestApiResponse we want to make assertions on is not null.
isNotNull();
// we overrides the default error message with a more explicit one
String errorMessage = format("\nExpected <%s> additionalHeaders to be:\n <%s>\n but was:\n <%s>", actual, additionalHeaders,
actual.getAdditionalHeaders());
// check
if (!actual.getAdditionalHeaders().equals(additionalHeaders)) {
throw new AssertionError(errorMessage);
}
// return the current assertion for method chaining
return this;
}
/**
* Verifies that the actual RestApiResponse's characterSet is equal to the given one.
* @param characterSet the given characterSet to compare the actual RestApiResponse's characterSet to.
* @return this assertion object.
* @throws AssertionError - if the actual RestApiResponse's characterSet is not equal to the given one.
*/
public RestApiResponseAssert hasCharacterSet(String characterSet) {
// check that actual RestApiResponse we want to make assertions on is not null.
isNotNull();
// we overrides the default error message with a more explicit one
String errorMessage = format("\nExpected <%s> characterSet to be:\n <%s>\n but was:\n <%s>", actual, characterSet, actual.getCharacterSet());
// check
if (!actual.getCharacterSet().equals(characterSet)) {
throw new AssertionError(errorMessage);
}
// return the current assertion for method chaining
return this;
}
/**
* Verifies that the actual RestApiResponse's httpStatus is equal to the given one.
* @param httpStatus the given httpStatus to compare the actual RestApiResponse's httpStatus to.
* @return this assertion object.
* @throws AssertionError - if the actual RestApiResponse's httpStatus is not equal to the given one.
*/
public RestApiResponseAssert hasHttpStatus(int httpStatus) {
// check that actual RestApiResponse we want to make assertions on is not null.
isNotNull();
// we overrides the default error message with a more explicit one
String errorMessage = format("\nExpected <%s> httpStatus to be:\n <%s>\n but was:\n <%s>", actual, httpStatus, actual.getHttpStatus());
// check
if (actual.getHttpStatus() != httpStatus) {
throw new AssertionError(errorMessage);
}
// return the current assertion for method chaining
return this;
}
/**
* Verifies that the actual RestApiResponse's mediaType is equal to the given one.
* @param mediaType the given mediaType to compare the actual RestApiResponse's mediaType to.
* @return this assertion object.
* @throws AssertionError - if the actual RestApiResponse's mediaType is not equal to the given one.
*/
public RestApiResponseAssert hasMediaType(String mediaType) {
// check that actual RestApiResponse we want to make assertions on is not null.
isNotNull();
// we overrides the default error message with a more explicit one
String errorMessage = format("\nExpected <%s> mediaType to be:\n <%s>\n but was:\n <%s>", actual, mediaType, actual.getMediaType());
// check
if (!actual.getMediaType().equals(mediaType)) {
throw new AssertionError(errorMessage);
}
// return the current assertion for method chaining
return this;
}
/**
* Verifies that the actual RestApiResponse's response is equal to the given one.
* @param response the given response to compare the actual RestApiResponse's response to.
* @return this assertion object.
* @throws AssertionError - if the actual RestApiResponse's response is not equal to the given one.
*/
public RestApiResponseAssert hasResponse(Serializable response) {
// check that actual RestApiResponse we want to make assertions on is not null.
isNotNull();
// we overrides the default error message with a more explicit one
String errorMessage = format("\nExpected <%s> response to be:\n <%s>\n but was:\n <%s>", actual, response, actual.getResponse());
// check
if (!actual.getResponse().equals(response)) {
throw new AssertionError(errorMessage);
}
// return the current assertion for method chaining
return this;
}
}