/*
 * Licensed to Elasticsearch under one or more contributor
 * license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright
 * ownership. Elasticsearch licenses this file to you under
 * the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.maven.plugin.github;

import junit.framework.TestCase;
import org.apache.maven.model.IssueManagement;
import org.apache.maven.plugin.issues.Issue;
import org.apache.maven.project.MavenProject;
import org.eclipse.egit.github.core.User;

import java.io.IOException;

public class GitHubDownloaderTestCase extends TestCase {
    public void testCreateIssue() throws IOException {

        MavenProject mavenProject = new MavenProject();
        IssueManagement issueManagement = new IssueManagement();
        issueManagement.setSystem("GitHub");
        issueManagement.setUrl("https://github.com/dadoonet/spring-elasticsearch/issues/");
        mavenProject.setIssueManagement(issueManagement);

        GitHubDownloader gitHubDownloader = new GitHubDownloader(
                mavenProject, "https", 80, true, false
        );

        org.eclipse.egit.github.core.Issue githubIssue = new org.eclipse.egit.github.core.Issue();
        githubIssue.setNumber(1);
        githubIssue.setBody("Body");
        githubIssue.setTitle("Title");
        User user = new User();
        githubIssue.setUser(user);

        Issue issue = gitHubDownloader.createIssue(githubIssue);

        assertEquals(Integer.toString(githubIssue.getNumber()), issue.getId());
        assertEquals(Integer.toString(githubIssue.getNumber()), issue.getKey());
        assertEquals(githubIssue.getTitle(), issue.getTitle());
        assertEquals(githubIssue.getBody(), issue.getSummary());
        assertEquals(issueManagement.getUrl()+githubIssue.getNumber(), issue.getLink());
    }
}

@@ -54,19 +54,16 @@
 tributor
-%0A *
  license
@@ -115,16 +115,16 @@
 with
-%0A *
  this
+%0A *
  wor
@@ -171,19 +171,16 @@
 opyright
-%0A *
  ownersh
@@ -232,15 +232,15 @@
 nder
-%0A *
  the
+%0A *
  Apa
@@ -288,19 +288,16 @@
  you may
-%0A *
  not use
@@ -349,19 +349,16 @@
 nse.
-%0A *
  You may
  obt
@@ -353,16 +353,19 @@
  You may
+%0A *
  obtain 
@@ -394,19 +394,16 @@
 at%0A *%0A *
-   
  http://
@@ -502,19 +502,16 @@
 writing,
-%0A *
  softwar
@@ -563,14 +563,14 @@
 d on
- an
 %0A *
+ an
  %22AS
@@ -620,19 +620,16 @@
 S OF ANY
-%0A *
  KIND, e
@@ -653,17 +653,16 @@
 implied.
- 
  See the
@@ -736,19 +736,16 @@
 itations
-%0A *
  under t
@@ -1082,16 +1082,20 @@
 TestCase
+%0A   
  extends
@@ -1103,18 +1103,19 @@
 TestCase
- %7B
+%0A%7B%0A
 %0A    pub
@@ -1140,16 +1140,24 @@
 eIssue()
+%0A       
  throws 
@@ -1167,16 +1167,20 @@
 xception
+%0A   
  %7B%0A%0A    
@@ -1334,16 +1334,17 @@
 tem(
+ 
 %22GitHub%22
 );%0A 
@@ -1339,16 +1339,17 @@
 %22GitHub%22
+ 
 );%0A     
@@ -1374,16 +1374,17 @@
 .setUrl(
+ 
 %22https:/
@@ -1433,16 +1433,17 @@
 issues/%22
+ 
 );%0A     
@@ -1477,16 +1477,17 @@
 agement(
+ 
 issueMan
@@ -1493,16 +1493,17 @@
 nagement
+ 
 );%0A%0A    
@@ -1567,24 +1567,8 @@
 der(
-%0A               
  mav
@@ -1602,24 +1602,16 @@
 e, false
-%0A       
  );%0A%0A   
@@ -1740,9 +1740,11 @@
 ber(
-1
+ 1 
 );%0A 
@@ -1774,14 +1774,16 @@
 ody(
+ 
 %22Body%22
+ 
 );%0A 
@@ -1814,15 +1814,17 @@
 tle(
+ 
 %22Title%22
+ 
 );%0A 
@@ -1882,20 +1882,22 @@
 setUser(
+ 
 user
+ 
 );%0A%0A    
@@ -1943,16 +1943,17 @@
 teIssue(
+ 
 githubIs
@@ -1955,16 +1955,17 @@
 hubIssue
+ 
 );%0A%0A    
@@ -1973,32 +1973,33 @@
    assertEquals(
+ 
 Integer.toString
@@ -1991,32 +1991,33 @@
 nteger.toString(
+ 
 githubIssue.getN
@@ -2015,32 +2015,33 @@
 ssue.getNumber()
+ 
 ), issue.getId()
@@ -2040,16 +2040,17 @@
 .getId()
+ 
 );%0A     
@@ -2065,16 +2065,17 @@
 tEquals(
+ 
 Integer.
@@ -2083,16 +2083,17 @@
 oString(
+ 
 githubIs
@@ -2107,16 +2107,17 @@
 Number()
+ 
 ), issue
@@ -2125,16 +2125,17 @@
 getKey()
+ 
 );%0A     
@@ -2142,32 +2142,33 @@
    assertEquals(
+ 
 githubIssue.getT
@@ -2191,16 +2191,17 @@
 tTitle()
+ 
 );%0A     
@@ -2216,16 +2216,17 @@
 tEquals(
+ 
 githubIs
@@ -2258,16 +2258,17 @@
 ummary()
+ 
 );%0A     
@@ -2283,16 +2283,17 @@
 tEquals(
+ 
 issueMan
@@ -2312,9 +2312,11 @@
 rl()
-+
+ + 
 gith
@@ -2351,16 +2351,17 @@
 etLink()
+ 
 );%0A    %7D

apply maven format