##### Coverage Report - org.jbehave.core.steps.Stepdoc

Classes in this File | Line Coverage | Branch Coverage | Complexity
Stepdoc |
100% | 17/17
N/A | N/A
| 1.0;1

1 |  |
     package org.jbehave.core.steps;
2 |  |
3 |  |
     import java.lang.reflect.Method;
4 |  |
5 |  |
     import org.apache.commons.lang.builder.CompareToBuilder;
6 |  |
     import org.apache.commons.lang.builder.ToStringBuilder;
7 |  |
8 |  |
     /**
9 |  |
      * A Stepdoc represents the documentation on a single {@link StepCandidate},
10 |  |
      * which includes:
11 |  |
      * <ul>
12 |  |
      * <li>the step type</li>
13 |  |
      * <li>the pattern to match the step candidate that is configured in the
14 |  |
      * annotation</li>
15 |  |
      * <li>the method in the steps instance class</li>
16 |  |
      * <li>the steps instance class</li>
17 |  |
      * </ul>
18 |  |
      */
19 | 2 |
     public class Stepdoc implements Comparable<Stepdoc> {
20 |  |
21 |  |
         private StepType stepType;
22 |  |
         private String startingWord;
23 |  |
         private String pattern;
24 |  |
         private Method method;
25 |  |
         private Object stepsInstance;
26 |  |
27 | 7 |
         public Stepdoc(StepCandidate candidate) {
28 | 7 |
             this.method = candidate.getMethod();
29 | 7 |
             this.stepType = candidate.getStepType();
30 | 7 |
             this.startingWord = candidate.getStartingWord();
31 | 7 |
             this.pattern = candidate.getPatternAsString();
32 | 7 |
             this.stepsInstance = candidate.getStepsInstance();
33 | 7 |
         }
34 |  |
35 |  |
         public StepType getStepType() {
36 | 3 |
             return stepType;
37 |  |
         }
38 |  |
39 |  |
         public String getStartingWord() {
40 | 7 |
             return startingWord;
41 |  |
         }
42 |  |
43 |  |
         public String getPattern() {
44 | 7 |
             return pattern;
45 |  |
         }
46 |  |
47 |  |
         public Method getMethod() {
48 | 3 |
             return method;
49 |  |
         }
50 |  |
51 |  |
         public Object getStepsInstance() {
52 | 3 |
             return stepsInstance;
53 |  |
         }
54 |  |
55 |  |
         /**
56 |  |
          * Method signature without "public void" prefix
57 |  |
          *
58 |  |
          * @return The method signature in String format
59 |  |
          */
60 |  |
         public String getMethodSignature() {
61 | 7 |
             String methodSignature = method.toString();
62 | 7 |
             return methodSignature.replaceFirst("public void ", "");
63 |  |
         }
64 |  |
65 |  |
         @Override
66 |  |
         public String toString() {
67 | 15 |
             return ToStringBuilder.reflectionToString(this).toString();
68 |  |
         }
69 |  |
70 |  |
         public int compareTo(Stepdoc that) {
71 | 2 |
             return CompareToBuilder.reflectionCompare(this, that);
72 |  |
         }
73 |  |
74 |  |
     }