Coverage Report - com.jcabi.github.mock.MkCommits
 
Classes in this File Line Coverage Branch Coverage Complexity
MkCommits
75%
9/12
0%
0/22
1.2
MkCommits$AjcClosure1
0%
0/1
N/A
1.2
MkCommits$AjcClosure3
100%
1/1
N/A
1.2
MkCommits$AjcClosure5
100%
1/1
N/A
1.2
MkCommits$AjcClosure7
0%
0/1
N/A
1.2
 
 1  2
 /**
 2  
  * Copyright (c) 2013-2015, 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  
 
 31  
 package com.jcabi.github.mock;
 32  
 
 33  
 import com.jcabi.aspects.Immutable;
 34  
 import com.jcabi.aspects.Loggable;
 35  
 import com.jcabi.github.Commit;
 36  
 import com.jcabi.github.Commits;
 37  
 import com.jcabi.github.Coordinates;
 38  
 import com.jcabi.github.Repo;
 39  
 import com.jcabi.github.Statuses;
 40  
 import java.io.IOException;
 41  
 import javax.json.JsonObject;
 42  
 import javax.validation.constraints.NotNull;
 43  
 import lombok.EqualsAndHashCode;
 44  
 import org.xembly.Directives;
 45  
 
 46  
 /**
 47  
  * Mock of Github Commits.
 48  
  * @author Ed Hillmann (edhillmann@yahoo.com)
 49  
  * @version $Id$
 50  
  */
 51  
 @Immutable
 52  
 @Loggable(Loggable.DEBUG)
 53  0
 @EqualsAndHashCode(of = { "storage", "self", "coords" })
 54  
 public final class MkCommits implements Commits {
 55  
 
 56  
     /**
 57  
      * Storage.
 58  
      */
 59  
     private final transient MkStorage storage;
 60  
 
 61  
     /**
 62  
      * Login of the user logged in.
 63  
      */
 64  
     private final transient String self;
 65  
 
 66  
     /**
 67  
      * Repo's name.
 68  
      */
 69  
     private final transient Coordinates coords;
 70  
 
 71  
     /**
 72  
      * Public constructor.
 73  
      * @param stg The storage.
 74  
      * @param login The login name.
 75  
      * @param rep Repo's coordinates.
 76  
      * @throws IOException If something goes wrong.
 77  
      */
 78  
     MkCommits(
 79  
         @NotNull(message = "stg can't be NULL") final MkStorage stg,
 80  
         @NotNull(message = "login can't be NULL") final String login,
 81  
         @NotNull(message = "rep can't be NULL") final Coordinates rep
 82  1
     ) throws IOException {
 83  1
         this.storage = stg;
 84  1
         this.self = login;
 85  1
         this.coords = rep;
 86  1
         this.storage.apply(
 87  
             new Directives().xpath(
 88  
                 String.format(
 89  
                     "/github/repos/repo[@coords='%s']/git",
 90  
                     this.coords
 91  
                 )
 92  
             ).addIf("commits")
 93  
         );
 94  1
     }
 95  
     @Override
 96  
     @NotNull(message = "Repository can't be NULL")
 97  
     public Repo repo() {
 98  0
         return new MkRepo(this.storage, this.self, this.coords);
 99  
     }
 100  
 
 101  
     @Override
 102  
     @NotNull(message = "created commit is never NULL")
 103  
     public Commit create(
 104  
         @NotNull(message = "params can't be NULL") final JsonObject params
 105  
     ) {
 106  2
         return this.get(params.getString("sha"));
 107  
     }
 108  
 
 109  
     @Override
 110  
     @NotNull(message = "commit is never NULL")
 111  
     public Commit get(
 112  
         @NotNull(message = "sha can't be NULL") final String sha
 113  
     ) {
 114  2
         return new MkCommit(this.storage, this.self, this.coords, sha);
 115  
     }
 116  
 
 117  
     @Override
 118  
     public Statuses statuses(
 119  
             @NotNull(message = "sha can't be NULL") final String sha
 120  
     ) {
 121  0
         throw new UnsupportedOperationException("Not implemented");
 122  
     }
 123  
 }