当前位置: 首页>>代码示例>>Java>>正文


Java ConsumableTestDefinition.setBuckets方法代码示例

本文整理汇总了Java中com.indeed.proctor.common.model.ConsumableTestDefinition.setBuckets方法的典型用法代码示例。如果您正苦于以下问题:Java ConsumableTestDefinition.setBuckets方法的具体用法?Java ConsumableTestDefinition.setBuckets怎么用?Java ConsumableTestDefinition.setBuckets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.indeed.proctor.common.model.ConsumableTestDefinition的用法示例。


在下文中一共展示了ConsumableTestDefinition.setBuckets方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupMocks

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入方法依赖的package包/类
@Before
public void setupMocks() throws Exception {
    expressionFactory = new ExpressionFactoryImpl();
    functionMapper = RuleEvaluator.FUNCTION_MAPPER;
    testName = "testName";
    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(INACTIVE_CONTROL_TEST_BUCKETS);

    updateAllocations(RANGES_50_50);

    final int effBuckets = INACTIVE_CONTROL_TEST_BUCKETS.size() - 1;
    counts = new int[effBuckets];
    hashes = new int[effBuckets];
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:19,代码来源:TestStandardTestChooser.java

示例2: initializeRandomTestChooser

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入方法依赖的package包/类
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;
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:18,代码来源:TestRandomTestChooser.java

示例3: constructDefinition

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入方法依赖的package包/类
public static ConsumableTestDefinition constructDefinition(List<TestBucket> buckets,
                                                     List<Allocation> allocations) {

    final ConsumableTestDefinition test = new ConsumableTestDefinition();
    test.setVersion(""); // don't care about version for this test
    test.setSalt(null); // don't care about salt for this test
    test.setRule(null); // don't care about rule for this test
    test.setTestType(TestType.ANONYMOUS_USER);    // don't really care, but need a valid value
    test.setConstants(Collections.<String, Object>emptyMap()); // don't care about constants for this test

    test.setBuckets(buckets);
    test.setAllocations(allocations);
    return test;
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:15,代码来源:TestProctorUtils.java

示例4: testDefaultAllocationWithNonEmptyRule_fallback

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入方法依赖的package包/类
@Test
public void testDefaultAllocationWithNonEmptyRule_fallback() {
    final String testName = "test";

    final ConsumableTestDefinition testDefinition = new ConsumableTestDefinition();
    testDefinition.setConstants(Collections.<String, Object>emptyMap());
    testDefinition.setTestType(TestType.ANONYMOUS_USER);
    testDefinition.setSalt(testName);

    testDefinition.setBuckets(INACTIVE_CONTROL_TEST_BUCKETS);

    final List<Allocation> allocations = Lists.newArrayList();
    allocations.add(new Allocation("${country == 'US'}", RANGES_100_0));
    allocations.add(new Allocation("${country == 'GB'}", RANGES_100_0));
    testDefinition.setAllocations(allocations);

    final RuleEvaluator ruleEvaluator = newRuleEvaluator(false);
    final TestRangeSelector selector = new TestRangeSelector(
        ruleEvaluator,
        testName,
        testDefinition
    );

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

    assertNull("Expected no bucket to be found", bucket);

    EasyMock.verify(ruleEvaluator);
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:31,代码来源:TestStandardTestChooser.java

示例5: testDefaultAllocationWithNonEmptyRule_match

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入方法依赖的package包/类
@Test
public void testDefaultAllocationWithNonEmptyRule_match() {
    final String testName = "test";

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

    testDefinition.setTestType(TestType.ANONYMOUS_USER);
    testDefinition.setSalt(testName);

    testDefinition.setBuckets(INACTIVE_CONTROL_TEST_BUCKETS);

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

    final RuleEvaluator ruleEvaluator = newRuleEvaluator(true);
    final TestRangeSelector selector = new TestRangeSelector(
        ruleEvaluator,
        testName,
        testDefinition
    );

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

    assertEquals("Test bucket with value 1 expected", 1, bucket.getValue());

    EasyMock.verify(ruleEvaluator);
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:32,代码来源:TestStandardTestChooser.java

示例6: consolidate

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入方法依赖的package包/类
private static void consolidate(@Nonnull final TestMatrixArtifact testMatrix, @Nonnull final Map<String, TestSpecification> requiredTests) {
    final Map<String, ConsumableTestDefinition> definedTests = testMatrix.getTests();

    // Sets.difference returns a "view" on the original set, which would require concurrent modification while iterating (copying the set will prevent this)
    final Set<String> toRemove = ImmutableSet.copyOf(Sets.difference(definedTests.keySet(), requiredTests.keySet()));
    for (String testInMatrixNotRequired : toRemove) {
        //  we don't care about this test
        definedTests.remove(testInMatrixNotRequired);
    }

    // Next, for any required tests that are missing, ensure that
    //  there is a nonnull test definition in the matrix
    final Set<String> missing =
            ImmutableSet.copyOf(Sets.difference(requiredTests.keySet(), definedTests.keySet()));
    for (String testNotInMatrix: missing) {
        definedTests.put(testNotInMatrix, defaultFor(testNotInMatrix, requiredTests.get(testNotInMatrix)));
    }

    // Now go through definedTests: for each test, if the test spec
    // didn't ask for a payload, then remove any payload that is in
    // the test matrix.  If buckets exist in the specification that
    // do not in the matrix, add buckets with null payloads to allow
    // forcing buckets that aren't in the matrix but are in the spec.
    for (Entry<String, ConsumableTestDefinition> next : definedTests.entrySet()) {
        final String testName = next.getKey();
        final ConsumableTestDefinition testDefinition = next.getValue();
        final TestSpecification testSpec = requiredTests.get(testName);

        final boolean noPayloads = (testSpec.getPayload() == null);
        final Set<Integer> bucketValues = Sets.newHashSet();
        List<TestBucket> buckets = testDefinition.getBuckets();
        for (final TestBucket bucket : buckets) {
            // Note bucket values that exist in matrix.
            bucketValues.add(bucket.getValue());
            if (noPayloads && (bucket.getPayload() != null)) {
                // stomp the unexpected payloads.
                bucket.setPayload(null);
            }
        }

        boolean replaceBuckets = false;
        final Map<String, Integer> specBuckets = testSpec.getBuckets();
        for (final Entry<String, Integer> bucketSpec : specBuckets.entrySet()) {
            if (!bucketValues.contains(bucketSpec.getValue())) {
                if (!replaceBuckets) {
                    buckets = Lists.newArrayList(buckets);
                    replaceBuckets = true;
                }
                buckets.add(new TestBucket(bucketSpec.getKey(), bucketSpec.getValue(), null, null));
            }
        }

        if (replaceBuckets) {
            testDefinition.setBuckets(buckets);
        }
    }
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:58,代码来源:ProctorUtils.java

示例7: testExceptionsDealtWith

import com.indeed.proctor.common.model.ConsumableTestDefinition; //导入方法依赖的package包/类
@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()
    ))
            // throw an unexpected type of runtime exception
            .andThrow(new RuntimeException() {})
            // Must be evaluated, or this was not a valid test
            .once();
    EasyMock.replay(ruleEvaluator);

    final TestRangeSelector selector = new TestRangeSelector(
            ruleEvaluator,
            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);

    EasyMock.verify(ruleEvaluator);
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:42,代码来源:TestStandardTestChooser.java


注:本文中的com.indeed.proctor.common.model.ConsumableTestDefinition.setBuckets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。