Added support for referencing and refactoring inside ``.extracting()`` methods with fields, properties and methods (though getter renaming does not work that perfect, but I'm giving up for now as the IntelliJ SDK docs are seriously lacking).

Fixed an exception in batch mode if the description string was the same but for different fixes. Now descriptions are different for quick fixes triggered by AssertThatJava8OptionalInspection and AssertThatGuavaOptionalInspection. Minor refactorings. Extended documentation.
This commit is contained in:
2019-04-18 22:12:48 +02:00
parent b58d8cfd2f
commit 9f91fb3ccf
28 changed files with 685 additions and 89 deletions
@@ -0,0 +1,20 @@
public class Address {
private String street;
private String country;
private String getStreet() {
return street;
}
public String getCountry() {
return country;
}
public boolean isNoMailings() {
return true;
}
public Boolean getREALLYnoMAILINGS() {
return true;
}
}
@@ -0,0 +1,9 @@
public class Contact {
private String name;
public Integer age;
protected Address address;
public String getStreetName()
{
return address.getStreet();
}
}
@@ -0,0 +1,15 @@
import org.assertj.core.extractor.Extractors;
import java.util.Collections;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class FindReference1 {
private void findReferences() {
Contact contact = new Contact();
assertThat(contact).extracting("name<caret>").isEqualTo("foo");
}
}
@@ -0,0 +1,15 @@
import org.assertj.core.extractor.Extractors;
import java.util.Collections;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class FindReference10 {
private void findReferences() {
List<Contact> contactList = Collections.emptyList();
assertThat(contactList).extractingResultOf("getStreetName<caret>").isEqualTo("foo");
}
}
@@ -0,0 +1,15 @@
import org.assertj.core.extractor.Extractors;
import java.util.Collections;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class FindReference2 {
private void findReferences() {
Contact contact = new Contact();
assertThat(contact).extracting("address<caret>.street", "streetName").containsExactly(1, "Elmst. 42");
}
}
@@ -0,0 +1,15 @@
import org.assertj.core.extractor.Extractors;
import java.util.Collections;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class FindReference3 {
private void findReferences() {
Contact contact = new Contact();
assertThat(contact).extracting("address.street<caret>", "address.REALLYnoMAILINGS").containsExactly(1, "Elmst. 42");
}
}
@@ -0,0 +1,15 @@
import org.assertj.core.extractor.Extractors;
import java.util.Collections;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class FindReference4 {
private void findReferences() {
Contact contact = new Contact();
assertThat(contact).extracting("address.getREALLYnoMAILINGS<caret>", "address.country").containsExactly(1, "Elmst. 42");
}
}
@@ -0,0 +1,15 @@
import org.assertj.core.extractor.Extractors;
import java.util.Collections;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class FindReference5 {
private void findReferences() {
Contact contact = new Contact();
assertThat(contact).extracting("address.noMailings<caret>").containsExactly(1, "Elmst. 42");
}
}
@@ -0,0 +1,15 @@
import org.assertj.core.extractor.Extractors;
import java.util.Collections;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class FindReference6 {
private void findReferences() {
Contact contact = new Contact();
assertThat(contact).extracting(Extractors.byName("name<caret>")).isEqualTo("foo");
}
}
@@ -0,0 +1,15 @@
import org.assertj.core.extractor.Extractors;
import java.util.Collections;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class FindReference7 {
private void findReferences() {
Contact contact = new Contact();
assertThat(contact).extracting(Extractors.resultOf("getStreetName<caret>")).isEqualTo("foo");
}
}
@@ -0,0 +1,15 @@
import org.assertj.core.extractor.Extractors;
import java.util.Collections;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class FindReference8 {
private void findReferences() {
List<Contact> contactList = Collections.emptyList();
assertThat(contactList).extracting("name<caret>").isEqualTo("foo");
}
}
@@ -0,0 +1,15 @@
import org.assertj.core.extractor.Extractors;
import java.util.Collections;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class FindReference9 {
private void findReferences() {
List<Contact> contactList = Collections.emptyList();
assertThat(contactList).flatExtracting("age", "address.street<caret>", "streetName").containsExactly(1, "Elmst. 42");
}
}