Package com.indeed.proctor.common.model

Examples of com.indeed.proctor.common.model.TestBucket


                    continue;
                }
                identifier = null;
            }
            if (forceGroupBucket != null) {
                final TestBucket forcedTestBucket = testChooser.getTestBucket(forceGroupBucket);
                if (forcedTestBucket != null) {
                    testGroups.put(testName, forcedTestBucket);
                    continue;
                }
            }
            final TestBucket testBucket;
            if (identifier == null) {
                testBucket = ((RandomTestChooser) testChooser).choose(null, inputContext);
            } else {
                testBucket = ((StandardTestChooser) testChooser).choose(identifier, inputContext);
            }
View Full Code Here


        return new ConsumableTestDefinition(
                "default",
                null,
                TestType.RANDOM,
                testName,
                ImmutableList.of(new TestBucket(
                        missingTestSoleBucketName,
                        testSpecification.getFallbackValue(),
                        missingTestSoleBucketDescription)),
                // Force a nonnull allocation just in case something somewhere assumes 1.0 total allocation
                Collections.singletonList(allocation),
View Full Code Here


        for(final Iterator<Map.Entry<String, TestBucket>> iterator = proctorResult.getBuckets().entrySet().iterator(); iterator.hasNext(); ) {
            final Map.Entry<String, TestBucket> entry = iterator.next();
            final String testName = entry.getKey();
            final TestBucket testBucket = entry.getValue();

            if(sb.length() > 0) {
                sb.append(",");
            }
            // String format is: {testName}:{testBucket.name}{testBucket.value}
            sb.append(testName).append(":").append(testBucket.getName()).append(testBucket.getValue());
        }
        return sb.toString();
    }
View Full Code Here


        for(final Iterator<Map.Entry<String, TestBucket>> iterator = proctorResult.getBuckets().entrySet().iterator(); iterator.hasNext(); ) {
            final Map.Entry<String, TestBucket> entry = iterator.next();
            final String testName = entry.getKey();
            final TestBucket testBucket = entry.getValue();

            if(sb.length() > 0) {
                sb.append(",");
            }
            // String format is: {testName}:{testBucket.name}{testBucket.value}
            sb.append(testName).append(":").append(testBucket.getName()).append(testBucket.getValue());
        }
        return sb.toString();
    }
View Full Code Here

        for (final Bucket<?> result: results) {
            final String testName = result.getClass().getSimpleName().toLowerCase();
            final int testValue = result.getValue();

            TestBucket testBucket = new TestBucket(testName, testValue, testName);

            Preconditions.checkState(!buckets.containsKey(testName), "Attempted to provide two values for dummy test bucket %s", testName);
            buckets.put(testName, testBucket);
        }
View Full Code Here

        for (final CannedProctorResult<?> result: results) {
            final String testName = result.testVal.getClass().getSimpleName().toLowerCase();
            final int testValue = result.testVal.getValue();

            TestBucket testBucket = new TestBucket(testName, testValue, testName);
            if (result.payload != null) {
                testBucket.setPayload(result.payload);
            }

            Preconditions.checkState(!buckets.containsKey(testName), "Attempted to provide two values for dummy test bucket %s", testName);
            buckets.put(testName, testBucket);
        }
View Full Code Here

                    bucketValueStart++;
                }
                //  bucketValueStart should now be the index of the minus sign or the first digit in a run of digits going to the end of the word
                final String testName = group.substring(0, bucketValueStart).trim();

                final TestBucket testBucket = buckets.get(testName);
                if (testBucket == null) {
                    title = null;
                } else {
                    final ConsumableTestDefinition testDefinition = testDefinitions.get(testName);
                    if (testDefinition == null) {
View Full Code Here

        audit.setUpdatedBy("nobody");
        audit.setVersion(Audit.EMPTY_VERSION);

        matrix.setAudit(audit);

        final TestBucket abcBucket0 = new TestBucket("always", 0, "always description", null);
        final List<TestBucket> abcBuckets = Lists.newArrayList(abcBucket0);
        final Map<String, Object> abcTestConstants = Maps.newHashMap();
        abcTestConstants.put("ANOTHER_NUM", Integer.valueOf(5));
        abcTestConstants.put("SOME_NUM", Integer.valueOf(1));

        final List<Allocation> abcAllocations = Collections.singletonList(new Allocation(null, Arrays.asList(new Range[] { new Range(abcBucket0.getValue(), 1) })));

        /**
final int id, final int version, final String rule, final TestType testType, final String salt, final List<TestBucket> buckets, final List<RuleRatio> ratios,
final Map<String, Object> constants, final String description) {

         */
        final ConsumableTestDefinition abcTD = new ConsumableTestDefinition("1", "${num > SOME_NUM && num < ANOTHER_NUM}", TestType.ANONYMOUS_USER, "abcsalt", abcBuckets, abcAllocations, abcTestConstants, "zingle boppity zip zop");

        final TestBucket defBucket0 = new TestBucket("control", 0, "control description", null);
        final TestBucket defBucket1 = new TestBucket("test1", 1, "test1 description", null);
        final TestBucket defBucket2 = new TestBucket("test2", 2, "test2 description", null);
        final List<TestBucket> defBuckets = Lists.newArrayList(defBucket0, defBucket1, defBucket2);
        final Map<String, Object> defTestConstants = Maps.newHashMap();
        defTestConstants.put("T", Boolean.TRUE);
        defTestConstants.put("COUNTRIES", Sets.newHashSet("AE", "IO", "UY"));
        final List<Allocation> defAllocations = Collections.singletonList(new Allocation(null, Arrays.asList(new Range[] {
                new Range(defBucket0.getValue(), 1/3f),
                new Range(defBucket1.getValue(), 1/3f),
                new Range(defBucket2.getValue(), 1/3f),
        })));
        final ConsumableTestDefinition defTD = new ConsumableTestDefinition("2", "${proctor:contains(COUNTRIES, country) && T}", TestType.ANONYMOUS_USER, "defsalt", defBuckets, defAllocations, defTestConstants, "finkle fangle foop");

        final TestBucket ghiBucket0 = new TestBucket("inactive", -1, "inactive description", null);
        final TestBucket ghiBucket1 = new TestBucket("control", 0, "control desc", null);
        final TestBucket ghiBucket2 = new TestBucket("optionA", 1, "option A desc", null);
        final TestBucket ghiBucket3 = new TestBucket("optionB", 2, "option B desc", null);
        final TestBucket ghiBucket4 = new TestBucket("optionC", 3, "option C desc", null);
        final List<TestBucket> ghiBuckets = Lists.newArrayList(ghiBucket0, ghiBucket1, ghiBucket2, ghiBucket3, ghiBucket4);
        final Map<String, Object> ghiTestConstants = Maps.newHashMap();
        ghiTestConstants.put("LANGUAGES", Sets.newHashSet("es", "fr", "pt", "nl"));
        ghiTestConstants.put("COUNTRIES", Sets.newHashSet("AE", "IO", "UY"));
        final List<Allocation> ghiAllocations = Collections.singletonList(new Allocation(null,
                Arrays.asList(new Range[] {
                        new Range(ghiBucket0.getValue(), 0.2),
                        new Range(ghiBucket1.getValue(), 0.2),
                        new Range(ghiBucket2.getValue(), 0.2),
                        new Range(ghiBucket3.getValue(), 0.2),
                        new Range(ghiBucket4.getValue(), 0.2),
                })));
        final ConsumableTestDefinition ghiTD = new ConsumableTestDefinition("3", "${proctor:contains(LANGUAGES, language)}", TestType.ANONYMOUS_USER, "ghisalt", ghiBuckets, ghiAllocations, ghiTestConstants, "jangle bing zimple plop");
        final Map<String, ConsumableTestDefinition> tests = Maps.newLinkedHashMap();
        tests.put("abc", abcTD);
        tests.put("def", defTD);
View Full Code Here

        final ProctorResult proctorResult = proctor.determineTestGroups(identifiers, context, forceGroups);
        final StringBuilder buckets = new StringBuilder();
        for (final Iterator<Entry<String, TestBucket>> iterator = proctorResult.getBuckets().entrySet().iterator(); iterator.hasNext(); ) {
            final Entry<String, TestBucket> entry = iterator.next();
            final String testName = entry.getKey();
            final TestBucket testBucket = entry.getValue();

            if (testBucket.getValue() >= 0) {
                if (buckets.length() > 0){
                    buckets.append(',');
                }
                buckets.append(testName)
                        .append(testBucket.getValue());
            }
        }

        return buckets.toString();
    }
View Full Code Here

    protected AbstractGroups(final ProctorResult proctorResult) {
        this.proctorResult = proctorResult;
        this.buckets = Maps.newLinkedHashMap();
        for (final Entry<String, TestBucket> entry : proctorResult.getBuckets().entrySet()) {
            final TestBucket testBucket = entry.getValue();
            this.buckets.put(entry.getKey(), testBucket);
        }
    }
View Full Code Here

TOP

Related Classes of com.indeed.proctor.common.model.TestBucket

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.