1
1
package com .bobocode .lambda_math_functions ;
2
2
3
- @ TestMethodOrder ( MethodOrderer .OrderAnnotation .class )
3
+ import org .junit .jupiter .api .*;
4
+
5
+ import java .util .function .Function ;
6
+
7
+ import static org .assertj .core .api .AssertionsForClassTypes .assertThat ;
8
+ import static org .assertj .core .api .AssertionsForClassTypes .assertThatExceptionOfType ;
9
+
10
+ @ TestMethodOrder (MethodOrderer .OrderAnnotation .class )
4
11
public class FunctionsTest {
5
- private com . bobocode . FunctionMap <Integer , Integer > integerFunctionMap ;
12
+ private FunctionMap <Integer , Integer > integerFunctionMap ;
6
13
7
14
@ BeforeEach
8
15
public void init () {
9
- integerFunctionMap = com . bobocode . Functions .intFunctionMap ();
16
+ integerFunctionMap = Functions .intFunctionMap ();
10
17
}
11
18
12
19
@ Test
13
20
@ Order (7 )
14
21
void squareFunction () {
15
22
Function <Integer , Integer > squareFunction = integerFunctionMap .getFunction ("square" );
16
23
17
- int actualResult = squareFunction .apply (5 );
24
+ int result = squareFunction .apply (5 );
18
25
19
26
assertThat (result ).isEqualTo (25 );
20
27
}
@@ -24,7 +31,7 @@ void squareFunction() {
24
31
void absFunction () {
25
32
Function <Integer , Integer > absFunction = integerFunctionMap .getFunction ("abs" );
26
33
27
- int actualResult = absFunction .apply (-192 );
34
+ int result = absFunction .apply (-192 );
28
35
29
36
assertThat (result ).isEqualTo (192 );
30
37
}
@@ -34,7 +41,7 @@ void absFunction() {
34
41
void incrementFunction () {
35
42
Function <Integer , Integer > incrementFunction = integerFunctionMap .getFunction ("increment" );
36
43
37
- int actualResult = incrementFunction .apply (399 );
44
+ int result = incrementFunction .apply (399 );
38
45
39
46
assertThat (result ).isEqualTo (400 );
40
47
}
@@ -44,7 +51,7 @@ void incrementFunction() {
44
51
void destDecrementFunction () {
45
52
Function <Integer , Integer > decrementFunction = integerFunctionMap .getFunction ("decrement" );
46
53
47
- int actualResult = decrementFunction .apply (800 );
54
+ int result = decrementFunction .apply (800 );
48
55
49
56
assertThat (result ).isEqualTo (799 );
50
57
}
@@ -54,7 +61,7 @@ void destDecrementFunction() {
54
61
void signFunctionOnNegativeValue () {
55
62
Function <Integer , Integer > signFunction = integerFunctionMap .getFunction ("sgn" );
56
63
57
- int actualResult = signFunction .apply (-123 );
64
+ int result = signFunction .apply (-123 );
58
65
59
66
assertThat (result ).isEqualTo (-1 );
60
67
}
@@ -64,7 +71,7 @@ void signFunctionOnNegativeValue() {
64
71
void signFunctionOnPositiveValue () {
65
72
Function <Integer , Integer > signFunction = integerFunctionMap .getFunction ("sgn" );
66
73
67
- int actualResult = signFunction .apply (23 );
74
+ int result = signFunction .apply (23 );
68
75
69
76
assertThat (result ).isEqualTo (1 );
70
77
}
@@ -74,14 +81,15 @@ void signFunctionOnPositiveValue() {
74
81
void signFunctionOnZero () {
75
82
Function <Integer , Integer > signFunction = integerFunctionMap .getFunction ("sgn" );
76
83
77
- int actualResult = signFunction .apply (0 );
84
+ int result = signFunction .apply (0 );
78
85
79
86
assertThat (result ).isEqualTo (0 );
80
87
}
81
88
82
89
@ Test
83
90
@ Order (8 )
84
91
void getUnknownFunction () {
85
- assertThatExceptionOfType (InvalidFunctionNameException .class ).isThrownBy (() -> integerFunctionMap .getFunction ("sqrt" ));
92
+ assertThatExceptionOfType (InvalidFunctionNameException .class ).isThrownBy (()
93
+ -> integerFunctionMap .getFunction ("sqrt" ));
86
94
}
87
95
}
0 commit comments