Skip to content

Commit 87049b6

Browse files
authored
Build opt 22 06 (eugenp#2132)
* Drools reformat * Further refactor * Further refactor * Refactor
1 parent 38dc204 commit 87049b6

48 files changed

Lines changed: 291 additions & 336 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎drools/src/test/java/com/baeldung/drools/service/ApplicantServiceIntegrationTest.java‎

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,39 @@ public class ApplicantServiceIntegrationTest {
1717
private ApplicantService applicantService;
1818

1919
@Before
20-
public void setup(){
20+
public void setup() {
2121
applicantService = new ApplicantService();
2222
}
2323

2424
@Test
2525
public void whenCriteriaMatching_ThenSuggestManagerRole() throws IOException {
26-
Applicant applicant=new Applicant("Davis",37,1600000.0,11);
27-
SuggestedRole suggestedRole=new SuggestedRole();
28-
applicantService.suggestARoleForApplicant(applicant,suggestedRole);
29-
assertEquals("Manager",suggestedRole.getRole());
26+
Applicant applicant = new Applicant("Davis", 37, 1600000.0, 11);
27+
SuggestedRole suggestedRole = new SuggestedRole();
28+
applicantService.suggestARoleForApplicant(applicant, suggestedRole);
29+
assertEquals("Manager", suggestedRole.getRole());
3030
}
3131

3232
@Test
3333
public void whenCriteriaMatching_ThenSuggestSeniorDeveloperRole() throws IOException {
34-
Applicant applicant=new Applicant("John",37,1200000.0,8);
35-
SuggestedRole suggestedRole=new SuggestedRole();
36-
applicantService.suggestARoleForApplicant(applicant,suggestedRole);
37-
assertEquals("Senior developer",suggestedRole.getRole());
34+
Applicant applicant = new Applicant("John", 37, 1200000.0, 8);
35+
SuggestedRole suggestedRole = new SuggestedRole();
36+
applicantService.suggestARoleForApplicant(applicant, suggestedRole);
37+
assertEquals("Senior developer", suggestedRole.getRole());
3838
}
39+
3940
@Test
4041
public void whenCriteriaMatching_ThenSuggestDeveloperRole() throws IOException {
41-
Applicant applicant=new Applicant("Davis",37,800000.0,3);
42-
SuggestedRole suggestedRole=new SuggestedRole();
43-
applicantService.suggestARoleForApplicant(applicant,suggestedRole);
44-
assertEquals("Developer",suggestedRole.getRole());
42+
Applicant applicant = new Applicant("Davis", 37, 800000.0, 3);
43+
SuggestedRole suggestedRole = new SuggestedRole();
44+
applicantService.suggestARoleForApplicant(applicant, suggestedRole);
45+
assertEquals("Developer", suggestedRole.getRole());
4546
}
47+
4648
@Test
4749
public void whenCriteriaNotMatching_ThenNoRole() throws IOException {
48-
Applicant applicant=new Applicant("John",37,1200000.0,5);
49-
SuggestedRole suggestedRole=new SuggestedRole();
50-
applicantService.suggestARoleForApplicant(applicant,suggestedRole);
50+
Applicant applicant = new Applicant("John", 37, 1200000.0, 5);
51+
SuggestedRole suggestedRole = new SuggestedRole();
52+
applicantService.suggestARoleForApplicant(applicant, suggestedRole);
5153
assertNull(suggestedRole.getRole());
5254
}
5355
}

‎drools/src/test/java/com/baeldung/drools/service/ProductServiceIntegrationTest.java‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.baeldung.drools.model.Product;
44
import org.junit.Before;
55
import org.junit.Test;
6+
67
import static junit.framework.TestCase.assertEquals;
78

89

@@ -11,22 +12,22 @@ public class ProductServiceIntegrationTest {
1112
private ProductService productService;
1213

1314
@Before
14-
public void setup(){
15-
productService=new ProductService();
15+
public void setup() {
16+
productService = new ProductService();
1617
}
1718

1819

1920
@Test
20-
public void whenProductTypeElectronic_ThenLabelBarcode(){
21-
Product product=new Product("Microwave","Electronic");
22-
product=productService.applyLabelToProduct(product);
23-
assertEquals("BarCode",product.getLabel());
21+
public void whenProductTypeElectronic_ThenLabelBarcode() {
22+
Product product = new Product("Microwave", "Electronic");
23+
product = productService.applyLabelToProduct(product);
24+
assertEquals("BarCode", product.getLabel());
2425
}
2526

2627
@Test
27-
public void whenProductTypeBook_ThenLabelIsbn(){
28-
Product product=new Product("AutoBiography","Book");
29-
product=productService.applyLabelToProduct(product);
30-
assertEquals("ISBN",product.getLabel());
28+
public void whenProductTypeBook_ThenLabelIsbn() {
29+
Product product = new Product("AutoBiography", "Book");
30+
product = productService.applyLabelToProduct(product);
31+
assertEquals("ISBN", product.getLabel());
3132
}
3233
}

‎libraries/src/main/java/com/baeldung/asciidoctor/AsciidoctorDemo.java‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,20 @@ public class AsciidoctorDemo {
1313

1414
private final Asciidoctor asciidoctor;
1515

16-
public AsciidoctorDemo() {
16+
AsciidoctorDemo() {
1717
asciidoctor = create();
1818
}
1919

2020
public void generatePDFFromString(final String input) {
2121

2222
final Map<String, Object> options = options().inPlace(true)
23-
.backend("pdf")
24-
.asMap();
23+
.backend("pdf")
24+
.asMap();
2525

2626
final String outfile = asciidoctor.convertFile(new File("sample.adoc"), options);
2727
}
2828

29-
public String generateHTMLFromString(final String input) {
30-
final String output = asciidoctor.convert("Hello _Baeldung_!", new HashMap<String, Object>());
31-
return output;
29+
String generateHTMLFromString(final String input) {
30+
return asciidoctor.convert("Hello _Baeldung_!", new HashMap<String, Object>());
3231
}
3332
}

‎libraries/src/test/java/com/baeldung/commons/lang3/ArrayUtilsUnitTest.java‎

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,77 +2,78 @@
22

33
import org.apache.commons.lang3.ArrayUtils;
44
import org.junit.Test;
5-
import static org.junit.Assert.assertEquals;
5+
66
import static org.junit.Assert.assertArrayEquals;
7+
import static org.junit.Assert.assertEquals;
78

89
public class ArrayUtilsUnitTest {
910
@Test
1011
public void givenArray_whenAddingElementAtSpecifiedPosition_thenCorrect() {
11-
int[] oldArray = { 2, 3, 4, 5 };
12+
int[] oldArray = {2, 3, 4, 5};
1213
int[] newArray = ArrayUtils.add(oldArray, 0, 1);
13-
int[] expectedArray = { 1, 2, 3, 4, 5 };
14+
int[] expectedArray = {1, 2, 3, 4, 5};
1415
assertArrayEquals(expectedArray, newArray);
1516
}
1617

1718
@Test
1819
public void givenArray_whenAddingElementAtTheEnd_thenCorrect() {
19-
int[] oldArray = { 2, 3, 4, 5 };
20+
int[] oldArray = {2, 3, 4, 5};
2021
int[] newArray = ArrayUtils.add(oldArray, 1);
21-
int[] expectedArray = { 2, 3, 4, 5, 1 };
22+
int[] expectedArray = {2, 3, 4, 5, 1};
2223
assertArrayEquals(expectedArray, newArray);
2324
}
2425

2526
@Test
2627
public void givenArray_whenAddingAllElementsAtTheEnd_thenCorrect() {
27-
int[] oldArray = { 0, 1, 2 };
28+
int[] oldArray = {0, 1, 2};
2829
int[] newArray = ArrayUtils.addAll(oldArray, 3, 4, 5);
29-
int[] expectedArray = { 0, 1, 2, 3, 4, 5 };
30+
int[] expectedArray = {0, 1, 2, 3, 4, 5};
3031
assertArrayEquals(expectedArray, newArray);
3132
}
3233

3334
@Test
3435
public void givenArray_whenRemovingElementAtSpecifiedPosition_thenCorrect() {
35-
int[] oldArray = { 1, 2, 3, 4, 5 };
36+
int[] oldArray = {1, 2, 3, 4, 5};
3637
int[] newArray = ArrayUtils.remove(oldArray, 1);
37-
int[] expectedArray = { 1, 3, 4, 5 };
38+
int[] expectedArray = {1, 3, 4, 5};
3839
assertArrayEquals(expectedArray, newArray);
3940
}
4041

4142
@Test
4243
public void givenArray_whenRemovingAllElementsAtSpecifiedPositions_thenCorrect() {
43-
int[] oldArray = { 1, 2, 3, 4, 5 };
44+
int[] oldArray = {1, 2, 3, 4, 5};
4445
int[] newArray = ArrayUtils.removeAll(oldArray, 1, 3);
45-
int[] expectedArray = { 1, 3, 5 };
46+
int[] expectedArray = {1, 3, 5};
4647
assertArrayEquals(expectedArray, newArray);
4748
}
4849

4950
@Test
5051
public void givenArray_whenRemovingAnElement_thenCorrect() {
51-
int[] oldArray = { 1, 2, 3, 3, 4 };
52+
int[] oldArray = {1, 2, 3, 3, 4};
5253
int[] newArray = ArrayUtils.removeElement(oldArray, 3);
53-
int[] expectedArray = { 1, 2, 3, 4 };
54+
int[] expectedArray = {1, 2, 3, 4};
5455
assertArrayEquals(expectedArray, newArray);
5556
}
5657

5758
@Test
5859
public void givenArray_whenRemovingElements_thenCorrect() {
59-
int[] oldArray = { 1, 2, 3, 3, 4 };
60+
int[] oldArray = {1, 2, 3, 3, 4};
6061
int[] newArray = ArrayUtils.removeElements(oldArray, 2, 3, 5);
61-
int[] expectedArray = { 1, 3, 4 };
62+
int[] expectedArray = {1, 3, 4};
6263
assertArrayEquals(expectedArray, newArray);
6364
}
6465

6566
@Test
6667
public void givenArray_whenRemovingAllElementOccurences_thenCorrect() {
67-
int[] oldArray = { 1, 2, 2, 2, 3 };
68+
int[] oldArray = {1, 2, 2, 2, 3};
6869
int[] newArray = ArrayUtils.removeAllOccurences(oldArray, 2);
69-
int[] expectedArray = { 1, 3 };
70+
int[] expectedArray = {1, 3};
7071
assertArrayEquals(expectedArray, newArray);
7172
}
7273

7374
@Test
7475
public void givenArray_whenCheckingExistingElement_thenCorrect() {
75-
int[] array = { 1, 3, 5, 7, 9 };
76+
int[] array = {1, 3, 5, 7, 9};
7677
boolean evenContained = ArrayUtils.contains(array, 2);
7778
boolean oddContained = ArrayUtils.contains(array, 7);
7879
assertEquals(false, evenContained);
@@ -81,57 +82,57 @@ public void givenArray_whenCheckingExistingElement_thenCorrect() {
8182

8283
@Test
8384
public void givenArray_whenReversingElementsWithinARange_thenCorrect() {
84-
int[] originalArray = { 1, 2, 3, 4, 5 };
85+
int[] originalArray = {1, 2, 3, 4, 5};
8586
ArrayUtils.reverse(originalArray, 1, 4);
86-
int[] expectedArray = { 1, 4, 3, 2, 5 };
87+
int[] expectedArray = {1, 4, 3, 2, 5};
8788
assertArrayEquals(expectedArray, originalArray);
8889
}
8990

9091
@Test
9192
public void givenArray_whenReversingAllElements_thenCorrect() {
92-
int[] originalArray = { 1, 2, 3, 4, 5 };
93+
int[] originalArray = {1, 2, 3, 4, 5};
9394
ArrayUtils.reverse(originalArray);
94-
int[] expectedArray = { 5, 4, 3, 2, 1 };
95+
int[] expectedArray = {5, 4, 3, 2, 1};
9596
assertArrayEquals(expectedArray, originalArray);
9697
}
9798

9899
@Test
99100
public void givenArray_whenShiftingElementsWithinARange_thenCorrect() {
100-
int[] originalArray = { 1, 2, 3, 4, 5 };
101+
int[] originalArray = {1, 2, 3, 4, 5};
101102
ArrayUtils.shift(originalArray, 1, 4, 1);
102-
int[] expectedArray = { 1, 4, 2, 3, 5 };
103+
int[] expectedArray = {1, 4, 2, 3, 5};
103104
assertArrayEquals(expectedArray, originalArray);
104105
}
105106

106107
@Test
107108
public void givenArray_whenShiftingAllElements_thenCorrect() {
108-
int[] originalArray = { 1, 2, 3, 4, 5 };
109+
int[] originalArray = {1, 2, 3, 4, 5};
109110
ArrayUtils.shift(originalArray, 1);
110-
int[] expectedArray = { 5, 1, 2, 3, 4 };
111+
int[] expectedArray = {5, 1, 2, 3, 4};
111112
assertArrayEquals(expectedArray, originalArray);
112113
}
113114

114115
@Test
115116
public void givenArray_whenExtractingElements_thenCorrect() {
116-
int[] oldArray = { 1, 2, 3, 4, 5 };
117+
int[] oldArray = {1, 2, 3, 4, 5};
117118
int[] newArray = ArrayUtils.subarray(oldArray, 2, 7);
118-
int[] expectedArray = { 3, 4, 5 };
119+
int[] expectedArray = {3, 4, 5};
119120
assertArrayEquals(expectedArray, newArray);
120121
}
121122

122123
@Test
123124
public void givenArray_whenSwapingElementsWithinARange_thenCorrect() {
124-
int[] originalArray = { 1, 2, 3, 4, 5 };
125+
int[] originalArray = {1, 2, 3, 4, 5};
125126
ArrayUtils.swap(originalArray, 0, 3, 2);
126-
int[] expectedArray = { 4, 5, 3, 1, 2 };
127+
int[] expectedArray = {4, 5, 3, 1, 2};
127128
assertArrayEquals(expectedArray, originalArray);
128129
}
129130

130131
@Test
131132
public void givenArray_whenSwapingElementsAtSpecifiedPositions_thenCorrect() {
132-
int[] originalArray = { 1, 2, 3, 4, 5 };
133+
int[] originalArray = {1, 2, 3, 4, 5};
133134
ArrayUtils.swap(originalArray, 0, 3);
134-
int[] expectedArray = { 4, 2, 3, 1, 5 };
135+
int[] expectedArray = {4, 2, 3, 1, 5};
135136
assertArrayEquals(expectedArray, originalArray);
136137
}
137138
}

‎libraries/src/test/java/com/baeldung/commons/math/ComplexUnitTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class ComplexUnitTest {
88

99
@Test
1010
public void whenComplexPow_thenCorrect() {
11-
Complex first = new Complex(1.0, 3.0);
11+
Complex first = new Complex(1.0, 3.0);
1212
Complex second = new Complex(2.0, 5.0);
1313

1414
Complex power = first.pow(second);

‎libraries/src/test/java/com/baeldung/flink/WordCountIntegrationTest.java‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public void givenDataSet_whenExecuteWordCount_thenReturnWordCount() throws Excep
3535
//then
3636
List<Tuple2<String, Integer>> collect = result.collect();
3737
assertThat(collect).containsExactlyInAnyOrder(
38-
new Tuple2<>("a", 3), new Tuple2<>("sentence", 2), new Tuple2<>("word", 1),
39-
new Tuple2<>("is", 2), new Tuple2<>("this", 2), new Tuple2<>("second", 1),
40-
new Tuple2<>("first", 1), new Tuple2<>("with", 1), new Tuple2<>("one", 1));
38+
new Tuple2<>("a", 3), new Tuple2<>("sentence", 2), new Tuple2<>("word", 1),
39+
new Tuple2<>("is", 2), new Tuple2<>("this", 2), new Tuple2<>("second", 1),
40+
new Tuple2<>("first", 1), new Tuple2<>("with", 1), new Tuple2<>("one", 1));
4141
}
4242

4343
@Test
@@ -48,9 +48,9 @@ public void givenListOfAmounts_whenUseMapReduce_thenSumAmountsThatAreOnlyAboveTh
4848

4949
//when
5050
List<Integer> collect = amounts
51-
.filter(a -> a > threshold)
52-
.reduce((integer, t1) -> integer + t1)
53-
.collect();
51+
.filter(a -> a > threshold)
52+
.reduce((integer, t1) -> integer + t1)
53+
.collect();
5454

5555
//then
5656
assertThat(collect.get(0)).isEqualTo(90);
@@ -78,13 +78,13 @@ public void givenDataSet_whenSortItByOneField_thenShouldReturnSortedDataSet() th
7878
Tuple2<Integer, String> fourthPerson = new Tuple2<>(200, "Michael");
7979
Tuple2<Integer, String> firstPerson = new Tuple2<>(1, "Jack");
8080
DataSet<Tuple2<Integer, String>> transactions = env.fromElements(fourthPerson, secondPerson,
81-
thirdPerson, firstPerson);
81+
thirdPerson, firstPerson);
8282

8383

8484
//when
8585
List<Tuple2<Integer, String>> sorted = transactions
86-
.sortPartition(new IdKeySelectorTransaction(), Order.ASCENDING)
87-
.collect();
86+
.sortPartition(new IdKeySelectorTransaction(), Order.ASCENDING)
87+
.collect();
8888

8989
//then
9090
assertThat(sorted).containsExactly(firstPerson, secondPerson, thirdPerson, fourthPerson);
@@ -99,15 +99,15 @@ public void giveTwoDataSets_whenJoinUsingId_thenProduceJoinedData() throws Excep
9999

100100
Tuple2<Integer, String> firstTransaction = new Tuple2<>(1, "Transaction_1");
101101
DataSet<Tuple2<Integer, String>> transactions =
102-
env.fromElements(firstTransaction, new Tuple2<>(12, "Transaction_2"));
102+
env.fromElements(firstTransaction, new Tuple2<>(12, "Transaction_2"));
103103

104104

105105
//when
106106
List<Tuple2<Tuple2<Integer, String>, Tuple3<Integer, String, String>>> joined =
107-
transactions.join(addresses)
108-
.where(new IdKeySelectorTransaction())
109-
.equalTo(new IdKeySelectorAddress())
110-
.collect();
107+
transactions.join(addresses)
108+
.where(new IdKeySelectorTransaction())
109+
.equalTo(new IdKeySelectorAddress())
110+
.collect();
111111

112112
//then
113113
assertThat(joined).hasSize(1);
@@ -121,7 +121,7 @@ public void givenStreamOfEvents_whenProcessEvents_thenShouldPrintResultsOnSinkOp
121121
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
122122

123123
DataStream<String> text
124-
= env.fromElements("This is a first sentence", "This is a second sentence with a one word");
124+
= env.fromElements("This is a first sentence", "This is a second sentence with a one word");
125125

126126

127127
SingleOutputStreamOperator<String> upperCase = text.map(String::toUpperCase);
@@ -139,8 +139,8 @@ public void givenStreamOfEvents_whenProcessEvents_thenShouldApplyWindowingOnTran
139139
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
140140

141141
SingleOutputStreamOperator<Tuple2<Integer, Long>> windowed = env.fromElements(
142-
new Tuple2<>(16, ZonedDateTime.now().plusMinutes(25).toInstant().getEpochSecond()),
143-
new Tuple2<>(15, ZonedDateTime.now().plusMinutes(2).toInstant().getEpochSecond())
142+
new Tuple2<>(16, ZonedDateTime.now().plusMinutes(25).toInstant().getEpochSecond()),
143+
new Tuple2<>(15, ZonedDateTime.now().plusMinutes(2).toInstant().getEpochSecond())
144144
).assignTimestampsAndWatermarks(new BoundedOutOfOrdernessTimestampExtractor<Tuple2<Integer, Long>>(Time.seconds(20)) {
145145
@Override
146146
public long extractTimestamp(Tuple2<Integer, Long> element) {
@@ -149,8 +149,8 @@ public long extractTimestamp(Tuple2<Integer, Long> element) {
149149
});
150150

151151
SingleOutputStreamOperator<Tuple2<Integer, Long>> reduced = windowed
152-
.windowAll(TumblingEventTimeWindows.of(Time.seconds(5)))
153-
.maxBy(0, true);
152+
.windowAll(TumblingEventTimeWindows.of(Time.seconds(5)))
153+
.maxBy(0, true);
154154

155155
reduced.print();
156156

0 commit comments

Comments
 (0)