30
30
public class ImportedFromLocationFormatterTest {
31
31
32
32
@ Test
33
- public void testImportedFromNullToString () {
33
+ public void testImportedFromSingleLocation () {
34
34
// Arrange
35
35
final MavenProject project = new MavenProject ();
36
36
final ImportedFromLocationFormatter formatter = new ImportedFromLocationFormatterMock (project );
@@ -47,7 +47,28 @@ public void testImportedFromNullToString() {
47
47
}
48
48
49
49
@ Test
50
- public void testImportedFromNotNullToString () {
50
+ public void testImportedFromDifferentLocation () {
51
+ // Arrange
52
+ final InputSource importedFromSource = new InputSource ();
53
+ importedFromSource .setModelId ("org.example:MPG-183-bom2:1-SNAPSHOT" );
54
+ final InputLocation importedFrom = new InputLocation (7 , 5 , importedFromSource );
55
+
56
+ final MavenProject project = new MavenProject ();
57
+ final ImportedFromLocationFormatter formatter = new ImportedFromLocationFormatterMock (project , importedFrom );
58
+
59
+ final InputSource source = new InputSource ();
60
+ source .setModelId ("org.example:MPG-183-bom1:1-SNAPSHOT" );
61
+ final InputLocation location = new InputLocation (7 , 5 , source );
62
+
63
+ // Act
64
+ final String result = formatter .toString (location );
65
+
66
+ // Assert
67
+ assertEquals ("}org.example:MPG-183-bom1:1-SNAPSHOT, line 7 from org.example:MPG-183-bom2:1-SNAPSHOT" , result );
68
+ }
69
+
70
+ @ Test
71
+ public void testImportedFromDoNotPrintSameLocationTwice () {
51
72
// Arrange
52
73
final InputSource importedFromSource = new InputSource ();
53
74
importedFromSource .setModelId ("org.example:MPG-183-bom:1-SNAPSHOT" );
@@ -57,18 +78,18 @@ public void testImportedFromNotNullToString() {
57
78
final ImportedFromLocationFormatter formatter = new ImportedFromLocationFormatterMock (project , importedFrom );
58
79
59
80
final InputSource source = new InputSource ();
60
- source .setModelId ("org.example:MPG-183-project :1-SNAPSHOT" );
81
+ source .setModelId ("org.example:MPG-183-bom :1-SNAPSHOT" );
61
82
final InputLocation location = new InputLocation (7 , 5 , source );
62
83
63
84
// Act
64
85
final String result = formatter .toString (location );
65
86
66
87
// Assert
67
- assertEquals ("}org.example:MPG-183-project :1-SNAPSHOT, line 7 from org.example:MPG-183-bom:1-SNAPSHOT " , result );
88
+ assertEquals ("}org.example:MPG-183-bom :1-SNAPSHOT, line 7" , result );
68
89
}
69
90
70
91
@ Test
71
- public void testMultipleImportedFromToString () {
92
+ public void testImportedFromMultiLevelPrintsWithFrom () {
72
93
// Arrange
73
94
final ImportedFromLocationFormatter formatter = createMultiImportedFromFormatter ();
74
95
0 commit comments