|
|
|
|
@ -31,26 +31,26 @@ import static org.assertj.core.api.Assertions.assertThat;
@@ -31,26 +31,26 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
class TextResourceOriginTests { |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void createWithNullResourceShouldSetNullResource() { |
|
|
|
|
void createWithNullResourceSetsNullResource() { |
|
|
|
|
TextResourceOrigin origin = new TextResourceOrigin(null, null); |
|
|
|
|
assertThat(origin.getResource()).isNull(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void createWithNullLocationShouldSetNullLocation() { |
|
|
|
|
void createWithNullLocationSetsNullLocation() { |
|
|
|
|
TextResourceOrigin origin = new TextResourceOrigin(null, null); |
|
|
|
|
assertThat(origin.getLocation()).isNull(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void getResourceShouldReturnResource() { |
|
|
|
|
void getResourceReturnResource() { |
|
|
|
|
ClassPathResource resource = new ClassPathResource("foo.txt"); |
|
|
|
|
TextResourceOrigin origin = new TextResourceOrigin(resource, null); |
|
|
|
|
assertThat(origin.getResource()).isEqualTo(resource); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void getLocationShouldReturnLocation() { |
|
|
|
|
void getLocationReturnsLocation() { |
|
|
|
|
Location location = new Location(1, 2); |
|
|
|
|
TextResourceOrigin origin = new TextResourceOrigin(null, location); |
|
|
|
|
assertThat(origin.getLocation()).isEqualTo(location); |
|
|
|
|
@ -58,25 +58,25 @@ class TextResourceOriginTests {
@@ -58,25 +58,25 @@ class TextResourceOriginTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void getLocationLineShouldReturnLine() { |
|
|
|
|
void getLocationLineReturnsLine() { |
|
|
|
|
Location location = new Location(1, 2); |
|
|
|
|
assertThat(location.getLine()).isEqualTo(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void getLocationColumnShouldReturnColumn() { |
|
|
|
|
void getLocationColumnReturnsColumn() { |
|
|
|
|
Location location = new Location(1, 2); |
|
|
|
|
assertThat(location.getColumn()).isEqualTo(2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void locationToStringShouldReturnNiceString() { |
|
|
|
|
void locationToStringReturnsNiceString() { |
|
|
|
|
Location location = new Location(1, 2); |
|
|
|
|
assertThat(location.toString()).isEqualTo("2:3"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void toStringShouldReturnNiceString() { |
|
|
|
|
void toStringReturnsNiceString() { |
|
|
|
|
ClassPathResource resource = new ClassPathResource("foo.txt"); |
|
|
|
|
Location location = new Location(1, 2); |
|
|
|
|
TextResourceOrigin origin = new TextResourceOrigin(resource, location); |
|
|
|
|
@ -84,21 +84,21 @@ class TextResourceOriginTests {
@@ -84,21 +84,21 @@ class TextResourceOriginTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void toStringWhenResourceIsNullShouldReturnNiceString() { |
|
|
|
|
void toStringWhenResourceIsNullReturnsNiceString() { |
|
|
|
|
Location location = new Location(1, 2); |
|
|
|
|
TextResourceOrigin origin = new TextResourceOrigin(null, location); |
|
|
|
|
assertThat(origin.toString()).isEqualTo("unknown resource [?]:2:3"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void toStringWhenLocationIsNullShouldReturnNiceString() { |
|
|
|
|
void toStringWhenLocationIsNullReturnsNiceString() { |
|
|
|
|
ClassPathResource resource = new ClassPathResource("foo.txt"); |
|
|
|
|
TextResourceOrigin origin = new TextResourceOrigin(resource, null); |
|
|
|
|
assertThat(origin.toString()).isEqualTo("class path resource [foo.txt]"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void locationEqualsAndHashCodeShouldUseLineAndColumn() { |
|
|
|
|
void locationEqualsAndHashCodeUsesLineAndColumn() { |
|
|
|
|
Location location1 = new Location(1, 2); |
|
|
|
|
Location location2 = new Location(1, 2); |
|
|
|
|
Location location3 = new Location(2, 2); |
|
|
|
|
@ -111,7 +111,7 @@ class TextResourceOriginTests {
@@ -111,7 +111,7 @@ class TextResourceOriginTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void equalsAndHashCodeShouldResourceAndLocation() { |
|
|
|
|
void equalsAndHashCodeUsesResourceAndLocation() { |
|
|
|
|
TextResourceOrigin origin1 = new TextResourceOrigin(new ClassPathResource("foo.txt"), new Location(1, 2)); |
|
|
|
|
TextResourceOrigin origin2 = new TextResourceOrigin(new ClassPathResource("foo.txt"), new Location(1, 2)); |
|
|
|
|
TextResourceOrigin origin3 = new TextResourceOrigin(new ClassPathResource("foo.txt"), new Location(2, 2)); |
|
|
|
|
|