Package com.indeed.proctor.common.model

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


import com.google.common.collect.Lists;

public class TestRandomTestChooser {
    @Test
    public void test100Percent() {
        final List<Range> ranges = Lists.newArrayList(new Range(-1, 0.0), new Range(0, 0.0), new Range(1, 1.0));
        final List<TestBucket> buckets = Lists.newArrayList(new TestBucket("inactive", -1, "zoot", null), new TestBucket("control", 0, "zoot", null), new TestBucket("test", 1, "zoot", null));

        final RandomTestChooser rtc = initializeRandomTestChooser(ranges, buckets);

        final Map<String, Object> values = Collections.emptyMap();
View Full Code Here


        }
    }

    @Test
    public void test5050Percent() {
        final List<Range> ranges = Lists.newArrayList(new Range(0, 0.5), new Range(1, 1.0));
        final List<TestBucket> buckets = Lists.newArrayList(new TestBucket("control", 0, "zoot", null), new TestBucket("test", 1, "zoot", null));

        final RandomTestChooser rtc = initializeRandomTestChooser(ranges, buckets);

        int[] found = { 0, 0 };
View Full Code Here

        assertTrue(found[1] < 600);
    }

    @Test
    public void test333333Percent() {
        final List<Range> ranges = Lists.newArrayList(new Range(0, 0.3333333333333333), new Range(1, 0.3333333333333333), new Range(2, 0.3333333333333333));
        final List<TestBucket> buckets = Lists.newArrayList(new TestBucket("inactive", 0, "zoot", null), new TestBucket("control", 1, "zoot", null), new TestBucket("test", 2, "zoot", null));

        final RandomTestChooser rtc = initializeRandomTestChooser(ranges, buckets);

        int[] found = { 0, 0, 0 };
View Full Code Here

    @Test
    public void convertToConsumableTestDefinitionTopLevelRulesSpecialConstants() {
        // Top Level rules can optionally have the "${}" around them.
        // rule: lang == 'en'
        // rule: ${lang == 'en'}
        final Range range = new Range(0, 1.0d);

        final String version = "100";
        final TestType testType = TestType.ANONYMOUS_USER;
        final String salt = "testsalt";
        final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
View Full Code Here

            assertEquals("trivially expected only one test in the matrix", 1, matrix.getTests().size());
            final List<Allocation> allocations = matrix.getTests().values().iterator().next().getAllocations();
            assertEquals("trivially expected only one allocation in the test (same as source)", 1, allocations.size());
            final List<Range> ranges = allocations.iterator().next().getRanges();
            assertEquals("Expected the ranges to be reduced from 3 to 1, since only the fallback value is now present", 1, ranges.size());
            final Range onlyRange = ranges.iterator().next();
            assertEquals("Should have adopted the fallback value from the test spec", onlyRange.getBucketValue(), testSpecification.getFallbackValue());
            assertEquals("Trivially should have been set to 100% fallback", 1.0, onlyRange.getLength(), 0.005);
        }
        {
            final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
            // Allocation of bucketValue=2 is == 0
            tests.put(TEST_A, constructDefinition(buckets, fromCompactAllocationFormat("0:0.5,1:0.5,2:0")));
View Full Code Here

            String[] allRanges = sRanges.split(",");
            final List<Range> ranges = Lists.newArrayListWithCapacity(allRanges.length);
            for(String sRange : allRanges) {
                // Could handle index-out of bounds + number formatting exception better.
                String[] rangeParts = sRange.split(":");
                ranges.add(new Range(Integer.parseInt(rangeParts[0], 10), Double.parseDouble(rangeParts[1])));
            }
            allocationList.add(new Allocation(rule, ranges));
        }
        return allocationList;
    }
View Full Code Here

        // all of the following "rules" should be treated as empty in the TestDefinition
        // rule: null
        // rule: ""
        // rule: " "
        final String[] emptyRules = new String[] { null, "", " " };
        final Range range = new Range(0, 1.0d);

        final String version = "100";
        final TestType testType = TestType.ANONYMOUS_USER;
        final String salt = "testsalt";
        final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
View Full Code Here

    @Test
    public void convertToConsumableTestDefinitionTopLevelRules() {
        // rules can optionally have the "${}" around them.
        // rule: lang == 'en'
        // rule: ${lang == 'en'}
        final Range range = new Range(0, 1.0d);

        final String version = "100";
        final TestType testType = TestType.ANONYMOUS_USER;
        final String salt = "testsalt";
        final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
View Full Code Here

        // all of the following "rules" should be treated as empty in the TestDefinition
        // rule: null
        // rule: ""
        // rule: " "
        final String[] emptyRules = new String[] { null, "", " " };
        final Range range = new Range(0, 1.0d);

        final String version = "100";
        final TestType testType = TestType.ANONYMOUS_USER;
        final String salt = "testsalt";
        final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
View Full Code Here

    @Test
    public void convertToConsumableTestDefinitionTopLevelRules() {
        // rules can optionally have the "${}" around them.
        // rule: lang == 'en'
        // rule: ${lang == 'en'}
        final Range range = new Range(0, 1.0d);

        final String version = "100";
        final TestType testType = TestType.ANONYMOUS_USER;
        final String salt = "testsalt";
        final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
View Full Code Here

TOP

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

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.