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

org.apache.juneau.rest.client.assertion.FluentResponseHeaderAssertion 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.lang.reflect.*;
import java.util.*;
import java.util.function.*;
import java.util.regex.*;

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

/**
 * Used for fluent assertion calls against {@link ResponseHeader} objects.
 *
 * 
Test Methods
*

*

    *
  • {@link FluentStringAssertion} *
      *
    • {@link FluentStringAssertion#is(String) is(String)} *
    • {@link FluentStringAssertion#isNot(String) isNot(String)} *
    • {@link FluentStringAssertion#isLines(String...) isLines(String...)} *
    • {@link FluentStringAssertion#isSortedLines(String...) isSortedLines(String...)} *
    • {@link FluentStringAssertion#isIc(String) isIc(String)} *
    • {@link FluentStringAssertion#isNotIc(String) isNotIc(String)} *
    • {@link FluentStringAssertion#isContains(String...) isContains(String...)} *
    • {@link FluentStringAssertion#isNotContains(String...) isNotContains(String...)} *
    • {@link FluentStringAssertion#isEmpty() isEmpty()} *
    • {@link FluentStringAssertion#isNotEmpty() isNotEmpty()} *
    • {@link FluentStringAssertion#isString(Object) isString(Object)} *
    • {@link FluentStringAssertion#isMatches(String) isMatches(String)} *
    • {@link FluentStringAssertion#isPattern(String) isPattern(String)} *
    • {@link FluentStringAssertion#isPattern(String,int) isPattern(String,int)} *
    • {@link FluentStringAssertion#isPattern(Pattern) isPattern(Pattern)} *
    • {@link FluentStringAssertion#isStartsWith(String) isStartsWith(String)} *
    • {@link FluentStringAssertion#isEndsWith(String) isEndsWith(String)} *
    *
  • {@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 FluentResponseHeaderAssertion} *
      *
    • {@link FluentResponseHeaderAssertion#asBoolean() asBoolean()} *
    • {@link FluentResponseHeaderAssertion#asInteger() asInteger()} *
    • {@link FluentResponseHeaderAssertion#asLong() asLong()} *
    • {@link FluentResponseHeaderAssertion#asZonedDateTime() asZonedDateTime()} *
    • {@link FluentResponseHeaderAssertion#as(Class) as(Class)} *
    • {@link FluentResponseHeaderAssertion#as(Type,Type...) as(Type,Type...)} *
    *
  • {@link FluentStringAssertion} *
      *
    • {@link FluentStringAssertion#asReplaceAll(String,String) asReplaceAll(String,String)} *
    • {@link FluentStringAssertion#asReplace(String,String) asReplace(String,String)} *
    • {@link FluentStringAssertion#asUrlDecode() asUrlDecode()} *
    • {@link FluentStringAssertion#asLc() asLc()} *
    • {@link FluentStringAssertion#asUc() asUc()} *
    • {@link FluentStringAssertion#asLines() asLines()} *
    • {@link FluentStringAssertion#asSplit(String) asSplit(String)} *
    • {@link FluentStringAssertion#asLength() asLength()} *
    • {@link FluentStringAssertion#asOneLine() asOneLine()} *
    *
  • {@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="FluentResponseHeaderAssertion") public class FluentResponseHeaderAssertion extends FluentStringAssertion { private final ResponseHeader value; //----------------------------------------------------------------------------------------------------------------- // 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 FluentResponseHeaderAssertion(ResponseHeader 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 FluentResponseHeaderAssertion(Assertion creator, ResponseHeader value, R returns) { super(creator, value.asString().orElse(null), returns); this.value = value; setThrowable(BadRequest.class); } //----------------------------------------------------------------------------------------------------------------- // Transform methods //----------------------------------------------------------------------------------------------------------------- /** * Converts this object assertion into a boolean assertion. * * @return A new assertion. * @throws AssertionError If object is not a boolean. */ public FluentBooleanAssertion asBoolean() { return new FluentBooleanAssertion<>(this, value.asBoolean().orElse(null), returns()); } /** * Converts this object assertion into an integer assertion. * * @return A new assertion. * @throws AssertionError If object is not an integer. */ public FluentIntegerAssertion asInteger() { return new FluentIntegerAssertion<>(this, value.asInteger().orElse(null), returns()); } /** * Converts this object assertion into a long assertion. * * @return A new assertion. * @throws AssertionError If object is not a long. */ public FluentLongAssertion asLong() { return new FluentLongAssertion<>(this, value.asLong().orElse(null), returns()); } /** * Converts this object assertion into a zoned-datetime assertion. * * @return A new assertion. * @throws AssertionError If object is not a zoned-datetime. */ public FluentZonedDateTimeAssertion asZonedDateTime() { return new FluentZonedDateTimeAssertion<>(this, value.asDateHeader().asZonedDateTime().orElse(null), returns()); } /** * Converts the parameter value to a type using {@link ResponseHeader#as(Class)} and then returns the value as an any-object assertion. * * @param The object type to create. * @param type The object type to create. * @return A new fluent assertion object. * @throws RestCallException If value could not be parsed. */ public FluentAnyAssertion as(Class type) throws RestCallException { return new FluentAnyAssertion<>(value.as(type).orElse(null), returns()); } /** * Converts the parameter value to a type using {@link ResponseHeader#as(Type,Type...)} and then returns the value as an any-object assertion. * *

* See Complex Data Types for information on defining complex generic types of {@link Map Maps} and {@link Collection Collections}. * * @param type The object type to create. * @param args Optional type arguments. * @return A new fluent assertion object. * @throws RestCallException If value could not be parsed. */ public FluentAnyAssertion as(Type type, Type...args) throws RestCallException { return new FluentAnyAssertion<>(value.as(type, args).orElse(null), returns()); } //----------------------------------------------------------------------------------------------------------------- // Fluent setters //----------------------------------------------------------------------------------------------------------------- // @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ public FluentResponseHeaderAssertion setMsg(String msg, Object...args) { super.setMsg(msg, args); return this; } @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ public FluentResponseHeaderAssertion setOut(PrintStream value) { super.setOut(value); return this; } @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ public FluentResponseHeaderAssertion setSilent() { super.setSilent(); return this; } @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ public FluentResponseHeaderAssertion setStdOut() { super.setStdOut(); return this; } @Override /* GENERATED - org.apache.juneau.assertions.Assertion */ public FluentResponseHeaderAssertion setThrowable(Class value) { super.setThrowable(value); return this; } @Override /* GENERATED - org.apache.juneau.assertions.FluentStringAssertion */ public FluentResponseHeaderAssertion asJavaStrings() { super.asJavaStrings(); return this; } // }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy