Package com.indeed.proctor.common.model

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


    @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

            for (int j = 0; j < ranges.size(); j++) {
                // ignoring the trailing comma
                if (j > 0) {
                    writer.print(", ");
                }
                final Range range = ranges.get(j);
                writer.printf("%s%d='%s'", testName, range.getBucketValue(), fmt.format(range.getLength()));
            }
        }
        writer.print(" },");
    }
View Full Code Here

    @Nonnull
    private static ConsumableTestDefinition defaultFor(final String testName, @Nonnull final TestSpecification testSpecification) {
        final String missingTestSoleBucketName = "inactive";
        final String missingTestSoleBucketDescription = "inactive";
        final Allocation allocation = new Allocation();
        allocation.setRanges(ImmutableList.of(new Range(testSpecification.getFallbackValue(), 1.0)));

        return new ConsumableTestDefinition(
                "default",
                null,
                TestType.RANDOM,
View Full Code Here

        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

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.