resolve path
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package click.kamil.springstatemachineexporter.analysis.resolver;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Set;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class RelativePathTest {
|
||||
@Test
|
||||
public void testRelativePathDirectory(@TempDir Path tempDir) throws Exception {
|
||||
Path rootDir = tempDir.resolve("root");
|
||||
Path childDir = tempDir.resolve("child");
|
||||
Files.createDirectories(rootDir);
|
||||
Files.createDirectories(childDir);
|
||||
|
||||
Files.writeString(rootDir.resolve("pom.xml"), "<project><groupId>com.acme</groupId><artifactId>root</artifactId></project>");
|
||||
Files.writeString(childDir.resolve("pom.xml"), "<project><parent><relativePath>../root</relativePath></parent></project>");
|
||||
|
||||
SiblingDependencyResolver resolver = new SiblingDependencyResolver();
|
||||
Set<Path> siblings = resolver.resolveSiblings(childDir);
|
||||
assertTrue(siblings.contains(rootDir), "Should resolve parent directory from <relativePath>");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRelativePathFile(@TempDir Path tempDir) throws Exception {
|
||||
Path rootDir = tempDir.resolve("root");
|
||||
Path childDir = tempDir.resolve("child");
|
||||
Files.createDirectories(rootDir);
|
||||
Files.createDirectories(childDir);
|
||||
|
||||
Files.writeString(rootDir.resolve("pom.xml"), "<project><groupId>com.acme</groupId><artifactId>root</artifactId></project>");
|
||||
Files.writeString(childDir.resolve("pom.xml"), "<project><parent><relativePath>../root/pom.xml</relativePath></parent></project>");
|
||||
|
||||
SiblingDependencyResolver resolver = new SiblingDependencyResolver();
|
||||
Set<Path> siblings = resolver.resolveSiblings(childDir);
|
||||
assertTrue(siblings.contains(rootDir), "Should resolve parent directory from <relativePath> file");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user