Skip to content

Commit 69cd5e0

Browse files
author
eugenp
committed
minor cleanup work
1 parent 0f8a022 commit 69cd5e0

8 files changed

Lines changed: 359 additions & 379 deletions

‎jee7/pom.xml‎

Lines changed: 318 additions & 303 deletions
Large diffs are not rendered by default.

jee7/src/test/java/com/baeldung/timer/AutomaticTimerBeanTest.java renamed to jee7/src/test/java/com/baeldung/timer/AutomaticTimerBeanIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
@RunWith(Arquillian.class)
24-
public class AutomaticTimerBeanTest {
24+
public class AutomaticTimerBeanIntegrationTest {
2525

2626
//the @AutomaticTimerBean has a method called every 10 seconds
2727
//testing the difference ==> 100000

jee7/src/test/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBeanTest.java renamed to jee7/src/test/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBeanIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
@RunWith(Arquillian.class)
24-
public class ProgrammaticAtFixedRateTimerBeanTest {
24+
public class ProgrammaticAtFixedRateTimerBeanIntegrationTest {
2525

2626
final static long TIMEOUT = 1000;
2727
final static long TOLERANCE = 500l;

jee7/src/test/java/com/baeldung/timer/ProgrammaticTimerBeanTest.java renamed to jee7/src/test/java/com/baeldung/timer/ProgrammaticTimerBeanIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
@RunWith(Arquillian.class)
22-
public class ProgrammaticTimerBeanTest {
22+
public class ProgrammaticTimerBeanIntegrationTest {
2323

2424
final static long TIMEOUT = 5000l;
2525
final static long TOLERANCE = 1000l;

jee7/src/test/java/com/baeldung/timer/ProgrammaticWithFixedDelayTimerBeanTest.java renamed to jee7/src/test/java/com/baeldung/timer/ProgrammaticWithFixedDelayTimerBeanIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
@RunWith(Arquillian.class)
24-
public class ProgrammaticWithFixedDelayTimerBeanTest {
24+
public class ProgrammaticWithFixedDelayTimerBeanIntegrationTest {
2525

2626
final static long TIMEOUT = 15000l;
2727
final static long TOLERANCE = 1000l;

jee7/src/test/java/com/baeldung/timer/ScheduleTimerBeanTest.java renamed to jee7/src/test/java/com/baeldung/timer/ScheduleTimerBeanIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222

2323
@RunWith(Arquillian.class)
24-
public class ScheduleTimerBeanTest {
24+
public class ScheduleTimerBeanIntegrationTest {
2525

2626
final static long TIMEOUT = 5000l;
2727
final static long TOLERANCE = 1000l;

‎orika/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
1515
</properties>
1616

17-
<name>Orika</name>
17+
<name>orika</name>
1818

1919
<dependencies>
2020

‎orika/src/test/java/com/baeldung/orika/OrikaTest.java‎

Lines changed: 35 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@
44
import static org.junit.Assert.assertFalse;
55
import static org.junit.Assert.assertTrue;
66

7-
import java.text.DateFormat;
8-
import java.text.ParseException;
9-
import java.text.SimpleDateFormat;
107
import java.util.Arrays;
11-
import java.util.Date;
128
import java.util.HashMap;
139
import java.util.List;
1410
import java.util.Map;
1511

12+
import org.junit.Before;
13+
import org.junit.Test;
14+
1615
import ma.glasnost.orika.BoundMapperFacade;
1716
import ma.glasnost.orika.CustomMapper;
1817
import ma.glasnost.orika.MapperFacade;
1918
import ma.glasnost.orika.MapperFactory;
20-
import ma.glasnost.orika.MappingContext;
2119
import ma.glasnost.orika.impl.DefaultMapperFactory;
2220

23-
import org.junit.Before;
24-
import org.junit.Test;
25-
2621
public class OrikaTest {
22+
2723
MapperFactory mapperFactory;
24+
2825
CustomMapper<Personne3, Person3> customMapper;
26+
2927
// constant to help us cover time zone differences
3028
private final long GMT_DIFFERENCE = 46800000;
3129

30+
//
31+
3232
@Before
3333
public void before() {
3434
mapperFactory = new DefaultMapperFactory.Builder().build();
@@ -68,8 +68,7 @@ public void givenSrcAndDest_whenMapsByObject_thenCorrect() {
6868

6969
@Test
7070
public void givenSrcAndDest_whenMapsUsingBoundMapper_thenCorrect() {
71-
BoundMapperFacade<Source, Dest> boundMapper = mapperFactory
72-
.getMapperFacade(Source.class, Dest.class);
71+
BoundMapperFacade<Source, Dest> boundMapper = mapperFactory.getMapperFacade(Source.class, Dest.class);
7372
Source src = new Source("baeldung", 10);
7473
Dest dest = boundMapper.map(src);
7574
assertEquals(dest.getAge(), src.getAge());
@@ -78,8 +77,7 @@ public void givenSrcAndDest_whenMapsUsingBoundMapper_thenCorrect() {
7877

7978
@Test
8079
public void givenSrcAndDest_whenMapsUsingBoundMapperInReverse_thenCorrect() {
81-
BoundMapperFacade<Source, Dest> boundMapper = mapperFactory
82-
.getMapperFacade(Source.class, Dest.class);
80+
BoundMapperFacade<Source, Dest> boundMapper = mapperFactory.getMapperFacade(Source.class, Dest.class);
8381
Dest src = new Dest("baeldung", 10);
8482
Source dest = boundMapper.mapReverse(src);
8583
assertEquals(dest.getAge(), src.getAge());
@@ -88,8 +86,7 @@ public void givenSrcAndDest_whenMapsUsingBoundMapperInReverse_thenCorrect() {
8886

8987
@Test
9088
public void givenSrcAndDest_whenMapsUsingBoundMapperByObject_thenCorrect() {
91-
BoundMapperFacade<Source, Dest> boundMapper = mapperFactory
92-
.getMapperFacade(Source.class, Dest.class);
89+
BoundMapperFacade<Source, Dest> boundMapper = mapperFactory.getMapperFacade(Source.class, Dest.class);
9390
Source src = new Source("baeldung", 10);
9491
Dest dest = new Dest();
9592
boundMapper.map(src, dest);
@@ -99,8 +96,7 @@ public void givenSrcAndDest_whenMapsUsingBoundMapperByObject_thenCorrect() {
9996

10097
@Test
10198
public void givenSrcAndDest_whenMapsUsingBoundMapperByObjectInReverse_thenCorrect() {
102-
BoundMapperFacade<Source, Dest> boundMapper = mapperFactory
103-
.getMapperFacade(Source.class, Dest.class);
99+
BoundMapperFacade<Source, Dest> boundMapper = mapperFactory.getMapperFacade(Source.class, Dest.class);
104100
Dest src = new Dest("baeldung", 10);
105101
Source dest = new Source();
106102
boundMapper.mapReverse(src, dest);
@@ -110,9 +106,7 @@ public void givenSrcAndDest_whenMapsUsingBoundMapperByObjectInReverse_thenCorrec
110106

111107
@Test
112108
public void givenSrcAndDestWithDifferentFieldNames_whenMaps_thenCorrect() {
113-
mapperFactory.classMap(Personne.class, Person.class)
114-
.field("nom", "name").field("surnom", "nickname")
115-
.field("age", "age").register();
109+
mapperFactory.classMap(Personne.class, Person.class).field("nom", "name").field("surnom", "nickname").field("age", "age").register();
116110

117111
MapperFacade mapper = mapperFactory.getMapperFacade();
118112

@@ -127,8 +121,7 @@ public void givenSrcAndDestWithDifferentFieldNames_whenMaps_thenCorrect() {
127121

128122
@Test
129123
public void givenBothDifferentAndSameFieldNames_whenFailsToMapSameNameFieldAutomatically_thenCorrect() {
130-
mapperFactory.classMap(Personne.class, Person.class)
131-
.field("nom", "name").field("surnom", "nickname").register();
124+
mapperFactory.classMap(Personne.class, Person.class).field("nom", "name").field("surnom", "nickname").register();
132125
MapperFacade mapper = mapperFactory.getMapperFacade();
133126
Personne frenchPerson = new Personne("Claire", "cla", 25);
134127

@@ -139,9 +132,7 @@ public void givenBothDifferentAndSameFieldNames_whenFailsToMapSameNameFieldAutom
139132

140133
@Test
141134
public void givenBothDifferentAndSameFieldNames_whenMapsSameNameFieldByDefault_thenCorrect() {
142-
mapperFactory.classMap(Personne.class, Person.class)
143-
.field("nom", "name").field("surnom", "nickname").byDefault()
144-
.register();
135+
mapperFactory.classMap(Personne.class, Person.class).field("nom", "name").field("surnom", "nickname").byDefault().register();
145136

146137
MapperFacade mapper = mapperFactory.getMapperFacade();
147138
Personne frenchPerson = new Personne("Claire", "cla", 25);
@@ -155,9 +146,7 @@ public void givenBothDifferentAndSameFieldNames_whenMapsSameNameFieldByDefault_t
155146

156147
@Test
157148
public void givenUnidirectionalMappingSetup_whenMapsUnidirectionally_thenCorrect() {
158-
mapperFactory.classMap(Personne.class, Person.class)
159-
.fieldAToB("nom", "name").fieldAToB("surnom", "nickname")
160-
.fieldAToB("age", "age").register();
149+
mapperFactory.classMap(Personne.class, Person.class).fieldAToB("nom", "name").fieldAToB("surnom", "nickname").fieldAToB("age", "age").register();
161150
;
162151
MapperFacade mapper = mapperFactory.getMapperFacade();
163152
Personne frenchPerson = new Personne("Claire", "cla", 25);
@@ -169,11 +158,9 @@ public void givenUnidirectionalMappingSetup_whenMapsUnidirectionally_thenCorrect
169158

170159
}
171160

172-
173161
@Test
174162
public void givenSrcAndDest_whenCanExcludeField_thenCorrect() {
175-
mapperFactory.classMap(Personne.class, Person.class).exclude("nom")
176-
.field("surnom", "nickname").field("age", "age").register();
163+
mapperFactory.classMap(Personne.class, Person.class).exclude("nom").field("surnom", "nickname").field("age", "age").register();
177164
MapperFacade mapper = mapperFactory.getMapperFacade();
178165

179166
Personne frenchPerson = new Personne("Claire", "cla", 25);
@@ -186,9 +173,7 @@ public void givenSrcAndDest_whenCanExcludeField_thenCorrect() {
186173

187174
@Test
188175
public void givenSpecificConstructorToUse_whenMaps_thenCorrect() {
189-
mapperFactory.classMap(Personne.class, Person.class).constructorB()
190-
.field("nom", "name").field("surnom", "nickname")
191-
.field("age", "age").register();
176+
mapperFactory.classMap(Personne.class, Person.class).constructorB().field("nom", "name").field("surnom", "nickname").field("age", "age").register();
192177
;
193178
MapperFacade mapper = mapperFactory.getMapperFacade();
194179
Personne frenchPerson = new Personne("Claire", "cla", 25);
@@ -202,12 +187,9 @@ public void givenSpecificConstructorToUse_whenMaps_thenCorrect() {
202187

203188
@Test
204189
public void givenSrcWithListAndDestWithPrimitiveAttributes_whenMaps_thenCorrect() {
205-
mapperFactory.classMap(PersonNameList.class, PersonNameParts.class)
206-
.field("nameList[0]", "firstName")
207-
.field("nameList[1]", "lastName").register();
190+
mapperFactory.classMap(PersonNameList.class, PersonNameParts.class).field("nameList[0]", "firstName").field("nameList[1]", "lastName").register();
208191
MapperFacade mapper = mapperFactory.getMapperFacade();
209-
List<String> nameList = Arrays.asList(new String[]{"Sylvester",
210-
"Stallone"});
192+
List<String> nameList = Arrays.asList(new String[] { "Sylvester", "Stallone" });
211193
PersonNameList src = new PersonNameList(nameList);
212194
PersonNameParts dest = mapper.map(src, PersonNameParts.class);
213195
assertEquals(dest.getFirstName(), "Sylvester");
@@ -216,11 +198,9 @@ public void givenSrcWithListAndDestWithPrimitiveAttributes_whenMaps_thenCorrect(
216198

217199
@Test
218200
public void givenSrcWithArrayAndDestWithPrimitiveAttributes_whenMaps_thenCorrect() {
219-
mapperFactory.classMap(PersonNameArray.class, PersonNameParts.class)
220-
.field("nameArray[0]", "firstName")
221-
.field("nameArray[1]", "lastName").register();
201+
mapperFactory.classMap(PersonNameArray.class, PersonNameParts.class).field("nameArray[0]", "firstName").field("nameArray[1]", "lastName").register();
222202
MapperFacade mapper = mapperFactory.getMapperFacade();
223-
String[] nameArray = new String[]{"Vin", "Diesel"};
203+
String[] nameArray = new String[] { "Vin", "Diesel" };
224204
PersonNameArray src = new PersonNameArray(nameArray);
225205
PersonNameParts dest = mapper.map(src, PersonNameParts.class);
226206
assertEquals(dest.getFirstName(), "Vin");
@@ -229,9 +209,7 @@ public void givenSrcWithArrayAndDestWithPrimitiveAttributes_whenMaps_thenCorrect
229209

230210
@Test
231211
public void givenSrcWithMapAndDestWithPrimitiveAttributes_whenMaps_thenCorrect() {
232-
mapperFactory.classMap(PersonNameMap.class, PersonNameParts.class)
233-
.field("nameMap['first']", "firstName")
234-
.field("nameMap[\"last\"]", "lastName").register();
212+
mapperFactory.classMap(PersonNameMap.class, PersonNameParts.class).field("nameMap['first']", "firstName").field("nameMap[\"last\"]", "lastName").register();
235213
MapperFacade mapper = mapperFactory.getMapperFacade();
236214
Map<String, String> nameMap = new HashMap<>();
237215
nameMap.put("first", "Leornado");
@@ -244,9 +222,7 @@ public void givenSrcWithMapAndDestWithPrimitiveAttributes_whenMaps_thenCorrect()
244222

245223
@Test
246224
public void givenSrcWithNestedFields_whenMaps_thenCorrect() {
247-
mapperFactory.classMap(PersonContainer.class, PersonNameParts.class)
248-
.field("name.firstName", "firstName")
249-
.field("name.lastName", "lastName").register();
225+
mapperFactory.classMap(PersonContainer.class, PersonNameParts.class).field("name.firstName", "firstName").field("name.lastName", "lastName").register();
250226
MapperFacade mapper = mapperFactory.getMapperFacade();
251227
PersonContainer src = new PersonContainer(new Name("Nick", "Canon"));
252228
PersonNameParts dest = mapper.map(src, PersonNameParts.class);
@@ -266,8 +242,7 @@ public void givenSrcWithNullField_whenMapsThenCorrect() {
266242

267243
@Test
268244
public void givenSrcWithNullAndGlobalConfigForNoNull_whenFailsToMap_ThenCorrect() {
269-
MapperFactory mapperFactory = new DefaultMapperFactory.Builder()
270-
.mapNulls(false).build();
245+
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().mapNulls(false).build();
271246
mapperFactory.classMap(Source.class, Dest.class);
272247
MapperFacade mapper = mapperFactory.getMapperFacade();
273248
Source src = new Source(null, 10);
@@ -279,8 +254,7 @@ public void givenSrcWithNullAndGlobalConfigForNoNull_whenFailsToMap_ThenCorrect(
279254

280255
@Test
281256
public void givenSrcWithNullAndLocalConfigForNoNull_whenFailsToMap_ThenCorrect() {
282-
mapperFactory.classMap(Source.class, Dest.class).field("age", "age")
283-
.mapNulls(false).field("name", "name").byDefault().register();
257+
mapperFactory.classMap(Source.class, Dest.class).field("age", "age").mapNulls(false).field("name", "name").byDefault().register();
284258
MapperFacade mapper = mapperFactory.getMapperFacade();
285259
Source src = new Source(null, 10);
286260
Dest dest = new Dest("Clinton", 55);
@@ -302,9 +276,7 @@ public void givenDestWithNullReverseMappedToSource_whenMapsByDefault_thenCorrect
302276

303277
@Test
304278
public void givenDestWithNullReverseMappedToSourceAndLocalConfigForNoNull_whenFailsToMap_thenCorrect() {
305-
mapperFactory.classMap(Source.class, Dest.class).field("age", "age")
306-
.mapNullsInReverse(false).field("name", "name").byDefault()
307-
.register();
279+
mapperFactory.classMap(Source.class, Dest.class).field("age", "age").mapNullsInReverse(false).field("name", "name").byDefault().register();
308280
MapperFacade mapper = mapperFactory.getMapperFacade();
309281
Dest src = new Dest(null, 10);
310282
Source dest = new Source("Vin", 44);
@@ -315,9 +287,7 @@ public void givenDestWithNullReverseMappedToSourceAndLocalConfigForNoNull_whenFa
315287

316288
@Test
317289
public void givenSrcWithNullAndFieldLevelConfigForNoNull_whenFailsToMap_ThenCorrect() {
318-
mapperFactory.classMap(Source.class, Dest.class).field("age", "age")
319-
.fieldMap("name", "name").mapNulls(false).add().byDefault()
320-
.register();
290+
mapperFactory.classMap(Source.class, Dest.class).field("age", "age").fieldMap("name", "name").mapNulls(false).add().byDefault().register();
321291
MapperFacade mapper = mapperFactory.getMapperFacade();
322292
Source src = new Source(null, 10);
323293
Dest dest = new Dest("Clinton", 55);
@@ -328,8 +298,7 @@ public void givenSrcWithNullAndFieldLevelConfigForNoNull_whenFailsToMap_ThenCorr
328298

329299
@Test
330300
public void givenSrcAndDest_whenCustomMapperWorks_thenCorrect() {
331-
mapperFactory.classMap(Personne3.class, Person3.class)
332-
.customize(customMapper).register();
301+
mapperFactory.classMap(Personne3.class, Person3.class).customize(customMapper).register();
333302
MapperFacade mapper = mapperFactory.getMapperFacade();
334303
long timestamp = new Long("1182882159000");
335304
Personne3 personne3 = new Personne3("Leornardo", timestamp);
@@ -339,14 +308,12 @@ public void givenSrcAndDest_whenCustomMapperWorks_thenCorrect() {
339308
// since different timezones will resolve the timestamp to a different
340309
// datetime string, it suffices to check only for format rather than
341310
// specific date
342-
assertTrue(timestampTest.charAt(10) == 'T'
343-
&& timestampTest.charAt(19) == 'Z');
311+
assertTrue(timestampTest.charAt(10) == 'T' && timestampTest.charAt(19) == 'Z');
344312
}
345313

346314
@Test
347315
public void givenSrcAndDest_whenCustomMapperWorksBidirectionally_thenCorrect() {
348-
mapperFactory.classMap(Personne3.class, Person3.class)
349-
.customize(customMapper).register();
316+
mapperFactory.classMap(Personne3.class, Person3.class).customize(customMapper).register();
350317
MapperFacade mapper = mapperFactory.getMapperFacade();
351318

352319
String dateTime = "2007-06-26T21:22:39Z";
@@ -355,12 +322,10 @@ public void givenSrcAndDest_whenCustomMapperWorksBidirectionally_thenCorrect() {
355322
Personne3 personne3 = mapper.map(person3, Personne3.class);
356323
long timestampToTest = personne3.getDtob();
357324
/*
358-
* since different timezones will resolve the datetime to a different
359-
* unix timestamp, we must provide a range of tolerance
360-
*/
361-
assertTrue(timestampToTest == timestamp
362-
|| timestampToTest >= timestamp - GMT_DIFFERENCE
363-
|| timestampToTest <= timestamp + GMT_DIFFERENCE);
325+
* since different timezones will resolve the datetime to a different
326+
* unix timestamp, we must provide a range of tolerance
327+
*/
328+
assertTrue(timestampToTest == timestamp || timestampToTest >= timestamp - GMT_DIFFERENCE || timestampToTest <= timestamp + GMT_DIFFERENCE);
364329

365330
}
366331

0 commit comments

Comments
 (0)