Search in sources :

Example 56 with GitConnection

use of org.eclipse.che.api.git.GitConnection in project che by eclipse.

the class TagListTest method testTagList.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testTagList(GitConnectionFactory connectionFactory) throws GitException, IOException {
    GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository);
    connection.tagCreate(TagCreateParams.create("first-tag"));
    connection.tagCreate(TagCreateParams.create("first-tag-other"));
    connection.tagCreate(TagCreateParams.create("second-tag"));
    assertTags(connection.tagList(null), "first-tag", "first-tag-other", "second-tag");
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 57 with GitConnection

use of org.eclipse.che.api.git.GitConnection in project che by eclipse.

the class StatusTest method testAdded.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testAdded(GitConnectionFactory connectionFactory) throws Exception {
    //given
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    addFile(connection, "a", "a content");
    addFile(connection, "b", "b content");
    addFile(connection, "c", "c content");
    //add "a" and "b" files
    connection.add(AddParams.create(ImmutableList.of("a", "b")));
    //when
    final Status status = connection.status(StatusFormat.SHORT);
    //then
    assertEquals(status.getAdded(), ImmutableList.of("a", "b"));
    assertEquals(status.getUntracked(), ImmutableList.of("c"));
    assertTrue(status.getChanged().isEmpty());
    assertTrue(status.getConflicting().isEmpty());
    assertTrue(status.getMissing().isEmpty());
    assertTrue(status.getRemoved().isEmpty());
    assertTrue(status.getUntrackedFolders().isEmpty());
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 58 with GitConnection

use of org.eclipse.che.api.git.GitConnection in project che by eclipse.

the class StatusTest method testMissing.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testMissing(GitConnectionFactory connectionFactory) throws Exception {
    //given
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    addFile(connection, "a", "content of a");
    //add "a"
    connection.add(AddParams.create(ImmutableList.of("a")));
    //delete "a"
    deleteFile(connection, "a");
    //when
    final Status status = connection.status(StatusFormat.SHORT);
    //then
    assertEquals(status.getMissing(), ImmutableList.of("a"));
    assertEquals(status.getAdded(), ImmutableList.of("a"));
    assertTrue(status.getChanged().isEmpty());
    assertTrue(status.getConflicting().isEmpty());
    assertTrue(status.getRemoved().isEmpty());
    assertTrue(status.getUntracked().isEmpty());
    assertTrue(status.getUntrackedFolders().isEmpty());
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 59 with GitConnection

use of org.eclipse.che.api.git.GitConnection in project che by eclipse.

the class TagDeleteTest method testDeleteTag.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testDeleteTag(GitConnectionFactory connectionFactory) throws GitException, IOException {
    //given
    //create tags
    GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository);
    connection.tagCreate(TagCreateParams.create("first-tag"));
    connection.tagCreate(TagCreateParams.create("second-tag"));
    List<Tag> tags = connection.tagList(null);
    assertTrue(tagExists(tags, "first-tag"));
    assertTrue(tagExists(tags, "second-tag"));
    //when
    //delete first-tag
    connection.tagDelete("first-tag");
    //then
    //check not exists more
    tags = connection.tagList(null);
    assertFalse(tagExists(tags, "first-tag"));
    assertTrue(tagExists(tags, "second-tag"));
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 60 with GitConnection

use of org.eclipse.che.api.git.GitConnection in project che by eclipse.

the class TagListTest method testTagListPattern.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = org.eclipse.che.git.impl.GitConnectionFactoryProvider.class)
public void testTagListPattern(GitConnectionFactory connectionFactory) throws GitException, IOException {
    GitConnection connection = connectToGitRepositoryWithContent(connectionFactory, repository);
    connection.tagCreate(TagCreateParams.create("first-tag"));
    connection.tagCreate(TagCreateParams.create("first-tag-other"));
    connection.tagCreate(TagCreateParams.create("second-tag"));
    assertTags(connection.tagList("first*"), "first-tag", "first-tag-other");
}
Also used : GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Aggregations

GitConnection (org.eclipse.che.api.git.GitConnection)102 Test (org.testng.annotations.Test)100 File (java.io.File)19 GitTestUtil.addFile (org.eclipse.che.git.impl.GitTestUtil.addFile)16 Revision (org.eclipse.che.api.git.shared.Revision)9 ArrayList (java.util.ArrayList)6 CommitParams (org.eclipse.che.api.git.params.CommitParams)5 FileOutputStream (java.io.FileOutputStream)3 MergeResult (org.eclipse.che.api.git.shared.MergeResult)3 DiffPage (org.eclipse.che.api.git.DiffPage)2 GitException (org.eclipse.che.api.git.exception.GitException)2 DiffParams (org.eclipse.che.api.git.params.DiffParams)2 ShowFileContentResponse (org.eclipse.che.api.git.shared.ShowFileContentResponse)2 Path (java.nio.file.Path)1 HashSet (java.util.HashSet)1 LineConsumer (org.eclipse.che.api.core.util.LineConsumer)1 LineConsumerFactory (org.eclipse.che.api.core.util.LineConsumerFactory)1 PullParams (org.eclipse.che.api.git.params.PullParams)1 RemoteAddParams (org.eclipse.che.api.git.params.RemoteAddParams)1 RemoteUpdateParams (org.eclipse.che.api.git.params.RemoteUpdateParams)1