Search in sources :

Example 1 with LabelTypeInfo

use of com.google.gerrit.extensions.common.LabelTypeInfo in project gerrit by GerritCodeReview.

the class ProjectJson method format.

public ProjectInfo format(ProjectState projectState) {
    ProjectInfo info = format(projectState.getProject());
    info.labels = new HashMap<>();
    for (LabelType t : projectState.getLabelTypes().getLabelTypes()) {
        LabelTypeInfo labelInfo = new LabelTypeInfo();
        labelInfo.values = t.getValues().stream().collect(toMap(LabelValue::formatValue, LabelValue::getText, (v1, v2) -> {
            logger.atSevere().log("Duplicate values for project: %s, label: %s found: '%s':'%s'", projectState.getName(), t.getName(), v1, v2);
            return v1;
        }));
        labelInfo.defaultValue = t.getDefaultValue();
        info.labels.put(t.getName(), labelInfo);
    }
    return info;
}
Also used : LabelValue(com.google.gerrit.entities.LabelValue) LabelType(com.google.gerrit.entities.LabelType) ProjectInfo(com.google.gerrit.extensions.common.ProjectInfo) LabelTypeInfo(com.google.gerrit.extensions.common.LabelTypeInfo)

Example 2 with LabelTypeInfo

use of com.google.gerrit.extensions.common.LabelTypeInfo in project gerrit by GerritCodeReview.

the class GetProjectIT method getProject.

@Test
public void getProject() throws Exception {
    String name = project.get();
    ProjectInfo p = gApi.projects().name(name).get();
    assertThat(p.name).isEqualTo(name);
    assertThat(p.labels).hasSize(1);
    LabelTypeInfo l = p.labels.get("Code-Review");
    ImmutableMap<String, String> want = ImmutableMap.of(" 0", "No score", "-1", "I would prefer this is not merged as is", "-2", "This shall not be merged", "+1", "Looks good to me, but someone else must approve", "+2", "Looks good to me, approved");
    assertThat(l.values).isEqualTo(want);
    assertThat(l.defaultValue).isEqualTo(0);
}
Also used : ProjectInfo(com.google.gerrit.extensions.common.ProjectInfo) LabelTypeInfo(com.google.gerrit.extensions.common.LabelTypeInfo) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

LabelTypeInfo (com.google.gerrit.extensions.common.LabelTypeInfo)2 ProjectInfo (com.google.gerrit.extensions.common.ProjectInfo)2 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)1 LabelType (com.google.gerrit.entities.LabelType)1 LabelValue (com.google.gerrit.entities.LabelValue)1 Test (org.junit.Test)1