Skip to content

Commit 8495699

Browse files
authored
Build optimization (eugenp#2253)
1 parent e5abeb4 commit 8495699

19 files changed

Lines changed: 178 additions & 170 deletions

‎libraries/src/test/java/com/baeldung/awaitility/AsyncServiceUnitTest.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import org.awaitility.Awaitility;
44
import org.awaitility.Duration;
55
import org.junit.Before;
6-
import org.junit.BeforeClass;
76
import org.junit.Test;
87

98
import java.util.concurrent.Callable;

‎libraries/src/test/java/com/baeldung/cglib/proxy/BeanGeneratorIntegrationTest.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ public void givenBeanCreator_whenAddProperty_thenClassShouldHaveFieldValue() thr
1919
beanGenerator.addProperty("name", String.class);
2020
Object myBean = beanGenerator.create();
2121
Method setter = myBean
22-
.getClass()
23-
.getMethod("setName", String.class);
22+
.getClass()
23+
.getMethod("setName", String.class);
2424
setter.invoke(myBean, "some string value set by a cglib");
2525

2626
//then
2727
Method getter = myBean
28-
.getClass()
29-
.getMethod("getName");
28+
.getClass()
29+
.getMethod("getName");
3030
assertEquals("some string value set by a cglib", getter.invoke(myBean));
3131
}
3232
}

‎libraries/src/test/java/com/baeldung/cglib/proxy/MixinUnitTest.java‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package com.baeldung.cglib.proxy;
22

3-
import com.baeldung.cglib.mixin.*;
3+
import com.baeldung.cglib.mixin.Class1;
4+
import com.baeldung.cglib.mixin.Class2;
5+
import com.baeldung.cglib.mixin.Interface1;
6+
import com.baeldung.cglib.mixin.Interface2;
7+
import com.baeldung.cglib.mixin.MixinInterface;
48
import net.sf.cglib.proxy.Mixin;
59
import org.junit.Test;
610

@@ -12,8 +16,8 @@ public class MixinUnitTest {
1216
public void givenTwoClasses_whenMixedIntoOne_thenMixinShouldHaveMethodsFromBothClasses() throws Exception {
1317
//when
1418
Mixin mixin = Mixin.create(
15-
new Class[]{Interface1.class, Interface2.class, MixinInterface.class},
16-
new Object[]{new Class1(), new Class2()}
19+
new Class[]{Interface1.class, Interface2.class, MixinInterface.class},
20+
new Object[]{new Class1(), new Class2()}
1721
);
1822
MixinInterface mixinDelegate = (MixinInterface) mixin;
1923

‎libraries/src/test/java/com/baeldung/commons/collections/BidiMapUnitTest.java‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22

33
import org.apache.commons.collections4.BidiMap;
44
import org.apache.commons.collections4.bidimap.DualHashBidiMap;
5-
import org.apache.commons.collections4.bidimap.DualLinkedHashBidiMap;
6-
import org.apache.commons.collections4.bidimap.DualTreeBidiMap;
7-
import org.apache.commons.collections4.bidimap.TreeBidiMap;
85
import org.junit.Test;
96

10-
import static org.junit.Assert.*;
7+
import static org.junit.Assert.assertEquals;
8+
import static org.junit.Assert.assertFalse;
9+
import static org.junit.Assert.assertTrue;
1110

12-
/**
13-
* Created by smatt on 03/07/2017.
14-
*/
1511
public class BidiMapUnitTest {
1612

1713
@Test

‎libraries/src/test/java/com/baeldung/commons/collections/CollectionUtilsGuideTest.java‎

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33

44
import com.baeldung.commons.collectionutil.Address;
55
import com.baeldung.commons.collectionutil.Customer;
6-
import org.apache.commons.collections4.Closure;
76
import org.apache.commons.collections4.CollectionUtils;
87
import org.apache.commons.collections4.Predicate;
98
import org.apache.commons.collections4.Transformer;
109
import org.junit.Before;
1110
import org.junit.Test;
1211

13-
import java.util.*;
12+
import java.util.ArrayList;
13+
import java.util.Arrays;
14+
import java.util.Collection;
15+
import java.util.LinkedList;
16+
import java.util.List;
1417

1518
import static org.junit.Assert.assertEquals;
1619
import static org.junit.Assert.assertFalse;
@@ -36,13 +39,13 @@ public void setup() {
3639

3740
linkedList1 = new LinkedList<>(list1);
3841
}
39-
42+
4043
@Test
4144
public void givenList_whenAddIgnoreNull_thenNoNullAdded() {
4245
CollectionUtils.addIgnoreNull(list1, null);
4346
assertFalse(list1.contains(null));
4447
}
45-
48+
4649
@Test
4750
public void givenTwoSortedLists_whenCollated_thenSorted() {
4851
List<Customer> sortedList = CollectionUtils.collate(list1, list2);
@@ -51,69 +54,69 @@ public void givenTwoSortedLists_whenCollated_thenSorted() {
5154
assertTrue(sortedList.get(0).getName().equals("Bob"));
5255
assertTrue(sortedList.get(2).getName().equals("Daniel"));
5356
}
54-
57+
5558
@Test
5659
public void givenListOfCustomers_whenTransformed_thenListOfAddress() {
5760
Collection<Address> addressCol = CollectionUtils.collect(list1, new Transformer<Customer, Address>() {
5861
public Address transform(Customer customer) {
5962
return new Address(customer.getLocality(), customer.getCity(), customer.getZip());
6063
}
6164
});
62-
65+
6366
List<Address> addressList = new ArrayList<>(addressCol);
6467
assertTrue(addressList.size() == 3);
6568
assertTrue(addressList.get(0).getLocality().equals("locality1"));
6669
}
67-
70+
6871
@Test
6972
public void givenCustomerList_whenFiltered_thenCorrectSize() {
7073

7174
boolean isModified = CollectionUtils.filter(linkedList1, new Predicate<Customer>() {
7275
public boolean evaluate(Customer customer) {
73-
return Arrays.asList("Daniel","Kyle").contains(customer.getName());
76+
return Arrays.asList("Daniel", "Kyle").contains(customer.getName());
7477
}
7578
});
7679

7780
//filterInverse does the opposite. It removes the element from the list if the Predicate returns true
7881
//select and selectRejected work the same way except that they do not remove elements from the given collection and return a new collection
79-
82+
8083
assertTrue(isModified && linkedList1.size() == 2);
8184
}
82-
85+
8386
@Test
8487
public void givenNonEmptyList_whenCheckedIsNotEmpty_thenTrue() {
8588
List<Customer> emptyList = new ArrayList<>();
8689
List<Customer> nullList = null;
87-
90+
8891
//Very handy at times where we want to check if a collection is not null and not empty too.
8992
//isNotEmpty does the opposite. Handy because using ! operator on isEmpty makes it missable while reading
9093
assertTrue(CollectionUtils.isNotEmpty(list1));
9194
assertTrue(CollectionUtils.isEmpty(nullList));
9295
assertTrue(CollectionUtils.isEmpty(emptyList));
9396
}
94-
97+
9598
@Test
9699
public void givenCustomerListAndASubcollection_whenChecked_thenTrue() {
97100
assertTrue(CollectionUtils.isSubCollection(list3, list1));
98101
}
99-
102+
100103
@Test
101104
public void givenTwoLists_whenIntersected_thenCheckSize() {
102105
Collection<Customer> intersection = CollectionUtils.intersection(list1, list3);
103106
assertTrue(intersection.size() == 2);
104107
}
105-
108+
106109
@Test
107110
public void givenTwoLists_whenSubtracted_thenCheckElementNotPresentInA() {
108111
Collection<Customer> result = CollectionUtils.subtract(list1, list3);
109112
assertFalse(result.contains(customer1));
110113
}
111-
114+
112115
@Test
113116
public void givenTwoLists_whenUnioned_thenCheckElementPresentInResult() {
114117
Collection<Customer> union = CollectionUtils.union(list1, list2);
115118
assertTrue(union.contains(customer1));
116119
assertTrue(union.contains(customer4));
117120
}
118-
121+
119122
}

‎libraries/src/test/java/com/baeldung/commons/collections/MapUtilsTest.java‎

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,35 @@
1616
import static org.hamcrest.collection.IsMapContaining.hasEntry;
1717
import static org.hamcrest.collection.IsMapWithSize.aMapWithSize;
1818
import static org.hamcrest.collection.IsMapWithSize.anEmptyMap;
19-
import static org.junit.Assert.*;
19+
import static org.junit.Assert.assertEquals;
20+
import static org.junit.Assert.assertThat;
21+
import static org.junit.Assert.assertTrue;
2022

2123
public class MapUtilsTest {
2224

23-
private String[][] color2DArray = new String[][] {
24-
{"RED", "#FF0000"},
25-
{"GREEN", "#00FF00"},
26-
{"BLUE", "#0000FF"}
25+
private String[][] color2DArray = new String[][]{
26+
{"RED", "#FF0000"},
27+
{"GREEN", "#00FF00"},
28+
{"BLUE", "#0000FF"}
2729
};
28-
private String[] color1DArray = new String[] {
29-
"RED", "#FF0000",
30-
"GREEN", "#00FF00",
31-
"BLUE", "#0000FF"
30+
private String[] color1DArray = new String[]{
31+
"RED", "#FF0000",
32+
"GREEN", "#00FF00",
33+
"BLUE", "#0000FF"
3234
};
3335
private Map<String, String> colorMap;
34-
36+
3537
@Before
3638
public void createMap() {
3739
this.colorMap = MapUtils.putAll(new HashMap<String, String>(), this.color2DArray);
3840
}
39-
41+
4042
@Test
4143
public void whenCreateMapFrom2DArray_theMapIsCreated() {
4244
this.colorMap = MapUtils.putAll(new HashMap<String, String>(), this.color2DArray);
4345

4446
assertThat(this.colorMap, is(aMapWithSize(this.color2DArray.length)));
45-
47+
4648
assertThat(this.colorMap, hasEntry("RED", "#FF0000"));
4749
assertThat(this.colorMap, hasEntry("GREEN", "#00FF00"));
4850
assertThat(this.colorMap, hasEntry("BLUE", "#0000FF"));
@@ -51,26 +53,26 @@ public void whenCreateMapFrom2DArray_theMapIsCreated() {
5153
@Test
5254
public void whenCreateMapFrom1DArray_theMapIsCreated() {
5355
this.colorMap = MapUtils.putAll(new HashMap<String, String>(), this.color1DArray);
54-
56+
5557
assertThat(this.colorMap, is(aMapWithSize(this.color1DArray.length / 2)));
5658

5759
assertThat(this.colorMap, hasEntry("RED", "#FF0000"));
5860
assertThat(this.colorMap, hasEntry("GREEN", "#00FF00"));
5961
assertThat(this.colorMap, hasEntry("BLUE", "#0000FF"));
6062
}
61-
63+
6264
@Test
6365
public void whenVerbosePrintMap_thenMustPrintFormattedMap() {
6466
ByteArrayOutputStream out = new ByteArrayOutputStream();
6567
PrintStream outPrint = new PrintStream(out);
66-
68+
6769
outPrint.println("Optional Label = ");
6870
outPrint.println("{");
6971
outPrint.println(" RED = #FF0000");
7072
outPrint.println(" BLUE = #0000FF");
7173
outPrint.println(" GREEN = #00FF00");
7274
outPrint.println("}");
73-
75+
7476
out.reset();
7577

7678
MapUtils.verbosePrint(outPrint, "Optional Label", this.colorMap);
@@ -80,65 +82,65 @@ public void whenVerbosePrintMap_thenMustPrintFormattedMap() {
8082
public void whenGetKeyNotPresent_thenMustReturnDefaultValue() {
8183
String defaultColorStr = "COLOR_NOT_FOUND";
8284
String color = MapUtils.getString(this.colorMap, "BLACK", defaultColorStr);
83-
85+
8486
assertEquals(color, defaultColorStr);
8587
}
86-
88+
8789
@Test
8890
public void whenGetOnNullMap_thenMustReturnDefaultValue() {
8991
String defaultColorStr = "COLOR_NOT_FOUND";
9092
String color = MapUtils.getString(null, "RED", defaultColorStr);
91-
93+
9294
assertEquals(color, defaultColorStr);
9395
}
9496

9597
@Test
9698
public void whenInvertMap_thenMustReturnInvertedMap() {
9799
Map<String, String> invColorMap = MapUtils.invertMap(this.colorMap);
98100
assertEquals(this.colorMap.size(), invColorMap.size());
99-
100-
MapIterator<String, String> itColorMap
101+
102+
MapIterator<String, String> itColorMap
101103
= MapUtils.iterableMap(this.colorMap).mapIterator();
102-
104+
103105
while (itColorMap.hasNext()) {
104106
String colorMapKey = itColorMap.next();
105107
String colorMapValue = itColorMap.getValue();
106108

107109
String invColorMapValue = MapUtils.getString(invColorMap, colorMapValue);
108-
110+
109111
assertTrue(invColorMapValue.equals(colorMapKey));
110112
}
111113
}
112-
114+
113115
@Test(expected = IllegalArgumentException.class)
114116
public void whenCreateFixedSizedMapAndAdd_thenMustThrowException() {
115117
Map<String, String> rgbMap = MapUtils.fixedSizeMap(MapUtils.putAll(
116-
new HashMap<String, String>(),
117-
this.color1DArray));
118-
118+
new HashMap<String, String>(),
119+
this.color1DArray));
120+
119121
rgbMap.put("ORANGE", "#FFA500");
120122
}
121-
123+
122124
@Test(expected = IllegalArgumentException.class)
123125
public void whenAddDuplicateToUniqueValuesPredicateMap_thenMustThrowException() {
124-
Map<String, String> uniqValuesMap
126+
Map<String, String> uniqValuesMap
125127
= MapUtils.predicatedMap(this.colorMap, null, PredicateUtils.uniquePredicate());
126-
128+
127129
uniqValuesMap.put("NEW_RED", "#FF0000");
128130
}
129131

130132
@Test
131133
public void whenCreateLazyMap_theMapIsCreated() {
132134
Map<Integer, String> intStrMap = MapUtils.lazyMap(
133-
new HashMap<Integer, String>(),
134-
TransformerUtils.stringValueTransformer());
135-
135+
new HashMap<Integer, String>(),
136+
TransformerUtils.stringValueTransformer());
137+
136138
assertThat(intStrMap, is(anEmptyMap()));
137-
139+
138140
intStrMap.get(1);
139141
intStrMap.get(2);
140142
intStrMap.get(3);
141-
143+
142144
assertThat(intStrMap, is(aMapWithSize(3)));
143145
}
144146
}

0 commit comments

Comments
 (0)