Skip to content

Commit ffbc04e

Browse files
committed
Removing not nessesary suppres warnings from production code
1 parent a2a3740 commit ffbc04e

File tree

8 files changed

+235
-6
lines changed

8 files changed

+235
-6
lines changed

src/main/java/pl/wavesoftware/eid/exceptions/EidContainer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
*
2121
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
2222
*/
23-
@SuppressWarnings("WeakerAccess")
2423
public interface EidContainer {
2524

2625
/**

src/main/java/pl/wavesoftware/eid/exceptions/EidIllegalArgumentException.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
* @see EidRuntimeException
2626
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
2727
*/
28-
@SuppressWarnings("unused")
2928
public class EidIllegalArgumentException extends EidRuntimeException {
3029

3130
private static final long serialVersionUID = -9876432123423427L;

src/main/java/pl/wavesoftware/eid/exceptions/EidIllegalStateException.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
* @see EidRuntimeException
2626
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
2727
*/
28-
@SuppressWarnings("unused")
2928
public class EidIllegalStateException extends EidRuntimeException {
3029

3130
private static final long serialVersionUID = -9876432123423443L;

src/main/java/pl/wavesoftware/eid/exceptions/EidIndexOutOfBoundsException.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
* @see EidRuntimeException
2626
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
2727
*/
28-
@SuppressWarnings("unused")
2928
public class EidIndexOutOfBoundsException extends EidRuntimeException {
3029

3130
private static final long serialVersionUID = -9876432123423451L;

src/main/java/pl/wavesoftware/eid/exceptions/EidNullPointerException.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
* @see EidRuntimeException
2626
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
2727
*/
28-
@SuppressWarnings("unused")
2928
public class EidNullPointerException extends EidRuntimeException {
3029

3130
private static final long serialVersionUID = -9876432123423469L;
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package pl.wavesoftware.eid.exceptions;
2+
3+
import org.hamcrest.CoreMatchers;
4+
import org.junit.After;
5+
import org.junit.Before;
6+
import org.junit.Rule;
7+
import org.junit.Test;
8+
import org.junit.rules.ExpectedException;
9+
10+
import static org.assertj.core.api.Assertions.assertThat;
11+
import static org.hamcrest.CoreMatchers.containsString;
12+
import static org.junit.internal.matchers.ThrowableMessageMatcher.hasMessage;
13+
14+
/**
15+
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
16+
* @since 2015-11-19
17+
*/
18+
public class EidIndexOutOfBoundsExceptionTest {
19+
20+
@Rule
21+
public ExpectedException thrown = ExpectedException.none();
22+
23+
private String constUniq = "deadfa11";
24+
private String causeString = "Index seams to be invalid";
25+
@SuppressWarnings("ThrowableInstanceNeverThrown")
26+
private Throwable cause = new ArrayIndexOutOfBoundsException(causeString);
27+
private Eid.UniqIdGenerator original;
28+
29+
@Before
30+
public void before() {
31+
original = Eid.setUniqIdGenerator(new Eid.UniqIdGenerator() {
32+
@Override
33+
public String generateUniqId() {
34+
return constUniq;
35+
}
36+
});
37+
}
38+
39+
@After
40+
public void after() {
41+
Eid.setUniqIdGenerator(original);
42+
}
43+
44+
@Test
45+
public void testGetStandardJdkClass() throws Exception {
46+
// given
47+
@SuppressWarnings("ThrowableInstanceNeverThrown")
48+
EidIndexOutOfBoundsException ex = new EidIndexOutOfBoundsException(new Eid("20151119:103152"));
49+
50+
// when
51+
Class<? extends RuntimeException> cls = ex.getStandardJdkClass();
52+
53+
// then
54+
assertThat(cls).isEqualTo(IndexOutOfBoundsException.class);
55+
}
56+
57+
@Test
58+
public void testEidIndexOutOfBoundsException_String_String_Throwable() {
59+
// given
60+
String eid = "20151119:103158";
61+
String ref = "MS+1233";
62+
63+
// then
64+
thrown.expectCause(hasMessage(containsString(causeString)));
65+
thrown.expectCause(CoreMatchers.<Throwable>instanceOf(ArrayIndexOutOfBoundsException.class));
66+
thrown.expect(EidIndexOutOfBoundsException.class);
67+
thrown.expectMessage("[20151119:103158|MS+1233]<deadfa11> => Index seams to be invalid");
68+
69+
// when
70+
throw new EidIndexOutOfBoundsException(eid, ref, cause);
71+
}
72+
73+
@Test
74+
public void testEidIndexOutOfBoundsException_String_String() {
75+
// given
76+
String eid = "20151119:103217";
77+
String ref = "MS+1233";
78+
79+
// then
80+
thrown.expect(EidIndexOutOfBoundsException.class);
81+
thrown.expectMessage("[20151119:103217|MS+1233]<deadfa11>");
82+
83+
// when
84+
throw new EidIndexOutOfBoundsException(eid, ref);
85+
}
86+
87+
@Test
88+
public void testEidIndexOutOfBoundsException_String_Throwable() {
89+
// given
90+
String eid = "20151119:103232";
91+
92+
// then
93+
thrown.expectCause(hasMessage(containsString(causeString)));
94+
thrown.expectCause(CoreMatchers.<Throwable>instanceOf(ArrayIndexOutOfBoundsException.class));
95+
thrown.expect(EidIndexOutOfBoundsException.class);
96+
thrown.expectMessage("[20151119:103232]<deadfa11> => Index seams to be invalid");
97+
98+
// when
99+
throw new EidIndexOutOfBoundsException(eid, cause);
100+
}
101+
102+
@Test
103+
public void testEidIndexOutOfBoundsException_Eid_Throwable() {
104+
// given
105+
String eidNum = "20151119:103245";
106+
Eid eid = new Eid(eidNum);
107+
108+
// then
109+
thrown.expectCause(hasMessage(containsString(causeString)));
110+
thrown.expectCause(CoreMatchers.<Throwable>instanceOf(ArrayIndexOutOfBoundsException.class));
111+
thrown.expect(EidIndexOutOfBoundsException.class);
112+
thrown.expectMessage("[20151119:103245]<deadfa11> => Index seams to be invalid");
113+
114+
// when
115+
throw new EidIndexOutOfBoundsException(eid, cause);
116+
}
117+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package pl.wavesoftware.eid.exceptions;
2+
3+
import org.hamcrest.CoreMatchers;
4+
import org.junit.After;
5+
import org.junit.Before;
6+
import org.junit.Rule;
7+
import org.junit.Test;
8+
import org.junit.rules.ExpectedException;
9+
10+
import static org.assertj.core.api.Assertions.assertThat;
11+
import static org.hamcrest.CoreMatchers.containsString;
12+
import static org.junit.internal.matchers.ThrowableMessageMatcher.hasMessage;
13+
14+
/**
15+
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
16+
* @since 2015-11-19
17+
*/
18+
public class EidNullPointerExceptionTest {
19+
20+
@Rule
21+
public ExpectedException thrown = ExpectedException.none();
22+
23+
private String constUniq = "cafedead";
24+
private String causeString = "A cause";
25+
@SuppressWarnings("ThrowableInstanceNeverThrown")
26+
private Throwable cause = new UnsupportedOperationException(causeString);
27+
private Eid.UniqIdGenerator original;
28+
29+
@Before
30+
public void before() {
31+
original = Eid.setUniqIdGenerator(new Eid.UniqIdGenerator() {
32+
@Override
33+
public String generateUniqId() {
34+
return constUniq;
35+
}
36+
});
37+
}
38+
39+
@After
40+
public void after() {
41+
Eid.setUniqIdGenerator(original);
42+
}
43+
44+
@Test
45+
public void testGetStandardJdkClass() throws Exception {
46+
// given
47+
@SuppressWarnings("ThrowableInstanceNeverThrown")
48+
EidNullPointerException ex = new EidNullPointerException(new Eid("20151119:102323"));
49+
50+
// when
51+
Class<? extends RuntimeException> cls = ex.getStandardJdkClass();
52+
53+
// then
54+
assertThat(cls).isEqualTo(NullPointerException.class);
55+
}
56+
57+
@Test
58+
public void testEidNullPointerException_String_String_Throwable() {
59+
// given
60+
String eid = "20151119:100854";
61+
String ref = "PL-9584";
62+
63+
// then
64+
thrown.expectCause(hasMessage(containsString(causeString)));
65+
thrown.expectCause(CoreMatchers.<Throwable>instanceOf(UnsupportedOperationException.class));
66+
thrown.expect(EidNullPointerException.class);
67+
thrown.expectMessage("[20151119:100854|PL-9584]<cafedead> => A cause");
68+
69+
// when
70+
throw new EidNullPointerException(eid, ref, cause);
71+
}
72+
73+
@Test
74+
public void testEidNullPointerException_String_String() {
75+
// given
76+
String eid = "20151119:100854";
77+
String ref = "PL-9584";
78+
79+
// then
80+
thrown.expect(EidNullPointerException.class);
81+
thrown.expectMessage("[20151119:100854|PL-9584]<cafedead>");
82+
83+
// when
84+
throw new EidNullPointerException(eid, ref);
85+
}
86+
87+
@Test
88+
public void testEidNullPointerException_String_Throwable() {
89+
// given
90+
String eid = "20151119:101810";
91+
92+
// then
93+
thrown.expectCause(hasMessage(containsString(causeString)));
94+
thrown.expectCause(CoreMatchers.<Throwable>instanceOf(UnsupportedOperationException.class));
95+
thrown.expect(EidNullPointerException.class);
96+
thrown.expectMessage("[20151119:101810]<cafedead> => A cause");
97+
98+
// when
99+
throw new EidNullPointerException(eid, cause);
100+
}
101+
102+
@Test
103+
public void testEidNullPointerException_Eid_Throwable() {
104+
// given
105+
String eidNum = "20151119:102150";
106+
Eid eid = new Eid(eidNum);
107+
108+
// then
109+
thrown.expectCause(hasMessage(containsString(causeString)));
110+
thrown.expectCause(CoreMatchers.<Throwable>instanceOf(UnsupportedOperationException.class));
111+
thrown.expect(EidNullPointerException.class);
112+
thrown.expectMessage("[20151119:102150]<cafedead> => A cause");
113+
114+
// when
115+
throw new EidNullPointerException(eid, cause);
116+
}
117+
}

src/test/java/pl/wavesoftware/eid/utils/EidPreconditionsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*
4343
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
4444
*/
45-
@SuppressWarnings({"ConstantConditions"})
45+
@SuppressWarnings("ConstantConditions")
4646
public class EidPreconditionsTest {
4747

4848
@Rule

0 commit comments

Comments
 (0)