@@ -0,0 +1,1430 @@
+/*%0A * Copyright 2014 SATO taichi%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A *  Unless required by applicable law or agreed to in writing, software%0A *  distributed under the License is distributed on an %22AS IS%22 BASIS,%0A *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A *  See the License for the specific language governing permissions and%0A *  limitations under the License.%0A */%0Apackage ninja.siden.util;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.util.Optional;%0A%0Aimport org.junit.Test;%0A%0A/**%0A * @author taichi%0A */%0Apublic class TrialTest %7B%0A%0A%09static File ok(String s) throws IOException %7B%0A%09%09return new File(s);%0A%09%7D%0A%0A%09static File ng(String s) throws IOException %7B%0A%09%09throw new IOException(s);%0A%09%7D%0A%0A%09@Test%0A%09public void success() throws Exception %7B%0A%09%09int ret = Optional.of(%22aaa%22).map(Trial.of(TrialTest::ok))%0A%09%09%09%09.%3CInteger%3E map(t -%3E t.either(f -%3E 200, ioex -%3E 400))%0A%09%09%09%09.map(i -%3E i + 10).get();%0A%09%09assertEquals(210, ret);%0A%09%7D%0A%0A%09@Test%0A%09public void failed() throws Exception %7B%0A%09%09int ret = Optional.of(%22aaa%22).map(Trial.of(TrialTest::ng))%0A%09%09%09%09.%3CInteger%3E map(t -%3E t.either(f -%3E 200, ioex -%3E 400))%0A%09%09%09%09.map(i -%3E i + 11).get();%0A%0A%09%09assertEquals(411, ret);%0A%09%7D%0A%0A%7D%0A

add TrialTest