Search in sources :

Example 1 with CmisTestResultImpl

use of org.apache.chemistry.opencmis.tck.impl.CmisTestResultImpl in project copper-cms by PogeyanOSS.

the class VersioningSmokeTest method checkVersionSeries.

private CmisTestResult checkVersionSeries(Session session, List<Document> versions, String[] properties, String message) {
    List<CmisTestResult> results = new ArrayList<CmisTestResult>();
    CmisTestResult f;
    // make sure there is only one latest version
    // and zero or one latest major version
    int countLatest = 0;
    int countLatestMajor = 0;
    String latestId = null;
    for (Document version : versions) {
        addResult(results, checkObject(session, version, properties, "Version object check: " + version.getId()));
        if (Boolean.TRUE.equals(version.isLatestVersion())) {
            countLatest++;
            latestId = version.getId();
        }
        if (Boolean.TRUE.equals(version.isLatestMajorVersion())) {
            countLatestMajor++;
        }
    }
    f = createResult(FAILURE, "The version series must have exactly one latest version, but it has " + countLatest + "!");
    addResult(results, assertEquals(1, countLatest, null, f));
    f = createResult(FAILURE, "The version series must have zero or one latest major version, but it has " + countLatestMajor + "!");
    addResult(results, assertIsTrue(countLatestMajor < 2, null, f));
    // check getObjectOfLatestVersion()
    if (countLatest == 1) {
        Document latestVersion = versions.get(0).getObjectOfLatestVersion(false, SELECT_ALL_NO_CACHE_OC);
        addResult(results, checkObject(session, latestVersion, properties, "Latest version object check: " + latestVersion.getId()));
        f = createResult(FAILURE, "The version that is flagged as latest version is not returned by getObjectOfLatestVersion()!");
        addResult(results, assertEquals(latestId, latestVersion.getId(), null, f));
        // check with session.getLatestDocumentVersion()
        Document latestVersion2 = session.getLatestDocumentVersion(versions.get(versions.size() - 1).getId(), SELECT_ALL_NO_CACHE_OC);
        addResult(results, checkObject(session, latestVersion2, properties, "Latest version object check (2): " + latestVersion2.getId()));
        f = createResult(FAILURE, "The version that is flagged as latest version is not returned by getObjectOfLatestVersion()!");
        addResult(results, assertEquals(latestId, latestVersion2.getId(), null, f));
    }
    CmisTestResultImpl result = createResult(getWorst(results), message);
    result.getChildren().addAll(results);
    return result.getStatus().getLevel() <= OK.getLevel() ? null : result;
}
Also used : CmisTestResultImpl(org.apache.chemistry.opencmis.tck.impl.CmisTestResultImpl) CmisTestResult(org.apache.chemistry.opencmis.tck.CmisTestResult) ArrayList(java.util.ArrayList) Document(org.apache.chemistry.opencmis.client.api.Document)

Aggregations

ArrayList (java.util.ArrayList)1 Document (org.apache.chemistry.opencmis.client.api.Document)1 CmisTestResult (org.apache.chemistry.opencmis.tck.CmisTestResult)1 CmisTestResultImpl (org.apache.chemistry.opencmis.tck.impl.CmisTestResultImpl)1