mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-10 08:21:21 +00:00
Merge pull request #1015 from seregamorph/feature/mock-previews
Fix mocking Previews
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -153,7 +153,7 @@
|
||||
<exclude>org.kohsuke.github.example.*</exclude>
|
||||
|
||||
<!-- No methods -->
|
||||
<exclude>org.kohsuke.github.Previews</exclude>
|
||||
<exclude>org.kohsuke.github.internal.Previews</exclude>
|
||||
|
||||
<!-- Deprecated -->
|
||||
<exclude>org.kohsuke.github.extras.OkHttp3Connector</exclude>
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.kohsuke.github.Previews.MACHINE_MAN;
|
||||
import static org.kohsuke.github.internal.Previews.MACHINE_MAN;
|
||||
|
||||
/**
|
||||
* A Github App.
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.kohsuke.github.Previews.MACHINE_MAN;
|
||||
import static org.kohsuke.github.internal.Previews.MACHINE_MAN;
|
||||
|
||||
/**
|
||||
* Creates a access token for a GitHub App Installation
|
||||
|
||||
@@ -8,8 +8,8 @@ import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.kohsuke.github.Previews.GAMBIT;
|
||||
import static org.kohsuke.github.Previews.MACHINE_MAN;
|
||||
import static org.kohsuke.github.internal.Previews.GAMBIT;
|
||||
import static org.kohsuke.github.internal.Previews.MACHINE_MAN;
|
||||
|
||||
/**
|
||||
* A Github App Installation.
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.kohsuke.github;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
@@ -6,7 +6,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.kohsuke.github.Previews.ZZZAX;
|
||||
import static org.kohsuke.github.internal.Previews.ZZZAX;
|
||||
|
||||
/**
|
||||
* The type GHBranchProtection.
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.kohsuke.github.Previews.*;
|
||||
import static org.kohsuke.github.internal.Previews.LUKE_CAGE;
|
||||
|
||||
/**
|
||||
* Builder to configure the branch protection settings.
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.kohsuke.github;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import edu.umd.cs.findbugs.annotations.NonNull;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import edu.umd.cs.findbugs.annotations.CheckForNull;
|
||||
import edu.umd.cs.findbugs.annotations.NonNull;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -11,8 +11,8 @@ import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static org.kohsuke.github.Previews.ANTIOPE;
|
||||
import static org.kohsuke.github.Previews.GROOT;
|
||||
import static org.kohsuke.github.internal.Previews.ANTIOPE;
|
||||
import static org.kohsuke.github.internal.Previews.GROOT;
|
||||
|
||||
/**
|
||||
* A commit in a repository.
|
||||
|
||||
@@ -5,7 +5,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import static org.kohsuke.github.Previews.*;
|
||||
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
|
||||
|
||||
/**
|
||||
* A comment attached to a commit (or a specific line in a specific file of a commit.)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.kohsuke.github.Previews.BAPTISTE;
|
||||
import static org.kohsuke.github.internal.Previews.BAPTISTE;
|
||||
|
||||
/**
|
||||
* Creates a repository
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
/**
|
||||
* Represents the state of deployment
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
@@ -39,7 +39,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.kohsuke.github.Previews.SQUIRREL_GIRL;
|
||||
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
|
||||
|
||||
/**
|
||||
* Represents an issue on GitHub.
|
||||
|
||||
@@ -26,7 +26,7 @@ package org.kohsuke.github;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import static org.kohsuke.github.Previews.*;
|
||||
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
|
||||
|
||||
/**
|
||||
* Comment to the issue
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import static org.kohsuke.github.Previews.INERTIA;
|
||||
import static org.kohsuke.github.internal.Previews.INERTIA;
|
||||
|
||||
/**
|
||||
* The type GHOrganization.
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Locale;
|
||||
|
||||
import static org.kohsuke.github.Previews.INERTIA;
|
||||
import static org.kohsuke.github.internal.Previews.INERTIA;
|
||||
|
||||
/**
|
||||
* A GitHub project.
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import static org.kohsuke.github.Previews.INERTIA;
|
||||
import static org.kohsuke.github.internal.Previews.INERTIA;
|
||||
|
||||
/**
|
||||
* The type GHProjectCard.
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import static org.kohsuke.github.Previews.INERTIA;
|
||||
import static org.kohsuke.github.internal.Previews.INERTIA;
|
||||
|
||||
/**
|
||||
* The type GHProjectColumn.
|
||||
|
||||
@@ -36,8 +36,8 @@ import java.util.Objects;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
|
||||
import static org.kohsuke.github.Previews.LYDIAN;
|
||||
import static org.kohsuke.github.Previews.SHADOW_CAT;
|
||||
import static org.kohsuke.github.internal.Previews.LYDIAN;
|
||||
import static org.kohsuke.github.internal.Previews.SHADOW_CAT;
|
||||
|
||||
/**
|
||||
* A pull request.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import static org.kohsuke.github.Previews.SHADOW_CAT;
|
||||
import static org.kohsuke.github.internal.Previews.SHADOW_CAT;
|
||||
|
||||
/**
|
||||
* Lists up pull requests with some filtering and sorting.
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.net.URL;
|
||||
|
||||
import javax.annotation.CheckForNull;
|
||||
|
||||
import static org.kohsuke.github.Previews.*;
|
||||
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
|
||||
|
||||
/**
|
||||
* Review comment to the pull request
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.kohsuke.github;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import static org.kohsuke.github.Previews.*;
|
||||
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
|
||||
|
||||
/**
|
||||
* Reaction to issue, comment, PR, and so on.
|
||||
|
||||
@@ -57,7 +57,13 @@ import java.util.WeakHashMap;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static java.util.Arrays.*;
|
||||
import static org.kohsuke.github.Previews.*;
|
||||
import static org.kohsuke.github.internal.Previews.ANTIOPE;
|
||||
import static org.kohsuke.github.internal.Previews.ANT_MAN;
|
||||
import static org.kohsuke.github.internal.Previews.BAPTISTE;
|
||||
import static org.kohsuke.github.internal.Previews.FLASH;
|
||||
import static org.kohsuke.github.internal.Previews.INERTIA;
|
||||
import static org.kohsuke.github.internal.Previews.MERCY;
|
||||
import static org.kohsuke.github.internal.Previews.SHADOW_CAT;
|
||||
|
||||
/**
|
||||
* A repository on GitHub.
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.kohsuke.github;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import static org.kohsuke.github.Previews.BAPTISTE;
|
||||
import static org.kohsuke.github.internal.Previews.BAPTISTE;
|
||||
|
||||
abstract class GHRepositoryBuilder<S> extends AbstractBuilder<GHRepository, S> {
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ package org.kohsuke.github;
|
||||
import com.fasterxml.jackson.databind.ObjectReader;
|
||||
import com.fasterxml.jackson.databind.ObjectWriter;
|
||||
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
@@ -37,8 +38,8 @@ import java.util.logging.Logger;
|
||||
import javax.annotation.CheckForNull;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static org.kohsuke.github.Previews.INERTIA;
|
||||
import static org.kohsuke.github.Previews.MACHINE_MAN;
|
||||
import static org.kohsuke.github.internal.Previews.INERTIA;
|
||||
import static org.kohsuke.github.internal.Previews.MACHINE_MAN;
|
||||
|
||||
/**
|
||||
* Root of the GitHub API.
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.kohsuke.github;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.NonNull;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.kohsuke.github.internal.Previews;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.kohsuke.github;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.kohsuke.github.Previews.SQUIRREL_GIRL;
|
||||
import static org.kohsuke.github.internal.Previews.SQUIRREL_GIRL;
|
||||
|
||||
/**
|
||||
* Those {@link GHObject}s that can have {@linkplain GHReaction reactions}.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.kohsuke.github;
|
||||
package org.kohsuke.github.internal;
|
||||
|
||||
/**
|
||||
* Provides the media type strings for GitHub API previews
|
||||
@@ -7,7 +7,7 @@ package org.kohsuke.github;
|
||||
*
|
||||
* @author Kohsuke Kawaguchi
|
||||
*/
|
||||
enum Previews {
|
||||
public enum Previews {
|
||||
|
||||
/**
|
||||
* Check-runs and check-suites
|
||||
21
src/test/java/org/kohsuke/github/GHPullRequestMockTest.java
Normal file
21
src/test/java/org/kohsuke/github/GHPullRequestMockTest.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class GHPullRequestMockTest {
|
||||
|
||||
@Test
|
||||
public void shouldMockGHPullRequest() throws IOException {
|
||||
GHPullRequest pullRequest = mock(GHPullRequest.class);
|
||||
when(pullRequest.isDraft()).thenReturn(true);
|
||||
|
||||
assertTrue("Mock should return true", pullRequest.isDraft());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user