Package com.indeed.proctor.common.model

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


            Assert.assertEquals(0, definition.getSpecialConstants().size());
            Assert.assertEquals(1, definition.getConstants().size());
            Assert.assertEquals("en", definition.getConstants().get("ENGLISH"));

            Assert.assertEquals(2, definition.getBuckets().size());
            final TestBucket controlBucket = definition.getBuckets().get(0);
            Assert.assertEquals("control", controlBucket.getName());
            Assert.assertEquals(0, controlBucket.getValue());
            Assert.assertNull(controlBucket.getDescription());

            final TestBucket testBucket = definition.getBuckets().get(1);
            Assert.assertEquals("test", testBucket.getName());
            Assert.assertEquals(1, testBucket.getValue());
            Assert.assertNull(testBucket.getDescription());

            Assert.assertEquals(2, definition.getAllocations().size());
            final Allocation englishAllocation = definition.getAllocations().get(0);
            Assert.assertEquals("${lang == ENGLISH}", englishAllocation.getRule());
            Assert.assertEquals(0.25, englishAllocation.getRanges().get(0).getLength(), 1E-16);
View Full Code Here


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();
        for (int i = 0; i < 100; i++) {
            final TestBucket chosen = rtc.choose(null, values);
            assertNotNull(chosen);
            assertEquals(1, chosen.getValue());
        }
    }
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 };
        final Map<String, Object> values = Collections.emptyMap();
        for (int i = 0; i < 1000; i++) {
            final TestBucket chosen = rtc.choose(null, values);
            assertNotNull(chosen);
            found[chosen.getValue()]++;
        }

        assertTrue(found[0] > 400);
        assertTrue(found[0] < 600);
        assertTrue(found[1] > 400);
View Full Code Here

    }

    @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 };
        final Map<String, Object> values = Collections.emptyMap();
        for (int i = 0; i < 1000; i++) {
            final TestBucket chosen = rtc.choose(null, values);
            assertNotNull(chosen);
            found[chosen.getValue()]++;
        }

        assertTrue(found[0] > 250);
        assertTrue(found[0] < 400);
        assertTrue(found[1] > 250);
View Full Code Here

    public void setupMocks() throws Exception {
        expressionFactory = new ExpressionFactoryImpl();
        functionMapper = RuleEvaluator.FUNCTION_MAPPER;
        testName = "testName";
        final List<TestBucket> buckets = ImmutableList.of(
                new TestBucket("inactive", -1, "zoot", null),
                new TestBucket("control", 0, "zoot", null),
                new TestBucket("test", 1, "zoot", null)
        );
        testDefinition = new ConsumableTestDefinition();
        testDefinition.setConstants(Collections.<String, Object>emptyMap());
        testDefinition.setTestType(TestType.AUTHENTICATED_USER);
        // most tests just set the salt to be the same as the test name
View Full Code Here

        updateAllocations(RANGES_100_0);
        final StandardTestChooser rtc = newChooser();

        final Map<String, Object> values = Collections.emptyMap();
        for (int i = 0; i < 100; i++) {
            final TestBucket chosen = rtc.choose(String.valueOf(i), values);
            assertNotNull(chosen);
            assertEquals(1, chosen.getValue());
        }
    }
View Full Code Here

                testName,
                testDefinition
        );

        // Ensure no exceptions thrown.
        final TestBucket bucket = new StandardTestChooser(selector)
                .choose("identifier", Collections.<String, Object>emptyMap());

        assertEquals(
                "Expected no bucket to be found ",
                null, bucket);
View Full Code Here

    private void exerciseChooser(final StandardTestChooser rtc) {
        final int num = 10000000;

        final Map<String, Object> values = Collections.emptyMap();
        for (int accountId = 1; accountId < num; accountId++) { // deliberately skipping 0
            final TestBucket chosen = rtc.choose(String.valueOf(accountId), values);
            assertNotNull(chosen);

            counts[chosen.getValue()]++;
            hashes[chosen.getValue()] = 31 * hashes[chosen.getValue()] + accountId;
        }
    }
View Full Code Here

        String[] bucketParts = sBuckets.split(",");
        List<TestBucket> buckets = Lists.newArrayListWithCapacity(bucketParts.length);
        for(int i = 0; i < bucketParts.length; i++) {
            // Could handle index-out of bounds + number formatting exception better.
            final String[] nameAndValue = bucketParts[i].split(":");
            buckets.add(new TestBucket(nameAndValue[0], Integer.parseInt(nameAndValue[1]), "bucket " + i, null));
        }
        return buckets;
    }
View Full Code Here

        String[] bucketParts = sBuckets.split(",");
        List<TestBucket> buckets = Lists.newArrayListWithCapacity(bucketParts.length);
        for(int i = 0; i < bucketParts.length; i++) {
            // Could handle index-out of bounds + number formatting exception better.
            final String[] nameAndValue = bucketParts[i].split(":");
            buckets.add(new TestBucket(nameAndValue[0], Integer.parseInt(nameAndValue[1]), "bucket " + i, null));
        }
        return buckets;
    }
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.