diff --git a/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithLongLengthAndLob.java b/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithLongLengthAndLob.java new file mode 100644 index 0000000..652ba40 --- /dev/null +++ b/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithLongLengthAndLob.java @@ -0,0 +1,14 @@ +package jp.co.worksap.oss.findbugs.jpa; + +import javax.persistence.Column; +import javax.persistence.Lob; + +public class GetterWithLongLengthAndLob { + private String name; + + @Lob + @Column(length = 10000) + public String getName() { + return name; + } +} diff --git a/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithTooLongLength.java b/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithTooLongLength.java new file mode 100644 index 0000000..6b54cbc --- /dev/null +++ b/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithTooLongLength.java @@ -0,0 +1,12 @@ +package jp.co.worksap.oss.findbugs.jpa; + +import javax.persistence.Column; + +public class GetterWithTooLongLength { + private String name; + + @Column(length = 10000) + public String getName() { + return name; + } +} diff --git a/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithoutElement.java b/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithoutElement.java new file mode 100644 index 0000000..d175307 --- /dev/null +++ b/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithoutElement.java @@ -0,0 +1,12 @@ +package jp.co.worksap.oss.findbugs.jpa; + +import javax.persistence.Column; + +public class GetterWithoutElement { + private String name; + + @Column + public String getName() { + return name; + } +} diff --git a/src/test/java/jp/co/worksap/oss/findbugs/jpa/ImplicitLengthTest.java b/src/test/java/jp/co/worksap/oss/findbugs/jpa/ImplicitLengthTest.java index 8a3b9ef..7a01985 100644 --- a/src/test/java/jp/co/worksap/oss/findbugs/jpa/ImplicitLengthTest.java +++ b/src/test/java/jp/co/worksap/oss/findbugs/jpa/ImplicitLengthTest.java @@ -30,12 +30,16 @@ public void testNegativeLength() throws Exception { public void testTooLongLength() throws Exception { assertBugReported(ColumnWithTooLongLength.class, detector, bugReporter, ofType("ILLEGAL_LENGTH")); + assertBugReported(GetterWithTooLongLength.class, detector, + bugReporter, ofType("ILLEGAL_LENGTH")); } @Test public void testLongLengthWithLob() throws Exception { assertNoBugsReported(ColumnWithLongLengthAndLob.class, detector, bugReporter); + assertNoBugsReported(GetterWithLongLengthAndLob.class, detector, + bugReporter); } @Test @@ -48,5 +52,7 @@ public void testExplicitLength() throws Exception { public void testImplicitLength() throws Exception { assertBugReported(ColumnWithoutElement.class, detector, bugReporter, ofType("IMPLICIT_LENGTH")); + assertBugReported(GetterWithoutElement.class, detector, + bugReporter, ofType("IMPLICIT_LENGTH")); } } diff --git a/src/test/java/jp/co/worksap/oss/findbugs/jpa/ImplicitNullnessTest.java b/src/test/java/jp/co/worksap/oss/findbugs/jpa/ImplicitNullnessTest.java index 1038896..109b92c 100644 --- a/src/test/java/jp/co/worksap/oss/findbugs/jpa/ImplicitNullnessTest.java +++ b/src/test/java/jp/co/worksap/oss/findbugs/jpa/ImplicitNullnessTest.java @@ -29,5 +29,7 @@ public void testExplicitNullness() throws Exception { public void testImplicitNullness() throws Exception { assertBugReported(ColumnWithoutElement.class, detector, bugReporter); + assertBugReported(GetterWithoutElement.class, detector, + bugReporter); } } diff --git a/src/test/java/jp/co/worksap/oss/findbugs/jpa/NullableBooleanGetter.java b/src/test/java/jp/co/worksap/oss/findbugs/jpa/NullableBooleanGetter.java new file mode 100644 index 0000000..5b2f52b --- /dev/null +++ b/src/test/java/jp/co/worksap/oss/findbugs/jpa/NullableBooleanGetter.java @@ -0,0 +1,14 @@ +package jp.co.worksap.oss.findbugs.jpa; + +import javax.persistence.Column; +import javax.persistence.Entity; + +@Entity +public class NullableBooleanGetter { + private boolean booleanValue; + + @Column(nullable = true) + public boolean isBooleanValue() { + return booleanValue; + } +} diff --git a/src/test/java/jp/co/worksap/oss/findbugs/jpa/NullablePrimitiveDetectorTest.java b/src/test/java/jp/co/worksap/oss/findbugs/jpa/NullablePrimitiveDetectorTest.java index 1f9c8dc..46c33a9 100644 --- a/src/test/java/jp/co/worksap/oss/findbugs/jpa/NullablePrimitiveDetectorTest.java +++ b/src/test/java/jp/co/worksap/oss/findbugs/jpa/NullablePrimitiveDetectorTest.java @@ -23,10 +23,11 @@ public void before() { @Test public void testNullableObject() throws Exception { assertNoBugsReported(UseColumnDefinition.class, detector, bugReporter); + assertNoBugsReported(ColumnWithoutElement.class, detector, bugReporter); } @Test - public void testNullableInt() throws Exception { + public void testNullablePrimitive() throws Exception { assertBugReported(NullableBooleanColumn.class, detector, bugReporter, ofType("NULLABLE_PRIMITIVE")); assertBugReported(NullableByteColumn.class, detector, @@ -41,6 +42,8 @@ public void testNullableInt() throws Exception { bugReporter, ofType("NULLABLE_PRIMITIVE")); assertBugReported(NullableDoubleColumn.class, detector, bugReporter, ofType("NULLABLE_PRIMITIVE")); + assertBugReported(NullableBooleanGetter.class, detector, + bugReporter, ofType("NULLABLE_PRIMITIVE")); } @Test diff --git a/src/test/java/jp/co/worksap/oss/findbugs/jsr305/MutableClass.java b/src/test/java/jp/co/worksap/oss/findbugs/jsr305/MutableClass.java index 73a1bcf..89d580d 100755 --- a/src/test/java/jp/co/worksap/oss/findbugs/jsr305/MutableClass.java +++ b/src/test/java/jp/co/worksap/oss/findbugs/jsr305/MutableClass.java @@ -1,7 +1,9 @@ package jp.co.worksap.oss.findbugs.jsr305; import javax.annotation.concurrent.Immutable; +import javax.annotation.concurrent.NotThreadSafe; +@NotThreadSafe @Immutable // marked as immutable, but field is not final public class MutableClass { public String value;