All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.juneau.rest.client.assertion.FluentResponseStatusLineAssertion Maven / Gradle / Ivy

// ***************************************************************************************************************************
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
// * to you 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 org.apache.juneau.rest.client.assertion;

import java.io.*;
import java.util.function.*;

import org.apache.http.*;
import org.apache.juneau.assertions.*;
import org.apache.juneau.http.response.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.serializer.*;

/**
 * Used for fluent assertion calls against a response {@link StatusLine} object.
 *
 * 
Example:
*

* // Validates the response status code is 200 or 404. * client * .get(URI) * .run() * .assertStatus().asCode().isAny(200,404); *

* * *
Test Methods
*

*

    *
  • {@link FluentObjectAssertion} *
      *
    • {@link FluentObjectAssertion#isExists() isExists()} *
    • {@link FluentObjectAssertion#is(Object) is(Object)} *
    • {@link FluentObjectAssertion#is(Predicate) is(Predicate)} *
    • {@link FluentObjectAssertion#isNot(Object) isNot(Object)} *
    • {@link FluentObjectAssertion#isAny(Object...) isAny(Object...)} *
    • {@link FluentObjectAssertion#isNotAny(Object...) isNotAny(Object...)} *
    • {@link FluentObjectAssertion#isNull() isNull()} *
    • {@link FluentObjectAssertion#isNotNull() isNotNull()} *
    • {@link FluentObjectAssertion#isString(String) isString(String)} *
    • {@link FluentObjectAssertion#isJson(String) isJson(String)} *
    • {@link FluentObjectAssertion#isSame(Object) isSame(Object)} *
    • {@link FluentObjectAssertion#isSameJsonAs(Object) isSameJsonAs(Object)} *
    • {@link FluentObjectAssertion#isSameSortedJsonAs(Object) isSameSortedJsonAs(Object)} *
    • {@link FluentObjectAssertion#isSameSerializedAs(Object, WriterSerializer) isSameSerializedAs(Object, WriterSerializer)} *
    • {@link FluentObjectAssertion#isType(Class) isType(Class)} *
    • {@link FluentObjectAssertion#isExactType(Class) isExactType(Class)} *
    *
* *
Transform Methods
*

*

    *
  • {@link FluentResponseStatusLineAssertion} *
      *
    • {@link FluentResponseStatusLineAssertion#asCode() asCode()} *
    • {@link FluentResponseStatusLineAssertion#asReason() asReason()} *
    • {@link FluentResponseStatusLineAssertion#asProtocol() asProtocol()} *
    • {@link FluentResponseStatusLineAssertion#asMajor() asMajor()} *
    • {@link FluentResponseStatusLineAssertion#asMinor() asMinor()} *
    *
  • {@link FluentObjectAssertion} *
      *
    • {@link FluentObjectAssertion#asString() asString()} *
    • {@link FluentObjectAssertion#asString(WriterSerializer) asString(WriterSerializer)} *
    • {@link FluentObjectAssertion#asString(Function) asString(Function)} *
    • {@link FluentObjectAssertion#asJson() asJson()} *
    • {@link FluentObjectAssertion#asJsonSorted() asJsonSorted()} *
    • {@link FluentObjectAssertion#asTransformed(Function) asApplied(Function)} *
    • {@link FluentObjectAssertion#asAny() asAny()} *
    *
* *
Configuration Methods
*

*

    *
  • {@link Assertion} *
      *
    • {@link Assertion#setMsg(String, Object...) setMsg(String, Object...)} *
    • {@link Assertion#setOut(PrintStream) setOut(PrintStream)} *
    • {@link Assertion#setSilent() setSilent()} *
    • {@link Assertion#setStdOut() setStdOut()} *
    • {@link Assertion#setThrowable(Class) setThrowable(Class)} *
    *
* *
See Also:
* * @param The return type. */ @FluentSetters(returns="FluentResponseStatusLineAssertion") public class FluentResponseStatusLineAssertion extends FluentObjectAssertion { //----------------------------------------------------------------------------------------------------------------- // Constructors //----------------------------------------------------------------------------------------------------------------- /** * Constructor. * * @param value * The object being tested. *
Can be null. * @param returns * The object to return after a test method is called. *
If null, the test method returns this object allowing multiple test method calls to be * used on the same assertion. */ public FluentResponseStatusLineAssertion(StatusLine value, R returns) { this(null, value, returns); } /** * Chained constructor. * *

* Used when transforming one assertion into another so that the assertion config can be used by the new assertion. * * @param creator * The assertion that created this assertion. *
Should be null if this is the top-level assertion. * @param value * The object being tested. *
Can be null. * @param returns * The object to return after a test method is called. *
If null, the test method returns this object allowing multiple test method calls to be * used on the same assertion. */ public FluentResponseStatusLineAssertion(Assertion creator, StatusLine value, R returns) { super(creator, value, returns); setThrowable(BadRequest.class); } //----------------------------------------------------------------------------------------------------------------- // Transform methods //----------------------------------------------------------------------------------------------------------------- /** * Returns an assertion against the status code on the response status object. * * @return An assertion against the status code on the response status object. */ public FluentIntegerAssertion asCode() { return new FluentIntegerAssertion<>(this, value().getStatusCode(), returns()); } /** * Returns an assertion against the reason phrase on the response status object. * * @return An assertion against the reason phrase on the response status object. */ public FluentStringAssertion asReason() { return new FluentStringAssertion<>(this, value().getReasonPhrase(), returns()); } /** * Returns an assertion against the protocol on the response status object. * * @return An assertion against the protocol on the response status object. */ public FluentStringAssertion asProtocol() { return new FluentStringAssertion<>(this, value().getProtocolVersion().getProtocol(), returns()); } /** * Returns an assertion against the protocol major version on the response status object. * * @return An assertion against the protocol major version on the response status object. */ public FluentIntegerAssertion asMajor() { return new FluentIntegerAssertion<>(this, value().getProtocolVersion().getMajor(), returns()); } /** * Returns an assertion against the protocol minor version on the response status object. * * @return An assertion against the protocol minor version on the response status object. */ public FluentIntegerAssertion asMinor() { return new FluentIntegerAssertion<>(this, value().getProtocolVersion().getMinor(), returns()); } //----------------------------------------------------------------------------------------------------------------- // Fluent setters //----------------------------------------------------------------------------------------------------------------- // @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ public FluentResponseStatusLineAssertion setMsg(String msg, Object...args) { super.setMsg(msg, args); return this; } @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ public FluentResponseStatusLineAssertion setOut(PrintStream value) { super.setOut(value); return this; } @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ public FluentResponseStatusLineAssertion setSilent() { super.setSilent(); return this; } @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ public FluentResponseStatusLineAssertion setStdOut() { super.setStdOut(); return this; } @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ public FluentResponseStatusLineAssertion setThrowable(Class value) { super.setThrowable(value); return this; } // }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy