All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.indeed.proctor.common.ProctorResult Maven / Gradle / Ivy

package com.indeed.proctor.common;

import com.indeed.proctor.common.model.Audit;
import com.indeed.proctor.common.model.ConsumableTestDefinition;
import com.indeed.proctor.common.model.TestBucket;

import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;

import com.google.common.collect.Maps;

import javax.annotation.Nonnull;

/**
 * Return value from {@link Proctor#determineTestGroups(Identifiers, java.util.Map, java.util.Map)}
 * @author ketan
 *
 */
public class ProctorResult {
    public static final ProctorResult EMPTY = new ProctorResult(Audit.EMPTY_VERSION, Collections.emptyMap(), Collections.emptyMap());

    private final String matrixVersion;
    @Nonnull
    private final Map buckets;
    @Nonnull
    private final Map testDefinitions;

    @Deprecated
    public ProctorResult(
            final int matrixVersion,
            @Nonnull final Map buckets,
            @Nonnull final Map testDefinitions
    ) {
        this(new Integer(matrixVersion).toString(), buckets, testDefinitions);
    }

    public ProctorResult(
            final String matrixVersion,
            @Nonnull final Map buckets,
            @Nonnull final Map testDefinitions
    ) {
        this.matrixVersion = matrixVersion;
        this.buckets = Maps.newTreeMap();
        this.buckets.putAll(buckets);
        this.testDefinitions = testDefinitions;
    }

    @SuppressWarnings("UnusedDeclaration")
    public String getMatrixVersion() {
        return matrixVersion;
    }

    @Nonnull
    public Map getBuckets() {
        return buckets;
    }

    @Nonnull
    public Map getTestDefinitions() {
        return testDefinitions;
    }

    @Nonnull
    public Map getTestVersions() {
        // TODO ImmutableMap?
        final Map testVersions = Maps.newHashMap();
        for (final Entry entry : testDefinitions.entrySet()) {
            testVersions.put(entry.getKey(), entry.getValue().getVersion());
        }
        return testVersions;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy