Search in sources :

Example 11 with Project

use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.

the class ProjectIT method maxObjectSizeOverridesParentProjectWhenLower.

@Test
public void maxObjectSizeOverridesParentProjectWhenLower() throws Exception {
    Project.NameKey child = projectOperations.newProject().parent(project).create();
    ConfigInfo info = setMaxObjectSize("200k");
    assertThat(info.maxObjectSizeLimit.value).isEqualTo("204800");
    assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("200k");
    assertThat(info.maxObjectSizeLimit.summary).isNull();
    info = setMaxObjectSize(child, "100k");
    assertThat(info.maxObjectSizeLimit.value).isEqualTo("102400");
    assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("100k");
    assertThat(info.maxObjectSizeLimit.summary).isNull();
}
Also used : Project(com.google.gerrit.entities.Project) ConfigInfo(com.google.gerrit.extensions.api.projects.ConfigInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 12 with Project

use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.

the class ProjectIT method maxObjectSizeIsInheritedFromParentProject.

@Test
@GerritConfig(name = "receive.inheritProjectMaxObjectSizeLimit", value = "true")
public void maxObjectSizeIsInheritedFromParentProject() throws Exception {
    Project.NameKey child = projectOperations.newProject().parent(project).create();
    ConfigInfo info = setMaxObjectSize("100k");
    assertThat(info.maxObjectSizeLimit.value).isEqualTo("102400");
    assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("100k");
    assertThat(info.maxObjectSizeLimit.summary).isNull();
    info = getConfig(child);
    assertThat(info.maxObjectSizeLimit.value).isEqualTo("102400");
    assertThat(info.maxObjectSizeLimit.configuredValue).isNull();
    assertThat(info.maxObjectSizeLimit.summary).isEqualTo(String.format(INHERITED_FROM_PARENT, project));
}
Also used : Project(com.google.gerrit.entities.Project) ConfigInfo(com.google.gerrit.extensions.api.projects.ConfigInfo) GerritConfig(com.google.gerrit.acceptance.config.GerritConfig) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 13 with Project

use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.

the class ProjectIT method localCommentLinkOverridesParentCommentLink.

@Test
public void localCommentLinkOverridesParentCommentLink() throws Exception {
    ConfigInput input = new ConfigInput();
    addCommentLink(input, BUGZILLA, BUGZILLA_MATCH, BUGZILLA_LINK);
    addCommentLink(input, JIRA, JIRA_MATCH, JIRA_LINK);
    ConfigInfo info = setConfig(project, input);
    Map<String, CommentLinkInfo> expected = new HashMap<>();
    expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, BUGZILLA_LINK));
    expected.put(JIRA, commentLinkInfo(JIRA, JIRA_MATCH, JIRA_LINK));
    assertCommentLinks(info, expected);
    Project.NameKey child = projectOperations.newProject().parent(project).create();
    String otherLink = "https://other.example.com";
    input = new ConfigInput();
    addCommentLink(input, BUGZILLA, BUGZILLA_MATCH, otherLink);
    setConfig(child, input);
    expected = new HashMap<>();
    expected.put(BUGZILLA, commentLinkInfo(BUGZILLA, BUGZILLA_MATCH, otherLink));
    expected.put(JIRA, commentLinkInfo(JIRA, JIRA_MATCH, JIRA_LINK));
    assertCommentLinks(getConfig(child), expected);
}
Also used : Project(com.google.gerrit.entities.Project) ConfigInput(com.google.gerrit.extensions.api.projects.ConfigInput) CommentLinkInfo(com.google.gerrit.extensions.api.projects.CommentLinkInfo) HashMap(java.util.HashMap) ConfigInfo(com.google.gerrit.extensions.api.projects.ConfigInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 14 with Project

use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.

the class SetParentIT method setParentToGrandchildNotAllowed.

@Test
public void setParentToGrandchildNotAllowed() throws Exception {
    Project.NameKey child = projectOperations.newProject().parent(project).create();
    String grandchild = projectOperations.newProject().parent(child).create().get();
    ResourceConflictException thrown = assertThrows(ResourceConflictException.class, () -> gApi.projects().name(project.get()).parent(grandchild));
    assertThat(thrown).hasMessageThat().contains("cycle exists between");
}
Also used : Project(com.google.gerrit.entities.Project) ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 15 with Project

use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.

the class ProjectIT method maxObjectSizeOverridesParentProjectWhenNotSetOnParent.

@Test
public void maxObjectSizeOverridesParentProjectWhenNotSetOnParent() throws Exception {
    Project.NameKey child = projectOperations.newProject().parent(project).create();
    ConfigInfo info = setMaxObjectSize("0");
    assertThat(info.maxObjectSizeLimit.value).isNull();
    assertThat(info.maxObjectSizeLimit.configuredValue).isNull();
    assertThat(info.maxObjectSizeLimit.summary).isNull();
    info = setMaxObjectSize(child, "100k");
    assertThat(info.maxObjectSizeLimit.value).isEqualTo("102400");
    assertThat(info.maxObjectSizeLimit.configuredValue).isEqualTo("100k");
    assertThat(info.maxObjectSizeLimit.summary).isNull();
}
Also used : Project(com.google.gerrit.entities.Project) ConfigInfo(com.google.gerrit.extensions.api.projects.ConfigInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

Project (com.google.gerrit.entities.Project)184 Test (org.junit.Test)109 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)67 Change (com.google.gerrit.entities.Change)43 Repository (org.eclipse.jgit.lib.Repository)34 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)33 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)32 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)31 BranchNameKey (com.google.gerrit.entities.BranchNameKey)30 Config (org.eclipse.jgit.lib.Config)26 ObjectId (org.eclipse.jgit.lib.ObjectId)26 IOException (java.io.IOException)25 ChangeNotes (com.google.gerrit.server.notedb.ChangeNotes)24 ProjectState (com.google.gerrit.server.project.ProjectState)23 Inject (com.google.inject.Inject)23 List (java.util.List)23 AuthException (com.google.gerrit.extensions.restapi.AuthException)22 ChangeData (com.google.gerrit.server.query.change.ChangeData)22 RevCommit (org.eclipse.jgit.revwalk.RevCommit)22 PatchSet (com.google.gerrit.entities.PatchSet)20