Search in sources :

Example 21 with Revision

use of org.eclipse.che.api.git.shared.Revision in project che by eclipse.

the class LogTest method testLogSince.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void testLogSince(GitConnectionFactory connectionFactory) throws GitException, IOException, InterruptedException {
    //given
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    addFile(connection, "1.txt", "someChanges");
    connection.add(AddParams.create());
    String firstCommitId = connection.commit(CommitParams.create("add 1.txt file")).getId();
    addFile(connection, "2.txt", "secondChanges");
    connection.add(AddParams.create());
    String secondCommitId = connection.commit(CommitParams.create("add 2.txt file")).getId();
    addFile(connection, "3.txt", "thirdChanges");
    connection.add(AddParams.create());
    String thirdCommitId = connection.commit(CommitParams.create("add 3.txt file")).getId();
    addFile(connection, "4.txt", "fourthChanges");
    connection.add(AddParams.create());
    String fourthCommitId = connection.commit(CommitParams.create("add 4.txt file")).getId();
    //when
    List<Revision> allCommits = connection.log(LogParams.create()).getCommits();
    List<Revision> secondAndThirdAndFourthCommits = connection.log(LogParams.create().withRevisionRangeSince(firstCommitId).withRevisionRangeUntil(fourthCommitId)).getCommits();
    List<Revision> thirdAndFourthCommits = connection.log(LogParams.create().withRevisionRangeSince(secondCommitId).withRevisionRangeUntil(fourthCommitId)).getCommits();
    //then
    assertEquals(4, allCommits.size());
    assertEquals(3, secondAndThirdAndFourthCommits.size());
    assertEquals(2, thirdAndFourthCommits.size());
    assertEquals(secondAndThirdAndFourthCommits.get(0).getMessage(), "add 4.txt file");
    assertEquals(secondAndThirdAndFourthCommits.get(1).getMessage(), "add 3.txt file");
    assertEquals(secondAndThirdAndFourthCommits.get(2).getMessage(), "add 2.txt file");
    assertEquals(thirdAndFourthCommits.get(0).getMessage(), "add 4.txt file");
    assertEquals(thirdAndFourthCommits.get(1).getMessage(), "add 3.txt file");
}
Also used : Revision(org.eclipse.che.api.git.shared.Revision) GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 22 with Revision

use of org.eclipse.che.api.git.shared.Revision in project che by eclipse.

the class LogTest method testLogWithSkipAndMaxCount.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void testLogWithSkipAndMaxCount(GitConnectionFactory connectionFactory) throws GitException, IOException {
    //given
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    addFile(connection, "1.txt", "someChanges");
    connection.add(AddParams.create());
    connection.commit(CommitParams.create("add 1.txt file"));
    addFile(connection, "2.txt", "newChanges");
    connection.add(AddParams.create());
    connection.commit(CommitParams.create("add 2.txt file"));
    addFile(connection, "3.txt", "otherChanges");
    connection.add(AddParams.create());
    connection.commit(CommitParams.create("add 3.txt file"));
    addFile(connection, "4.txt", "someChanges");
    connection.add(AddParams.create());
    connection.commit(CommitParams.create("add 4.txt file"));
    //when
    List<Revision> allCommits = connection.log(LogParams.create()).getCommits();
    List<Revision> firstBacketOfCommits = connection.log(LogParams.create().withSkip(1).withMaxCount(2)).getCommits();
    List<Revision> secondBacketOfCommits = connection.log(LogParams.create().withSkip(2).withMaxCount(2)).getCommits();
    //then
    assertEquals(4, allCommits.size());
    assertEquals(2, firstBacketOfCommits.size());
    assertEquals(firstBacketOfCommits.get(0).getMessage(), "add 3.txt file");
    assertEquals(firstBacketOfCommits.get(0).getBranches().get(0).getName(), "refs/heads/master");
    assertEquals(firstBacketOfCommits.get(0).getDiffCommitFile().get(0).getOldPath(), "/dev/null");
    assertEquals(firstBacketOfCommits.get(0).getDiffCommitFile().get(0).getNewPath(), "3.txt");
    assertEquals(firstBacketOfCommits.get(0).getDiffCommitFile().get(0).getChangeType(), "ADD");
    assertEquals(firstBacketOfCommits.get(1).getMessage(), "add 2.txt file");
    assertEquals(firstBacketOfCommits.get(1).getBranches().get(0).getName(), "refs/heads/master");
    assertEquals(firstBacketOfCommits.get(1).getDiffCommitFile().get(0).getOldPath(), "/dev/null");
    assertEquals(firstBacketOfCommits.get(1).getDiffCommitFile().get(0).getNewPath(), "2.txt");
    assertEquals(firstBacketOfCommits.get(1).getDiffCommitFile().get(0).getChangeType(), "ADD");
    assertEquals(2, secondBacketOfCommits.size());
    assertEquals(secondBacketOfCommits.get(0).getMessage(), "add 2.txt file");
    assertEquals(secondBacketOfCommits.get(0).getBranches().get(0).getName(), "refs/heads/master");
    assertEquals(secondBacketOfCommits.get(0).getDiffCommitFile().get(0).getOldPath(), "/dev/null");
    assertEquals(secondBacketOfCommits.get(0).getDiffCommitFile().get(0).getNewPath(), "2.txt");
    assertEquals(secondBacketOfCommits.get(0).getDiffCommitFile().get(0).getChangeType(), "ADD");
    assertEquals(secondBacketOfCommits.get(1).getMessage(), "add 1.txt file");
    assertEquals(secondBacketOfCommits.get(1).getBranches().get(0).getName(), "refs/heads/master");
    assertEquals(secondBacketOfCommits.get(1).getDiffCommitFile().get(0).getOldPath(), "/dev/null");
    assertEquals(secondBacketOfCommits.get(1).getDiffCommitFile().get(0).getNewPath(), "1.txt");
    assertEquals(secondBacketOfCommits.get(1).getDiffCommitFile().get(0).getChangeType(), "ADD");
}
Also used : Revision(org.eclipse.che.api.git.shared.Revision) GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Example 23 with Revision

use of org.eclipse.che.api.git.shared.Revision in project che by eclipse.

the class LogTest method testLogMaxCount.

@Test(dataProvider = "GitConnectionFactory", dataProviderClass = GitConnectionFactoryProvider.class)
public void testLogMaxCount(GitConnectionFactory connectionFactory) throws GitException, IOException {
    //given
    GitConnection connection = connectToInitializedGitRepository(connectionFactory, repository);
    addFile(connection, "1.txt", "someChanges");
    connection.add(AddParams.create());
    connection.commit(CommitParams.create("add 1.txt file"));
    addFile(connection, "2.txt", "newChanges");
    connection.add(AddParams.create());
    connection.commit(CommitParams.create("add 2.txt file"));
    addFile(connection, "3.txt", "otherChanges");
    connection.add(AddParams.create());
    connection.commit(CommitParams.create("add 3.txt file"));
    addFile(connection, "4.txt", "someChanges");
    connection.add(AddParams.create());
    connection.commit(CommitParams.create("add 4.txt file"));
    //when
    List<Revision> allCommits = connection.log(LogParams.create()).getCommits();
    List<Revision> firstBucketOfCommits = connection.log(LogParams.create().withMaxCount(4)).getCommits();
    List<Revision> secondBucketOfCommits = connection.log(LogParams.create().withMaxCount(2)).getCommits();
    //then
    assertEquals(4, allCommits.size());
    assertEquals(4, firstBucketOfCommits.size());
    assertEquals(firstBucketOfCommits.get(0).getMessage(), "add 4.txt file");
    assertEquals(firstBucketOfCommits.get(1).getMessage(), "add 3.txt file");
    assertEquals(firstBucketOfCommits.get(2).getMessage(), "add 2.txt file");
    assertEquals(firstBucketOfCommits.get(3).getMessage(), "add 1.txt file");
    assertEquals(2, secondBucketOfCommits.size());
    assertEquals(secondBucketOfCommits.get(0).getMessage(), "add 4.txt file");
    assertEquals(secondBucketOfCommits.get(1).getMessage(), "add 3.txt file");
}
Also used : Revision(org.eclipse.che.api.git.shared.Revision) GitConnection(org.eclipse.che.api.git.GitConnection) Test(org.testng.annotations.Test)

Aggregations

Revision (org.eclipse.che.api.git.shared.Revision)23 GitConnection (org.eclipse.che.api.git.GitConnection)10 Test (org.testng.annotations.Test)9 ArrayList (java.util.ArrayList)6 LogResponse (org.eclipse.che.api.git.shared.LogResponse)5 BaseTest (org.eclipse.che.ide.ext.git.client.BaseTest)5 Test (org.junit.Test)5 CommitParams (org.eclipse.che.api.git.params.CommitParams)4 TextCell (com.google.gwt.cell.client.TextCell)3 Column (com.google.gwt.user.cellview.client.Column)3 SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)3 GitUser (org.eclipse.che.api.git.shared.GitUser)3 DoubleClickEvent (com.google.gwt.event.dom.client.DoubleClickEvent)2 DoubleClickHandler (com.google.gwt.event.dom.client.DoubleClickHandler)2 IOException (java.io.IOException)2 Date (java.util.Date)2 LogPage (org.eclipse.che.api.git.LogPage)2 GitException (org.eclipse.che.api.git.exception.GitException)2 Branch (org.eclipse.che.api.git.shared.Branch)2 CommitRequest (org.eclipse.che.api.git.shared.CommitRequest)2