[87] | 1 | package com.framsticks.core; |
---|
| 2 | |
---|
| 3 | // import static org.mutabilitydetector.unittesting.MutabilityAssert.*; |
---|
| 4 | // import static org.mutabilitydetector.unittesting.MutabilityMatchers.*; |
---|
| 5 | // import static org.mutabilitydetector.unittesting.AllowedReason.*; |
---|
| 6 | |
---|
| 7 | // import java.util.LinkedList; |
---|
| 8 | |
---|
| 9 | import org.testng.annotations.BeforeClass; |
---|
[99] | 10 | import org.testng.annotations.DataProvider; |
---|
[87] | 11 | import org.testng.annotations.Test; |
---|
| 12 | |
---|
[105] | 13 | import com.framsticks.structure.Path; |
---|
[87] | 14 | import com.framsticks.test.TestConfiguration; |
---|
[99] | 15 | import com.framsticks.util.lang.Pair; |
---|
[87] | 16 | |
---|
[99] | 17 | import static org.fest.assertions.Assertions.*; |
---|
| 18 | |
---|
[87] | 19 | @Test |
---|
| 20 | public class PathTest extends TestConfiguration { |
---|
| 21 | |
---|
| 22 | @BeforeClass |
---|
| 23 | public void setUp() { |
---|
| 24 | // assertInstancesOf(Path.class, |
---|
| 25 | // areImmutable(), |
---|
| 26 | // allowingNonFinalFields(), |
---|
| 27 | // provided(String.class).isAlsoImmutable(), |
---|
| 28 | // provided(LinkedList.class).isAlsoImmutable() |
---|
| 29 | // ); |
---|
| 30 | } |
---|
| 31 | |
---|
[99] | 32 | @Test(dataProvider = "pathValidationProvider") |
---|
| 33 | public void pathValidation(String path, boolean ok) { |
---|
| 34 | assertThat(Path.isValidString(path)).describedAs(path).isEqualTo(ok); |
---|
[87] | 35 | } |
---|
| 36 | |
---|
[99] | 37 | @Test(dataProvider = "pathSplitingProvider") |
---|
| 38 | public void pathSpliting(String path, String prefix, String suffix) { |
---|
| 39 | Pair<String, String> p = Path.removeLastElement(path); |
---|
| 40 | assertThat(p.first).isEqualTo(prefix); |
---|
| 41 | assertThat(p.second).isEqualTo(suffix); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | @DataProvider |
---|
| 45 | public Object[][] pathValidationProvider() { |
---|
| 46 | return new Object[][] { |
---|
| 47 | { "/", true }, |
---|
| 48 | { "/path", true }, |
---|
| 49 | { "path", false }, |
---|
| 50 | { "/path/to/", false }, |
---|
| 51 | { "/path/to", true }, |
---|
| 52 | { "/testClass/history_changed", true }, |
---|
| 53 | { "/cli/events/e0", true } |
---|
| 54 | |
---|
| 55 | }; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | @DataProvider |
---|
| 59 | public Object[][] pathSplitingProvider() { |
---|
| 60 | return new Object[][] { |
---|
| 61 | { "/event", "/", "event" }, |
---|
| 62 | { "/path/event", "/path", "event" } |
---|
| 63 | }; |
---|
| 64 | } |
---|
| 65 | |
---|
[87] | 66 | } |
---|