##### Coverage Report - org.jbehave.core.io.UnderscoredToCapitalized

Classes in this File | Line Coverage | Branch Coverage | Complexity
UnderscoredToCapitalized |
100% | 13/13
100% | 6/6
| 2.0;2

1 |  |
     package org.jbehave.core.io;
2 |  |
3 |  |
     import static org.apache.commons.lang.StringUtils.contains;
4 |  |
     import static org.apache.commons.lang.StringUtils.substringAfterLast;
5 |  |
     import static org.apache.commons.lang.StringUtils.substringBeforeLast;
6 |  |
     import static org.apache.commons.lang.WordUtils.capitalize;
7 |  |
8 |  |
     public class UnderscoredToCapitalized implements StoryNameResolver {
9 |  |
10 |  |
         private final String extension;
11 |  |
12 |  |
         public UnderscoredToCapitalized() {
13 | 1008 |
             this(".story");
14 | 1008 |
         }
15 |  |
16 | 1011 |
         public UnderscoredToCapitalized(String extension) {
17 | 1011 |
             this.extension = extension;
18 | 1011 |
         }
19 |  |
20 |  |
         public String resolveName(String path) {
21 | 66 |
             String name = path;
22 | 66 |
             if (contains(name, extension)) {
23 | 32 |
                 name = substringBeforeLast(name, extension);
24 |  |
             }
25 | 66 |
             if (contains(name, '/')) {
26 | 25 |
                 name = substringAfterLast(name, "/");
27 |  |
             }
28 | 66 |
             if (contains(name, '.')) {
29 | 19 |
                 name = substringAfterLast(name, ".");
30 |  |
             }
31 | 66 |
             return capitalize(name.replace("_", " "));
32 |  |
         }
33 |  |
34 |  |
     }