Internally: Upgraded to AssertJ 13.2.2.
Support for hasSizeLessThan(), hasSizeLessThanOrEqualTo(), hasSizeGreaterThanOrEqualTo(), and hasSizeGreaterThan() for AssertThatSizeInspection (with AssertJ >=13.2.0). Really fixed highlighting for JUnit conversion. Sorry. Fixed testing code to work against IDEA 2019.1.
This commit is contained in:
@@ -131,7 +131,6 @@ public class LightCodeInsightExtension implements ParameterResolver, AfterTestEx
|
||||
VirtualFile jarFile = LocalFileSystem.getInstance().findFileByIoFile(jarPath.toFile());
|
||||
myFixture.allowTreeAccessForFile(jarFile);
|
||||
PsiTestUtil.addLibrary(
|
||||
myFixture.getModule(),
|
||||
model,
|
||||
jarPath.getFileName().toString().replace(".jar", ""),
|
||||
jarPath.getParent().toString(),
|
||||
|
||||
@@ -4,9 +4,11 @@ import org.assertj.core.api.ListAssert;
|
||||
import org.assertj.core.data.Offset;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
import static org.assertj.guava.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class Playground {
|
||||
@@ -27,6 +29,7 @@ public class Playground {
|
||||
assertThat(new ArrayList<String>().size()).isEqualTo(1);
|
||||
assertThat(new ArrayList<String>().size()).isGreaterThanOrEqualTo(1);
|
||||
assertThat(new ArrayList<String>().size()).isZero();
|
||||
assertThat(new ArrayList<String>()).hasSizeGreaterThan(1);
|
||||
assertThat(new ArrayList<String>()).hasSameSizeAs(new ArrayList<>());
|
||||
assertThat(new Long[1]).as("etc").hasSameSizeAs(new Long[2]);
|
||||
}
|
||||
@@ -75,6 +78,30 @@ public class Playground {
|
||||
assertThat(foo).hasSize(0);
|
||||
}
|
||||
|
||||
private void java8Optional() {
|
||||
Optional<String> foo = Optional.empty();
|
||||
assertThat(foo.get()).isEqualTo("bla");
|
||||
assertThat(foo).contains("bla");
|
||||
assertThat(foo.isPresent()).isTrue();
|
||||
assertThat(!foo.isPresent()).isFalse();
|
||||
assertThat(foo).isPresent();
|
||||
assertThat(foo.isPresent()).isFalse();
|
||||
assertThat(!foo.isPresent()).isTrue();
|
||||
assertThat(foo).isNotPresent();
|
||||
}
|
||||
|
||||
private void guavaOptional() {
|
||||
com.google.common.base.Optional<String> foo = com.google.common.base.Optional.absent();
|
||||
assertThat(foo.get()).isEqualTo("bla");
|
||||
assertThat(foo).contains("bla");
|
||||
assertThat(foo.isPresent()).isTrue();
|
||||
assertThat(!foo.isPresent()).isFalse();
|
||||
assertThat(foo).isPresent();
|
||||
assertThat(foo.isPresent()).isFalse();
|
||||
assertThat(!foo.isPresent()).isTrue();
|
||||
assertThat(foo).isAbsent();
|
||||
}
|
||||
|
||||
private void junitAssertions() {
|
||||
assertTrue(true);
|
||||
assertTrue("message", true);
|
||||
@@ -183,6 +210,8 @@ public class Playground {
|
||||
assertThat(new double[1]).as("array equals").containsExactly(new double[2], offset(1.0));
|
||||
assertThat(new float[1]).containsExactly(new float[2], offset(1.0f));
|
||||
assertThat(new float[1]).as("array equals").containsExactly(new float[2], offset(1.0f));
|
||||
|
||||
assertThat(new Object()).extracting(Object::toString, Object::hashCode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ internal class AssertThatSizeInspectionTest : AbstractCajonTest() {
|
||||
runTest {
|
||||
myFixture.enableInspections(AssertThatSizeInspection::class.java)
|
||||
myFixture.configureByFile("AssertThatSizeBefore.java")
|
||||
executeQuickFixes(myFixture, Regex("Replace .*"), 20)
|
||||
executeQuickFixes(myFixture, Regex("Replace .*"), 28)
|
||||
myFixture.checkResultByFile("AssertThatSizeAfter.java")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import java.util.ArrayList;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class assertThatSize {
|
||||
public class AssertThatSize {
|
||||
|
||||
private void assertThatSize() {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
@@ -20,6 +20,10 @@ public class assertThatSize {
|
||||
assertThat(list).hasSameSizeAs(otherList);
|
||||
assertThat(list).hasSameSizeAs(array);
|
||||
assertThat(list).hasSize(1);
|
||||
assertThat(list).hasSizeGreaterThan(list.size() * 2);
|
||||
assertThat(list).hasSizeGreaterThanOrEqualTo(list.size() * 2);
|
||||
assertThat(list).hasSizeLessThan(list.size() * 2);
|
||||
assertThat(list).hasSizeLessThanOrEqualTo(list.size() * 2);
|
||||
|
||||
assertThat(array).isEmpty();
|
||||
assertThat(array).isEmpty();
|
||||
@@ -31,5 +35,9 @@ public class assertThatSize {
|
||||
assertThat(array).hasSameSizeAs(list);
|
||||
assertThat(array).hasSameSizeAs(otherArray);
|
||||
assertThat(array).hasSize(1);
|
||||
assertThat(array).hasSizeGreaterThan(otherArray.length - 1);
|
||||
assertThat(array).hasSizeGreaterThanOrEqualTo(otherArray.length + 1);
|
||||
assertThat(array).hasSizeLessThan(otherArray.length - 3);
|
||||
assertThat(array).hasSizeLessThanOrEqualTo(1 - otherArray.length);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import java.util.ArrayList;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class assertThatSize {
|
||||
public class AssertThatSize {
|
||||
|
||||
private void assertThatSize() {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
@@ -20,6 +20,10 @@ public class assertThatSize {
|
||||
assertThat(list.size()).isEqualTo(otherList.size());
|
||||
assertThat(list.size()).isEqualTo(array.length);
|
||||
assertThat(list.size()).isEqualTo(1);
|
||||
assertThat(list.size()).isGreaterThan(list.size() * 2);
|
||||
assertThat(list.size()).isGreaterThanOrEqualTo(list.size() * 2);
|
||||
assertThat(list.size()).isLessThan(list.size() * 2);
|
||||
assertThat(list.size()).isLessThanOrEqualTo(list.size() * 2);
|
||||
|
||||
assertThat(array.length).isEqualTo(0);
|
||||
assertThat(array.length).isZero();
|
||||
@@ -31,5 +35,9 @@ public class assertThatSize {
|
||||
assertThat(array.length).isEqualTo(list.size());
|
||||
assertThat(array.length).isEqualTo(otherArray.length);
|
||||
assertThat(array.length).isEqualTo(1);
|
||||
assertThat(array.length).isGreaterThan(otherArray.length - 1);
|
||||
assertThat(array.length).isGreaterThanOrEqualTo(otherArray.length + 1);
|
||||
assertThat(array.length).isLessThan(otherArray.length - 3);
|
||||
assertThat(array.length).isLessThanOrEqualTo(1 - otherArray.length);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user