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


Java TestBucket.getValue方法代码示例

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


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

示例1: 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

示例2: 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

示例3: getTestBucketForBucket

import com.indeed.proctor.common.model.TestBucket; //导入方法依赖的package包/类
/**
 * Return the TestBucket, as defined in the current test matrix, for the test called testName with bucket value targetBucket.getValue().
 * Can return null if it can't find any such bucket.
 * This does a linear search over the list of defined buckets.  There shouldn't be too many buckets in any test,
 * so this should be fast enough.
 *
 * @param testName     test name
 * @param targetBucket target bucket
 * @return the TestBucket. Return null if not found.
 */
protected @Nullable
TestBucket getTestBucketForBucket(final String testName, Bucket<?> targetBucket) {
    final @Nullable Map<String, ConsumableTestDefinition> testDefinitions = proctorResult.getTestDefinitions();
    if (testDefinitions != null) {
        final @Nullable ConsumableTestDefinition testDefinition = testDefinitions.get(testName);
        if (testDefinition != null) {
            final @Nullable List<TestBucket> buckets = testDefinition.getBuckets();
            if (buckets != null) {
                for (final TestBucket testBucket : buckets) {
                    if (targetBucket.getValue() == testBucket.getValue()) {
                        return testBucket;
                    }
                }
            }
        }
    }
    return null;
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:29,代码来源:AbstractGroups.java

示例4: calcGroups

import com.indeed.proctor.common.model.TestBucket; //导入方法依赖的package包/类
private String calcGroups(final Proctor proctor, final String id, final String country, final String language, final int num,
        final Map<String, Integer> forceGroups) {
    final Map<String, Object> context = Maps.newHashMap();
    context.put("num", Integer.valueOf(num));
    context.put("country", country);
    context.put("language", language);

    final Identifiers identifiers = new Identifiers(TestType.ANONYMOUS_USER, id);
    final ProctorResult proctorResult = proctor.determineTestGroups(identifiers, context, forceGroups);
    final StringBuilder buckets = new StringBuilder();
    for (final Iterator<Entry<String, TestBucket>> iterator = proctorResult.getBuckets().entrySet().iterator(); iterator.hasNext(); ) {
        final Entry<String, TestBucket> entry = iterator.next();
        final String testName = entry.getKey();
        final TestBucket testBucket = entry.getValue();

        if (testBucket.getValue() >= 0) {
            if (buckets.length() > 0){
                buckets.append(',');
            }
            buckets.append(testName)
                    .append(testBucket.getValue());
        }
    }

    return buckets.toString();
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:27,代码来源:TestProctor.java

示例5: findIdentifier

import com.indeed.proctor.common.model.TestBucket; //导入方法依赖的package包/类
private String findIdentifier(final TestType testType,
                              final UnitTestGroupsContext context,
                              final UnitTestGroups.Test test,
                              final int targetValue,
                              final int maxIteration) {
    for (int i = 0; i < maxIteration; i++) {
        final String identifier = String.valueOf(i);
        final Identifiers identifiers = Identifiers.of(testType, identifier);
        final ProctorResult result = context.getProctorResult(manager, identifiers);
        final TestBucket bucket = result.getBuckets().get(test.getName());
        if (bucket.getValue() == targetValue) {
            return identifier;
        }
    }
    throw new RuntimeException("identifier not found for target bucket within " + maxIteration + " iterations");
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:17,代码来源:TestUnitTestGroupsManager.java

示例6: getTestBucketForRange

import com.indeed.proctor.common.model.TestBucket; //导入方法依赖的package包/类
public static TestBucket getTestBucketForRange(final TestDefinition definition, final Range range) {
    for(TestBucket tb : definition.getBuckets()) {
        if(tb.getValue() == range.getBucketValue()) {
            return tb;
        }
    }
    return null;
}
 
开发者ID:indeedeng,项目名称:proctor-webapp-library,代码行数:9,代码来源:TestDefinitionFunctions.java

示例7: JsonTestBucket

import com.indeed.proctor.common.model.TestBucket; //导入方法依赖的package包/类
/**
 * Serializes the object using an existing bucket and a separate version.
 *
 * Version needs to be obtained outside of the bucket through ProctorResult.getTestVersions()
 */
public JsonTestBucket(final TestBucket bucket, final String version) {
    name = bucket.getName();
    value = bucket.getValue();
    this.version = version;

    // This means the JSON output will have type names like "stringValue" and "doubleArray".
    // It makes the API look less clean, especially for clients that use duck-typed languages.
    // But it may make deserialization easier for clients with rigid types, especially if they use something like
    // Jackson's data binding in Java.
    // This is also consistent with the test matrix definition.
    payload = bucket.getPayload();
}
 
开发者ID:indeedeng,项目名称:proctor-pipet,代码行数:18,代码来源:JsonTestBucket.java

示例8: generateSpecification

import com.indeed.proctor.common.model.TestBucket; //导入方法依赖的package包/类
/**
 * Generates a usable test specification for a given test definition
 * Uses the first bucket as the fallback value
 *
 * @param testDefinition a {@link TestDefinition}
 * @return a {@link TestSpecification} which corresponding to given test definition.
 */
public static TestSpecification generateSpecification(@Nonnull final TestDefinition testDefinition) {
    final TestSpecification testSpecification = new TestSpecification();
    // Sort buckets by value ascending
    final Map<String,Integer> buckets = Maps.newLinkedHashMap();
    final List<TestBucket> testDefinitionBuckets = Ordering.from(new Comparator<TestBucket>() {
        @Override
        public int compare(final TestBucket lhs, final TestBucket rhs) {
            return Ints.compare(lhs.getValue(), rhs.getValue());
        }
    }).immutableSortedCopy(testDefinition.getBuckets());
    int fallbackValue = -1;
    if(testDefinitionBuckets.size() > 0) {
        final TestBucket firstBucket = testDefinitionBuckets.get(0);
        fallbackValue = firstBucket.getValue(); // buckets are sorted, choose smallest value as the fallback value

        final PayloadSpecification payloadSpecification = new PayloadSpecification();
        if(firstBucket.getPayload() != null && !firstBucket.getPayload().equals(Payload.EMPTY_PAYLOAD)) {
            final PayloadType payloadType = PayloadType.payloadTypeForName(firstBucket.getPayload().fetchType());
            payloadSpecification.setType(payloadType.payloadTypeName);
            if (payloadType == PayloadType.MAP) {
                final Map<String, String> payloadSpecificationSchema = new HashMap<String, String>();
                for (Map.Entry<String, Object> entry : firstBucket.getPayload().getMap().entrySet()) {
                    payloadSpecificationSchema.put(entry.getKey(), PayloadType.payloadTypeForValue(entry.getValue()).payloadTypeName);
                }
                payloadSpecification.setSchema(payloadSpecificationSchema);
            }
            testSpecification.setPayload(payloadSpecification);
        }

        for (int i = 0; i < testDefinitionBuckets.size(); i++) {
            final TestBucket bucket = testDefinitionBuckets.get(i);
            buckets.put(bucket.getName(), bucket.getValue());
        }
    }
    testSpecification.setBuckets(buckets);
    testSpecification.setDescription(testDefinition.getDescription());
    testSpecification.setFallbackValue(fallbackValue);
    return testSpecification;
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:47,代码来源:ProctorUtils.java

示例9: getTestBucket

import com.indeed.proctor.common.model.TestBucket; //导入方法依赖的package包/类
/**
 * Do not evaluate the rule, do not use the pseudo-random allocation algorithm, do not collect $200.
 * This should ONLY be used by privileged code for debugging.
 *
 * @param value bucket number
 * @return a {@link TestBucket} with the specified value or null if none exists
 */
@Nullable
public TestBucket getTestBucket(final int value) {
    for (final TestBucket testBucket : testDefinition.getBuckets()) {
        if (testBucket.getValue() == value) {
            return testBucket;
        }
    }
    return null;
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:17,代码来源:TestRangeSelector.java

示例10: getBucketForValue

import com.indeed.proctor.common.model.TestBucket; //导入方法依赖的package包/类
static TestBucket getBucketForValue(final int matchingBucketValue, @Nonnull final TestBucket[] matchingBucketRange) {
    for (TestBucket bucket : matchingBucketRange) {
        if (matchingBucketValue == bucket.getValue()) {
            return bucket;
        }
    }
    throw new IllegalStateException("Unable to find a bucket with value " + matchingBucketValue);
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:9,代码来源:RandomTestChooser.java

示例11: exerciseChooser

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

示例12: getTargetTestGroups

import com.indeed.proctor.common.model.TestBucket; //导入方法依赖的package包/类
private Set<String> getTargetTestGroups(final Set<String> targetTestNames) {
    final Proctor proctor = getProctorNotNull();

    final Set<String> testGroups = Sets.newTreeSet();
    for (final String testName : targetTestNames) {
        final ConsumableTestDefinition testDefinition = proctor.getTestDefinition(testName);
        for (final TestBucket bucket : testDefinition.getBuckets()) {
            final String testGroup = testName + bucket.getValue();
            testGroups.add(testGroup);
        }
    }

    return testGroups;
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:15,代码来源:SampleRandomGroupsHttpHandler.java

示例13: isBucketActive

import com.indeed.proctor.common.model.TestBucket; //导入方法依赖的package包/类
protected boolean isBucketActive(final String testName, final int value, final int defaultValue) {
    final TestBucket testBucket = buckets.get(testName);
    if (null == testBucket) {
        return value == defaultValue;
    } else {
        return value == testBucket.getValue();
    }
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:9,代码来源:AbstractGroups.java

示例14: getValue

import com.indeed.proctor.common.model.TestBucket; //导入方法依赖的package包/类
protected int getValue(final String testName, final int defaultValue) {
    final TestBucket testBucket = buckets.get(testName);
    if (testBucket == null) {
        return defaultValue;
    }
    return testBucket.getValue();
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:8,代码来源:AbstractGroups.java

示例15: appendTestGroups

import com.indeed.proctor.common.model.TestBucket; //导入方法依赖的package包/类
/**
 * Appends each group to the StringBuilder using the separator to delimit
 * group names. the separator should be appended for each group added
 * to the string builder
 * {@link #toString()}
 * {@link #buildTestGroupString()} or {@link #appendTestGroups(StringBuilder)}
 *
 * @param sb        a string builder
 * @param separator a char used as separator
 */
public void appendTestGroups(final StringBuilder sb, char separator) {
    for (final Entry<String, TestBucket> entry : proctorResult.getBuckets().entrySet()) {
        final String testName = entry.getKey();
        final TestBucket testBucket = entry.getValue();
        if (testBucket.getValue() < 0) {
            continue;
        }
        sb.append(testName).append(testBucket.getValue()).append(separator);
    }
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:21,代码来源:AbstractGroups.java


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