Search in sources :

Example 6 with FileContent

use of org.jetbrains.plugins.github.api.requests.GithubGistRequest.FileContent in project intellij-community by JetBrains.

the class GithubCreateGistContentTest method testCreateFromEditorWithoutFile.

public void testCreateFromEditorWithoutFile() throws Throwable {
    VirtualFile file = myProjectRoot.findFileByRelativePath("file.txt");
    assertNotNull(file);
    Document document = FileDocumentManager.getInstance().getDocument(file);
    assertNotNull(document);
    myEditor = EditorFactory.getInstance().createEditor(document, myProject);
    assertNotNull(myEditor);
    List<FileContent> expected = new ArrayList<>();
    expected.add(new FileContent("", "file.txt content"));
    List<FileContent> actual = GithubCreateGistAction.collectContents(myProject, myEditor, null, null);
    checkEquals(expected, actual);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileContent(org.jetbrains.plugins.github.api.requests.GithubGistRequest.FileContent) ArrayList(java.util.ArrayList) Document(com.intellij.openapi.editor.Document)

Example 7 with FileContent

use of org.jetbrains.plugins.github.api.requests.GithubGistRequest.FileContent in project intellij-community by JetBrains.

the class GithubCreateGistContentTest method testCreateFromFiles.

public void testCreateFromFiles() throws Throwable {
    List<FileContent> expected = new ArrayList<>();
    expected.add(new FileContent("file.txt", "file.txt content"));
    expected.add(new FileContent("file2", "file2 content"));
    expected.add(new FileContent("file3", "file3 content"));
    VirtualFile[] files = new VirtualFile[3];
    files[0] = myProjectRoot.findFileByRelativePath("file.txt");
    files[1] = myProjectRoot.findFileByRelativePath("folder/file2");
    files[2] = myProjectRoot.findFileByRelativePath("folder/dir/file3");
    assertNotNull(files[0]);
    assertNotNull(files[1]);
    assertNotNull(files[2]);
    List<FileContent> actual = GithubCreateGistAction.collectContents(myProject, null, null, files);
    checkEquals(expected, actual);
}
Also used : FileContent(org.jetbrains.plugins.github.api.requests.GithubGistRequest.FileContent) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ArrayList(java.util.ArrayList)

Example 8 with FileContent

use of org.jetbrains.plugins.github.api.requests.GithubGistRequest.FileContent in project intellij-community by JetBrains.

the class GithubCreateGistContentTest method testCreateFromFile.

public void testCreateFromFile() throws Throwable {
    List<FileContent> expected = new ArrayList<>();
    expected.add(new FileContent("file.txt", "file.txt content"));
    VirtualFile file = myProjectRoot.findFileByRelativePath("file.txt");
    assertNotNull(file);
    List<FileContent> actual = GithubCreateGistAction.collectContents(myProject, null, file, null);
    checkEquals(expected, actual);
}
Also used : FileContent(org.jetbrains.plugins.github.api.requests.GithubGistRequest.FileContent) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ArrayList(java.util.ArrayList)

Example 9 with FileContent

use of org.jetbrains.plugins.github.api.requests.GithubGistRequest.FileContent in project intellij-community by JetBrains.

the class GithubCreateGistContentTest method testCreateFromEditor.

public void testCreateFromEditor() throws Throwable {
    VirtualFile file = myProjectRoot.findFileByRelativePath("file.txt");
    assertNotNull(file);
    Document document = FileDocumentManager.getInstance().getDocument(file);
    assertNotNull(document);
    myEditor = EditorFactory.getInstance().createEditor(document, myProject);
    assertNotNull(myEditor);
    List<FileContent> expected = new ArrayList<>();
    expected.add(new FileContent("file.txt", "file.txt content"));
    List<FileContent> actual = GithubCreateGistAction.collectContents(myProject, myEditor, file, null);
    checkEquals(expected, actual);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileContent(org.jetbrains.plugins.github.api.requests.GithubGistRequest.FileContent) ArrayList(java.util.ArrayList) Document(com.intellij.openapi.editor.Document)

Example 10 with FileContent

use of org.jetbrains.plugins.github.api.requests.GithubGistRequest.FileContent in project intellij-community by JetBrains.

the class GithubCreateGistTest method testUsedFilenameField.

public void testUsedFilenameField() throws Throwable {
    List<FileContent> content = Collections.singletonList(new FileContent("file.txt", "file.txt content"));
    List<FileContent> expected = Collections.singletonList(new FileContent("filename", "file.txt content"));
    String url = GithubCreateGistAction.createGist(myProject, getAuthDataHolder(), myIndicator, content, true, GIST_DESCRIPTION, "filename");
    assertNotNull(url);
    GIST_ID = url.substring(url.lastIndexOf('/') + 1);
    checkGistExists();
    checkGistNotAnonymous();
    checkGistPrivate();
    checkGistDescription(GIST_DESCRIPTION);
    checkGistContent(expected);
}
Also used : FileContent(org.jetbrains.plugins.github.api.requests.GithubGistRequest.FileContent)

Aggregations

FileContent (org.jetbrains.plugins.github.api.requests.GithubGistRequest.FileContent)14 ArrayList (java.util.ArrayList)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 Document (com.intellij.openapi.editor.Document)4 NotNull (org.jetbrains.annotations.NotNull)4 IOException (java.io.IOException)2 BrowserUtil (com.intellij.ide.BrowserUtil)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)1 ReadAction (com.intellij.openapi.application.ReadAction)1 Logger (com.intellij.openapi.diagnostic.Logger)1 Editor (com.intellij.openapi.editor.Editor)1 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)1 FileTypeManager (com.intellij.openapi.fileTypes.FileTypeManager)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)1 Project (com.intellij.openapi.project.Project)1 Ref (com.intellij.openapi.util.Ref)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1