Convert project REST API acceptance tests to use Google Truth
Change-Id: Iacc1ef1fc8bcdabf2931d0aad2aca06eee284aeb
This commit is contained in:
@@ -17,6 +17,7 @@ java_library(
|
||||
deps = [
|
||||
'//lib:guava',
|
||||
'//lib:junit',
|
||||
'//lib:truth',
|
||||
'//gerrit-server:server',
|
||||
],
|
||||
)
|
||||
@@ -33,5 +34,6 @@ java_library(
|
||||
'//lib:gwtorm',
|
||||
'//lib:guava',
|
||||
'//lib:junit',
|
||||
'//lib:truth',
|
||||
],
|
||||
)
|
||||
|
||||
@@ -14,12 +14,10 @@
|
||||
|
||||
package com.google.gerrit.acceptance.rest.project;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.acceptance.GitUtil.add;
|
||||
import static com.google.gerrit.acceptance.GitUtil.createCommit;
|
||||
import static com.google.gerrit.acceptance.GitUtil.pushHead;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
@@ -42,15 +40,16 @@ public class BanCommitIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
adminSession.put("/projects/" + project.get() + "/ban/",
|
||||
BanCommit.Input.fromCommits(c.getCommit().getName()));
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
BanResultInfo info = newGson().fromJson(r.getReader(), BanResultInfo.class);
|
||||
assertEquals(c.getCommit().getName(), Iterables.getOnlyElement(info.newlyBanned));
|
||||
assertNull(info.alreadyBanned);
|
||||
assertNull(info.ignored);
|
||||
assertThat(Iterables.getOnlyElement(info.newlyBanned))
|
||||
.isEqualTo(c.getCommit().getName());
|
||||
assertThat(info.alreadyBanned).isNull();
|
||||
assertThat(info.ignored).isNull();
|
||||
|
||||
PushResult pushResult = pushHead(git, "refs/heads/master", false);
|
||||
assertTrue(pushResult.getRemoteUpdate("refs/heads/master").getMessage()
|
||||
.startsWith("contains banned commit"));
|
||||
assertThat(pushResult.getRemoteUpdate("refs/heads/master").getMessage())
|
||||
.startsWith("contains banned commit");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -62,11 +61,12 @@ public class BanCommitIT extends AbstractDaemonTest {
|
||||
|
||||
r = adminSession.put("/projects/" + project.get() + "/ban/",
|
||||
BanCommit.Input.fromCommits("a8a477efffbbf3b44169bb9a1d3a334cbbd9aa96"));
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
BanResultInfo info = newGson().fromJson(r.getReader(), BanResultInfo.class);
|
||||
assertEquals("a8a477efffbbf3b44169bb9a1d3a334cbbd9aa96", Iterables.getOnlyElement(info.alreadyBanned));
|
||||
assertNull(info.newlyBanned);
|
||||
assertNull(info.ignored);
|
||||
assertThat(Iterables.getOnlyElement(info.alreadyBanned))
|
||||
.isEqualTo("a8a477efffbbf3b44169bb9a1d3a334cbbd9aa96");
|
||||
assertThat(info.newlyBanned).isNull();
|
||||
assertThat(info.ignored).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -74,6 +74,6 @@ public class BanCommitIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
userSession.put("/projects/" + project.get() + "/ban/",
|
||||
BanCommit.Input.fromCommits("a8a477efffbbf3b44169bb9a1d3a334cbbd9aa96"));
|
||||
assertEquals(HttpStatus.SC_FORBIDDEN, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_FORBIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,7 @@
|
||||
|
||||
package com.google.gerrit.acceptance.rest.project;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
@@ -38,20 +36,19 @@ public class BranchAssert {
|
||||
return info.ref.equals(b.ref);
|
||||
}
|
||||
}, null);
|
||||
assertNotNull("missing branch: " + b.ref, info);
|
||||
assertThat(info).named("branch " + b.ref).isNotNull();
|
||||
assertBranchInfo(b, info);
|
||||
missingBranches.remove(info);
|
||||
}
|
||||
assertTrue("unexpected branches: " + missingBranches,
|
||||
missingBranches.isEmpty());
|
||||
assertThat(missingBranches).named("" + missingBranches).isEmpty();
|
||||
}
|
||||
|
||||
public static void assertBranchInfo(BranchInfo expected, BranchInfo actual) {
|
||||
assertEquals(expected.ref, actual.ref);
|
||||
assertThat(actual.ref).isEqualTo(expected.ref);
|
||||
if (expected.revision != null) {
|
||||
assertEquals(expected.revision, actual.revision);
|
||||
assertThat(actual.revision).isEqualTo(expected.revision);
|
||||
}
|
||||
assertEquals(expected.canDelete, toBoolean(actual.canDelete));
|
||||
assertThat(toBoolean(actual.canDelete)).isEqualTo(expected.canDelete);
|
||||
}
|
||||
|
||||
private static boolean toBoolean(Boolean b) {
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
|
||||
package com.google.gerrit.acceptance.rest.project;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
import static com.google.gerrit.server.project.Util.block;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
@@ -42,7 +42,7 @@ public class CreateBranchIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
userSession.put("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_FORBIDDEN, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_FORBIDDEN);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -50,12 +50,12 @@ public class CreateBranchIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
adminSession.put("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_CREATED, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_CREATED);
|
||||
r.consume();
|
||||
|
||||
r = adminSession.get("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,12 +63,12 @@ public class CreateBranchIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
adminSession.put("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_CREATED, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_CREATED);
|
||||
r.consume();
|
||||
|
||||
r = adminSession.put("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_CONFLICT, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_CONFLICT);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,12 +78,12 @@ public class CreateBranchIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
userSession.put("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_CREATED, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_CREATED);
|
||||
r.consume();
|
||||
|
||||
r = adminSession.get("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -92,12 +92,12 @@ public class CreateBranchIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
adminSession.put("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_CREATED, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_CREATED);
|
||||
r.consume();
|
||||
|
||||
r = adminSession.get("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,7 +108,7 @@ public class CreateBranchIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
userSession.put("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_FORBIDDEN, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_FORBIDDEN);
|
||||
}
|
||||
|
||||
private void blockCreateReference() throws Exception {
|
||||
|
||||
@@ -14,11 +14,9 @@
|
||||
|
||||
package com.google.gerrit.acceptance.rest.project;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.acceptance.rest.project.ProjectAssert.assertProjectInfo;
|
||||
import static com.google.gerrit.acceptance.rest.project.ProjectAssert.assertProjectOwners;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
@@ -52,9 +50,9 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
public void testCreateProjectApi() throws Exception {
|
||||
final String newProjectName = "newProject";
|
||||
ProjectInfo p = gApi.projects().name(newProjectName).create().get();
|
||||
assertEquals(newProjectName, p.name);
|
||||
assertThat(p.name).isEqualTo(newProjectName);
|
||||
ProjectState projectState = projectCache.get(new Project.NameKey(newProjectName));
|
||||
assertNotNull(projectState);
|
||||
assertThat(projectState).isNotNull();
|
||||
assertProjectInfo(projectState.getProject(), p);
|
||||
assertHead(newProjectName, "refs/heads/master");
|
||||
}
|
||||
@@ -63,11 +61,11 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
public void testCreateProject() throws Exception {
|
||||
final String newProjectName = "newProject";
|
||||
RestResponse r = adminSession.put("/projects/" + newProjectName);
|
||||
assertEquals(HttpStatus.SC_CREATED, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_CREATED);
|
||||
ProjectInfo p = newGson().fromJson(r.getReader(), ProjectInfo.class);
|
||||
assertEquals(newProjectName, p.name);
|
||||
assertThat(p.name).isEqualTo(newProjectName);
|
||||
ProjectState projectState = projectCache.get(new Project.NameKey(newProjectName));
|
||||
assertNotNull(projectState);
|
||||
assertThat(projectState).isNotNull();
|
||||
assertProjectInfo(projectState.getProject(), p);
|
||||
assertHead(newProjectName, "refs/heads/master");
|
||||
}
|
||||
@@ -77,7 +75,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
ProjectInput in = new ProjectInput();
|
||||
in.name = "otherName";
|
||||
RestResponse r = adminSession.put("/projects/someName", in);
|
||||
assertEquals(HttpStatus.SC_BAD_REQUEST, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_BAD_REQUEST);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -92,15 +90,15 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
in.requireChangeId = InheritableBoolean.TRUE;
|
||||
RestResponse r = adminSession.put("/projects/" + newProjectName, in);
|
||||
ProjectInfo p = newGson().fromJson(r.getReader(), ProjectInfo.class);
|
||||
assertEquals(newProjectName, p.name);
|
||||
assertThat(p.name).isEqualTo(newProjectName);
|
||||
Project project = projectCache.get(new Project.NameKey(newProjectName)).getProject();
|
||||
assertProjectInfo(project, p);
|
||||
assertEquals(in.description, project.getDescription());
|
||||
assertEquals(in.submitType, project.getSubmitType());
|
||||
assertEquals(in.useContributorAgreements, project.getUseContributorAgreements());
|
||||
assertEquals(in.useSignedOffBy, project.getUseSignedOffBy());
|
||||
assertEquals(in.useContentMerge, project.getUseContentMerge());
|
||||
assertEquals(in.requireChangeId, project.getRequireChangeID());
|
||||
assertThat(project.getDescription()).isEqualTo(in.description);
|
||||
assertThat(project.getSubmitType()).isEqualTo(in.submitType);
|
||||
assertThat(project.getUseContributorAgreements()).isEqualTo(in.useContributorAgreements);
|
||||
assertThat(project.getUseSignedOffBy()).isEqualTo(in.useSignedOffBy);
|
||||
assertThat(project.getUseContentMerge()).isEqualTo(in.useContentMerge);
|
||||
assertThat(project.getRequireChangeID()).isEqualTo(in.requireChangeId);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,7 +111,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
in.parent = parentName;
|
||||
r = adminSession.put("/projects/" + childName, in);
|
||||
Project project = projectCache.get(new Project.NameKey(childName)).getProject();
|
||||
assertEquals(in.parent, project.getParentName());
|
||||
assertThat(project.getParentName()).isEqualTo(in.parent);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -122,7 +120,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
ProjectInput in = new ProjectInput();
|
||||
in.parent = "non-existing-project";
|
||||
RestResponse r = adminSession.put("/projects/child", in);
|
||||
assertEquals(HttpStatus.SC_UNPROCESSABLE_ENTITY, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -149,7 +147,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
ProjectInput in = new ProjectInput();
|
||||
in.owners = Collections.singletonList("non-existing-group");
|
||||
RestResponse r = adminSession.put("/projects/newProject", in);
|
||||
assertEquals(HttpStatus.SC_UNPROCESSABLE_ENTITY, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -188,14 +186,14 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void testCreateProjectWithoutCapability_Forbidden() throws Exception {
|
||||
RestResponse r = userSession.put("/projects/newProject");
|
||||
assertEquals(HttpStatus.SC_FORBIDDEN, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_FORBIDDEN);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateProjectWhenProjectAlreadyExists_Conflict()
|
||||
throws Exception {
|
||||
RestResponse r = adminSession.put("/projects/All-Projects");
|
||||
assertEquals(HttpStatus.SC_CONFLICT, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_CONFLICT);
|
||||
}
|
||||
|
||||
private AccountGroup.UUID groupUuid(String groupName) {
|
||||
@@ -207,8 +205,8 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
Repository repo =
|
||||
repoManager.openRepository(new Project.NameKey(projectName));
|
||||
try {
|
||||
assertEquals(expectedRef, repo.getRef(Constants.HEAD).getTarget()
|
||||
.getName());
|
||||
assertThat(repo.getRef(Constants.HEAD).getTarget().getName())
|
||||
.isEqualTo(expectedRef);
|
||||
} finally {
|
||||
repo.close();
|
||||
}
|
||||
@@ -225,7 +223,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
||||
RevCommit commit = rw.lookupCommit(repo.getRef(ref).getObjectId());
|
||||
rw.parseBody(commit);
|
||||
tw.addTree(commit.getTree());
|
||||
assertFalse("ref " + ref + " has non empty commit", tw.next());
|
||||
assertThat(tw.next()).isFalse();
|
||||
tw.reset();
|
||||
}
|
||||
} finally {
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
|
||||
package com.google.gerrit.acceptance.rest.project;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
import static com.google.gerrit.server.project.Util.block;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
@@ -45,7 +45,7 @@ public class DeleteBranchIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
userSession.delete("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_FORBIDDEN, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_FORBIDDEN);
|
||||
r.consume();
|
||||
}
|
||||
|
||||
@@ -54,12 +54,12 @@ public class DeleteBranchIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
adminSession.delete("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_NO_CONTENT, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_NO_CONTENT);
|
||||
r.consume();
|
||||
|
||||
r = adminSession.get("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_NOT_FOUND, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_NOT_FOUND);
|
||||
r.consume();
|
||||
}
|
||||
|
||||
@@ -70,12 +70,12 @@ public class DeleteBranchIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
userSession.delete("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_NO_CONTENT, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_NO_CONTENT);
|
||||
r.consume();
|
||||
|
||||
r = userSession.get("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_NOT_FOUND, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_NOT_FOUND);
|
||||
r.consume();
|
||||
}
|
||||
|
||||
@@ -85,12 +85,12 @@ public class DeleteBranchIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
adminSession.delete("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_NO_CONTENT, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_NO_CONTENT);
|
||||
r.consume();
|
||||
|
||||
r = adminSession.get("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_NOT_FOUND, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_NOT_FOUND);
|
||||
r.consume();
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class DeleteBranchIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
userSession.delete("/projects/" + project.get()
|
||||
+ "/branches/" + branch.getShortName());
|
||||
assertEquals(HttpStatus.SC_FORBIDDEN, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_FORBIDDEN);
|
||||
r.consume();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
package com.google.gerrit.acceptance.rest.project;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.acceptance.GitUtil.createProject;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.GcAssert;
|
||||
@@ -45,20 +45,22 @@ public class GarbageCollectionIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void testGcNonExistingProject_NotFound() throws Exception {
|
||||
assertEquals(HttpStatus.SC_NOT_FOUND, POST("/projects/non-existing/gc"));
|
||||
assertThat(POST("/projects/non-existing/gc")).isEqualTo(
|
||||
HttpStatus.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGcNotAllowed_Forbidden() throws Exception {
|
||||
assertEquals(HttpStatus.SC_FORBIDDEN,
|
||||
assertThat(
|
||||
userSession.post("/projects/" + allProjects.get() + "/gc")
|
||||
.getStatusCode());
|
||||
.getStatusCode()).isEqualTo(HttpStatus.SC_FORBIDDEN);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UseLocalDisk
|
||||
public void testGcOneProject() throws Exception {
|
||||
assertEquals(HttpStatus.SC_OK, POST("/projects/" + allProjects.get() + "/gc"));
|
||||
assertThat(POST("/projects/" + allProjects.get() + "/gc")).isEqualTo(
|
||||
HttpStatus.SC_OK);
|
||||
gcAssert.assertHasPackFile(allProjects);
|
||||
gcAssert.assertHasNoPackFile(project, project2);
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
|
||||
package com.google.gerrit.acceptance.rest.project;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.acceptance.GitUtil.createProject;
|
||||
import static com.google.gerrit.acceptance.rest.project.ProjectAssert.assertProjectInfo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
@@ -33,8 +33,9 @@ public class GetChildProjectIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void getNonExistingChildProject_NotFound() throws Exception {
|
||||
assertEquals(HttpStatus.SC_NOT_FOUND,
|
||||
GET("/projects/" + allProjects.get() + "/children/non-existing").getStatusCode());
|
||||
assertThat(
|
||||
GET("/projects/" + allProjects.get() + "/children/non-existing")
|
||||
.getStatusCode()).isEqualTo(HttpStatus.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -45,8 +46,9 @@ public class GetChildProjectIT extends AbstractDaemonTest {
|
||||
Project.NameKey p2 = new Project.NameKey("p2");
|
||||
createProject(sshSession, p2.get());
|
||||
sshSession.close();
|
||||
assertEquals(HttpStatus.SC_NOT_FOUND,
|
||||
GET("/projects/" + p1.get() + "/children/" + p2.get()).getStatusCode());
|
||||
assertThat(
|
||||
GET("/projects/" + p1.get() + "/children/" + p2.get()).getStatusCode())
|
||||
.isEqualTo(HttpStatus.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -55,8 +57,9 @@ public class GetChildProjectIT extends AbstractDaemonTest {
|
||||
Project.NameKey child = new Project.NameKey("p1");
|
||||
createProject(sshSession, child.get());
|
||||
sshSession.close();
|
||||
RestResponse r = GET("/projects/" + allProjects.get() + "/children/" + child.get());
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
RestResponse r =
|
||||
GET("/projects/" + allProjects.get() + "/children/" + child.get());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
ProjectInfo childInfo =
|
||||
newGson().fromJson(r.getReader(), ProjectInfo.class);
|
||||
assertProjectInfo(projectCache.get(child).getProject(), childInfo);
|
||||
@@ -70,9 +73,9 @@ public class GetChildProjectIT extends AbstractDaemonTest {
|
||||
Project.NameKey grandChild = new Project.NameKey("p1.1");
|
||||
createProject(sshSession, grandChild.get(), child);
|
||||
sshSession.close();
|
||||
assertEquals(HttpStatus.SC_NOT_FOUND,
|
||||
assertThat(
|
||||
GET("/projects/" + allProjects.get() + "/children/" + grandChild.get())
|
||||
.getStatusCode());
|
||||
.getStatusCode()).isEqualTo(HttpStatus.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,7 +89,7 @@ public class GetChildProjectIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
GET("/projects/" + allProjects.get() + "/children/" + grandChild.get()
|
||||
+ "?recursive");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
ProjectInfo grandChildInfo =
|
||||
newGson().fromJson(r.getReader(), ProjectInfo.class);
|
||||
assertProjectInfo(projectCache.get(grandChild).getProject(), grandChildInfo);
|
||||
|
||||
@@ -14,9 +14,8 @@
|
||||
|
||||
package com.google.gerrit.acceptance.rest.project;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
@@ -72,20 +71,20 @@ public class GetCommitIT extends AbstractDaemonTest {
|
||||
.create());
|
||||
|
||||
CommitInfo info = getCommit(commit);
|
||||
assertEquals(commit.name(), info.commit);
|
||||
assertEquals("Create", info.subject);
|
||||
assertEquals("Create\n\nNew commit\n", info.message);
|
||||
assertEquals("J. Author", info.author.name);
|
||||
assertEquals("jauthor@example.com", info.author.email);
|
||||
assertEquals("J. Committer", info.committer.name);
|
||||
assertEquals("jcommitter@example.com", info.committer.email);
|
||||
assertThat(info.commit).isEqualTo(commit.name());
|
||||
assertThat(info.subject).isEqualTo("Create");
|
||||
assertThat(info.message).isEqualTo("Create\n\nNew commit\n");
|
||||
assertThat(info.author.name).isEqualTo("J. Author");
|
||||
assertThat(info.author.email).isEqualTo("jauthor@example.com");
|
||||
assertThat(info.committer.name).isEqualTo("J. Committer");
|
||||
assertThat(info.committer.email).isEqualTo("jcommitter@example.com");
|
||||
|
||||
CommitInfo parent = Iterables.getOnlyElement(info.parents);
|
||||
assertEquals(commit.getParent(0).name(), parent.commit);
|
||||
assertEquals("Initial empty repository", parent.subject);
|
||||
assertNull(parent.message);
|
||||
assertNull(parent.author);
|
||||
assertNull(parent.committer);
|
||||
assertThat(parent.commit).isEqualTo(commit.getParent(0).name());
|
||||
assertThat(parent.subject).isEqualTo("Initial empty repository");
|
||||
assertThat(parent.message).isNull();
|
||||
assertThat(parent.author).isNull();
|
||||
assertThat(parent.committer).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -105,21 +104,21 @@ public class GetCommitIT extends AbstractDaemonTest {
|
||||
r.assertOkStatus();
|
||||
|
||||
CommitInfo info = getCommit(r.getCommitId());
|
||||
assertEquals(r.getCommitId().name(), info.commit);
|
||||
assertEquals("test commit", info.subject);
|
||||
assertEquals("test commit\n\nChange-Id: " + r.getChangeId() + "\n",
|
||||
info.message);
|
||||
assertEquals("admin", info.author.name);
|
||||
assertEquals("admin@example.com", info.author.email);
|
||||
assertEquals("admin", info.committer.name);
|
||||
assertEquals("admin@example.com", info.committer.email);
|
||||
assertThat(info.commit).isEqualTo(r.getCommitId().name());
|
||||
assertThat(info.subject).isEqualTo("test commit");
|
||||
assertThat(info.message).isEqualTo(
|
||||
"test commit\n\nChange-Id: " + r.getChangeId() + "\n");
|
||||
assertThat(info.author.name).isEqualTo("admin");
|
||||
assertThat(info.author.email).isEqualTo("admin@example.com");
|
||||
assertThat(info.committer.name).isEqualTo("admin");
|
||||
assertThat(info.committer.email).isEqualTo("admin@example.com");
|
||||
|
||||
CommitInfo parent = Iterables.getOnlyElement(info.parents);
|
||||
assertEquals(r.getCommit().getParent(0).name(), parent.commit);
|
||||
assertEquals("Initial empty repository", parent.subject);
|
||||
assertNull(parent.message);
|
||||
assertNull(parent.author);
|
||||
assertNull(parent.committer);
|
||||
assertThat(parent.commit).isEqualTo(r.getCommit().getParent(0).name());
|
||||
assertThat(parent.subject).isEqualTo("Initial empty repository");
|
||||
assertThat(parent.message).isNull();
|
||||
assertThat(parent.author).isNull();
|
||||
assertThat(parent.committer).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -133,13 +132,13 @@ public class GetCommitIT extends AbstractDaemonTest {
|
||||
private void assertNotFound(ObjectId id) throws Exception {
|
||||
RestResponse r = userSession.get(
|
||||
"/projects/" + project.get() + "/commits/" + id.name());
|
||||
assertEquals(HttpStatus.SC_NOT_FOUND, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
private CommitInfo getCommit(ObjectId id) throws Exception {
|
||||
RestResponse r = userSession.get(
|
||||
"/projects/" + project.get() + "/commits/" + id.name());
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
CommitInfo result = newGson().fromJson(r.getReader(), CommitInfo.class);
|
||||
r.consume();
|
||||
return result;
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
|
||||
package com.google.gerrit.acceptance.rest.project;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.acceptance.GitUtil.createProject;
|
||||
import static com.google.gerrit.acceptance.rest.project.BranchAssert.assertBranches;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
@@ -35,15 +35,16 @@ import java.util.List;
|
||||
public class ListBranchesIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void listBranchesOfNonExistingProject_NotFound() throws Exception {
|
||||
assertEquals(HttpStatus.SC_NOT_FOUND,
|
||||
GET("/projects/non-existing/branches").getStatusCode());
|
||||
assertThat(GET("/projects/non-existing/branches").getStatusCode())
|
||||
.isEqualTo(HttpStatus.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listBranchesOfNonVisibleProject_NotFound() throws Exception {
|
||||
blockRead(project, "refs/*");
|
||||
assertEquals(HttpStatus.SC_NOT_FOUND,
|
||||
userSession.get("/projects/" + project.get() + "/branches").getStatusCode());
|
||||
assertThat(
|
||||
userSession.get("/projects/" + project.get() + "/branches")
|
||||
.getStatusCode()).isEqualTo(HttpStatus.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -77,10 +78,10 @@ public class ListBranchesIT extends AbstractDaemonTest {
|
||||
assertBranches(expected, result);
|
||||
|
||||
// verify correct sorting
|
||||
assertEquals("HEAD", result.get(0).ref);
|
||||
assertEquals("refs/meta/config", result.get(1).ref);
|
||||
assertEquals("refs/heads/dev", result.get(2).ref);
|
||||
assertEquals("refs/heads/master", result.get(3).ref);
|
||||
assertThat(result.get(0).ref).isEqualTo("HEAD");
|
||||
assertThat(result.get(1).ref).isEqualTo("refs/meta/config");
|
||||
assertThat(result.get(2).ref).isEqualTo("refs/heads/dev");
|
||||
assertThat(result.get(3).ref).isEqualTo("refs/heads/master");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -122,43 +123,43 @@ public class ListBranchesIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
adminSession.get("/projects/" + project.get() + "/branches?n=4");
|
||||
List<BranchInfo> result = toBranchInfoList(r);
|
||||
assertEquals(4, result.size());
|
||||
assertEquals("HEAD", result.get(0).ref);
|
||||
assertEquals("refs/meta/config", result.get(1).ref);
|
||||
assertEquals("refs/heads/master", result.get(2).ref);
|
||||
assertEquals("refs/heads/someBranch1", result.get(3).ref);
|
||||
assertThat(result).hasSize(4);
|
||||
assertThat(result.get(0).ref).isEqualTo("HEAD");
|
||||
assertThat(result.get(1).ref).isEqualTo("refs/meta/config");
|
||||
assertThat(result.get(2).ref).isEqualTo("refs/heads/master");
|
||||
assertThat(result.get(3).ref).isEqualTo("refs/heads/someBranch1");
|
||||
|
||||
// limit higher than total number of branches
|
||||
r = adminSession.get("/projects/" + project.get() + "/branches?n=25");
|
||||
result = toBranchInfoList(r);
|
||||
assertEquals(6, result.size());
|
||||
assertEquals("HEAD", result.get(0).ref);
|
||||
assertEquals("refs/meta/config", result.get(1).ref);
|
||||
assertEquals("refs/heads/master", result.get(2).ref);
|
||||
assertEquals("refs/heads/someBranch1", result.get(3).ref);
|
||||
assertEquals("refs/heads/someBranch2", result.get(4).ref);
|
||||
assertEquals("refs/heads/someBranch3", result.get(5).ref);
|
||||
assertThat(result).hasSize(6);
|
||||
assertThat(result.get(0).ref).isEqualTo("HEAD");
|
||||
assertThat(result.get(1).ref).isEqualTo("refs/meta/config");
|
||||
assertThat(result.get(2).ref).isEqualTo("refs/heads/master");
|
||||
assertThat(result.get(3).ref).isEqualTo("refs/heads/someBranch1");
|
||||
assertThat(result.get(4).ref).isEqualTo("refs/heads/someBranch2");
|
||||
assertThat(result.get(5).ref).isEqualTo("refs/heads/someBranch3");
|
||||
|
||||
// using skip only
|
||||
r = adminSession.get("/projects/" + project.get() + "/branches?s=2");
|
||||
result = toBranchInfoList(r);
|
||||
assertEquals(4, result.size());
|
||||
assertEquals("refs/heads/master", result.get(0).ref);
|
||||
assertEquals("refs/heads/someBranch1", result.get(1).ref);
|
||||
assertEquals("refs/heads/someBranch2", result.get(2).ref);
|
||||
assertEquals("refs/heads/someBranch3", result.get(3).ref);
|
||||
assertThat(result).hasSize(4);
|
||||
assertThat(result.get(0).ref).isEqualTo("refs/heads/master");
|
||||
assertThat(result.get(1).ref).isEqualTo("refs/heads/someBranch1");
|
||||
assertThat(result.get(2).ref).isEqualTo("refs/heads/someBranch2");
|
||||
assertThat(result.get(3).ref).isEqualTo("refs/heads/someBranch3");
|
||||
|
||||
// skip more branches than the number of available branches
|
||||
r = adminSession.get("/projects/" + project.get() + "/branches?s=7");
|
||||
result = toBranchInfoList(r);
|
||||
assertEquals(0, result.size());
|
||||
assertThat(result).isEmpty();
|
||||
|
||||
// using skip and limit
|
||||
r = adminSession.get("/projects/" + project.get() + "/branches?s=2&n=2");
|
||||
result = toBranchInfoList(r);
|
||||
assertEquals(2, result.size());
|
||||
assertEquals("refs/heads/master", result.get(0).ref);
|
||||
assertEquals("refs/heads/someBranch1", result.get(1).ref);
|
||||
assertThat(result).hasSize(2);
|
||||
assertThat(result.get(0).ref).isEqualTo("refs/heads/master");
|
||||
assertThat(result.get(1).ref).isEqualTo("refs/heads/someBranch1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -172,23 +173,23 @@ public class ListBranchesIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
adminSession.get("/projects/" + project.get() + "/branches?m=some");
|
||||
List<BranchInfo> result = toBranchInfoList(r);
|
||||
assertEquals(3, result.size());
|
||||
assertEquals("refs/heads/someBranch1", result.get(0).ref);
|
||||
assertEquals("refs/heads/someBranch2", result.get(1).ref);
|
||||
assertEquals("refs/heads/someBranch3", result.get(2).ref);
|
||||
assertThat(result).hasSize(3);
|
||||
assertThat(result.get(0).ref).isEqualTo("refs/heads/someBranch1");
|
||||
assertThat(result.get(1).ref).isEqualTo("refs/heads/someBranch2");
|
||||
assertThat(result.get(2).ref).isEqualTo("refs/heads/someBranch3");
|
||||
|
||||
r = adminSession.get("/projects/" + project.get() + "/branches?m=Branch");
|
||||
result = toBranchInfoList(r);
|
||||
assertEquals(3, result.size());
|
||||
assertEquals("refs/heads/someBranch1", result.get(0).ref);
|
||||
assertEquals("refs/heads/someBranch2", result.get(1).ref);
|
||||
assertEquals("refs/heads/someBranch3", result.get(2).ref);
|
||||
assertThat(result).hasSize(3);
|
||||
assertThat(result.get(0).ref).isEqualTo("refs/heads/someBranch1");
|
||||
assertThat(result.get(1).ref).isEqualTo("refs/heads/someBranch2");
|
||||
assertThat(result.get(2).ref).isEqualTo("refs/heads/someBranch3");
|
||||
|
||||
//using regex
|
||||
r = adminSession.get("/projects/" + project.get() + "/branches?r=.*ast.*r");
|
||||
result = toBranchInfoList(r);
|
||||
assertEquals(1, result.size());
|
||||
assertEquals("refs/heads/master", result.get(0).ref);
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.get(0).ref).isEqualTo("refs/heads/master");
|
||||
}
|
||||
|
||||
private RestResponse GET(String endpoint) throws IOException {
|
||||
|
||||
@@ -14,10 +14,9 @@
|
||||
|
||||
package com.google.gerrit.acceptance.rest.project;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.acceptance.GitUtil.createProject;
|
||||
import static com.google.gerrit.acceptance.rest.project.ProjectAssert.assertProjects;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
@@ -36,17 +35,17 @@ public class ListChildProjectsIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void listChildrenOfNonExistingProject_NotFound() throws Exception {
|
||||
assertEquals(HttpStatus.SC_NOT_FOUND,
|
||||
GET("/projects/non-existing/children/").getStatusCode());
|
||||
assertThat(GET("/projects/non-existing/children/").getStatusCode())
|
||||
.isEqualTo(HttpStatus.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listNoChildren() throws Exception {
|
||||
RestResponse r = GET("/projects/" + allProjects.get() + "/children/");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
List<ProjectInfo> projectInfoList = toProjectInfoList(r);
|
||||
// Project 'p' was already created in the base class
|
||||
assertTrue(projectInfoList.size() == 2);
|
||||
assertThat(projectInfoList).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -59,7 +58,7 @@ public class ListChildProjectsIT extends AbstractDaemonTest {
|
||||
createProject(sshSession, "p1.1", child1);
|
||||
|
||||
RestResponse r = GET("/projects/" + allProjects.get() + "/children/");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
assertProjects(
|
||||
Arrays.asList(
|
||||
new Project.NameKey("All-Users"),
|
||||
@@ -82,7 +81,7 @@ public class ListChildProjectsIT extends AbstractDaemonTest {
|
||||
createProject(sshSession, child1_1_1_1.get(), child1_1_1);
|
||||
|
||||
RestResponse r = GET("/projects/" + child1.get() + "/children/?recursive");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
assertProjects(Arrays.asList(child1_1, child1_2,
|
||||
child1_1_1, child1_1_1_1), toProjectInfoList(r));
|
||||
}
|
||||
|
||||
@@ -14,11 +14,9 @@
|
||||
|
||||
package com.google.gerrit.acceptance.rest.project;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.acceptance.GitUtil.createProject;
|
||||
import static com.google.gerrit.acceptance.rest.project.ProjectAssert.assertProjects;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
@@ -47,7 +45,7 @@ public class ListProjectsIT extends AbstractDaemonTest {
|
||||
createProject(sshSession, someProject.get());
|
||||
|
||||
RestResponse r = GET("/projects/");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
Map<String, ProjectInfo> result = toProjectInfoMap(r);
|
||||
assertProjects(Arrays.asList(allUsers, someProject, project),
|
||||
result.values());
|
||||
@@ -56,12 +54,12 @@ public class ListProjectsIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void listProjectsWithBranch() throws Exception {
|
||||
RestResponse r = GET("/projects/?b=master");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
Map<String, ProjectInfo> result = toProjectInfoMap(r);
|
||||
assertNotNull(result.get(project.get()));
|
||||
assertNotNull(result.get(project.get()).branches);
|
||||
assertEquals(1, result.get(project.get()).branches.size());
|
||||
assertNotNull(result.get(project.get()).branches.get("master"));
|
||||
assertThat(result.get(project.get())).isNotNull();
|
||||
assertThat(result.get(project.get()).branches).isNotNull();
|
||||
assertThat(result.get(project.get()).branches).hasSize(1);
|
||||
assertThat(result.get(project.get()).branches.get("master")).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -73,17 +71,17 @@ public class ListProjectsIT extends AbstractDaemonTest {
|
||||
|
||||
// description not be included in the results by default.
|
||||
RestResponse r = GET("/projects/");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
Map<String, ProjectInfo> result = toProjectInfoMap(r);
|
||||
assertNotNull(result.get(projectInput.name));
|
||||
assertNull(result.get(projectInput.name).description);
|
||||
assertThat(result.get(projectInput.name)).isNotNull();
|
||||
assertThat(result.get(projectInput.name).description).isNull();
|
||||
|
||||
r = GET("/projects/?d");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
result = toProjectInfoMap(r);
|
||||
assertNotNull(result.get(projectInput.name));
|
||||
assertEquals(projectInput.description,
|
||||
result.get(projectInput.name).description);
|
||||
assertThat(result.get(projectInput.name)).isNotNull();
|
||||
assertThat(result.get(projectInput.name).description).isEqualTo(
|
||||
projectInput.description);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,15 +91,15 @@ public class ListProjectsIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
RestResponse r = GET("/projects/");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
Map<String, ProjectInfo> result = toProjectInfoMap(r);
|
||||
assertEquals(7, result.size()); // 5 plus 2 existing projects: p and
|
||||
// All-Users
|
||||
assertThat(result).hasSize(7); // 5 plus 2 existing projects: p and
|
||||
// All-Users
|
||||
|
||||
r = GET("/projects/?n=2");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
result = toProjectInfoMap(r);
|
||||
assertEquals(2, result.size());
|
||||
assertThat(result).hasSize(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -114,13 +112,13 @@ public class ListProjectsIT extends AbstractDaemonTest {
|
||||
Project.NameKey projectAwesome = new Project.NameKey("project-awesome");
|
||||
createProject(sshSession, projectAwesome.get());
|
||||
|
||||
assertEquals(HttpStatus.SC_BAD_REQUEST,
|
||||
GET("/projects/?p=some&r=.*").getStatusCode());
|
||||
assertEquals(HttpStatus.SC_BAD_REQUEST,
|
||||
GET("/projects/?p=some&m=some").getStatusCode());
|
||||
assertThat(GET("/projects/?p=some&r=.*").getStatusCode()).isEqualTo(
|
||||
HttpStatus.SC_BAD_REQUEST);
|
||||
assertThat(GET("/projects/?p=some&m=some").getStatusCode()).isEqualTo(
|
||||
HttpStatus.SC_BAD_REQUEST);
|
||||
|
||||
RestResponse r = GET("/projects/?p=some");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
Map<String, ProjectInfo> result = toProjectInfoMap(r);
|
||||
assertProjects(Arrays.asList(someProject, someOtherProject),
|
||||
result.values());
|
||||
@@ -136,25 +134,25 @@ public class ListProjectsIT extends AbstractDaemonTest {
|
||||
Project.NameKey projectAwesome = new Project.NameKey("project-awesome");
|
||||
createProject(sshSession, projectAwesome.get());
|
||||
|
||||
assertEquals(HttpStatus.SC_BAD_REQUEST,
|
||||
GET("/projects/?r=[.*some").getStatusCode());
|
||||
assertEquals(HttpStatus.SC_BAD_REQUEST,
|
||||
GET("/projects/?r=.*&p=s").getStatusCode());
|
||||
assertEquals(HttpStatus.SC_BAD_REQUEST,
|
||||
GET("/projects/?r=.*&m=s").getStatusCode());
|
||||
assertThat(GET("/projects/?r=[.*some").getStatusCode()).isEqualTo(
|
||||
HttpStatus.SC_BAD_REQUEST);
|
||||
assertThat(GET("/projects/?r=.*&p=s").getStatusCode()).isEqualTo(
|
||||
HttpStatus.SC_BAD_REQUEST);
|
||||
assertThat(GET("/projects/?r=.*&m=s").getStatusCode()).isEqualTo(
|
||||
HttpStatus.SC_BAD_REQUEST);
|
||||
|
||||
RestResponse r = GET("/projects/?r=.*some");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
Map<String, ProjectInfo> result = toProjectInfoMap(r);
|
||||
assertProjects(Arrays.asList(projectAwesome), result.values());
|
||||
|
||||
r = GET("/projects/?r=some-project$");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
result = toProjectInfoMap(r);
|
||||
assertProjects(Arrays.asList(someProject), result.values());
|
||||
|
||||
r = GET("/projects/?r=.*");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
result = toProjectInfoMap(r);
|
||||
assertProjects(Arrays.asList(someProject, someOtherProject, projectAwesome,
|
||||
project, allUsers), result.values());
|
||||
@@ -167,15 +165,15 @@ public class ListProjectsIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
RestResponse r = GET("/projects/");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
Map<String, ProjectInfo> result = toProjectInfoMap(r);
|
||||
assertEquals(7, result.size()); // 5 plus 2 existing projects: p and
|
||||
// All-Users
|
||||
assertThat(result).hasSize(7); // 5 plus 2 existing projects: p and
|
||||
// All-Users
|
||||
|
||||
r = GET("/projects/?S=6");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
result = toProjectInfoMap(r);
|
||||
assertEquals(1, result.size());
|
||||
assertThat(result).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -188,13 +186,13 @@ public class ListProjectsIT extends AbstractDaemonTest {
|
||||
Project.NameKey projectAwesome = new Project.NameKey("project-awesome");
|
||||
createProject(sshSession, projectAwesome.get());
|
||||
|
||||
assertEquals(HttpStatus.SC_BAD_REQUEST,
|
||||
GET("/projects/?m=some&r=.*").getStatusCode());
|
||||
assertEquals(HttpStatus.SC_BAD_REQUEST,
|
||||
GET("/projects/?m=some&p=some").getStatusCode());
|
||||
assertThat(GET("/projects/?m=some&r=.*").getStatusCode()).isEqualTo(
|
||||
HttpStatus.SC_BAD_REQUEST);
|
||||
assertThat(GET("/projects/?m=some&p=some").getStatusCode()).isEqualTo(
|
||||
HttpStatus.SC_BAD_REQUEST);
|
||||
|
||||
RestResponse r = GET("/projects/?m=some");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
Map<String, ProjectInfo> result = toProjectInfoMap(r);
|
||||
assertProjects(
|
||||
Arrays.asList(someProject, someOtherProject, projectAwesome),
|
||||
@@ -211,25 +209,25 @@ public class ListProjectsIT extends AbstractDaemonTest {
|
||||
createProject(sshSession, someChildProject.get(), someParentProject);
|
||||
|
||||
RestResponse r = GET("/projects/?tree");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
Map<String, ProjectInfo> result = toProjectInfoMap(r);
|
||||
assertNotNull(result.get(someChildProject.get()));
|
||||
assertEquals(someParentProject.get(),
|
||||
result.get(someChildProject.get()).parent);
|
||||
assertThat(result.get(someChildProject.get())).isNotNull();
|
||||
assertThat(result.get(someChildProject.get()).parent).isEqualTo(
|
||||
someParentProject.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listProjectWithType() throws Exception {
|
||||
RestResponse r = GET("/projects/?type=PERMISSIONS");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
Map<String, ProjectInfo> result = toProjectInfoMap(r);
|
||||
assertEquals(1, result.size());
|
||||
assertNotNull(result.get(allProjects.get()));
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.get(allProjects.get())).isNotNull();
|
||||
|
||||
r = GET("/projects/?type=ALL");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
result = toProjectInfoMap(r);
|
||||
assertEquals(3, result.size());
|
||||
assertThat(result).hasSize(3);
|
||||
assertProjects(Arrays.asList(allProjects, allUsers, project),
|
||||
result.values());
|
||||
}
|
||||
|
||||
@@ -14,9 +14,7 @@
|
||||
|
||||
package com.google.gerrit.acceptance.rest.project;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Strings;
|
||||
@@ -42,29 +40,33 @@ public class ProjectAssert {
|
||||
return new Project.NameKey(info.name != null ? info.name : Url
|
||||
.decode(info.id)).equals(p);
|
||||
}}, null);
|
||||
assertNotNull("missing project: " + p, info);
|
||||
assertThat(info).isNotNull();
|
||||
actual.remove(info);
|
||||
}
|
||||
assertTrue("unexpected projects: " + actual, actual.isEmpty());
|
||||
assertThat(actual).isEmpty();
|
||||
}
|
||||
|
||||
public static void assertProjectInfo(Project project, ProjectInfo info) {
|
||||
if (info.name != null) {
|
||||
// 'name' is not set if returned in a map
|
||||
assertEquals(project.getName(), info.name);
|
||||
assertThat(info.name).isEqualTo(project.getName());
|
||||
}
|
||||
assertEquals(project.getName(), Url.decode(info.id));
|
||||
assertThat(Url.decode(info.id)).isEqualTo(project.getName());
|
||||
Project.NameKey parentName = project.getParent(new Project.NameKey("All-Projects"));
|
||||
assertEquals(parentName != null ? parentName.get() : null, info.parent);
|
||||
assertEquals(project.getDescription(), Strings.nullToEmpty(info.description));
|
||||
if (parentName != null) {
|
||||
assertThat(info.parent).isEqualTo(parentName.get());
|
||||
} else {
|
||||
assertThat(info.parent).isNull();
|
||||
}
|
||||
assertThat(Strings.nullToEmpty(info.description)).isEqualTo(
|
||||
project.getDescription());
|
||||
}
|
||||
|
||||
public static void assertProjectOwners(Set<AccountGroup.UUID> expectedOwners,
|
||||
ProjectState state) {
|
||||
for (AccountGroup.UUID g : state.getOwners()) {
|
||||
assertTrue("unexpected owner group " + g, expectedOwners.remove(g));
|
||||
assertThat(expectedOwners.remove(g)).isTrue();
|
||||
}
|
||||
assertTrue("missing owner groups: " + expectedOwners,
|
||||
expectedOwners.isEmpty());
|
||||
assertThat(expectedOwners).isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
|
||||
package com.google.gerrit.acceptance.rest.project;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.acceptance.GitUtil.checkout;
|
||||
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
|
||||
import static com.google.gerrit.acceptance.GitUtil.fetch;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
@@ -48,13 +48,14 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest {
|
||||
push.to(git, RefNames.REFS_CONFIG);
|
||||
|
||||
ProjectState state = projectCache.get(project);
|
||||
assertEquals(cfg.toText(), state.getConfig(configName).get().toText());
|
||||
assertThat(state.getConfig(configName).get().toText()).isEqualTo(
|
||||
cfg.toText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonExistingConfig() {
|
||||
ProjectState state = projectCache.get(project);
|
||||
assertEquals("", state.getConfig("test.config").get().toText());
|
||||
assertThat(state.getConfig("test.config").get().toText()).isEqualTo("");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -91,9 +92,10 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest {
|
||||
expectedCfg.setString("s2", "ss", "k3", "childValue2");
|
||||
expectedCfg.setString("s2", "ss", "k4", "parentValue4");
|
||||
|
||||
assertEquals(expectedCfg.toText(), state.getConfig(configName)
|
||||
.getWithInheritance().toText());
|
||||
assertThat(state.getConfig(configName).getWithInheritance().toText())
|
||||
.isEqualTo(expectedCfg.toText());
|
||||
|
||||
assertEquals(cfg.toText(), state.getConfig(configName).get().toText());
|
||||
assertThat(state.getConfig(configName).get().toText()).isEqualTo(
|
||||
cfg.toText());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
package com.google.gerrit.acceptance.rest.project;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.acceptance.GitUtil.createProject;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
@@ -33,7 +33,7 @@ public class SetParentIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
userSession.put("/projects/" + project.get() + "/parent",
|
||||
newParentInput(parent));
|
||||
assertEquals(HttpStatus.SC_FORBIDDEN, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_FORBIDDEN);
|
||||
r.consume();
|
||||
}
|
||||
|
||||
@@ -44,14 +44,14 @@ public class SetParentIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
adminSession.put("/projects/" + project.get() + "/parent",
|
||||
newParentInput(parent));
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
r.consume();
|
||||
|
||||
r = adminSession.get("/projects/" + project.get() + "/parent");
|
||||
assertEquals(HttpStatus.SC_OK, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_OK);
|
||||
String newParent =
|
||||
newGson().fromJson(r.getReader(), String.class);
|
||||
assertEquals(parent, newParent);
|
||||
assertThat(newParent).isEqualTo(parent);
|
||||
r.consume();
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public class SetParentIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
adminSession.put("/projects/" + allProjects.get() + "/parent",
|
||||
newParentInput(project.get()));
|
||||
assertEquals(HttpStatus.SC_CONFLICT, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_CONFLICT);
|
||||
r.consume();
|
||||
}
|
||||
|
||||
@@ -69,21 +69,21 @@ public class SetParentIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
adminSession.put("/projects/" + project.get() + "/parent",
|
||||
newParentInput(project.get()));
|
||||
assertEquals(HttpStatus.SC_CONFLICT, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_CONFLICT);
|
||||
r.consume();
|
||||
|
||||
String child = "child";
|
||||
createProject(sshSession, child, project, true);
|
||||
r = adminSession.put("/projects/" + project.get() + "/parent",
|
||||
newParentInput(child));
|
||||
assertEquals(HttpStatus.SC_CONFLICT, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_CONFLICT);
|
||||
r.consume();
|
||||
|
||||
String grandchild = "grandchild";
|
||||
createProject(sshSession, grandchild, new Project.NameKey(child), true);
|
||||
r = adminSession.put("/projects/" + project.get() + "/parent",
|
||||
newParentInput(grandchild));
|
||||
assertEquals(HttpStatus.SC_CONFLICT, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_CONFLICT);
|
||||
r.consume();
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class SetParentIT extends AbstractDaemonTest {
|
||||
RestResponse r =
|
||||
adminSession.put("/projects/" + project.get() + "/parent",
|
||||
newParentInput("non-existing"));
|
||||
assertEquals(HttpStatus.SC_UNPROCESSABLE_ENTITY, r.getStatusCode());
|
||||
assertThat(r.getStatusCode()).isEqualTo(HttpStatus.SC_UNPROCESSABLE_ENTITY);
|
||||
r.consume();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
package com.google.gerrit.acceptance.rest.project;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
@@ -31,15 +31,16 @@ import java.util.List;
|
||||
public class TagsIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void listTagsOfNonExistingProject_NotFound() throws Exception {
|
||||
assertEquals(HttpStatus.SC_NOT_FOUND,
|
||||
adminSession.get("/projects/non-existing/tags").getStatusCode());
|
||||
assertThat(adminSession.get("/projects/non-existing/tags").getStatusCode())
|
||||
.isEqualTo(HttpStatus.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void listTagsOfNonVisibleProject_NotFound() throws Exception {
|
||||
blockRead(project, "refs/*");
|
||||
assertEquals(HttpStatus.SC_NOT_FOUND,
|
||||
userSession.get("/projects/" + project.get() + "/tags").getStatusCode());
|
||||
assertThat(
|
||||
userSession.get("/projects/" + project.get() + "/tags").getStatusCode())
|
||||
.isEqualTo(HttpStatus.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,18 +64,18 @@ public class TagsIT extends AbstractDaemonTest {
|
||||
|
||||
List<TagInfo> result =
|
||||
toTagInfoList(adminSession.get("/projects/" + project.get() + "/tags"));
|
||||
assertEquals(2, result.size());
|
||||
assertThat(result).hasSize(2);
|
||||
|
||||
TagInfo t = result.get(0);
|
||||
assertEquals("refs/tags/" + tag1.name, t.ref);
|
||||
assertEquals(r1.getCommitId().getName(), t.revision);
|
||||
assertThat(t.ref).isEqualTo("refs/tags/" + tag1.name);
|
||||
assertThat(t.revision).isEqualTo(r1.getCommitId().getName());
|
||||
|
||||
t = result.get(1);
|
||||
assertEquals("refs/tags/" + tag2.name, t.ref);
|
||||
assertEquals(r2.getCommitId().getName(), t.object);
|
||||
assertEquals(tag2.message, t.message);
|
||||
assertEquals(tag2.tagger.getName(), t.tagger.name);
|
||||
assertEquals(tag2.tagger.getEmailAddress(), t.tagger.email);
|
||||
assertThat(t.ref).isEqualTo("refs/tags/" + tag2.name);
|
||||
assertThat(t.object).isEqualTo(r2.getCommitId().getName());
|
||||
assertThat(t.message).isEqualTo(tag2.message);
|
||||
assertThat(t.tagger.name).isEqualTo(tag2.tagger.getName());
|
||||
assertThat(t.tagger.email).isEqualTo(tag2.tagger.getEmailAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,18 +100,18 @@ public class TagsIT extends AbstractDaemonTest {
|
||||
|
||||
List<TagInfo> result =
|
||||
toTagInfoList(adminSession.get("/projects/" + project.get() + "/tags"));
|
||||
assertEquals(2, result.size());
|
||||
assertEquals("refs/tags/" + tag1.name, result.get(0).ref);
|
||||
assertEquals(r1.getCommitId().getName(), result.get(0).revision);
|
||||
assertEquals("refs/tags/" + tag2.name, result.get(1).ref);
|
||||
assertEquals(r2.getCommitId().getName(), result.get(1).revision);
|
||||
assertThat(result).hasSize(2);
|
||||
assertThat(result.get(0).ref).isEqualTo("refs/tags/" + tag1.name);
|
||||
assertThat(result.get(0).revision).isEqualTo(r1.getCommitId().getName());
|
||||
assertThat(result.get(1).ref).isEqualTo("refs/tags/" + tag2.name);
|
||||
assertThat(result.get(1).revision).isEqualTo(r2.getCommitId().getName());
|
||||
|
||||
blockRead(project, "refs/heads/hidden");
|
||||
result =
|
||||
toTagInfoList(adminSession.get("/projects/" + project.get() + "/tags"));
|
||||
assertEquals(1, result.size());
|
||||
assertEquals("refs/tags/" + tag1.name, result.get(0).ref);
|
||||
assertEquals(r1.getCommitId().getName(), result.get(0).revision);
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.get(0).ref).isEqualTo("refs/tags/" + tag1.name);
|
||||
assertThat(result.get(0).revision).isEqualTo(r1.getCommitId().getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -129,8 +130,8 @@ public class TagsIT extends AbstractDaemonTest {
|
||||
adminSession.get("/projects/" + project.get() + "/tags/" + tag1.name);
|
||||
TagInfo tagInfo =
|
||||
newGson().fromJson(response.getReader(), TagInfo.class);
|
||||
assertEquals("refs/tags/" + tag1.name, tagInfo.ref);
|
||||
assertEquals(r1.getCommitId().getName(), tagInfo.revision);
|
||||
assertThat(tagInfo.ref).isEqualTo("refs/tags/" + tag1.name);
|
||||
assertThat(tagInfo.revision).isEqualTo(r1.getCommitId().getName());
|
||||
}
|
||||
|
||||
private static List<TagInfo> toTagInfoList(RestResponse r) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user