Coverage Report - org.jbehave.core.io.rest.Resource
 
Classes in this File Line Coverage Branch Coverage Complexity
Resource
96%
25/26
50%
3/6
1.059
 
 1  
 package org.jbehave.core.io.rest;
 2  
 
 3  
 import static org.apache.commons.lang.StringUtils.isNotBlank;
 4  
 import static org.apache.commons.lang.StringUtils.substringAfterLast;
 5  
 
 6  
 import java.util.List;
 7  
 
 8  
 import org.apache.commons.lang.builder.ToStringBuilder;
 9  
 import org.apache.commons.lang.builder.ToStringStyle;
 10  
 
 11  
 /**
 12  
  * Represents a resource retrieved from a REST API.
 13  
  */
 14  
 public class Resource {
 15  
 
 16  
     private final String uri;
 17  
     private final String name;
 18  
     private final String parentName;
 19  
     private List<String> breadcrumbs;
 20  
     private String content;
 21  
     private String syntax;
 22  
 
 23  
         public Resource(String uri) {
 24  9
         this(uri, substringAfterLast(uri, "/"));
 25  9
     }
 26  
 
 27  
     public Resource(String uri, String name) {
 28  11
         this(uri, name, null);
 29  11
     }
 30  
 
 31  33
     public Resource(String uri, String name, String parentName) {
 32  33
         this.uri = uri;
 33  33
         this.name = name;
 34  33
         this.parentName = parentName;
 35  33
     }
 36  
 
 37  
     public String getURI() {
 38  15
         return uri;
 39  
     }
 40  
 
 41  
     public String getName() {
 42  17
         return name;
 43  
     }
 44  
 
 45  
     public String getParentName() {
 46  15
         return parentName;
 47  
     }
 48  
 
 49  
     public boolean hasParent() {
 50  20
         return parentName != null;
 51  
     }
 52  
 
 53  
     public List<String> getBreadcrumbs() {
 54  3
         return breadcrumbs;
 55  
     }
 56  
 
 57  
         public void setBreadcrumbs(List<String> breadcrumbs) {
 58  10
         this.breadcrumbs = breadcrumbs;
 59  10
     }
 60  
 
 61  
     public boolean hasBreadcrumbs() {
 62  6
         return breadcrumbs != null && !breadcrumbs.isEmpty();
 63  
     }
 64  
 
 65  
     public void setContent(String content) {
 66  25
         this.content = content;
 67  25
     }
 68  
 
 69  
     public String getContent() {
 70  10
         return content;
 71  
     }
 72  
 
 73  
     public boolean hasContent() {
 74  4
         return isNotBlank(content);
 75  
     }
 76  
 
 77  
     public String getSyntax() {
 78  4
                 return syntax;
 79  
         }
 80  
 
 81  
         public void setSyntax(String syntax) {
 82  8
                 this.syntax = syntax;
 83  8
         }
 84  
 
 85  
     public boolean hasSyntax() {
 86  3
         return isNotBlank(syntax);
 87  
     }
 88  
 
 89  
         public String toString() {
 90  0
         return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
 91  
     }
 92  
 
 93  
 }