Coverage Report - com.jcabi.github.mock.MkGitignores
 
Classes in this File Line Coverage Branch Coverage Complexity
MkGitignores
69%
9/13
8%
1/12
1.5
MkGitignores$AjcClosure1
0%
0/1
N/A
1.5
MkGitignores$AjcClosure3
100%
1/1
N/A
1.5
MkGitignores$AjcClosure5
100%
1/1
N/A
1.5
 
 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  
 package com.jcabi.github.mock;
 31  
 
 32  
 import com.jcabi.aspects.Immutable;
 33  
 import com.jcabi.aspects.Loggable;
 34  
 import com.jcabi.github.Github;
 35  
 import com.jcabi.github.Gitignores;
 36  
 import java.io.IOException;
 37  
 import java.util.Collections;
 38  
 import java.util.Map;
 39  
 import javax.validation.constraints.NotNull;
 40  
 import lombok.EqualsAndHashCode;
 41  
 import lombok.ToString;
 42  
 
 43  
 /**
 44  
  * Mock Gitignore.
 45  
  * @author Paul Polishchuk (ppol@ua.fm)
 46  
  * @version $Id$
 47  
  * @since 0.8
 48  
  */
 49  
 @Immutable
 50  
 @Loggable(Loggable.DEBUG)
 51  0
 @ToString
 52  0
 @EqualsAndHashCode(of = { "ghub" })
 53  
 @SuppressWarnings("PMD.UseConcurrentHashMap")
 54  
 final class MkGitignores implements Gitignores {
 55  
 
 56  
     /**
 57  
      * The gitignore templates.
 58  
      */
 59  1
     private static final Map<String, String> GITIGNORES =
 60  
         Collections.singletonMap(
 61  
             "Java",
 62  
             "*.class\n\n# Package Files #\n*.jar\n*.war\n*.ear\n"
 63  
         );
 64  
 
 65  
     /**
 66  
      * Github.
 67  
      */
 68  
     private final transient MkGithub ghub;
 69  
 
 70  
     /**
 71  
      * Public ctor.
 72  
      * @param github The github
 73  
      */
 74  
     MkGitignores(@NotNull(message = "github can't NULL")
 75  2
         final MkGithub github) {
 76  2
         this.ghub = github;
 77  2
     }
 78  
 
 79  
     @Override
 80  
     @NotNull(message = "github is never NULL")
 81  
     public Github github() {
 82  0
         return this.ghub;
 83  
     }
 84  
 
 85  
     @Override
 86  
     @NotNull(message = "Iterable is never NULL")
 87  
     public Iterable<String> iterate() throws IOException {
 88  2
         return GITIGNORES.keySet();
 89  
     }
 90  
 
 91  
     @Override
 92  
     @NotNull(message = "template is never NULL")
 93  
     public String template(
 94  
         @NotNull(message = "Template name can't be NULL")
 95  
         final String name) throws IOException {
 96  2
         final String template = GITIGNORES.get(name);
 97  1
         if (template == null) {
 98  0
             throw new IllegalArgumentException("Template not found.");
 99  
         }
 100  1
         return template;
 101  
     }
 102  
 }