001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.assertions; 014 015 016import org.apache.juneau.internal.*; 017 018/** 019 * Used for fluent assertion calls against integers. 020 * 021 * <h5 class='section'>Example:</h5> 022 * <p class='bcode w800'> 023 * <jc>// Validates the response status code is 200 or 404.</jc> 024 * <jv>client</jv> 025 * .get(<jsf>URL</jsf>) 026 * .run() 027 * .assertStatus().isAny(200,404); 028 * </p> 029 * 030 * @param <R> The return type. 031 */ 032@FluentSetters(returns="FluentIntegerAssertion<R>") 033public class FluentIntegerAssertion<R> extends FluentComparableAssertion<R> { 034 035 private final Integer value; 036 037 /** 038 * Constructor. 039 * 040 * @param value The value being tested. 041 * @param returns The object to return after the test. 042 */ 043 public FluentIntegerAssertion(Integer value, R returns) { 044 this(null, value, returns); 045 } 046 047 /** 048 * Constructor. 049 * 050 * @param creator The assertion that created this assertion. 051 * @param value The value being tested. 052 * @param returns The object to return after the test. 053 */ 054 public FluentIntegerAssertion(Assertion creator, Integer value, R returns) { 055 super(creator, value, returns); 056 this.value = value; 057 } 058 059 @Override 060 protected int compareTo(Object value) { 061 return this.value.compareTo(((Number)value).intValue()); 062 } 063 064 @Override 065 protected Object equivalent(Object o) { 066 if (o instanceof Number) 067 return ((Number)o).intValue(); 068 return o; 069 } 070 071 // <FluentSetters> 072 073 @Override /* GENERATED - Assertion */ 074 public FluentIntegerAssertion<R> msg(String msg, Object...args) { 075 super.msg(msg, args); 076 return this; 077 } 078 079 @Override /* GENERATED - Assertion */ 080 public FluentIntegerAssertion<R> stderr() { 081 super.stderr(); 082 return this; 083 } 084 085 @Override /* GENERATED - Assertion */ 086 public FluentIntegerAssertion<R> stdout() { 087 super.stdout(); 088 return this; 089 } 090 091 // </FluentSetters> 092}