本文整理汇总了Java中com.indeed.proctor.common.model.ConsumableTestDefinition.setSalt方法的典型用法代码示例。如果您正苦于以下问题:Java ConsumableTestDefinition.setSalt方法的具体用法?Java ConsumableTestDefinition.setSalt怎么用?Java ConsumableTestDefinition.setSalt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.indeed.proctor.common.model.ConsumableTestDefinition
的用法示例。
在下文中一共展示了ConsumableTestDefinition.setSalt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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];
}
示例2: 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;
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}