diff options
author | Kevin Sawicki | 2012-09-22 17:26:39 +0000 |
---|---|---|
committer | Kevin Sawicki | 2012-09-22 17:26:39 +0000 |
commit | 6e8dd15c95ba0c3d7fdea8fad177dc7389609357 (patch) | |
tree | 71b7e0777369e15315f9a5eaac3154b77865ed79 /org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests | |
parent | fe350995bfaf999334789c34baf91241bd88b478 (diff) | |
download | egit-github-6e8dd15c95ba0c3d7fdea8fad177dc7389609357.tar.gz egit-github-6e8dd15c95ba0c3d7fdea8fad177dc7389609357.tar.xz egit-github-6e8dd15c95ba0c3d7fdea8fad177dc7389609357.zip |
Add service support for Markdown API
Change-Id: Ief3262ab239f10be11ecca0a2c3f043ef673eaee
Diffstat (limited to 'org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests')
2 files changed, 92 insertions, 0 deletions
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java index 5d50e1fd..927d2841 100644 --- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java +++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java @@ -63,6 +63,7 @@ import org.junit.runners.Suite.SuiteClasses; LabelServiceTest.class, // LabelTest.class, // LanguageTest.class, // + MarkdownServiceTest.class, // MergeStatusTest.class, // MilestoneComparatorTest.class, // MilestoneServiceTest.class, // diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/MarkdownServiceTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/MarkdownServiceTest.java new file mode 100644 index 00000000..09a24039 --- /dev/null +++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/MarkdownServiceTest.java @@ -0,0 +1,91 @@ +/****************************************************************************** + * Copyright (c) 2012 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: + * Kevin Sawicki (GitHub Inc.) - initial API and implementation + *****************************************************************************/ +package org.eclipse.egit.github.core.tests; + +import static org.eclipse.egit.github.core.client.IGitHubConstants.CHARSET_UTF8; +import static org.eclipse.egit.github.core.service.MarkdownService.MODE_MARKDOWN; +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doReturn; + +import java.io.ByteArrayInputStream; +import java.io.IOException; + +import org.eclipse.egit.github.core.RepositoryId; +import org.eclipse.egit.github.core.client.GitHubClient; +import org.eclipse.egit.github.core.service.MarkdownService; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; + +/** + * Unit tests of {@link MarkdownService} + */ +@RunWith(MockitoJUnitRunner.class) +public class MarkdownServiceTest { + + @Mock + private GitHubClient client; + + private MarkdownService service; + + private RepositoryId repo; + + private String content; + + /** + * Test case set up + * + * @throws IOException + */ + @Before + public void before() throws IOException { + content = "<p>content</p>"; + ByteArrayInputStream stream = new ByteArrayInputStream( + content.getBytes(CHARSET_UTF8)); + doReturn(stream).when(client).postStream(any(String.class), + any(Object.class)); + service = new MarkdownService(client); + repo = new RepositoryId("o", "n"); + } + + /** + * Get repository HTML + * + * @throws Exception + */ + @Test + public void getRepositoryHtml() throws Exception { + assertEquals(content, service.getRepositoryHtml(repo, "input")); + } + + /** + * Get repository HTML + * + * @throws Exception + */ + @Test(expected = IllegalArgumentException.class) + public void getRepositoryHtmlNullRepository() throws Exception { + service.getRepositoryHtml(null, "input"); + } + + /** + * Get HTML + * + * @throws Exception + */ + @Test + public void getHtml() throws Exception { + assertEquals(content, service.getHtml("input", MODE_MARKDOWN)); + } +} |