Skip to content

Commit

Permalink
add tests case to improve coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
worksap-bot committed Mar 21, 2014
1 parent 50b9537 commit 9cd2a17
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ public void testExplicitNullness() throws Exception {
public void testImplicitNullness() throws Exception {
assertBugReported(ColumnWithoutElement.class, detector,
bugReporter);
assertBugReported(GetterWithoutElement.class, detector,
bugReporter);
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 9cd2a17

Please sign in to comment.