diff options
Diffstat (limited to 'gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/ProjectAssert.java')
-rw-r--r-- | gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/ProjectAssert.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/ProjectAssert.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/ProjectAssert.java new file mode 100644 index 0000000000..25ccbee94c --- /dev/null +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/project/ProjectAssert.java @@ -0,0 +1,49 @@ +// Copyright (C) 2013 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.gerrit.acceptance.rest.project; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.google.common.base.Strings; +import com.google.gerrit.extensions.restapi.Url; +import com.google.gerrit.reviewdb.client.AccountGroup; +import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.server.project.ProjectState; + +import java.util.Set; + +public class ProjectAssert { + + 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); + } + assertEquals(project.getName(), Url.decode(info.id)); + 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)); + } + + public static void assertProjectOwners(Set<AccountGroup.UUID> expectedOwners, + ProjectState state) { + for (AccountGroup.UUID g : state.getOwners()) { + assertTrue("unexpected owner group " + g, expectedOwners.remove(g)); + } + assertTrue("missing owner groups: " + expectedOwners, + expectedOwners.isEmpty()); + } +} |