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


Java TestBucket类代码示例

本文整理汇总了Java中com.indeed.proctor.common.model.TestBucket的典型用法代码示例。如果您正苦于以下问题:Java TestBucket类的具体用法?Java TestBucket怎么用?Java TestBucket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TestBucket类属于com.indeed.proctor.common.model包,在下文中一共展示了TestBucket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import com.indeed.proctor.common.model.TestBucket; //导入依赖的package包/类
@RequestMapping(value = "/create", method = RequestMethod.GET)
public String create(
    final Model model
) {

    final TestDefinition definition = new TestDefinition(
        "" /* version */,
        null /* rule */,
        TestType.USER /* testType */,
        "" /* salt */,
        Collections.<TestBucket>emptyList(),
        Lists.<Allocation>newArrayList(
            new Allocation(null, Collections.<Range>emptyList())
        ),
        Collections.<String, Object>emptyMap(),
        Collections.<String, Object>emptyMap(),
        "" /* description */
    );
    final List<RevisionDefinition> history = Collections.emptyList();
    final EnvironmentVersion version = null;
    return doView(Environment.WORKING, Views.CREATE, "", definition, history, version, model);
}
 
开发者ID:indeedeng,项目名称:proctor-webapp-library,代码行数:23,代码来源:ProctorTestDefinitionController.java

示例2: createTestDefinition

import com.indeed.proctor.common.model.TestBucket; //导入依赖的package包/类
public TestDefinition createTestDefinition(String bucketsString, TestType testType, String salt, double[] ranges, Payload[] payloads) {
    final List<Range> rangeList = new ArrayList<Range>();
    for (int i = 0; i < ranges.length; i++) {
        final Range newRange = new Range(i, ranges[i]);
        rangeList.add(newRange);
    }
    String[] buckets = bucketsString.split(",");
    List<TestBucket> buckList = new ArrayList<TestBucket>();
    for (int i = 0; i < buckets.length; i++) {
        String bucket = buckets[i];
        final int colonInd = bucket.indexOf(':');
        final TestBucket tempBucket= new TestBucket(bucket.substring(0,colonInd),Integer.parseInt(bucket.substring(colonInd+1)),"description",(payloads==null)?null:payloads[i]);
        buckList.add(tempBucket);

    }
    final Allocation alloc = new Allocation(null, rangeList);
    final List<Allocation> allocList = new ArrayList<Allocation>();
    allocList.add(alloc);
    return new TestDefinition(EnvironmentVersion.UNKNOWN_REVISION, null, testType, salt, buckList, allocList, Collections.<String, Object>emptyMap(), Collections.<String, Object>emptyMap(), null);
}
 
开发者ID:indeedeng,项目名称:proctor-webapp-library,代码行数:21,代码来源:TestProctorTestDefinitionController.java

示例3: generateJsonBuckets

import com.indeed.proctor.common.model.TestBucket; //导入依赖的package包/类
private Map<String, JsonTestBucket> generateJsonBuckets(final ProctorResult result) {
    final Map<String, JsonTestBucket> jsonBuckets = Maps.newHashMap();

    // As we process each TestBucket into a JsonBucket, we also need to obtain a version for that test.
    final Map<String, String> versions = result.getTestVersions();

    for (Map.Entry<String, TestBucket> e : result.getBuckets().entrySet()) {
        final String testName = e.getKey();
        final TestBucket testBucket = e.getValue();

        final JsonTestBucket jsonBucket = new JsonTestBucket(testBucket, versions.get(testName));
        jsonBuckets.put(testName, jsonBucket);
    }

    return jsonBuckets;
}
 
开发者ID:indeedeng,项目名称:proctor-pipet,代码行数:17,代码来源:JsonResult.java

示例4: defaultFor

import com.indeed.proctor.common.model.TestBucket; //导入依赖的package包/类
@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,
            testName,
            ImmutableList.of(new TestBucket(
                    missingTestSoleBucketName,
                    testSpecification.getFallbackValue(),
                    missingTestSoleBucketDescription)),
            // Force a nonnull allocation just in case something somewhere assumes 1.0 total allocation
            Collections.singletonList(allocation),
            Collections.<String, Object>emptyMap(),
            testName);
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:22,代码来源:ProctorUtils.java

示例5: allocateRandomGroup

import com.indeed.proctor.common.model.TestBucket; //导入依赖的package包/类
/**
 * @deprecated Temporary implementation; this should be more like {@link StandardTestChooser}, with the cutoffs etc. set in the constructor.
 */
TestBucket allocateRandomGroup(final int matchingRuleIndex) {
    final TestBucket[] matchingBucketRange = testRangeSelector.getBucketRange(matchingRuleIndex);
    final Allocation allocation = allocations.get(matchingRuleIndex);
    final List<Range> ranges = allocation.getRanges();

    final double nextDouble = random.nextDouble();
    double current = 0;

    for (final Range range : ranges) {
        final double max = current + range.getLength();
        if (nextDouble < max) {
            final int matchingBucketValue = range.getBucketValue();
            return getBucketForValue(matchingBucketValue, matchingBucketRange);
        }
        current = max;
    }
    //  fallback because I don't trust double math to always do the right thing
    return getBucketForValue(ranges.get(ranges.size() - 1).getBucketValue(), matchingBucketRange);
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:23,代码来源:RandomTestChooser.java

示例6: StandardTestChooser

import com.indeed.proctor.common.model.TestBucket; //导入依赖的package包/类
@VisibleForTesting
StandardTestChooser(@Nonnull final TestRangeSelector selector) {
    this.testRangeSelector = selector;
    this.hasher = newHasherFor(selector);

    final ConsumableTestDefinition testDefinition = selector.getTestDefinition();

    final Map<Integer, TestBucket> bucketValueToTest = Maps.newHashMap();
    for (final TestBucket testBucket : testDefinition.getBuckets()) {
        bucketValueToTest.put(testBucket.getValue(), testBucket);
    }

    final List<Allocation> allocations = testDefinition.getAllocations();
    this.cutoffs = new int[allocations.size()][];
    for (int i = 0; i < allocations.size(); i++) {
        final Allocation allocation = allocations.get(i);
        final List<Range> ranges = allocation.getRanges();
        cutoffs[i] = constructCutoffArray(allocation.getRule(), ranges);
    }
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:21,代码来源:StandardTestChooser.java

示例7: testELValidity_inProctorBuilderAllocationRules

import com.indeed.proctor.common.model.TestBucket; //导入依赖的package包/类
@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);

}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:21,代码来源:TestProctorUtils.java

示例8: testELValidity_inProctorBuilderTestRule

import com.indeed.proctor.common.model.TestBucket; //导入依赖的package包/类
@Test
public void testELValidity_inProctorBuilderTestRule() throws IncompatibleTestMatrixException {
    //Testing syntax validation with a test rule
    final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
    final ConsumableTestDefinition testDefInValTestRule = constructDefinition(buckets,
            fromCompactAllocationFormat("${proctor:now()>-1}|-1:0.5,0:0.5,1:0.0", "-1:0.25,0:0.5,1:0.25"));
    testDefInValTestRule.setRule("${b4t#+=}");
    try {
        ProctorUtils.verifyInternallyConsistentDefinition("testELevalInValTestRule", "test el recognition - inval test rule", testDefInValTestRule);
        fail("expected IncompatibleTestMatrixException");
    } catch (IncompatibleTestMatrixException e) {
        //expected
    }

    //testing the test rule el function recognition
    final ConsumableTestDefinition testDefValTestRule = constructDefinition(buckets,
            fromCompactAllocationFormat("${true}|-1:0.5,0:0.5,1:0.0", "-1:0.25,0:0.5,1:0.25"));
    testDefValTestRule.setRule("${proctor:now()==indeed:now()}");
    ProctorUtils.verifyInternallyConsistentDefinition("testELevalValTestRule", "test el recognition - val test rule and functions", testDefValTestRule);


}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:23,代码来源:TestProctorUtils.java

示例9: noBucketsSpecified

import com.indeed.proctor.common.model.TestBucket; //导入依赖的package包/类
@Test
public void noBucketsSpecified() throws IncompatibleTestMatrixException {
    // The test-matrix has 3 buckets
    List<TestBucket> buckets = fromCompactBucketFormat("zero:0,one:1,two:2");
    // The proctor-specification does not specify any buckets
    final TestSpecification testSpecification = transformTestBuckets(Collections.<TestBucket>emptyList());
    Map<String, TestSpecification> requiredTests = ImmutableMap.of(TEST_A, testSpecification);

    {
        final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
        // Allocation of bucketValue=2 is > 0
        final ConsumableTestDefinition testDefinition = constructDefinition(buckets, fromCompactAllocationFormat("0:0,1:0,2:1.0"));
        tests.put(TEST_A, testDefinition);

        final TestMatrixArtifact matrix = constructArtifact(tests);

        assertValid("allocation for externally unknown bucket (two) > 0 when no buckets are specified", matrix, requiredTests);
    }
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:20,代码来源:TestProctorUtils.java

示例10: requiredTestBucketsMissing

import com.indeed.proctor.common.model.TestBucket; //导入依赖的package包/类
@Test
public void requiredTestBucketsMissing() throws IncompatibleTestMatrixException {
     // The test-matrix has fewer buckets than the required tests
    List<TestBucket> buckets_matrix = fromCompactBucketFormat("zero:0,one:1");
    List<TestBucket> buckets_required = fromCompactBucketFormat("zero:0,one:1,two:2,three:3");
    Map<String, TestSpecification> requiredTests = ImmutableMap.of(TEST_A, transformTestBuckets(buckets_required));

    {
        final Map<String, ConsumableTestDefinition> tests = Maps.newHashMap();
        tests.put(TEST_A, constructDefinition(buckets_matrix, fromCompactAllocationFormat("0:0,1:1.0")));

        final TestMatrixArtifact matrix = constructArtifact(tests);

        // internally inconsistent matrix
        assertValid("test-matrix has a subset of required buckets", matrix, requiredTests);
    }
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:18,代码来源:TestProctorUtils.java

示例11: testGenerateSpecificationFromEmptyDefinition

import com.indeed.proctor.common.model.TestBucket; //导入依赖的package包/类
@Test
public void testGenerateSpecificationFromEmptyDefinition() {
    final String description = "this is an empty test with no buckets";
    final TestDefinition empty = new TestDefinition(
        "empty",
        "",
        TestType.ANONYMOUS_USER,
        "salty",
        Collections.<TestBucket>emptyList(),
        Collections.<Allocation>emptyList(),
        Collections.<String, Object>emptyMap(),
        Collections.<String, Object>emptyMap(),
        description
    );
    final TestSpecification specification = ProctorUtils.generateSpecification(empty);
    assertEquals(description, specification.getDescription());
    assertEquals(0, specification.getBuckets().size());
    assertEquals(-1, specification.getFallbackValue());
    assertNull(specification.getPayload());
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:21,代码来源:TestProctorUtils.java

示例12: test5050Percent

import com.indeed.proctor.common.model.TestBucket; //导入依赖的package包/类
@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);
    assertTrue(found[1] < 600);
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:21,代码来源:TestRandomTestChooser.java

示例13: test333333Percent

import com.indeed.proctor.common.model.TestBucket; //导入依赖的package包/类
@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);
    assertTrue(found[1] < 400);
    assertTrue(found[2] > 250);
    assertTrue(found[2] < 400);
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:23,代码来源:TestRandomTestChooser.java

示例14: initializeRandomTestChooser

import com.indeed.proctor.common.model.TestBucket; //导入依赖的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

示例15: getPayload

import com.indeed.proctor.common.model.TestBucket; //导入依赖的package包/类
/**
 * Return the Payload attached to the current active bucket for |test|.
 * Always returns a payload so the client doesn't crash on a malformed
 * test definition.
 *
 * @param testName test name
 * @return pay load attached to the current active bucket
 * @deprecated Use {@link #getPayload(String, Bucket)} instead
 */
@Nonnull
protected Payload getPayload(final String testName) {
    // Get the current bucket.
    final TestBucket testBucket = buckets.get(testName);

    // Lookup Payloads for this test
    if (testBucket != null) {
        final Payload payload = testBucket.getPayload();
        if (null != payload) {
            return payload;
        }
    }

    return Payload.EMPTY_PAYLOAD;
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:25,代码来源:AbstractGroups.java


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