本文整理汇总了Java中org.hamcrest.core.IsCollectionContaining类的典型用法代码示例。如果您正苦于以下问题:Java IsCollectionContaining类的具体用法?Java IsCollectionContaining怎么用?Java IsCollectionContaining使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IsCollectionContaining类属于org.hamcrest.core包,在下文中一共展示了IsCollectionContaining类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refresh
import org.hamcrest.core.IsCollectionContaining; //导入依赖的package包/类
@Test
public void refresh() throws Exception {
final Reddit reddit = new Reddit();
PublishSubject<Reddit> subject = PublishSubject.create();
Mockito.doReturn(subject.asObservable().toList())
.when(mRepository)
.getReddits(Mockito.anyString());
mViewModel.refresh();
Mockito.verify(mRepository).getReddits("test");
Assert.assertThat(mViewModel.errorText.get(), IsNull.nullValue());
Assert.assertThat(mViewModel.isLoading.get(), Is.is(true));
subject.onNext(reddit);
subject.onCompleted();
Assert.assertThat(mViewModel.isLoading.get(), Is.is(false));
Assert.assertThat(mViewModel.reddits, IsCollectionContaining.hasItems(reddit));
}
示例2: searchQueryChange
import org.hamcrest.core.IsCollectionContaining; //导入依赖的package包/类
@Test
public void searchQueryChange() throws Exception {
final Subreddit subreddit = new Subreddit();
PublishSubject<Subreddit> subject = PublishSubject.create();
Mockito.doReturn(subject.asObservable().toList())
.when(mRepository)
.searchSubreddits(Mockito.anyString());
mViewModel.subscribeOnSearchQueryChange();
mViewModel.mSearchQuery.onNext("test");
Mockito.verify(mRepository).searchSubreddits("test");
Assert.assertThat(mViewModel.isLoading.get(), Is.is(true));
subject.onNext(subreddit);
subject.onCompleted();
Assert.assertThat(mViewModel.isLoading.get(), Is.is(false));
Assert.assertThat(mViewModel.subreddits, IsCollectionContaining.hasItems(subreddit));
}
示例3: verifyResults
import org.hamcrest.core.IsCollectionContaining; //导入依赖的package包/类
private void verifyResults(final CloseableIterable<? extends Element> resultsItr) {
final Edge[] expectedResults = {
new Edge.Builder()
.group("RoadUse")
.source("10")
.dest("11")
.directed(true)
.property("visibility", "public")
.property("count", 3L)
.build(),
new Edge.Builder()
.group("RoadUse")
.source("11")
.dest("10")
.directed(true)
.property("visibility", "public")
.property("count", 1L)
.build()
};
final List<Element> results = Lists.newArrayList(resultsItr);
assertEquals(expectedResults.length, results.size());
assertThat(results, IsCollectionContaining.hasItems(expectedResults));
}
示例4: verifyResults
import org.hamcrest.core.IsCollectionContaining; //导入依赖的package包/类
private void verifyResults(final CloseableIterable<? extends Element> resultsItr) {
final Edge[] expectedResults = {
new Edge.Builder()
.group("RoadUse")
.source("10")
.dest("11")
.directed(true)
.property("count", 3L)
.build(),
new Edge.Builder()
.group("RoadUse")
.source("11")
.dest("10")
.directed(true)
.property("count", 1L)
.build()
};
final List<Element> results = Lists.newArrayList(resultsItr);
assertEquals(expectedResults.length, results.size());
assertThat(results, IsCollectionContaining.hasItems(expectedResults));
}
示例5: verifyResults
import org.hamcrest.core.IsCollectionContaining; //导入依赖的package包/类
private void verifyResults(final CloseableIterable<? extends Element> resultsItr) {
final Edge[] expectedResults = {
new Edge.Builder()
.source("10")
.dest("11")
.directed(true)
.group("RoadUse")
.property("count", 1L)
.property("startDate", Aggregation.MAY_01_2000)
.property("endDate", new Date(Aggregation.MAY_03_2000.getTime() - 1))
.build()
};
final List<Element> results = Lists.newArrayList(resultsItr);
assertEquals(expectedResults.length, results.size());
assertThat(results, IsCollectionContaining.hasItems(expectedResults));
}
示例6: verifyResults
import org.hamcrest.core.IsCollectionContaining; //导入依赖的package包/类
private void verifyResults(final CloseableIterable<? extends Element> resultsItr) {
final Edge[] expectedResults = {
new Edge.Builder()
.group("RoadUse")
.source("10")
.dest("11")
.directed(true)
.property("description", "3 vehicles have travelled between junction 10 and junction 11")
.build(),
new Edge.Builder()
.group("RoadUse")
.source("11")
.dest("10")
.directed(true)
.property("description", "1 vehicles have travelled between junction 11 and junction 10")
.build()
};
final List<Element> results = Lists.newArrayList(resultsItr);
assertEquals(expectedResults.length, results.size());
assertThat(results, IsCollectionContaining.hasItems(expectedResults));
}
示例7: shouldReturnSubclasses
import org.hamcrest.core.IsCollectionContaining; //导入依赖的package包/类
@Test
public void shouldReturnSubclasses() throws IOException {
// When
final Set<Class> subclasses = ReflectionUtil.getSubTypes(Number.class);
// Then
assertThat(subclasses,
Matchers.allOf(
IsCollectionContaining.hasItems(
TestCustomNumber.class,
uk.gov.gchq.koryphe.serialisation.json.obj.second.TestCustomNumber.class
),
Matchers.not(IsCollectionContaining.hasItems(UnsignedLong.class))
)
);
}
示例8: shouldGetStringArrayWhenParsingArrayNode
import org.hamcrest.core.IsCollectionContaining; //导入依赖的package包/类
@Test
public void shouldGetStringArrayWhenParsingArrayNode() throws Exception {
Map<String, JsonNode> tree = new HashMap<>();
List<JsonNode> subNodes = new ArrayList<>();
TextNode textNode1 = new TextNode("one");
TextNode textNode2 = new TextNode("two");
subNodes.add(textNode1);
subNodes.add(textNode2);
ArrayNode arrNode = new ArrayNode(JsonNodeFactory.instance, subNodes);
tree.put("key", arrNode);
List<String> values = deserializer.getStringOrArray(tree, "key");
assertThat(values, is(notNullValue()));
assertThat(values, is(IsCollectionWithSize.hasSize(2)));
assertThat(values, is(IsCollectionContaining.hasItems("one", "two")));
}
示例9: testSplittingDrivers
import org.hamcrest.core.IsCollectionContaining; //导入依赖的package包/类
@Test
public void testSplittingDrivers() {
final List<InputDriver> subDriverList = createSubInputDrivers("test");
final InputDriver subDriver = new GroupDriver("sub1", subDriverList);
final List<InputDriver> drivers = new ArrayList<>(2);
drivers.add(subDriver);
drivers.add(new StringDriver("string1"));
drivers.add(new RegexDriver("regex.?"));
final GroupDriver group = new GroupDriver("group", drivers);
assertNotNull(group);
assertThat(group.convertDrivers(),
IsCollectionContaining.hasItems("string1", "regex.?", "VG:sub1:test1:test2:test3:tes.?4"));
final List<String> nonGroupDrivers = new ArrayList<>();
final List<String> groupDrivers = new ArrayList<>();
GroupDriver.convertDriversIntoDriversAndGroups(Arrays.asList(group.getSubDrivers(false)),
nonGroupDrivers, groupDrivers);
assertEquals("VG:sub1:test1:test2:test3:tes.?4", groupDrivers.get(0));
assertThat(nonGroupDrivers, IsCollectionContaining.hasItems("string1", "regex.?"));
}
示例10: testEvaluatorWithRegexMultipleRules
import org.hamcrest.core.IsCollectionContaining; //导入依赖的package包/类
@Test
public void testEvaluatorWithRegexMultipleRules() {
final Builder<RuleSetBuilder, DecisionTreeRuleSet> ruleSetBuilder =
CommisionRuleSetSupplier.getCommissionRuleSetWithRegex();
final DecisionTreeRuleSet ruleSet = ruleSetBuilder.build();
final TreeNode node = constructTree(ruleSet);
final List<EvaluationResult> results = Evaluator.evaluateAllResults(Arrays.asList("ELECTRONIC", "CME", "S&P",
"US", "INDEX"), null, node);
assertNotNull(results);
assertEquals(3, results.size());
final List<UUID> idResults = results.stream().map(EvaluationResult::getRuleIdentifier)
.collect(Collectors.toList());
assertThat(idResults, IsCollectionContaining.hasItems(new UUID(0, 0), new UUID(0, 1), new UUID(0, 7)));
final Optional<UUID> result = Evaluator.singleEvaluate(Arrays.asList("ELECTRONIC", "CME", "S&P",
"US", "INDEX"), null, node);
assertTrue(result.isPresent());
assertEquals(new UUID(0, 7), result.get());
}
示例11: testFindByType
import org.hamcrest.core.IsCollectionContaining; //导入依赖的package包/类
@Test
public void testFindByType() {
final DriverCache cache = new DriverCache();
final InputDriver stringDriver = new StringDriver("testString1");
final InputDriver stringDriver2 = new StringDriver("testString2");
final InputDriver regexDriver = new RegexDriver("tes.?");
final InputDriver groupDriver = new GroupDriver("testGroup", Arrays.asList(
new StringDriver("testSub1"), new StringDriver("testSub2")));
cache.put(stringDriver);
cache.put(stringDriver2);
cache.put(regexDriver);
cache.put(groupDriver);
final List<InputDriver> regexResults = cache.findByInputDriverType(InputValueType.REGEX);
assertNotNull(regexResults);
assertEquals(regexDriver, regexResults.get(0));
final List<InputDriver> groupDrivers = cache.findByInputDriverType(InputValueType.VALUE_GROUP);
assertEquals(groupDriver, groupDrivers.get(0));
final List<InputDriver> stringDrivers = cache.findByInputDriverType(InputValueType.STRING);
assertThat(stringDrivers, IsCollectionContaining.hasItems(stringDriver, stringDriver2));
}
示例12: testFindingInputDrivers
import org.hamcrest.core.IsCollectionContaining; //导入依赖的package包/类
@Test
public void testFindingInputDrivers() {
final DecisionTreeRuleSet commisssionRuleSet = CommisionRuleSetSupplier.getCommissionRuleSetWithRegex().build();
List<InputDriver> driversByType = commisssionRuleSet.getDriversByType(InputValueType.STRING);
assertNotNull(driversByType);
assertEquals(11, driversByType.size());
assertThat(driversByType,
IsCollectionContaining.hasItems(new StringDriver("VOICE"), new StringDriver("RATE"),
new StringDriver("UK"), new StringDriver("*"), new StringDriver("CME"),
new StringDriver("INDEX"), new StringDriver("S&P"),
new StringDriver("US"), new StringDriver("ED"), new StringDriver("NDK")));
driversByType = commisssionRuleSet.getDriversByType(InputValueType.REGEX);
assertNotNull(driversByType);
assertEquals(3, driversByType.size());
assertThat(driversByType, IsCollectionContaining.hasItems(new RegexDriver("AP.?C"),
new RegexDriver("C.?E"), new RegexDriver("^[A-Z]{1,2}[A-Z][0-9]{1,2}$")));
}
示例13: convertStringToGroupDriver
import org.hamcrest.core.IsCollectionContaining; //导入依赖的package包/类
@Test
public void convertStringToGroupDriver() {
final DriverCache cache = new DriverCache();
final String testString = "VG:TestGroup:Test1:Test2:Test3";
final Supplier<InputDriver> groupSupplier = DomainSerialiser.createInputDriver(testString, cache);
final InputDriver groupDriver = groupSupplier.get();
assertNotNull(groupDriver);
assertEquals("TestGroup", groupDriver.getValue());
assertEquals(InputValueType.VALUE_GROUP, groupDriver.getType());
assertEquals(groupDriver, cache.get("TestGroup", InputValueType.VALUE_GROUP));
final InputDriver[] drivers = ((GroupDriver) groupDriver).getSubDrivers(false);
final InputDriver[] expected = {new StringDriver("Test1"), new StringDriver("Test2"),
new StringDriver("Test3")};
assertThat(Arrays.asList(drivers), IsCollectionContaining.hasItems(expected));
List<String> serialisedDrivers = DomainSerialiser.convertDriversWithSubGroups(Arrays.asList(groupDriver));
assertNotNull(serialisedDrivers);
assertEquals(1, serialisedDrivers.size());
assertEquals(testString, serialisedDrivers.get(0));
serialisedDrivers = DomainSerialiser.convertDrivers(new InputDriver[]{groupDriver});
assertNotNull(serialisedDrivers);
assertEquals(1, serialisedDrivers.size());
assertEquals(groupDriver.toString(), serialisedDrivers.get(0));
}
示例14: testEmptyTokensAtEndOfGroupDriver
import org.hamcrest.core.IsCollectionContaining; //导入依赖的package包/类
@Test
@Ignore("The support for a blank token at the end is not working. Putting in test and will return to it.")
public void testEmptyTokensAtEndOfGroupDriver() {
final DriverCache cache = new DriverCache();
final String testString = "VG:TestGroup:Test1:Test2:Test3::VG:SubGroup:Test4:Test5:";
final Supplier<InputDriver> groupSupplier = DomainSerialiser.createInputDriver(testString, cache);
final InputDriver groupDriver = groupSupplier.get();
assertNotNull(groupDriver);
final InputDriver[] drivers = ((GroupDriver) groupDriver).getSubDrivers(false);
final InputDriver[] expectedList = new InputDriver[]{
new StringDriver("Test1"), new StringDriver("Test2"), new StringDriver("Test3"),
new StringDriver(""),
new GroupDriver("SubGroup",
Arrays.asList(new StringDriver("Test4"), new StringDriver("Test5"),
new StringDriver("")))};
assertEquals(expectedList.length, drivers.length);
assertThat(Arrays.asList(drivers), IsCollectionContaining.hasItems(expectedList));
final List<String> serialisedDrivers = DomainSerialiser.convertDrivers(new InputDriver[]{groupDriver});
assertEquals(testString, serialisedDrivers.get(0));
}
示例15: testConvertGroupDrivers
import org.hamcrest.core.IsCollectionContaining; //导入依赖的package包/类
@Test
public void testConvertGroupDrivers() {
final Builder<RuleBuilder, DecisionTreeRule> ruleBuilder = RuleBuilder.creator();
final DriverCache cache = new DriverCache();
final List<String> testInputs = Arrays.asList("VG:VG1:test1:test2:test3:test4", "singleTest",
"VG:VG2:test10:test20:test30:test40:VG:VG3:test50:test9.?:test200.*");
ruleBuilder.with(RuleBuilder::input, testInputs);
ruleBuilder.with(RuleBuilder::cache, cache);
ruleBuilder.with(RuleBuilder::setDriverCount, 3L);
ruleBuilder.with(RuleBuilder::setId, new UUID(0, 1));
ruleBuilder.with(RuleBuilder::output, Collections.singletonMap("outputDriver", "result"));
final DecisionTreeRule rule = ruleBuilder.build();
assertNotNull(rule);
final InputDriver[] derivedInputDrivers = rule.getDrivers();
List<String> result = DomainSerialiser.convertDriversWithSubGroups(Arrays.asList(derivedInputDrivers));
assertNotNull(result);
assertEquals(testInputs, result);
result = DomainSerialiser.convertDrivers(derivedInputDrivers);
assertNotNull(result);
assertThat(result, IsCollectionContaining.hasItems("VG:VG1", "singleTest", "VG:VG2"));
}