BAEL-6228 Updated test names (#13571)
This commit is contained in:
parent
78fc83b30d
commit
cfedf55a29
|
@ -1,17 +0,0 @@
|
|||
package com.baeldung.pipeline.functional;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class BiFunctionExample {
|
||||
|
||||
public static void main(String[] args) {
|
||||
BiFunction<Integer, Integer, Integer> add = Integer::sum;
|
||||
BiFunction<Integer, Integer, Integer> mul = (a, b) -> a * b;
|
||||
Function<Integer, String> toString = Object::toString;
|
||||
BiFunction<Integer, Integer, String> pipeline
|
||||
= add.andThen(a -> mul.apply(a, 2)).andThen(toString);
|
||||
String result = pipeline.apply(1, 2);
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package com.baeldung.pipeline.functional;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class FunctionExample {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Function<Integer, Integer> square = s -> s * s;
|
||||
Function<Integer, Integer> half = s -> s / 2;
|
||||
Function<Integer, String> toString = Object::toString;
|
||||
Function<Integer, String> pipeline = square.andThen(half)
|
||||
.andThen(toString);
|
||||
String result = pipeline.apply(5);
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.baeldung.pipeline;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class BiFunctionPipelineUnitTest {
|
||||
|
||||
@Test
|
||||
void whenCombiningFunctionAndBiFunctions_andInitializingPipeline_thenResultIsCorrect() {
|
||||
BiFunction<Integer, Integer, Integer> add = Integer::sum;
|
||||
BiFunction<Integer, Integer, Integer> mul = (a, b) -> a * b;
|
||||
Function<Integer, String> toString = Object::toString;
|
||||
BiFunction<Integer, Integer, String> pipeline = add.andThen(a -> mul.apply(a, 2))
|
||||
.andThen(toString);
|
||||
String result = pipeline.apply(1, 2);
|
||||
String expected = "6";
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.baeldung.pipeline;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.function.Function;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class FunctionPipelineUnitTest {
|
||||
|
||||
@Test
|
||||
void whenCombiningThreeFunctions_andInitializingPipeline_thenResultIsCorrect() {
|
||||
Function<Integer, Integer> square = s -> s * s;
|
||||
Function<Integer, Integer> half = s -> s / 2;
|
||||
Function<Integer, String> toString = Object::toString;
|
||||
Function<Integer, String> pipeline = square.andThen(half)
|
||||
.andThen(toString);
|
||||
String result = pipeline.apply(5);
|
||||
String expected = "12";
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test;
|
|||
class PipeUnitTest {
|
||||
|
||||
@Test
|
||||
void simplePipeTest() {
|
||||
void whenCombiningThreePipes_andInitializingPipeline_thenResultIsCorrect() {
|
||||
Pipe<Integer, Integer> square = s -> s * s;
|
||||
Pipe<Integer, Integer> half = s -> s / 2;
|
||||
Pipe<Integer, String> toString = Object::toString;
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.junit.jupiter.api.Test;
|
|||
class PipelineUnitTest {
|
||||
|
||||
@Test
|
||||
void simplePipelineTest() {
|
||||
void whenCombiningThreePipes_andInitializingPipeline_thenResultIsCorrect() {
|
||||
Pipe<Integer, Integer> square = s -> s * s;
|
||||
Pipe<Integer, Integer> half = s -> s / 2;
|
||||
Pipe<Integer, String> toString = Object::toString;
|
||||
|
|
Loading…
Reference in New Issue