本文整理汇总了Java中org.hamcrest.core.IsNull类的典型用法代码示例。如果您正苦于以下问题:Java IsNull类的具体用法?Java IsNull怎么用?Java IsNull使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IsNull类属于org.hamcrest.core包,在下文中一共展示了IsNull类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refresh
import org.hamcrest.core.IsNull; //导入依赖的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: testCustomCharFilterInRequest
import org.hamcrest.core.IsNull; //导入依赖的package包/类
public void testCustomCharFilterInRequest() throws Exception {
Map<String, Object> charFilterSettings = new HashMap<>();
charFilterSettings.put("type", "mapping");
charFilterSettings.put("mappings", new String[]{"ph => f", "qu => q"});
AnalyzeResponse analyzeResponse = client().admin().indices()
.prepareAnalyze()
.setText("jeff quit phish")
.setTokenizer("keyword")
.addCharFilter(charFilterSettings)
.setExplain(true)
.get();
assertThat(analyzeResponse.detail().analyzer(), IsNull.nullValue());
//charfilters
assertThat(analyzeResponse.detail().charfilters().length, equalTo(1));
assertThat(analyzeResponse.detail().charfilters()[0].getName(), equalTo("_anonymous_charfilter_[0]"));
assertThat(analyzeResponse.detail().charfilters()[0].getTexts().length, equalTo(1));
assertThat(analyzeResponse.detail().charfilters()[0].getTexts()[0], equalTo("jeff qit fish"));
//tokenizer
assertThat(analyzeResponse.detail().tokenizer().getName(), equalTo("keyword"));
assertThat(analyzeResponse.detail().tokenizer().getTokens().length, equalTo(1));
assertThat(analyzeResponse.detail().tokenizer().getTokens()[0].getTerm(), equalTo("jeff qit fish"));
assertThat(analyzeResponse.detail().tokenizer().getTokens()[0].getStartOffset(), equalTo(0));
assertThat(analyzeResponse.detail().tokenizer().getTokens()[0].getEndOffset(), equalTo(15));
assertThat(analyzeResponse.detail().tokenizer().getTokens()[0].getPositionLength(), equalTo(1));
}
示例3: refreshError
import org.hamcrest.core.IsNull; //导入依赖的package包/类
@Test
public void refreshError() throws Exception {
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.onError(new Exception("error text"));
Assert.assertThat(mViewModel.isLoading.get(), Is.is(false));
Assert.assertThat(mViewModel.errorText.get(), IsEqual.equalTo("error text"));
}
示例4: testRenameCluster
import org.hamcrest.core.IsNull; //导入依赖的package包/类
@Test
public void testRenameCluster() {
Tree<ClusterVO, ItemAssocVO<Integer,Integer>> clusters = clusterService.getClustersForTenant(1);
ClusterVO root = clusters.getRoot();
printCluster(clusters, root);
assertThat(clusters.getHeight(), is(2));
assertThat(clusters.getChildCount(root), is(2));
assertThat(clusters.getVertexCount(), is(5));
assertThat(clusterService.loadCluster(1,"CLUSTER3"), IsNull.nullValue());
try {
clusterService.renameCluster(1, "CLUSTER1", "CLUSTER3");
} catch (ClusterException ce) {
logger.info(ce);
}
printCluster(clusters, root);
assertThat(clusters.getHeight(), is(2));
assertThat(clusters.getChildCount(root), is(2));
assertThat(clusters.getVertexCount(), is(5));
assertThat(clusterService.loadCluster(1,"CLUSTER3"), IsNull.notNullValue());
}
示例5: shouldSupportImgRefLink
import org.hamcrest.core.IsNull; //导入依赖的package包/类
@Test
public void shouldSupportImgRefLink() throws IOException {
final InputStream stream = getClass().getClassLoader().getResourceAsStream("withImgRefLink.md");
assertThat( stream, IsNull.notNullValue());
final InputStream inputStream = Site.processMarkdown(stream, "Test IMG");
assertThat( inputStream, IsNull.notNullValue());
final String converted = IOUtils.toString(inputStream);
assertThat(converted, containsString("!http://www.lewe.com/wp-content/uploads/2016/03/conf-icon-64.png|alt=\"conf-icon\"|title=\"My conf-icon\"!"));
assertThat(converted, containsString("!conf-icon-64.png|alt=\"conf-icon\"|title=\"My conf-icon\"!"));
assertThat(converted, containsString("!conf-icon-64.png|alt=\"conf-icon\"!"));
assertThat(converted, containsString("!http://www.lewe.com/wp-content/uploads/2016/03/conf-icon-64.png|alt=\"conf-icon-y\"|title=\"My conf-icon\"!"));
assertThat(converted, containsString("!http://www.lewe.com/wp-content/uploads/2016/03/conf-icon-64.png|alt=\"conf-icon-y1\"!"));
assertThat(converted, containsString("!conf-icon-64.png|alt=\"conf-icon-y2\"!"));
assertThat(converted, containsString("!conf-icon-64.png|alt=\"conf-icon-none\"!"));
}
示例6: shouldSupportSimpleNode
import org.hamcrest.core.IsNull; //导入依赖的package包/类
@Test
public void shouldSupportSimpleNode() throws IOException {
final InputStream stream = getClass().getClassLoader().getResourceAsStream("simpleNodes.md");
assertThat( stream, IsNull.notNullValue());
final InputStream inputStream = Site.processMarkdown(stream, "Test");
assertThat( inputStream, IsNull.notNullValue());
final String converted = IOUtils.toString(inputStream);
assertThat("All forms of HRules should be supported", converted, containsString("----\n1\n----\n2\n----\n3\n----\n4\n----"));
/* only when Extensions.SMARTS is activated
assertThat(converted, containsString("…"));
assertThat(converted, containsString("–"));
assertThat(converted, containsString("—"));
*/
assertThat(converted, containsString("Forcing a line-break\nNext line in the list"));
assertThat(converted, containsString(" "));
}
示例7: shouldCreateSpecificNoticeBlock
import org.hamcrest.core.IsNull; //导入依赖的package包/类
@Test
public void shouldCreateSpecificNoticeBlock() throws IOException {
final InputStream stream = getClass().getClassLoader().getResourceAsStream("createSpecificNoticeBlock.md");
assertThat( stream, IsNull.notNullValue());
final InputStream inputStream = Site.processMarkdown(stream, "Test Macro");
assertThat( inputStream, IsNull.notNullValue());
final String converted = IOUtils.toString(inputStream);
assertThat(converted, containsString("{info:title=About me}\n"));
assertThat("Should not generate unneeded param 'title'", converted, not(containsString("{note:title=}\n")));
assertThat(converted, containsString("{tip:title=About you}\n"));
assertThat(converted, containsString("bq. test a simple blockquote"));
assertThat(converted, containsString("{quote}\n"));
assertThat(converted, containsString("* one\n* two"));
assertThat(converted, containsString("a *strong* and _pure_ feeling"));
}
示例8: initService
import org.hamcrest.core.IsNull; //导入依赖的package包/类
@Before
@Override
public void initService() throws Exception {
super.initService();
try {
// SSL Implementation
final SSLSocketFactory sslSocketFactory = SSLFactories.newInstance( new YesTrustManager());
Assert.assertThat(sslSocketFactory, IsNull.notNullValue());
final X509TrustManager trustManager = new YesTrustManager();
final HostnameVerifier hostnameVerifier = new YesHostnameVerifier();
service.client
.hostnameVerifier(hostnameVerifier)
.sslSocketFactory(sslSocketFactory, trustManager)
;
} catch (Exception ex) {
throw new IllegalStateException(ex);
}
}
示例9: createClientId
import org.hamcrest.core.IsNull; //导入依赖的package包/类
/**
* clientIdを作成する.
* @return clientId
* @throws Exception clientIdの作成に失敗した場合に発生
*/
private String createClientId() throws Exception {
String uri = "http://localhost:4035/gotapi/authorization/grant";
Map<String, String> headers = new HashMap<>();
headers.put("Origin", getOrigin());
HttpUtil.Response response = HttpUtil.get(uri, headers);
assertThat(response, is(notNullValue()));
JSONObject json = response.getJSONObject();
assertThat(json, is(notNullValue()));
assertThat(json.getInt("result"), is(0));
assertThat(json.getString("clientId"), is(IsNull.notNullValue()));
return json.getString("clientId");
}
示例10: buyOrderOfCustomerWithEnoughCashAndKnownStock
import org.hamcrest.core.IsNull; //导入依赖的package包/类
@Test
public void buyOrderOfCustomerWithEnoughCashAndKnownStock() {
Mockito.when(stockRepository.findOneByName(Matchers.anyString())).thenReturn(Optional.of(new Stock("TSLA", 10)));
Mockito.when(customerRepository.findOne(Matchers.anyLong())).thenReturn(new Customer("Test user", 500));
BuyOrder optional = buyOrderServiceActivator.processOrder(new BuyOrder("TSLA", 10, 1));
assertThat(optional, is(IsNull.notNullValue()));
Mockito.verify(stockRepository).findOneByName("TSLA");
Mockito.verify(customerRepository).findOne(1L);
ArgumentCaptor<Customer> customerArgumentCaptor = ArgumentCaptor.forClass(Customer.class);
Mockito.verify(customerRepository).save(customerArgumentCaptor.capture());
Customer customer = customerArgumentCaptor.getValue();
assertThat(customer.getFreeCash(), is(400));
assertThat(customer.getName(), is("Test user"));
Mockito.verifyNoMoreInteractions(customerRepository, stockRepository);
}
开发者ID:gfoster-pivotal,项目名称:spring-streaming-processing,代码行数:20,代码来源:BuyOrderServiceActivatorTest.java
示例11: shouldEasilyDoSimpleAtomicMutationMulti
import org.hamcrest.core.IsNull; //导入依赖的package包/类
@Test
public void shouldEasilyDoSimpleAtomicMutationMulti() throws Exception {
ByteBuffer regionLocation = ByteBuffer.wrap(Bytes.toBytes("testTable"));
RegionSpecifier regionSpecifier = new RegionSpecifier(RegionSpecifier.RegionSpecifierType.REGION_NAME,
regionLocation);
context.checking(new Expectations() {
{
oneOf(hRegionInterface).processRowsWithLocks(with(any(MultiRowMutationProcessor.class)));
}
});
MutationProto mutation = ProtobufUtil.toMutation(MutationProto.MutationType.PUT, new Put(Bytes.toBytes("fakeRow")));
RegionActionResult actions = hRegionBridge.processRegionAction(new RegionAction(regionSpecifier,
true,
Arrays.asList(new Action(0, mutation, null))));
assertThat(actions.getException(), IsNull.nullValue());
assertThat(actions.getResultOrExceptionList().size(), is(1));
}
示例12: shouldEasilyDoAtomicMutationOnlyMultiPut
import org.hamcrest.core.IsNull; //导入依赖的package包/类
@Test
public void shouldEasilyDoAtomicMutationOnlyMultiPut() throws Exception {
ByteBuffer regionLocation = ByteBuffer.wrap(Bytes.toBytes("testTable"));
RegionSpecifier regionSpecifier = new RegionSpecifier(RegionSpecifier.RegionSpecifierType.REGION_NAME,
regionLocation);
context.checking(new Expectations() {
{
oneOf(hRegionInterface).processRowsWithLocks(with(any(MultiRowMutationProcessor.class)));
}
});
MutationProto mutation = ProtobufUtil.toMutation(MutationProto.MutationType.PUT, new Put(Bytes.toBytes("fakeRow")));
RegionActionResult actions = hRegionBridge.processRegionAction(new RegionAction(regionSpecifier,
true,
Arrays.asList(
new Action(0, mutation, null),
new Action(1, mutation, null),
new Action(2, mutation, null))
));
assertThat(actions.getException(), IsNull.nullValue());
assertThat(actions.getResultOrExceptionList().size(), is(3));
}
示例13: shouldEasilyDoAtomicMutationOnlyMultiDelete
import org.hamcrest.core.IsNull; //导入依赖的package包/类
@Test
public void shouldEasilyDoAtomicMutationOnlyMultiDelete() throws Exception {
ByteBuffer regionLocation = ByteBuffer.wrap(Bytes.toBytes("testTable"));
RegionSpecifier regionSpecifier = new RegionSpecifier(RegionSpecifier.RegionSpecifierType.REGION_NAME,
regionLocation);
context.checking(new Expectations() {
{
oneOf(hRegionInterface).processRowsWithLocks(with(any(MultiRowMutationProcessor.class)));
}
});
MutationProto mutation = ProtobufUtil.toMutation(MutationProto.MutationType.DELETE, new Delete(Bytes.toBytes("fakeRow")));
RegionActionResult actions = hRegionBridge.processRegionAction(new RegionAction(regionSpecifier,
true,
Arrays.asList(
new Action(0, mutation, null),
new Action(1, mutation, null),
new Action(2, mutation, null))
));
assertThat(actions.getException(), IsNull.nullValue());
assertThat(actions.getResultOrExceptionList().size(), is(3));
}
示例14: shouldFailWhenWeTryToAtomicMutateAndGet
import org.hamcrest.core.IsNull; //导入依赖的package包/类
@Test
public void shouldFailWhenWeTryToAtomicMutateAndGet() throws Exception {
ByteBuffer regionLocation = ByteBuffer.wrap(Bytes.toBytes("testTable"));
RegionSpecifier regionSpecifier = new RegionSpecifier(RegionSpecifier.RegionSpecifierType.REGION_NAME,
regionLocation);
MutationProto mutation = ProtobufUtil.toMutation(MutationProto.MutationType.DELETE, new Delete(Bytes.toBytes("fakeRow")));
Get get = ProtobufUtil.toGet(new org.apache.hadoop.hbase.client.Get(Bytes.toBytes("fakeRow2")), false);
Get exists = ProtobufUtil.toGet(new org.apache.hadoop.hbase.client.Get(Bytes.toBytes("fakeRow2")), true);
RegionActionResult actions = hRegionBridge.processRegionAction(new RegionAction(regionSpecifier,
true,
Arrays.asList(
new Action(0, mutation, get),
new Action(1, mutation, exists))
));
assertThat(actions.getException(), IsNull.notNullValue());
assertThat(actions.getResultOrExceptionList().size(), is(0));
}
示例15: shouldEasilyDoSimpleMutationMulti
import org.hamcrest.core.IsNull; //导入依赖的package包/类
@Test
public void shouldEasilyDoSimpleMutationMulti() throws Exception {
ByteBuffer regionLocation = ByteBuffer.wrap(Bytes.toBytes("testTable"));
RegionSpecifier regionSpecifier = new RegionSpecifier(RegionSpecifier.RegionSpecifierType.REGION_NAME,
regionLocation);
context.checking(new Expectations() {
{
oneOf(hRegionInterface).put(with(any(Put.class)));
}
});
MutationProto mutation = ProtobufUtil.toMutation(MutationProto.MutationType.PUT, new Put(Bytes.toBytes("fakeRow")));
RegionActionResult actions = hRegionBridge.processRegionAction(new RegionAction(regionSpecifier,
false,
Arrays.asList(new Action(0, mutation, null))));
assertThat(actions.getException(), IsNull.nullValue());
assertThat(actions.getResultOrExceptionList().size(), is(1));
}