-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #387 from gdgib/G2-1667-GetArgumentAsPath
G2-1667 CommandInvocation Path Argument Accessor
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...ommand/src/test/java/com/g2forge/alexandria/command/invocation/TestCommandInvocation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.g2forge.alexandria.command.invocation; | ||
|
||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import org.junit.Test; | ||
|
||
import com.g2forge.alexandria.java.core.helpers.HCollection; | ||
import com.g2forge.alexandria.test.HAssert; | ||
|
||
public class TestCommandInvocation { | ||
@Test | ||
public void getArgumentAsPathAbsolute() { | ||
final Path absolutePath = CommandInvocation.of().getWorking().toAbsolutePath(); | ||
HAssert.assertEquals(absolutePath, new CommandInvocation<>(null, HCollection.asList(absolutePath.toString()), null, null, null).getArgumentAsPath(0)); | ||
} | ||
|
||
@Test | ||
public void getArgumentAsPathNull() { | ||
HAssert.assertNull(new CommandInvocation<>(null, HCollection.asList((String) null), null, null, null).getArgumentAsPath(0)); | ||
} | ||
|
||
@Test | ||
public void getArgumentAsPathRelative() { | ||
final Path relativePath = CommandInvocation.of().getWorking(); | ||
HAssert.assertEquals(relativePath, new CommandInvocation<>(null, HCollection.asList(relativePath.toString()), null, null, null).getArgumentAsPath(0)); | ||
} | ||
|
||
@Test | ||
public void getArgumentAsPathWorkingRelative() { | ||
final Path relativePath = Paths.get("relative"); | ||
final Path working = CommandInvocation.of().getWorking(); | ||
HAssert.assertEquals(working.resolve(relativePath), new CommandInvocation<>(null, HCollection.asList(relativePath.toString()), null, working, null).getArgumentAsPath(0)); | ||
} | ||
} |