Package com.indeed.proctor.common.model

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


    static RandomTestChooser initializeRandomTestChooser(final List<Range> ranges, final List<TestBucket> buckets) {
        final ExpressionFactory expressionFactory = new ExpressionFactoryImpl();

        final FunctionMapper functionMapper = RuleEvaluator.FUNCTION_MAPPER;

        final ConsumableTestDefinition testDefinition = new ConsumableTestDefinition();
        testDefinition.setConstants(Collections.<String, Object>emptyMap());

        testDefinition.setBuckets(buckets);

        final List<Allocation> allocations = Lists.newArrayList();
        allocations.add(new Allocation("${}", ranges));
        testDefinition.setAllocations(allocations);

        final RandomTestChooser rtc = new RandomTestChooser(expressionFactory, functionMapper, "testName", testDefinition);
        return rtc;
    }
View Full Code Here


        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
        testDefinition.setSalt(testName);
        testDefinition.setBuckets(buckets);
View Full Code Here

    @Test
    public void testExceptionsDealtWith() {
        final String testName = "test";

        final ConsumableTestDefinition testDefinition = new ConsumableTestDefinition();
        testDefinition.setConstants(Collections.<String, Object>emptyMap());
        testDefinition.setRule("${lang == 'en'}");

        testDefinition.setTestType(TestType.ANONYMOUS_USER);

        // most tests just set the salt to be the same as the test name
        testDefinition.setSalt(testName);
        testDefinition.setBuckets(Collections.<TestBucket>emptyList());

        final RuleEvaluator ruleEvaluator = EasyMock.createMock(RuleEvaluator.class);
        EasyMock.expect(ruleEvaluator.evaluateBooleanRule(
                EasyMock.<String>anyObject(),
                EasyMock.<Map<String,Object>>anyObject()
View Full Code Here

                    constants,
                    specialConstants,
                    description
                );

                final ConsumableTestDefinition ctd = ProctorUtils.convertToConsumableTestDefinition(testDefinition);
                assertEquals(version, ctd.getVersion());
                assertEquals(testType, ctd.getTestType());
                assertEquals(salt, ctd.getSalt());
                assertEquals(description, ctd.getDescription());
                assertEquals(0, ctd.getConstants().size());
                assertEquals(buckets, ctd.getBuckets());

                assertEquals(String.format("TestDefinition rule '%s' should convert to a null ConsumableTestDefinition.rule", tdRule), null, ctd.getRule());

                assertEquals(1, ctd.getAllocations().size());
                final Allocation ctdAllocation = ctd.getAllocations().get(0);
                assertEquals(String.format("Allocation rule '%s' should convert to a null ConsumableTestDefinition.Allocation.rule", allocRule), null, ctdAllocation.getRule());
                assertEquals(allocation.getRanges(), ctdAllocation.getRanges());
            }
        }
    }
View Full Code Here

                constants,
                specialConstants,
                description
            );

            final ConsumableTestDefinition ctd = ProctorUtils.convertToConsumableTestDefinition(testDefinition);
            assertEquals(String.format("TestDefinition rule '%s' should convert to a ${lang == 'en'} ConsumableTestDefinition.rule", rule), "${lang == 'en'}", ctd.getRule());

            assertEquals(1, ctd.getAllocations().size());
            final Allocation ctdAllocation = ctd.getAllocations().get(0);
            assertEquals(String.format("Allocation rule '%s' should convert to a ${lang == 'en'} ConsumableTestDefinition.Allocation.rule", rule), "${lang == 'en'}", ctdAllocation.getRule());
            assertEquals(allocation.getRanges(), ctdAllocation.getRanges());
        }
    }
View Full Code Here

                constants,
                specialConstants,
                description
            );

            final ConsumableTestDefinition ctd = ProctorUtils.convertToConsumableTestDefinition(testDefinition);
            assertEquals(String.format("TestDefinition rule '%s' should convert to ${proctor:contains(__COUNTRIES, country) && lang == 'en'} ConsumableTestDefinition.rule", tdRule), "${proctor:contains(__COUNTRIES, country) && lang == 'en'}", ctd.getRule());
            assertEquals(1, ctd.getConstants().size());
            assertEquals("special constants should be added to constants", Lists.newArrayList("US", "CA"), ctd.getConstants().get("__COUNTRIES"));
        }
    }
View Full Code Here

                    constants,
                    specialConstants,
                    description
                );

                final ConsumableTestDefinition ctd = ProctorUtils.convertToConsumableTestDefinition(testDefinition);
                assertEquals(version, ctd.getVersion());
                assertEquals(testType, ctd.getTestType());
                assertEquals(salt, ctd.getSalt());
                assertEquals(description, ctd.getDescription());
                assertEquals(0, ctd.getConstants().size());
                assertEquals(buckets, ctd.getBuckets());

                assertEquals(String.format("TestDefinition rule '%s' should convert to a null ConsumableTestDefinition.rule", tdRule), null, ctd.getRule());

                assertEquals(1, ctd.getAllocations().size());
                final Allocation ctdAllocation = ctd.getAllocations().get(0);
                assertEquals(String.format("Allocation rule '%s' should convert to a null ConsumableTestDefinition.Allocation.rule", allocRule), null, ctdAllocation.getRule());
                assertEquals(allocation.getRanges(), ctdAllocation.getRanges());
            }
        }
    }
View Full Code Here

                constants,
                specialConstants,
                description
            );

            final ConsumableTestDefinition ctd = ProctorUtils.convertToConsumableTestDefinition(testDefinition);
            assertEquals(String.format("TestDefinition rule '%s' should convert to a ${lang == 'en'} ConsumableTestDefinition.rule", rule), "${lang == 'en'}", ctd.getRule());

            assertEquals(1, ctd.getAllocations().size());
            final Allocation ctdAllocation = ctd.getAllocations().get(0);
            assertEquals(String.format("Allocation rule '%s' should convert to a ${lang == 'en'} ConsumableTestDefinition.Allocation.rule", rule), "${lang == 'en'}", ctdAllocation.getRule());
            assertEquals(allocation.getRanges(), ctdAllocation.getRanges());
        }
    }
View Full Code Here

                constants,
                specialConstants,
                description
            );

            final ConsumableTestDefinition ctd = ProctorUtils.convertToConsumableTestDefinition(testDefinition);
            assertEquals(String.format("TestDefinition rule '%s' should convert to ${proctor:contains(__COUNTRIES, country) && lang == 'en'} ConsumableTestDefinition.rule", tdRule), "${proctor:contains(__COUNTRIES, country) && lang == 'en'}", ctd.getRule());
            assertEquals(1, ctd.getConstants().size());
            assertEquals("special constants should be added to constants", Lists.newArrayList("US", "CA"), ctd.getConstants().get("__COUNTRIES"));
        }
    }
View Full Code Here

    @Test
    public void testELValidity_inProctorBuilderAllocationRules() throws IncompatibleTestMatrixException {

        //testing invalid allocation rule
        final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
        final ConsumableTestDefinition testDefInVal = constructDefinition(buckets,
                fromCompactAllocationFormat("${b4t#+=}|-1:0.5,0:0.5,1:0.0", "-1:0.25,0:0.5,1:0.25")); // invalid EL, nonsense rule
        try {
            ProctorUtils.verifyInternallyConsistentDefinition("testELevalInval", "test el recognition - inval", testDefInVal);
            fail("expected IncompatibleTestMatrixException");
        } catch (IncompatibleTestMatrixException e) {
            //expected
        }

        //testing valid functions pass with proctor included functions (will throw exception if can't find) and backwards compatibility
        final ConsumableTestDefinition testDefVal1 = constructDefinition(buckets,
                fromCompactAllocationFormat("${proctor:now()==indeed:now()}|-1:0.5,0:0.5,1:0.0", "-1:0.25,0:0.5,1:0.25"));
        ProctorUtils.verifyInternallyConsistentDefinition("testELevalProctor", "test el recognition", testDefVal1);

    }
View Full Code Here

TOP

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

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.