blob: 25ccbee94c22fea2c67a8a0198201e31b60eaa6c [file] [log] [blame]
// 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());
}
}