Skip to content

Commit 38dd5cd

Browse files
author
Suszyński Krzysztof
committed
More tests to fix #3
1 parent cfddc7c commit 38dd5cd

File tree

4 files changed

+288
-41
lines changed

4 files changed

+288
-41
lines changed

.travis.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
language: java
22
sudo: false
3-
script: mvn clean install -P '!sonar,ci' --fail-at-end
3+
script: mvn clean install --fail-at-end
44
notifications:
55
email:
66
on_failure: true
7-
jdk:
8-
- openjdk6
9-
- openjdk7
10-
- oraclejdk7
11-
- oraclejdk8
7+
matrix:
8+
include:
9+
- jdk: openjdk6
10+
env: JACOCO=true COVERALLS=true
11+
- jdk: openjdk7
12+
env: JACOCO=true COVERALLS=true
13+
- jdk: oraclejdk7
14+
env: JACOCO=true COVERALLS=true
15+
script: mvn clean install sonar:sonar --fail-at-end
16+
- jdk: oraclejdk8
17+
env: JACOCO=true COVERALLS=true
18+
- jdk: openjdk6
19+
env: JACOCO=false
20+
- jdk: openjdk7
21+
env: JACOCO=false
22+
- jdk: oraclejdk7
23+
env: JACOCO=false
24+
- jdk: oraclejdk8
25+
env: JACOCO=false

pom.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,12 @@
321321
<profiles>
322322
<profile>
323323
<id>ci</id>
324-
324+
<activation>
325+
<property>
326+
<name>env.JACOCO</name>
327+
<value>true</value>
328+
</property>
329+
</activation>
325330
<build>
326331
<plugins>
327332
<plugin>
@@ -400,10 +405,10 @@
400405
</profile>
401406

402407
<profile>
403-
<id>travis</id>
408+
<id>coveralls</id>
404409
<activation>
405410
<property>
406-
<name>env.TRAVIS</name>
411+
<name>env.COVERALLS</name>
407412
<value>true</value>
408413
</property>
409414
</activation>

src/main/java/pl/wavesoftware/eid/utils/EidPreconditions.java

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ protected EidPreconditions() {
122122
*/
123123
public static void checkArgument(final boolean expression, final String eid) {
124124
if (!expression) {
125-
throw new EidIllegalArgumentException(new Eid(eid));
125+
throw new EidIllegalArgumentException(ensureEid(eid));
126126
}
127127
}
128128

@@ -139,7 +139,7 @@ public static void checkArgument(final boolean expression, final String eid) {
139139
public static void checkArgument(final boolean expression, final String eid,
140140
final String messageFormat, final Object... parameters) {
141141
if (!expression) {
142-
throw new EidIllegalArgumentException(new Eid(eid), messageFormat, parameters);
142+
throw new EidIllegalArgumentException(ensureEid(eid), messageFormat, parameters);
143143
}
144144
}
145145

@@ -153,7 +153,7 @@ public static void checkArgument(final boolean expression, final String eid,
153153
*/
154154
public static void checkArgument(final boolean expression, final Eid eid) {
155155
if (!expression) {
156-
throw new EidIllegalArgumentException(eid);
156+
throw new EidIllegalArgumentException(ensureEid(eid));
157157
}
158158
}
159159

@@ -170,7 +170,7 @@ public static void checkArgument(final boolean expression, final Eid eid) {
170170
public static void checkArgument(final boolean expression, final Eid eid,
171171
final String messageFormat, final Object... parameters) {
172172
if (!expression) {
173-
throw new EidIllegalArgumentException(eid, messageFormat, parameters);
173+
throw new EidIllegalArgumentException(ensureEid(eid), messageFormat, parameters);
174174
}
175175
}
176176

@@ -185,7 +185,7 @@ public static void checkArgument(final boolean expression, final Eid eid,
185185
*/
186186
public static void checkState(final boolean expression, final String eid) {
187187
if (!expression) {
188-
throw new EidIllegalStateException(new Eid(eid));
188+
throw new EidIllegalStateException(ensureEid(eid));
189189
}
190190
}
191191

@@ -203,7 +203,7 @@ public static void checkState(final boolean expression, final String eid) {
203203
public static void checkState(final boolean expression, final String eid,
204204
final String messageFormat, final Object... parameters) {
205205
if (!expression) {
206-
throw new EidIllegalStateException(new Eid(eid), messageFormat, parameters);
206+
throw new EidIllegalStateException(ensureEid(eid), messageFormat, parameters);
207207
}
208208
}
209209

@@ -218,7 +218,7 @@ public static void checkState(final boolean expression, final String eid,
218218
*/
219219
public static void checkState(final Boolean expression, final Eid eid) {
220220
if (!expression) {
221-
throw new EidIllegalStateException(eid);
221+
throw new EidIllegalStateException(ensureEid(eid));
222222
}
223223
}
224224

@@ -236,7 +236,7 @@ public static void checkState(final Boolean expression, final Eid eid) {
236236
public static void checkState(final boolean expression, final Eid eid,
237237
final String messageFormat, final Object... parameters) {
238238
if (!expression) {
239-
throw new EidIllegalStateException(eid, messageFormat, parameters);
239+
throw new EidIllegalStateException(ensureEid(eid), messageFormat, parameters);
240240
}
241241
}
242242

@@ -252,7 +252,7 @@ public static void checkState(final boolean expression, final Eid eid,
252252
*/
253253
public static <T> T checkNotNull(@Nullable final T reference, final String eid) {
254254
if (reference == null) {
255-
throw new EidNullPointerException(new Eid(eid));
255+
throw new EidNullPointerException(ensureEid(eid));
256256
}
257257
return reference;
258258
}
@@ -272,7 +272,7 @@ public static <T> T checkNotNull(@Nullable final T reference, final String eid)
272272
public static <T> T checkNotNull(@Nullable final T reference, final String eid,
273273
final String messageFormat, final Object... parameters) {
274274
if (reference == null) {
275-
throw new EidNullPointerException(new Eid(eid), messageFormat, parameters);
275+
throw new EidNullPointerException(ensureEid(eid), messageFormat, parameters);
276276
}
277277
return reference;
278278
}
@@ -289,7 +289,7 @@ public static <T> T checkNotNull(@Nullable final T reference, final String eid,
289289
*/
290290
public static <T> T checkNotNull(@Nullable final T reference, final Eid eid) {
291291
if (reference == null) {
292-
throw new EidNullPointerException(eid);
292+
throw new EidNullPointerException(ensureEid(eid));
293293
}
294294
return reference;
295295
}
@@ -310,7 +310,7 @@ public static <T> T checkNotNull(@Nullable final T reference, final Eid eid) {
310310
public static <T> T checkNotNull(@Nullable final T reference, final Eid eid,
311311
final String messageFormat, final Object... parameters) {
312312
if (reference == null) {
313-
throw new EidNullPointerException(eid, messageFormat, parameters);
313+
throw new EidNullPointerException(ensureEid(eid), messageFormat, parameters);
314314
}
315315
return reference;
316316
}
@@ -328,10 +328,10 @@ public static <T> T checkNotNull(@Nullable final T reference, final Eid eid,
328328
*/
329329
public static int checkElementIndex(int index, int size, final String eid) {
330330
if (isSizeIllegal(size)) {
331-
throw new EidIllegalArgumentException(new Eid(eid));
331+
throw new EidIllegalArgumentException(ensureEid(eid));
332332
}
333333
if (isIndexAndSizeIllegal(index, size)) {
334-
throw new EidIndexOutOfBoundsException(new Eid(eid));
334+
throw new EidIndexOutOfBoundsException(ensureEid(eid));
335335
}
336336
return index;
337337
}
@@ -352,10 +352,10 @@ public static int checkElementIndex(int index, int size, final String eid) {
352352
public static int checkElementIndex(int index, int size, final String eid,
353353
final String messageFormat, final Object... parameters) {
354354
if (isSizeIllegal(size)) {
355-
throw new EidIllegalArgumentException(new Eid(eid), messageFormat, parameters);
355+
throw new EidIllegalArgumentException(ensureEid(eid), messageFormat, parameters);
356356
}
357357
if (isIndexAndSizeIllegal(index, size)) {
358-
throw new EidIndexOutOfBoundsException(new Eid(eid), messageFormat, parameters);
358+
throw new EidIndexOutOfBoundsException(ensureEid(eid), messageFormat, parameters);
359359
}
360360
return index;
361361
}
@@ -373,10 +373,10 @@ public static int checkElementIndex(int index, int size, final String eid,
373373
*/
374374
public static int checkElementIndex(int index, int size, final Eid eid) {
375375
if (isSizeIllegal(size)) {
376-
throw new EidIllegalArgumentException(eid);
376+
throw new EidIllegalArgumentException(ensureEid(eid));
377377
}
378378
if (isIndexAndSizeIllegal(index, size)) {
379-
throw new EidIndexOutOfBoundsException(eid);
379+
throw new EidIndexOutOfBoundsException(ensureEid(eid));
380380
}
381381
return index;
382382
}
@@ -397,10 +397,10 @@ public static int checkElementIndex(int index, int size, final Eid eid) {
397397
public static int checkElementIndex(int index, int size, final Eid eid, final String messageFormat,
398398
final Object... parameters) {
399399
if (isSizeIllegal(size)) {
400-
throw new EidIllegalArgumentException(eid, messageFormat, parameters);
400+
throw new EidIllegalArgumentException(ensureEid(eid), messageFormat, parameters);
401401
}
402402
if (isIndexAndSizeIllegal(index, size)) {
403-
throw new EidIndexOutOfBoundsException(eid, messageFormat, parameters);
403+
throw new EidIndexOutOfBoundsException(ensureEid(eid), messageFormat, parameters);
404404
}
405405
return index;
406406
}
@@ -427,7 +427,7 @@ public static <R> R tryToExecute(final UnsafeSupplier<R> supplier, final String
427427
try {
428428
return supplier.get();
429429
} catch (Exception throwable) {
430-
throw new EidRuntimeException(new Eid(eid), throwable);
430+
throw new EidRuntimeException(ensureEid(eid), throwable);
431431
}
432432
}
433433

@@ -443,7 +443,7 @@ public static void tryToExecute(final UnsafeProcedure procedure, final String ei
443443
try {
444444
procedure.execute();
445445
} catch (Exception throwable) {
446-
throw new EidRuntimeException(new Eid(eid), throwable);
446+
throw new EidRuntimeException(ensureEid(eid), throwable);
447447
}
448448
}
449449

@@ -473,7 +473,7 @@ public static <R> R tryToExecute(final UnsafeSupplier<R> supplier, final Eid eid
473473
try {
474474
return supplier.get();
475475
} catch (Exception throwable) {
476-
throw new EidRuntimeException(eid, throwable);
476+
throw new EidRuntimeException(ensureEid(eid), throwable);
477477
}
478478
}
479479

@@ -500,7 +500,7 @@ public static void tryToExecute(final UnsafeProcedure procedure, final Eid eid)
500500
try {
501501
procedure.execute();
502502
} catch (Exception throwable) {
503-
throw new EidRuntimeException(eid, throwable);
503+
throw new EidRuntimeException(ensureEid(eid), throwable);
504504
}
505505
}
506506

@@ -536,4 +536,18 @@ public interface UnsafeProcedure {
536536
*/
537537
void execute() throws Exception;
538538
}
539+
540+
private static Eid ensureEid(@Nullable Eid eid) {
541+
if (eid == null) {
542+
return new Eid("20160329:132823", "EID-NULL");
543+
}
544+
return eid;
545+
}
546+
547+
private static Eid ensureEid(@Nullable String eid) {
548+
if (eid == null) {
549+
return new Eid("20160329:133052", "EID-NULL");
550+
}
551+
return new Eid(eid);
552+
}
539553
}

0 commit comments

Comments
 (0)