Coverage Report - com.jcabi.github.mock.MkCommitsComparison
 
Classes in this File Line Coverage Branch Coverage Complexity
MkCommitsComparison
88%
8/9
N/A
1
MkCommitsComparison$AjcClosure1
100%
1/1
N/A
1
MkCommitsComparison$AjcClosure3
100%
1/1
N/A
1
 
 1  4
 /**
 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  
 package com.jcabi.github.mock;
 31  
 
 32  
 import com.jcabi.aspects.Immutable;
 33  
 import com.jcabi.aspects.Loggable;
 34  
 import com.jcabi.github.CommitsComparison;
 35  
 import com.jcabi.github.Coordinates;
 36  
 import com.jcabi.github.Repo;
 37  
 import java.io.IOException;
 38  
 import javax.json.Json;
 39  
 import javax.json.JsonObject;
 40  
 import javax.validation.constraints.NotNull;
 41  
 import lombok.ToString;
 42  
 
 43  
 /**
 44  
  * Mock commits' comparison of a Github repository.
 45  
  * @author Andrej Istomin (andrej.istomin.ikeen@gmail.com)
 46  
  * @version $Id$
 47  
  */
 48  
 @Immutable
 49  
 @Loggable(Loggable.DEBUG)
 50  0
 @ToString
 51  
 final class MkCommitsComparison implements CommitsComparison {
 52  
 
 53  
     /**
 54  
      * Storage.
 55  
      */
 56  
     private final transient MkStorage storage;
 57  
 
 58  
     /**
 59  
      * Login of the user logged in.
 60  
      */
 61  
     private final transient String self;
 62  
 
 63  
     /**
 64  
      * Repo coordinates.
 65  
      */
 66  
     private final transient Coordinates coords;
 67  
 
 68  
     /**
 69  
      * Public ctor.
 70  
      * @param stg Storage
 71  
      * @param login User to login
 72  
      * @param repo Repository coordinates
 73  
      */
 74  
     MkCommitsComparison(
 75  
         @NotNull(message = "stg can not be NULL") final MkStorage stg,
 76  
         @NotNull(message = "login can not be NULL") final String login,
 77  
         @NotNull(message = "repo can not be NULL") final Coordinates repo
 78  5
     ) {
 79  5
         this.storage = stg;
 80  5
         this.self = login;
 81  5
         this.coords = repo;
 82  5
     }
 83  
 
 84  
     @Override
 85  
     @NotNull(message = "Repo is never NULL")
 86  
     public Repo repo() {
 87  4
         return new MkRepo(this.storage, this.self, this.coords);
 88  
     }
 89  
 
 90  
     @Override
 91  
     @NotNull(message = "JsonObject is never NULL")
 92  
     public JsonObject json() throws IOException {
 93  8
         return Json.createObjectBuilder()
 94  
             // @checkstyle MultipleStringLiterals (3 lines)
 95  
             .add("status", "test-status")
 96  
             .add("ahead_by", 1)
 97  
             .add("behind_by", 2)
 98  
             .add(
 99  
                 "author",
 100  
                 Json.createObjectBuilder()
 101  
                     // @checkstyle MultipleStringLiterals (3 lines)
 102  
                     .add("login", "test")
 103  
                     .build()
 104  
             )
 105  
             .add(
 106  
                 "files",
 107  
                 Json.createObjectBuilder()
 108  
                     .add("sha", "bbcd538c8e72b8c175046e27cc8f907076331401")
 109  
                     .add("filename", "test-file")
 110  
                         // @checkstyle MultipleStringLiterals (1 lines)
 111  
                     .add("status", "test")
 112  
                     .build()
 113  
             )
 114  
             .add("commits", Json.createArrayBuilder())
 115  
             .build();
 116  
     }
 117  
 }