summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Trutz2011-04-10 18:25:14 (EDT)
committer Christian Trutz2011-04-10 18:25:14 (EDT)
commitfaa3199eeccbf8be7c870ea57ecff57b5453af2d (patch)
tree8d2aec5566df42719dcf521151537a0a540a8513
parent052abaf070d99db240665456da9af53765438173 (diff)
downloadegit-github-faa3199eeccbf8be7c870ea57ecff57b5453af2d.zip
egit-github-faa3199eeccbf8be7c870ea57ecff57b5453af2d.tar.gz
egit-github-faa3199eeccbf8be7c870ea57ecff57b5453af2d.tar.bz2
Not null unit tests for IssueService#getIssuerefs/changes/52/3052/1
Change-Id: I1e22682fa36f81ec25ccb9aabf872a4c010ce520 Signed-off-by: Christian Trutz <christian.trutz@gmail.com>
-rw-r--r--org.eclipse.mylyn.github-feature/github.target7
-rw-r--r--org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java3
-rw-r--r--org.eclipse.mylyn.github.tests/META-INF/MANIFEST.MF7
-rw-r--r--org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueServiceTest.java61
4 files changed, 74 insertions, 4 deletions
diff --git a/org.eclipse.mylyn.github-feature/github.target b/org.eclipse.mylyn.github-feature/github.target
index a780920..9fbaaac 100644
--- a/org.eclipse.mylyn.github-feature/github.target
+++ b/org.eclipse.mylyn.github-feature/github.target
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde version="3.6"?>
-<target name="Mylyn GitHub Connector Target" sequenceNumber="9">
+<target includeMode="feature" name="Mylyn GitHub Connector Target">
<locations>
<location includeAllPlatforms="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.mylyn.sdk_feature.feature.group" version="3.4.3.v20110131-0200-e3x-8j9F7_FXiI9jRBM4_bFl96vsIL"/>
@@ -9,7 +9,10 @@
</location>
<location includeAllPlatforms="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="com.google.gson" version="1.6.0.v201101131530"/>
-<unit id="org.apache.commons.logging" version="1.1.1.v201101211721"/>
+<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20110124210048/repository"/>
+</location>
+<location includeAllPlatforms="false" includeMode="planner" includeSource="true" type="InstallableUnit">
+<unit id="org.mockito" version="1.8.4.v201006030840"/>
<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/S20110124210048/repository"/>
</location>
</locations>
diff --git a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java
index 5b2d8e9..9798259 100644
--- a/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java
+++ b/org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/github/internal/IssueService.java
@@ -96,6 +96,9 @@ public class IssueService {
*/
public Issue getIssue(String user, String repository, String id)
throws IOException {
+ Assert.isNotNull(user, "User cannot be null"); //$NON-NLS-1$
+ Assert.isNotNull(repository, "Repository cannot be null"); //$NON-NLS-1$
+ Assert.isNotNull(id, "Id cannot be null"); //$NON-NLS-1$
StringBuilder builder = new StringBuilder(
IGitHubConstants.SEGMENT_REPOS);
builder.append('/').append(user).append('/').append(repository);
diff --git a/org.eclipse.mylyn.github.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.github.tests/META-INF/MANIFEST.MF
index 2076b5b..b30a226 100644
--- a/org.eclipse.mylyn.github.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.github.tests/META-INF/MANIFEST.MF
@@ -10,6 +10,9 @@ Require-Bundle: org.junit4;bundle-version="4.5.0",
org.eclipse.jface.text;bundle-version="3.5.0",
org.eclipse.mylyn.tasks.ui;bundle-version="3.2.0",
org.eclipse.equinox.security;bundle-version="1.0.100",
- org.eclipse.mylyn.tasks.core
+ org.eclipse.mylyn.tasks.core,
+ org.eclipse.core.runtime;bundle-version="3.5.0"
Bundle-Vendor: Eclipse EGit
-Import-Package: com.google.gson;version="1.6.0"
+Import-Package: com.google.gson;version="1.6.0",
+ org.mockito;version="1.8.4",
+ org.mockito.runners;version="1.8.4"
diff --git a/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueServiceTest.java b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueServiceTest.java
new file mode 100644
index 0000000..a69265e
--- /dev/null
+++ b/org.eclipse.mylyn.github.tests/src/org/eclipse/mylyn/github/internal/IssueServiceTest.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * 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 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 IssueService}.
+ *
+ * @author Christian Trutz (christian.trutz@gmail.com)
+ */
+@SuppressWarnings("restriction")
+@RunWith(MockitoJUnitRunner.class)
+public class IssueServiceTest {
+
+ @Mock
+ private GitHubClient gitHubClient;
+
+ private IssueService issueService;
+
+ @Before
+ public void before() {
+ issueService = new IssueService(gitHubClient);
+ }
+
+ @Test(expected = AssertionFailedException.class)
+ public void constructor_NullArgument() {
+ new IssueService(null);
+ }
+
+ @Test(expected = AssertionFailedException.class)
+ public void getIssue_NullUser() throws IOException{
+ issueService.getIssue(null, "not null", "not null");
+ }
+
+ @Test(expected = AssertionFailedException.class)
+ public void getIssue_NullRepository() throws IOException{
+ issueService.getIssue("not null", null, "not null");
+ }
+
+ @Test(expected = AssertionFailedException.class)
+ public void getIssue_NullId() throws IOException{
+ issueService.getIssue("not null", "not null", null);
+ }
+
+}