Search in sources :

Example 1 with LegacySubmitRequirement

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

the class ChangeJson method submitRecordToInfo.

private SubmitRecordInfo submitRecordToInfo(SubmitRecord record) {
    SubmitRecordInfo info = new SubmitRecordInfo();
    if (record.status != null) {
        info.status = SubmitRecordInfo.Status.valueOf(record.status.name());
    }
    info.ruleName = record.ruleName;
    info.errorMessage = record.errorMessage;
    if (record.labels != null) {
        info.labels = new ArrayList<>();
        for (SubmitRecord.Label label : record.labels) {
            SubmitRecordInfo.Label labelInfo = new SubmitRecordInfo.Label();
            labelInfo.label = label.label;
            if (label.status != null) {
                labelInfo.status = SubmitRecordInfo.Label.Status.valueOf(label.status.name());
            }
            labelInfo.appliedBy = accountLoader.get(label.appliedBy);
            info.labels.add(labelInfo);
        }
    }
    if (record.requirements != null) {
        info.requirements = new ArrayList<>();
        for (LegacySubmitRequirement requirement : record.requirements) {
            info.requirements.add(requirementToInfo(requirement, record.status));
        }
    }
    return info;
}
Also used : SubmitRecord(com.google.gerrit.entities.SubmitRecord) LegacySubmitRequirement(com.google.gerrit.entities.LegacySubmitRequirement) SubmitRecordInfo(com.google.gerrit.extensions.common.SubmitRecordInfo)

Example 2 with LegacySubmitRequirement

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

the class EventFactory method addSubmitRecordRequirements.

private void addSubmitRecordRequirements(SubmitRecord submitRecord, SubmitRecordAttribute sa) {
    if (submitRecord.requirements != null && !submitRecord.requirements.isEmpty()) {
        sa.requirements = new ArrayList<>();
        for (LegacySubmitRequirement req : submitRecord.requirements) {
            SubmitRequirementAttribute re = new SubmitRequirementAttribute();
            re.fallbackText = req.fallbackText();
            re.type = req.type();
            sa.requirements.add(re);
        }
    }
}
Also used : LegacySubmitRequirement(com.google.gerrit.entities.LegacySubmitRequirement) SubmitRequirementAttribute(com.google.gerrit.server.data.SubmitRequirementAttribute)

Example 3 with LegacySubmitRequirement

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

the class ChangeFieldTest method storedSubmitRequirementWithoutCustomData.

@Test
public void storedSubmitRequirementWithoutCustomData() {
    SubmitRecord r = record(SubmitRecord.Status.OK, label(SubmitRecord.Label.Status.MAY, "Label-1", null), label(SubmitRecord.Label.Status.OK, "Label-2", 1));
    // Doesn't have any custom data value
    LegacySubmitRequirement sr = LegacySubmitRequirement.builder().setFallbackText("short_type").setType("ci_status").build();
    r.requirements = Collections.singletonList(sr);
    assertStoredRecordRoundTrip(r);
}
Also used : SubmitRecord(com.google.gerrit.entities.SubmitRecord) LegacySubmitRequirement(com.google.gerrit.entities.LegacySubmitRequirement) Test(org.junit.Test)

Example 4 with LegacySubmitRequirement

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

the class ChangeFieldTest method storedSubmitRecordsWithRequirement.

@Test
public void storedSubmitRecordsWithRequirement() {
    SubmitRecord r = record(SubmitRecord.Status.OK, label(SubmitRecord.Label.Status.MAY, "Label-1", null), label(SubmitRecord.Label.Status.OK, "Label-2", 1));
    LegacySubmitRequirement sr = LegacySubmitRequirement.builder().setType("short_type").setFallbackText("Fallback text may contain special symbols like < > \\ / ; :").build();
    r.requirements = Collections.singletonList(sr);
    assertStoredRecordRoundTrip(r);
}
Also used : SubmitRecord(com.google.gerrit.entities.SubmitRecord) LegacySubmitRequirement(com.google.gerrit.entities.LegacySubmitRequirement) Test(org.junit.Test)

Aggregations

LegacySubmitRequirement (com.google.gerrit.entities.LegacySubmitRequirement)4 SubmitRecord (com.google.gerrit.entities.SubmitRecord)3 Test (org.junit.Test)2 SubmitRecordInfo (com.google.gerrit.extensions.common.SubmitRecordInfo)1 SubmitRequirementAttribute (com.google.gerrit.server.data.SubmitRequirementAttribute)1