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; |
---|
10 | import org.testng.annotations.DataProvider; |
---|
11 | import org.testng.annotations.Test; |
---|
12 | |
---|
13 | import com.framsticks.structure.Path; |
---|
14 | import com.framsticks.test.TestConfiguration; |
---|
15 | import com.framsticks.util.lang.Pair; |
---|
16 | |
---|
17 | import static org.fest.assertions.Assertions.*; |
---|
18 | |
---|
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 | |
---|
32 | @Test(dataProvider = "pathValidationProvider") |
---|
33 | public void pathValidation(String path, boolean ok) { |
---|
34 | assertThat(Path.isValidString(path)).describedAs(path).isEqualTo(ok); |
---|
35 | } |
---|
36 | |
---|
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 | |
---|
66 | } |
---|