{
boolean isCreated = false;
String[] commitMsgs = { "initial commit", "First commit" };
Project project = projectFactory.createTempProject();
Git repo = gitUtils.init(project.getRootDirectory());
gitUtils.addAll(repo);
gitUtils.commitAll(repo, commitMsgs[0]);
FileResource<?> file1 = project.getRootDirectory().getChild("test.txt").reify(FileResource.class);
isCreated = file1.createNewFile();
Assert.assertTrue("file 1 was not created", isCreated);
file1.setContents("Foo bar baz contents");
gitUtils.addAll(repo);
gitUtils.stashCreate(repo);
Assert.assertTrue("should contain one stash", repo.stashList().call().iterator().hasNext());
gitUtils.stashApply(repo);
gitUtils.addAll(repo);
gitUtils.commit(repo, commitMsgs[1]);
gitUtils.stashDrop(repo);
List<String> logs = gitUtils.getLogForCurrentBranch(repo);
Collections.reverse(logs); // git-log shows logs in DESC order
Assert.assertNotNull("log should not be null", logs);
Assert.assertEquals("log should contain two items", 2, logs.size());
Assert.assertEquals("commit messages should be the same", commitMsgs[0], logs.get(0));
Assert.assertEquals("commit messages should be the same", commitMsgs[1], logs.get(1));
Assert.assertFalse("should contain no stashes", repo.stashList().call().iterator().hasNext());
}