Browse Source

Add missing javadoc in org.eclipse.jgit.junit

Change-Id: Ib709ef050bec31c87f542fb2cc977863dda93ef9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.1
Matthias Sohn 5 years ago
parent
commit
376c20f454
  1. 18
      org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepeatRule.java
  2. 139
      org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java

18
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepeatRule.java

@ -81,13 +81,31 @@ public class RepeatRule implements TestRule {
private static Logger LOG = Logger private static Logger LOG = Logger
.getLogger(RepeatRule.class.getName()); .getLogger(RepeatRule.class.getName());
/**
* Exception thrown if repeated execution of a test annotated with
* {@code @Repeat} failed.
*/
public static class RepeatedTestException extends RuntimeException { public static class RepeatedTestException extends RuntimeException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**
* Constructor
*
* @param message
* the error message
*/
public RepeatedTestException(String message) { public RepeatedTestException(String message) {
super(message); super(message);
} }
/**
* Constructor
*
* @param message
* the error message
* @param cause
* exception causing this exception
*/
public RepeatedTestException(String message, Throwable cause) { public RepeatedTestException(String message, Throwable cause) {
super(message, cause); super(message, cause);
} }

139
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java

@ -1059,6 +1059,14 @@ public class TestRepository<R extends Repository> {
parents.add(prior.create()); parents.add(prior.create());
} }
/**
* set parent commit
*
* @param p
* parent commit
* @return this commit builder
* @throws Exception
*/
public CommitBuilder parent(RevCommit p) throws Exception { public CommitBuilder parent(RevCommit p) throws Exception {
if (parents.isEmpty()) { if (parents.isEmpty()) {
DirCacheBuilder b = tree.builder(); DirCacheBuilder b = tree.builder();
@ -1071,29 +1079,71 @@ public class TestRepository<R extends Repository> {
return this; return this;
} }
/**
* Get parent commits
*
* @return parent commits
*/
public List<RevCommit> parents() { public List<RevCommit> parents() {
return Collections.unmodifiableList(parents); return Collections.unmodifiableList(parents);
} }
/**
* Remove parent commits
*
* @return this commit builder
*/
public CommitBuilder noParents() { public CommitBuilder noParents() {
parents.clear(); parents.clear();
return this; return this;
} }
/**
* Remove files
*
* @return this commit builder
*/
public CommitBuilder noFiles() { public CommitBuilder noFiles() {
tree.clear(); tree.clear();
return this; return this;
} }
/**
* Set top level tree
*
* @param treeId
* the top level tree
* @return this commit builder
*/
public CommitBuilder setTopLevelTree(ObjectId treeId) { public CommitBuilder setTopLevelTree(ObjectId treeId) {
topLevelTree = treeId; topLevelTree = treeId;
return this; return this;
} }
/**
* Add file with given content
*
* @param path
* path of the file
* @param content
* the file content
* @return this commit builder
* @throws Exception
*/
public CommitBuilder add(String path, String content) throws Exception { public CommitBuilder add(String path, String content) throws Exception {
return add(path, blob(content)); return add(path, blob(content));
} }
/**
* Add file with given path and blob
*
* @param path
* path of the file
* @param id
* blob for this file
* @return this commit builder
* @throws Exception
*/
public CommitBuilder add(String path, RevBlob id) public CommitBuilder add(String path, RevBlob id)
throws Exception { throws Exception {
return edit(new PathEdit(path) { return edit(new PathEdit(path) {
@ -1105,6 +1155,13 @@ public class TestRepository<R extends Repository> {
}); });
} }
/**
* Edit the index
*
* @param edit
* the index record update
* @return this commit builder
*/
public CommitBuilder edit(PathEdit edit) { public CommitBuilder edit(PathEdit edit) {
DirCacheEditor e = tree.editor(); DirCacheEditor e = tree.editor();
e.add(edit); e.add(edit);
@ -1112,6 +1169,13 @@ public class TestRepository<R extends Repository> {
return this; return this;
} }
/**
* Remove a file
*
* @param path
* path of the file
* @return this commit builder
*/
public CommitBuilder rm(String path) { public CommitBuilder rm(String path) {
DirCacheEditor e = tree.editor(); DirCacheEditor e = tree.editor();
e.add(new DeletePath(path)); e.add(new DeletePath(path));
@ -1120,49 +1184,111 @@ public class TestRepository<R extends Repository> {
return this; return this;
} }
/**
* Set commit message
*
* @param m
* the message
* @return this commit builder
*/
public CommitBuilder message(String m) { public CommitBuilder message(String m) {
message = m; message = m;
return this; return this;
} }
/**
* Get the commit message
*
* @return the commit message
*/
public String message() { public String message() {
return message; return message;
} }
/**
* Tick the clock
*
* @param secs
* number of seconds
* @return this commit builder
*/
public CommitBuilder tick(int secs) { public CommitBuilder tick(int secs) {
tick = secs; tick = secs;
return this; return this;
} }
/**
* Set author and committer identity
*
* @param ident
* identity to set
* @return this commit builder
*/
public CommitBuilder ident(PersonIdent ident) { public CommitBuilder ident(PersonIdent ident) {
author = ident; author = ident;
committer = ident; committer = ident;
return this; return this;
} }
/**
* Set the author identity
*
* @param a
* the author's identity
* @return this commit builder
*/
public CommitBuilder author(PersonIdent a) { public CommitBuilder author(PersonIdent a) {
author = a; author = a;
return this; return this;
} }
/**
* Get the author identity
*
* @return the author identity
*/
public PersonIdent author() { public PersonIdent author() {
return author; return author;
} }
/**
* Set the committer identity
*
* @param c
* the committer identity
* @return this commit builder
*/
public CommitBuilder committer(PersonIdent c) { public CommitBuilder committer(PersonIdent c) {
committer = c; committer = c;
return this; return this;
} }
/**
* Get the committer identity
*
* @return the committer identity
*/
public PersonIdent committer() { public PersonIdent committer() {
return committer; return committer;
} }
/**
* Insert changeId
*
* @return this commit builder
*/
public CommitBuilder insertChangeId() { public CommitBuilder insertChangeId() {
changeId = ""; changeId = "";
return this; return this;
} }
/**
* Insert given changeId
*
* @param c
* changeId
* @return this commit builder
*/
public CommitBuilder insertChangeId(String c) { public CommitBuilder insertChangeId(String c) {
// Validate, but store as a string so we can use "" as a sentinel. // Validate, but store as a string so we can use "" as a sentinel.
ObjectId.fromString(c); ObjectId.fromString(c);
@ -1170,6 +1296,13 @@ public class TestRepository<R extends Repository> {
return this; return this;
} }
/**
* Create the commit
*
* @return the new commit
* @throws Exception
* if creation failed
*/
public RevCommit create() throws Exception { public RevCommit create() throws Exception {
if (self == null) { if (self == null) {
TestRepository.this.tick(tick); TestRepository.this.tick(tick);
@ -1230,6 +1363,12 @@ public class TestRepository<R extends Repository> {
+ cid.getName() + "\n"); //$NON-NLS-1$ + cid.getName() + "\n"); //$NON-NLS-1$
} }
/**
* Create child commit builder
*
* @return child commit builder
* @throws Exception
*/
public CommitBuilder child() throws Exception { public CommitBuilder child() throws Exception {
return new CommitBuilder(this); return new CommitBuilder(this);
} }

Loading…
Cancel
Save