Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Trutz2011-04-20 21:27:25 +0000
committerChristian Trutz2011-04-20 21:27:25 +0000
commita643de5a62bb60c825def6d1c6911863386ef538 (patch)
tree4e1866fd96e911c7240fda3f280de65ef8efaf1b /org.eclipse.mylyn.github.tests
parent1c9e970df80170d28dc664e2085ee3552e6722ab (diff)
downloadegit-github-a643de5a62bb60c825def6d1c6911863386ef538.tar.gz
egit-github-a643de5a62bb60c825def6d1c6911863386ef538.tar.xz
egit-github-a643de5a62bb60c825def6d1c6911863386ef538.zip
Unit tests for GistService#getGist
Change-Id: I49cad2ab4fe81fce5e4068f1956f5ca403667a8d Signed-off-by: Christian Trutz <christian.trutz@gmail.com>
Diffstat (limited to 'org.eclipse.mylyn.github.tests')
-rw-r--r--org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistServiceTest.java57
-rw-r--r--org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/tests/AllHeadlessTests.java4
2 files changed, 60 insertions, 1 deletions
diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistServiceTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistServiceTest.java
new file mode 100644
index 00000000..6f05d4b8
--- /dev/null
+++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/GistServiceTest.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Christian Trutz
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian Trutz - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylyn.github.internal;
+
+import static org.mockito.Mockito.verify;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.AssertionFailedException;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+/**
+ * Unit tests for {@link GistService}
+ */
+@SuppressWarnings("restriction")
+@RunWith(MockitoJUnitRunner.class)
+public class GistServiceTest {
+
+ @Mock
+ private GitHubClient gitHubClient;
+
+ private GistService gistService;
+
+ @Before
+ public void before() {
+ gistService = new GistService(gitHubClient);
+ }
+
+ @Test(expected = AssertionFailedException.class)
+ public void constructor_NullArgument() {
+ new GistService(null);
+ }
+
+ @Test(expected = AssertionFailedException.class)
+ public void getGist_NullId() throws IOException {
+ gistService.getGist(null);
+ }
+
+ @Test
+ public void getGist_OK() throws IOException {
+ gistService.getGist("1");
+ verify(gitHubClient).get("/gists/1.json", Gist.class);
+ }
+
+}
diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/tests/AllHeadlessTests.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/tests/AllHeadlessTests.java
index 561b4e91..c20c5eac 100644
--- a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/tests/AllHeadlessTests.java
+++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/tests/AllHeadlessTests.java
@@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.mylyn.github.tests;
+import org.eclipse.mylyn.github.internal.GistServiceTest;
import org.eclipse.mylyn.github.internal.IssueServiceTest;
import org.eclipse.mylyn.github.internal.LabelServiceTest;
import org.eclipse.mylyn.github.internal.MilestoneServiceTest;
@@ -21,7 +22,8 @@ import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({ //
-IssueServiceTest.class, LabelServiceTest.class, MilestoneServiceTest.class })
+IssueServiceTest.class, LabelServiceTest.class, MilestoneServiceTest.class,
+ GistServiceTest.class })
public class AllHeadlessTests {
}

Back to the top