View Javadoc
1   /*
2    * Licensed to Elasticsearch under one or more contributor license agreements. See the NOTICE file distributed with this
3    * work for additional information regarding copyright ownership. Elasticsearch licenses this file to you under the
4    * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10   * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11   * specific language governing permissions and limitations under the License.
12   */
13  
14  package org.apache.maven.plugin.github;
15  
16  import junit.framework.TestCase;
17  import org.apache.maven.model.IssueManagement;
18  import org.apache.maven.plugin.issues.Issue;
19  import org.apache.maven.project.MavenProject;
20  import org.eclipse.egit.github.core.User;
21  
22  import java.io.IOException;
23  
24  public class GitHubDownloaderTestCase
25      extends TestCase
26  {
27  
28      public void testCreateIssue()
29          throws IOException
30      {
31  
32          MavenProject mavenProject = new MavenProject();
33          IssueManagement issueManagement = new IssueManagement();
34          issueManagement.setSystem( "GitHub" );
35          issueManagement.setUrl( "https://github.com/dadoonet/spring-elasticsearch/issues/" );
36          mavenProject.setIssueManagement( issueManagement );
37  
38          GitHubDownloader gitHubDownloader = new GitHubDownloader( mavenProject, "https", 80, true, false );
39  
40          org.eclipse.egit.github.core.Issue githubIssue = new org.eclipse.egit.github.core.Issue();
41          githubIssue.setNumber( 1 );
42          githubIssue.setBody( "Body" );
43          githubIssue.setTitle( "Title" );
44          User user = new User();
45          githubIssue.setUser( user );
46  
47          Issue issue = gitHubDownloader.createIssue( githubIssue );
48  
49          assertEquals( Integer.toString( githubIssue.getNumber() ), issue.getId() );
50          assertEquals( Integer.toString( githubIssue.getNumber() ), issue.getKey() );
51          assertEquals( githubIssue.getTitle(), issue.getTitle() );
52          assertEquals( githubIssue.getTitle(), issue.getSummary() );
53          assertEquals( issueManagement.getUrl() + githubIssue.getNumber(), issue.getLink() );
54      }
55  }