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");
}
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");
}
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");
}
Aggregations