1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 *9 * https://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */1718package org.apache.commons.lang3.function;
1920importstatic org.junit.jupiter.api.Assertions.assertEquals;
21importstatic org.junit.jupiter.api.Assertions.assertNotNull;
22importstatic org.junit.jupiter.api.Assertions.assertNull;
23importstatic org.junit.jupiter.api.Assertions.assertThrows;
2425import java.io.IOException;
2627import org.apache.commons.lang3.AbstractLangTest;
28import org.junit.jupiter.api.Test;
2930/**31 * Tests {@link FailableIntFunction}.32 */33classFailableIntFunctionTestextendsAbstractLangTest {
3435 @Test
36void testApply_returnsResult() throws IOException {
37final FailableIntFunction<String, IOException> f = v -> "v=" + v;
38 assertEquals("v=5", f.apply(5));
39 }
4041 @Test
42void testApply_throwsException() {
43final IOException expected = new IOException("fail");
44final FailableIntFunction<String, IOException> f = v -> {
45throw expected;
46 };
47final IOException thrown = assertThrows(IOException.class, () -> f.apply(1));
48 assertEquals(expected, thrown);
49 }
5051 @Test
52void testNop_applyReturnsNull() throws Throwable {
53 assertNull(FailableIntFunction.nop().apply(1));
54 }
5556 @Test
57void testNop_returnsNonNull() {
58 assertNotNull(FailableIntFunction.nop());
59 }
60 }