| // *************************************************************************************************************************** |
| // * 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.assertions; |
| |
| import java.io.*; |
| |
| import org.apache.juneau.assertions.*; |
| import org.apache.juneau.http.response.*; |
| import org.apache.juneau.internal.*; |
| import org.apache.juneau.rest.*; |
| |
| /** |
| * Used for fluent assertion calls against {@link RequestHeader} objects. |
| * |
| * @param <R> The return type. |
| */ |
| @FluentSetters(returns="FluentRequestHeaderAssertion<R>") |
| public class FluentRequestHeaderAssertion<R> extends FluentBaseAssertion<String,R> { |
| |
| private final RequestHeader value; |
| |
| /** |
| * Constructor. |
| * |
| * @param value The object being tested. |
| * @param returns The object to return after the test. |
| */ |
| public FluentRequestHeaderAssertion(RequestHeader value, R returns) { |
| this(null, value, returns); |
| } |
| |
| /** |
| * Constructor. |
| * |
| * @param creator The assertion that created this assertion. |
| * @param value The object being tested. |
| * @param returns The object to return after the test. |
| */ |
| public FluentRequestHeaderAssertion(Assertion creator, RequestHeader value, R returns) { |
| super(creator, value.getValue(), returns); |
| this.value = value; |
| throwable(BadRequest.class); |
| } |
| |
| /** |
| * Converts this object assertion into a boolean assertion. |
| * |
| * @return A new assertion. |
| * @throws AssertionError If object is not a boolean. |
| */ |
| public FluentBooleanAssertion<R> 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<R> 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<R> 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<R> asZonedDateTime() { |
| return new FluentZonedDateTimeAssertion<>(this, value.asDateHeader().asZonedDateTime().orElse(null), returns()); |
| } |
| |
| // <FluentSetters> |
| |
| @Override /* GENERATED - Assertion */ |
| public FluentRequestHeaderAssertion<R> msg(String msg, Object...args) { |
| super.msg(msg, args); |
| return this; |
| } |
| |
| @Override /* GENERATED - Assertion */ |
| public FluentRequestHeaderAssertion<R> out(PrintStream value) { |
| super.out(value); |
| return this; |
| } |
| |
| @Override /* GENERATED - Assertion */ |
| public FluentRequestHeaderAssertion<R> silent() { |
| super.silent(); |
| return this; |
| } |
| |
| @Override /* GENERATED - Assertion */ |
| public FluentRequestHeaderAssertion<R> stdout() { |
| super.stdout(); |
| return this; |
| } |
| |
| @Override /* GENERATED - Assertion */ |
| public FluentRequestHeaderAssertion<R> throwable(Class<? extends java.lang.RuntimeException> value) { |
| super.throwable(value); |
| return this; |
| } |
| |
| // </FluentSetters> |
| } |