Examples of Gist


Examples of com.github.api.v2.schema.Gist

   *            the arguments
   */
  public static void main(String[] args) {
    GitHubServiceFactory factory = GitHubServiceFactory.newInstance();
    GistService service = factory.createGistService();
    Gist gist = service.getGist("289179");
    printResult(gist);
    System.out.println(convertStreamToString(service.getGistContent("289179", "TimeZoneDSTUtil.java")));
  }
View Full Code Here

Examples of com.github.api.v2.schema.Gist

  @Override
  public Gist createGist(String userName, String description, Visibility visibility,
      Map<String, String> contents) {
    GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.GistApiUrls.CREATE_GIST_URL);
    String apiUrl = builder.withField(ParameterNames.USER_NAME, userName).buildUrl();
    Gist gist = new Gist();
    gist.setDescription(description);
    gist.setVisibility(visibility);
    for (String filename : contents.keySet()) {
      File file = new File();
      file.setFilename(filename);
      file.setContent(contents.get(filename));
     
      gist.getFiles().put(filename, file);
    }
        JsonObject json = unmarshall(callApiMethod(apiUrl, marshall(gist), ApplicationConstants.CONTENT_TYPE_JSON, HttpMethod.POST, 201));
        return unmarshall(new TypeToken<Gist>(){}, json);
  }
View Full Code Here

Examples of com.github.api.v2.schema.Gist

  @Override
  public Gist updateGist(String gistId, String description,
      Map<String, String> contents) {
    GitHubApiUrlBuilder builder = createGitHubApiUrlBuilder(GitHubApiUrls.GistApiUrls.UPDATE_GIST_URL);
    String apiUrl = builder.withField(ParameterNames.GIST_ID, gistId).buildUrl();
    Gist gist = new Gist();
    gist.setDescription(description);
    for (String filename : contents.keySet()) {
      File file = new File();
      file.setFilename(filename);
      file.setContent(contents.get(filename));
     
      gist.getFiles().put(filename, file);
    }
        JsonObject json = unmarshall(callApiMethod(apiUrl, marshall(gist), ApplicationConstants.CONTENT_TYPE_JSON, HttpMethod.POST, 200));
        return unmarshall(new TypeToken<Gist>(){}, json);
  }
View Full Code Here

Examples of com.github.api.v2.schema.Gist

   * Test get gist.
   */
  @Test
  public void testGetGist() {
      assertNotNullOrEmpty(String.format(RESOURCE_MISSING_MESSAGE, "Test Gist Id."), TestConstants.TEST_GIST_ID);
    Gist gist = service.getGist(TestConstants.TEST_GIST_ID);
    assertNotNull("Gist cannot be null", gist);
  }
View Full Code Here

Examples of com.jcabi.github.Gist

     * MkGists can work with gists.
     * @throws Exception If some problem inside
     */
    @Test
    public void worksWithMockedGists() throws Exception {
        final Gist gist = new MkGithub().gists().create(
            Collections.singletonMap("test-file-name.txt", "none"), false
        );
        final String file = "t.txt";
        gist.write(file, "hello, everybody!");
        MatcherAssert.assertThat(
            gist.read(file),
            Matchers.startsWith("hello, ")
        );
    }
View Full Code Here

Examples of com.jcabi.github.Gist

     * @throws Exception - if anything goes wrong.
     */
    @Test
    public void removesGistByIdentifier() throws Exception {
        final Gists gists = new MkGithub().gists();
        final Gist gist = gists.create(
            Collections.singletonMap("fileName.txt", "content"), false
        );
        MatcherAssert.assertThat(
            gists.iterate(),
            Matchers.hasItem(gist)
        );
        gists.remove(gist.identifier());
        MatcherAssert.assertThat(
            gists.iterate(),
            Matchers.not(Matchers.hasItem(gist))
        );
    }
View Full Code Here

Examples of com.jcabi.github.Gist

     * @throws Exception If some problem inside
     */
    @Test
    public void worksWithSeveralGists() throws Exception {
        final Gists gists = new MkGithub().gists();
        final Gist gist = gists.create(
            Collections.singletonMap("test-file-name.txt", "none"), false
        );
        final Gist othergist = gists.create(
            Collections.singletonMap("test-file-name2.txt", ""), false
        );
        final String file = "t.txt";
        gist.write(file, "hello, everybody!");
        othergist.write(file, "bye, everybody!");
        MatcherAssert.assertThat(
            gist.read(file),
            Matchers.startsWith("hello, ")
        );
        MatcherAssert.assertThat(
            othergist.read(file),
            Matchers.startsWith("bye, ")
        );
    }
View Full Code Here

Examples of com.jcabi.github.Gist

     * Test starring and star-checking of a gist.
     * @throws Exception If some problem inside
     */
    @Test
    public void testStar() throws Exception {
        final Gist gist = new MkGithub().gists().create(
            Collections.singletonMap("file-name.txt", ""), false
        );
        MatcherAssert.assertThat(
            gist.starred(),
            Matchers.equalTo(false)
        );
        gist.star();
        MatcherAssert.assertThat(
            gist.starred(),
            Matchers.equalTo(true)
        );
    }
View Full Code Here

Examples of com.jcabi.github.Gist

     * Test unstarring and star-checking of a gist.
     * @throws Exception If some problem inside
     */
    @Test
    public void testUnstar() throws Exception {
        final Gist gist = new MkGithub().gists().create(
            Collections.singletonMap("file-name.txt", ""), false
        );
        MatcherAssert.assertThat(
            gist.starred(),
            Matchers.equalTo(false)
        );
        gist.star();
        MatcherAssert.assertThat(
            gist.starred(),
            Matchers.equalTo(true)
        );
        gist.unstar();
        MatcherAssert.assertThat(
            gist.starred(),
            Matchers.equalTo(false)
        );
    }
View Full Code Here

Examples of com.jcabi.github.Gist

     * @throws IOException If some problem inside
     */
    @Test
    public void createGistWithEmptyFile() throws IOException {
        final String filename = "file.txt";
        final Gist gist = new MkGithub().gists().create(
            Collections.singletonMap(filename, ""), false
        );
        MatcherAssert.assertThat(
            gist.read(filename),
            Matchers.isEmptyString()
        );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.