Acceptance tests: Remove duplicated JSON container classes
This change makes it possible to reuse server side classes for both input and output JSON container classes. To solve the mismatch between server-side CamelCase and lower case with underscore the field naming policy is set to FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES in GsonBuilder in RestSession in acceptance framework. Now we can remove dozen of duplicated classes in acceptance framework. Change-Id: Icdc7f63a38c304f3a744a7a12b768cda2504a55e
This commit is contained in:
@@ -98,12 +98,9 @@ public class ListBranches implements RestReadView<ProjectResource> {
|
||||
target = target.substring(Constants.R_HEADS.length());
|
||||
}
|
||||
|
||||
BranchInfo b = new BranchInfo();
|
||||
b.ref = ref.getName();
|
||||
b.revision = target;
|
||||
BranchInfo b = new BranchInfo(ref.getName(), target, false);
|
||||
|
||||
if (Constants.HEAD.equals(ref.getName())) {
|
||||
b.setCanDelete(false);
|
||||
headBranch = b;
|
||||
} else {
|
||||
b.setCanDelete(targetRefControl.canDelete());
|
||||
@@ -141,13 +138,9 @@ public class ListBranches implements RestReadView<ProjectResource> {
|
||||
|
||||
private static BranchInfo createBranchInfo(Ref ref, RefControl refControl,
|
||||
Set<String> targets) {
|
||||
BranchInfo b = new BranchInfo();
|
||||
b.ref = ref.getName();
|
||||
if (ref.getObjectId() != null) {
|
||||
b.revision = ref.getObjectId().name();
|
||||
}
|
||||
b.setCanDelete(!targets.contains(ref.getName()) && refControl.canDelete());
|
||||
return b;
|
||||
return new BranchInfo(ref.getName(),
|
||||
ref.getObjectId() != null ? ref.getObjectId().name() : null,
|
||||
!targets.contains(ref.getName()) && refControl.canDelete());
|
||||
}
|
||||
|
||||
public static class BranchInfo {
|
||||
@@ -155,6 +148,12 @@ public class ListBranches implements RestReadView<ProjectResource> {
|
||||
public String revision;
|
||||
public Boolean canDelete;
|
||||
|
||||
public BranchInfo(String ref, String revision, boolean canDelete) {
|
||||
this.ref = ref;
|
||||
this.revision = revision;
|
||||
this.canDelete = canDelete;
|
||||
}
|
||||
|
||||
void setCanDelete(boolean canDelete) {
|
||||
this.canDelete = canDelete ? true : null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user