Coverage Report - com.jcabi.github.RtOrganization
 
Classes in this File Line Coverage Branch Coverage Complexity
RtOrganization
80%
16/20
0%
0/20
1
RtOrganization$AjcClosure1
0%
0/1
N/A
1
RtOrganization$AjcClosure11
100%
1/1
N/A
1
RtOrganization$AjcClosure3
100%
1/1
N/A
1
RtOrganization$AjcClosure5
0%
0/1
N/A
1
RtOrganization$AjcClosure7
100%
1/1
N/A
1
RtOrganization$AjcClosure9
100%
1/1
N/A
1
 
 1  12
 /**
 2  
  * Copyright (c) 2013-2017, jcabi.com
 3  
  * All rights reserved.
 4  
  *
 5  
  * Redistribution and use in source and binary forms, with or without
 6  
  * modification, are permitted provided that the following conditions
 7  
  * are met: 1) Redistributions of source code must retain the above
 8  
  * copyright notice, this list of conditions and the following
 9  
  * disclaimer. 2) Redistributions in binary form must reproduce the above
 10  
  * copyright notice, this list of conditions and the following
 11  
  * disclaimer in the documentation and/or other materials provided
 12  
  * with the distribution. 3) Neither the name of the jcabi.com nor
 13  
  * the names of its contributors may be used to endorse or promote
 14  
  * products derived from this software without specific prior written
 15  
  * permission.
 16  
  *
 17  
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 18  
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
 19  
  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 20  
  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 21  
  * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 22  
  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 23  
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 24  
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 25  
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 26  
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 27  
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 28  
  * OF THE POSSIBILITY OF SUCH DAMAGE.
 29  
  */
 30  
 package com.jcabi.github;
 31  
 
 32  
 import com.jcabi.aspects.Immutable;
 33  
 import com.jcabi.aspects.Loggable;
 34  
 import com.jcabi.http.Request;
 35  
 import java.io.IOException;
 36  
 import javax.json.JsonObject;
 37  
 import lombok.EqualsAndHashCode;
 38  
 
 39  
 /**
 40  
  * Github organization.
 41  
  * @author Paul Polishchuk (ppol@ua.fm)
 42  
  * @version $Id: be25d07d091345541a7daedac6f97748da55eb82 $
 43  
  * @see <a href="http://developer.github.com/v3/orgs/">Organizations API</a>
 44  
  * @since 0.7
 45  
  */
 46  0
 @Immutable
 47  
 @Loggable(Loggable.DEBUG)
 48  0
 @EqualsAndHashCode(of = { "ghub", "request" })
 49  
 final class RtOrganization implements Organization {
 50  
 
 51  
     /**
 52  
      * Github.
 53  
      */
 54  
     private final transient Github ghub;
 55  
 
 56  
     /**
 57  
      * API entry point.
 58  
      */
 59  
     private final transient Request entry;
 60  
 
 61  
     /**
 62  
      * RESTful request.
 63  
      */
 64  
     private final transient Request request;
 65  
 
 66  
     /**
 67  
      * Login of the organization.
 68  
      */
 69  
     private final transient String self;
 70  
 
 71  
     /**
 72  
      * Public ctor.
 73  
      * @param github Github
 74  
      * @param req Request
 75  
      * @param login Organization login name
 76  
      */
 77  
     public RtOrganization(
 78  
         final Github github,
 79  
         final Request req,
 80  
         final String login
 81  9
     ) {
 82  9
         this.ghub = github;
 83  9
         this.entry = req;
 84  9
         this.request = req.uri()
 85  9
             .path("/orgs")
 86  9
             .path(login)
 87  9
             .back();
 88  9
         this.self = login;
 89  9
     }
 90  
 
 91  
     @Override
 92  
     public String toString() {
 93  1
         return this.request.uri().get().toString();
 94  
     }
 95  
 
 96  
     @Override
 97  
     public Github github() {
 98  0
         return this.ghub;
 99  
     }
 100  
 
 101  
     @Override
 102  
     public String login() {
 103  12
         return this.self;
 104  
     }
 105  
 
 106  
     @Override
 107  
     public PublicMembers publicMembers() {
 108  0
         return new RtPublicMembers(this.entry, this);
 109  
     }
 110  
 
 111  
     @Override
 112  
     public int compareTo(
 113  
         final Organization other
 114  
     ) {
 115  6
         return this.login().compareTo(other.login());
 116  
     }
 117  
 
 118  
     @Override
 119  
     public void patch(
 120  
         final JsonObject json) throws IOException {
 121  2
         new RtJson(this.request).patch(json);
 122  1
     }
 123  
 
 124  
     @Override
 125  
     public JsonObject json() throws IOException {
 126  2
         return new RtJson(this.request).fetch();
 127  
     }
 128  
 
 129  
 }