Add Java API for change edits and use it in tests

For some reason, a Java API for change edits didn't exist previously
even though a detailed REST API has been available. Because of that,
tests needed to use internal classes when they interacted with change
edits. Using internal classes is fragile and impedes refactorings.
That's why we should avoid it.

If possible, the structure and behavior of the tests is kept. Some of
them might and should be improved but that's beyond the scope of this
change. Some of the tests are adapted a bit because the internal
classes allow change edits to be created for previous patch sets
which isn't possible when using the REST API (and hence the Java API).

As modifications to the mentioned internal classes are necessary to
properly implement the 'Apply fix' feature of robot comments, it is
crucial that none of the tests use the internal classes directly.
In addition, the tests which will be added for the 'Apply fix' feature
will also need to modify and query change edits, which will be much
easier with the Java API.

Change-Id: I6b455541d1bc1b7a05b5f0507911181b0451829a
This commit is contained in:
Alice Kober-Sotzek
2017-01-16 12:07:13 +01:00
parent 2a82c08023
commit 5dd17b647e
18 changed files with 1454 additions and 544 deletions

View File

@@ -699,9 +699,12 @@ public abstract class AbstractDaemonTest {
return gApi.changes().id(id).get();
}
protected EditInfo getEdit(String id)
protected Optional<EditInfo> getEdit(String id)
throws RestApiException {
return gApi.changes().id(id).getEdit();
return gApi.changes()
.id(id)
.edit()
.get();
}
protected ChangeInfo get(String id, ListChangesOption... options)