New AssertThatInvertedBooleanCondition inspection that will remove inverted boolean expressions inside assertThat().
Renamed a few inspections to better/shorter names (and fixed file and directory names accordingly).
This commit is contained in:
+2
-2
@@ -1,8 +1,8 @@
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class BooleanIsTrueOrFalse {
|
||||
public class BooleanCondition {
|
||||
|
||||
private void booleanIsTrueOrFalse() {
|
||||
private void booleanCondition() {
|
||||
boolean primitive = false;
|
||||
Boolean object = Boolean.TRUE;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class BooleanIsTrueOrFalse {
|
||||
public class BooleanCondition {
|
||||
|
||||
private void booleanIsTrueOrFalse() {
|
||||
private void booleanCondition() {
|
||||
boolean primitive = false;
|
||||
Boolean object = Boolean.TRUE;
|
||||
|
||||
+2
-2
@@ -3,9 +3,9 @@ import com.google.common.base.Optional;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.guava.api.Assertions.assertThat;
|
||||
|
||||
public class AssertThatGuavaOptional {
|
||||
public class GuavaOptional {
|
||||
|
||||
private void assertThatGuavaOptional() {
|
||||
private void guavaOptional() {
|
||||
Optional<String> opt = Optional.absent();
|
||||
|
||||
assertThat(opt).isPresent();
|
||||
+2
-2
@@ -3,9 +3,9 @@ import com.google.common.base.Optional;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.guava.api.Assertions.assertThat;
|
||||
|
||||
public class AssertThatGuavaOptional {
|
||||
public class GuavaOptional {
|
||||
|
||||
private void assertThatGuavaOptional() {
|
||||
private void guavaOptional() {
|
||||
Optional<String> opt = Optional.absent();
|
||||
|
||||
assertThat(opt.isPresent()).isEqualTo(true);
|
||||
+2
-2
@@ -3,9 +3,9 @@ import com.google.common.base.Optional;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.guava.api.Assertions.assertThat;
|
||||
|
||||
public class AssertThatGuavaOptional {
|
||||
public class GuavaOptional {
|
||||
|
||||
private void assertThatGuavaOptional() {
|
||||
private void guavaOptional() {
|
||||
Optional<String> opt = Optional.absent();
|
||||
|
||||
assertThat(opt).contains("foo");
|
||||
+2
-2
@@ -2,9 +2,9 @@ import com.google.common.base.Optional;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class AssertThatGuavaOptional {
|
||||
public class GuavaOptional {
|
||||
|
||||
private void assertThatGuavaOptional() {
|
||||
private void guavaOptional() {
|
||||
Optional<String> opt = Optional.absent();
|
||||
|
||||
assertThat(opt).isEqualTo(Optional.of("foo"));
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class InvertedBooleanCondition {
|
||||
|
||||
private void invertedBooleanCondition() {
|
||||
boolean primitive = false;
|
||||
Boolean object = Boolean.TRUE;
|
||||
|
||||
assertThat(primitive).isFalse();
|
||||
assertThat(primitive).isFalse();
|
||||
assertThat(primitive).isFalse();
|
||||
assertThat(primitive).isFalse();
|
||||
assertThat(primitive).isFalse();
|
||||
assertThat(object).isFalse();
|
||||
assertThat(object).isFalse();
|
||||
assertThat(object).isFalse();
|
||||
assertThat(object).isFalse();
|
||||
assertThat(object).isFalse();
|
||||
|
||||
assertThat(primitive).isTrue();
|
||||
assertThat(primitive).isTrue();
|
||||
assertThat(primitive).isTrue();
|
||||
assertThat(primitive).isTrue();
|
||||
assertThat(primitive).isTrue();
|
||||
assertThat(object).isTrue();
|
||||
assertThat(object).isTrue();
|
||||
assertThat(object).isTrue();
|
||||
assertThat(object).isTrue();
|
||||
assertThat(object).isTrue();
|
||||
|
||||
assertThat(!((primitive))).as("nah").isTrue();
|
||||
assertThat(!object).isEqualTo(Boolean.TRUE && !Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class InvertedBooleanCondition {
|
||||
|
||||
private void invertedBooleanCondition() {
|
||||
boolean primitive = false;
|
||||
Boolean object = Boolean.TRUE;
|
||||
|
||||
assertThat(!primitive).isEqualTo(Boolean.TRUE);
|
||||
assertThat(!primitive).isEqualTo(true);
|
||||
assertThat(!primitive).isNotEqualTo(Boolean.FALSE);
|
||||
assertThat(!primitive).isNotEqualTo(false);
|
||||
assertThat(!primitive).isTrue();
|
||||
assertThat(!object).isEqualTo(Boolean.TRUE);
|
||||
assertThat(!object).isEqualTo(true);
|
||||
assertThat(!object).isNotEqualTo(Boolean.FALSE);
|
||||
assertThat(!object).isNotEqualTo(false);
|
||||
assertThat(!object).isTrue();
|
||||
|
||||
assertThat(!primitive).isEqualTo(Boolean.FALSE);
|
||||
assertThat(!primitive).isEqualTo(false);
|
||||
assertThat(!primitive).isNotEqualTo(Boolean.TRUE);
|
||||
assertThat(!primitive).isNotEqualTo(true);
|
||||
assertThat(!primitive).isFalse();
|
||||
assertThat(!object).isEqualTo(Boolean.FALSE);
|
||||
assertThat(!object).isEqualTo(false);
|
||||
assertThat(!object).isNotEqualTo(Boolean.TRUE);
|
||||
assertThat(!object).isNotEqualTo(true);
|
||||
assertThat(!object).isFalse();
|
||||
|
||||
assertThat(!(((!((primitive)))))).as("nah").isEqualTo(true && !true);
|
||||
assertThat(!object).isEqualTo(Boolean.TRUE && !Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -2,9 +2,9 @@ import java.util.Optional;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class AssertThatJava8Optional {
|
||||
public class Java8Optional {
|
||||
|
||||
private void assertThatJava8Optional() {
|
||||
private void java8Optional() {
|
||||
Optional<String> opt = Optional.empty();
|
||||
|
||||
assertThat(opt).isPresent();
|
||||
+2
-2
@@ -2,9 +2,9 @@ import java.util.Optional;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class AssertThatJava8Optional {
|
||||
public class Java8Optional {
|
||||
|
||||
private void assertThatJava8Optional() {
|
||||
private void java8Optional() {
|
||||
Optional<String> opt = Optional.empty();
|
||||
|
||||
assertThat(opt.isPresent()).isEqualTo(true);
|
||||
+2
-2
@@ -2,9 +2,9 @@ import java.util.ArrayList;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class AssertThatSize {
|
||||
public class Size {
|
||||
|
||||
private void assertThatSize() {
|
||||
private void size() {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
ArrayList<String> otherList = new ArrayList<>();
|
||||
long[] array = new long[5];
|
||||
+2
-2
@@ -2,9 +2,9 @@ import java.util.ArrayList;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class AssertThatSize {
|
||||
public class Size {
|
||||
|
||||
private void assertThatSize() {
|
||||
private void size() {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
ArrayList<String> otherList = new ArrayList<>();
|
||||
long[] array = new long[5];
|
||||
Reference in New Issue
Block a user