BAEL-1049: Re-merge changes. (#5895)

* BAEL-1049: Re-merge changes.

* Change to re-trigger build

* Change to re-trigger the build

* Change to re-trigger build

* Change to re-trigger build
This commit is contained in:
Paul van Gool 2018-12-12 14:20:14 -08:00 committed by Eugen
parent cb7e515723
commit 5525c12776
1 changed files with 18 additions and 24 deletions

View File

@ -1,6 +1,8 @@
package com.baeldung.fj;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
@ -30,7 +32,7 @@ public class FunctionalJavaUnitTest {
List<Integer> fList1 = fList.map(timesTwo);
List<Integer> fList2 = fList.map(i -> i * 2);
assertEquals(fList1.equals(fList2), true);
assertTrue(fList1.equals(fList2));
}
@Test
@ -41,7 +43,7 @@ public class FunctionalJavaUnitTest {
List<Integer> fList2 = fList.map(plusOne).map(timesTwo);
Show.listShow(Show.intShow).println(fList2);
assertEquals(fList1.equals(fList2), false);
assertFalse(fList1.equals(fList2));
}
@Test
@ -49,10 +51,8 @@ public class FunctionalJavaUnitTest {
List<Integer> fList = List.list(3, 4, 5, 6);
List<Boolean> evenList = fList.map(isEven);
List<Boolean> evenListTrueResult = List.list(false, true, false, true);
List<Boolean> evenListFalseResult = List.list(true, false, false, true);
assertEquals(evenList.equals(evenListTrueResult), true);
assertEquals(evenList.equals(evenListFalseResult), false);
assertTrue(evenList.equals(evenListTrueResult));
}
@Test
@ -60,10 +60,8 @@ public class FunctionalJavaUnitTest {
List<Integer> fList = List.list(3, 4, 5, 6);
fList = fList.map(i -> i + 100);
List<Integer> resultList = List.list(103, 104, 105, 106);
List<Integer> falseResultList = List.list(15, 504, 105, 106);
assertEquals(fList.equals(resultList), true);
assertEquals(fList.equals(falseResultList), false);
assertTrue(fList.equals(resultList));
}
@Test
@ -71,23 +69,19 @@ public class FunctionalJavaUnitTest {
Array<Integer> array = Array.array(3, 4, 5, 6);
Array<Integer> filteredArray = array.filter(isEven);
Array<Integer> result = Array.array(4, 6);
Array<Integer> wrongResult = Array.array(3, 5);
assertEquals(filteredArray.equals(result), true);
assertEquals(filteredArray.equals(wrongResult), false);
assertTrue(filteredArray.equals(result));
}
@Test
public void checkForLowerCase_givenStringArray_returnResult() {
Array<String> array = Array.array("Welcome", "To", "baeldung");
assertTrue(array.exists(s -> List.fromString(s).forall(Characters.isLowerCase)));
Array<String> array2 = Array.array("Welcome", "To", "Baeldung");
Boolean isExist = array.exists(s -> List.fromString(s).forall(Characters.isLowerCase));
Boolean isExist2 = array2.exists(s -> List.fromString(s).forall(Characters.isLowerCase));
Boolean isAll = array.forall(s -> List.fromString(s).forall(Characters.isLowerCase));
assertEquals(isExist, true);
assertEquals(isExist2, false);
assertEquals(isAll, false);
assertFalse(array2.exists(s -> List.fromString(s).forall(Characters.isLowerCase)));
assertFalse(array.forall(s -> List.fromString(s).forall(Characters.isLowerCase)));
}
@Test
@ -102,9 +96,9 @@ public class FunctionalJavaUnitTest {
Option<Integer> result2 = n2.bind(function);
Option<Integer> result3 = n3.bind(function);
assertEquals(result1, Option.none());
assertEquals(result2, Option.some(102));
assertEquals(result3, Option.none());
assertEquals(Option.none(), result1);
assertEquals(Option.some(102), result2);
assertEquals(Option.none(), result3);
}
@Test
@ -112,11 +106,11 @@ public class FunctionalJavaUnitTest {
Array<Integer> intArray = Array.array(17, 44, 67, 2, 22, 80, 1, 27);
int sumAll = intArray.foldLeft(Integers.add, 0);
assertEquals(sumAll, 260);
assertEquals(260, sumAll);
int sumEven = intArray.filter(isEven).foldLeft(Integers.add, 0);
assertEquals(sumEven, 148);
assertEquals(148, sumEven);
}
}