@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));
}
java类org.hamcrest.core.IsNull的实例源码
RedditListViewModelTest.java 文件源码
项目:droidcon2016
阅读 26
收藏 0
点赞 0
评论 0
AnalyzeActionIT.java 文件源码
项目:elasticsearch_my
阅读 24
收藏 0
点赞 0
评论 0
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));
}
RedditListViewModelTest.java 文件源码
项目:droidcon2016
阅读 30
收藏 0
点赞 0
评论 0
@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"));
}
ClusterServiceTest.java 文件源码
项目:easyrec_major
阅读 25
收藏 0
点赞 0
评论 0
@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());
}
SiteTest.java 文件源码
项目:maven-confluence-plugin
阅读 19
收藏 0
点赞 0
评论 0
@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\"!"));
}
SiteTest.java 文件源码
项目:maven-confluence-plugin
阅读 22
收藏 0
点赞 0
评论 0
@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(" "));
}
SiteTest.java 文件源码
项目:maven-confluence-plugin
阅读 21
收藏 0
点赞 0
评论 0
@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"));
}
Issue130IntegrationTest.java 文件源码
项目:maven-confluence-plugin
阅读 20
收藏 0
点赞 0
评论 0
@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);
}
}
FailAuthorizationProfileTestCase.java 文件源码
项目:DeviceConnect-Android
阅读 42
收藏 0
点赞 0
评论 0
/**
* 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");
}
BuyOrderServiceActivatorTest.java 文件源码
项目:spring-streaming-processing
阅读 21
收藏 0
点赞 0
评论 0
@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);
}
ClusterServiceTest.java 文件源码
项目:easyrec-PoC
阅读 70
收藏 0
点赞 0
评论 0
@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());
}
HRegionBridgeTest.java 文件源码
项目:c5
阅读 37
收藏 0
点赞 0
评论 0
@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));
}
HRegionBridgeTest.java 文件源码
项目:c5
阅读 19
收藏 0
点赞 0
评论 0
@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));
}
HRegionBridgeTest.java 文件源码
项目:c5
阅读 18
收藏 0
点赞 0
评论 0
@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));
}
HRegionBridgeTest.java 文件源码
项目:c5
阅读 20
收藏 0
点赞 0
评论 0
@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));
}
HRegionBridgeTest.java 文件源码
项目:c5
阅读 22
收藏 0
点赞 0
评论 0
@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));
}
HRegionBridgeTest.java 文件源码
项目:c5
阅读 19
收藏 0
点赞 0
评论 0
@Test
public void shouldEasilyDoMutationOnlyMultiPut() throws Exception {
ByteBuffer regionLocation = ByteBuffer.wrap(Bytes.toBytes("testTable"));
RegionSpecifier regionSpecifier = new RegionSpecifier(RegionSpecifier.RegionSpecifierType.REGION_NAME,
regionLocation);
context.checking(new Expectations() {
{
exactly(3).of(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),
new Action(1, mutation, null),
new Action(2, mutation, null))
));
assertThat(actions.getException(), IsNull.nullValue());
assertThat(actions.getResultOrExceptionList().size(), is(3));
}
HRegionBridgeTest.java 文件源码
项目:c5
阅读 22
收藏 0
点赞 0
评论 0
@Test
public void shouldEasilyDoMutationOnlyMultiDelete() throws Exception {
ByteBuffer regionLocation = ByteBuffer.wrap(Bytes.toBytes("testTable"));
RegionSpecifier regionSpecifier = new RegionSpecifier(RegionSpecifier.RegionSpecifierType.REGION_NAME,
regionLocation);
context.checking(new Expectations() {
{
oneOf(hRegionInterface).delete(with(any(Delete.class)));
oneOf(hRegionInterface).delete(with(any(Delete.class)));
oneOf(hRegionInterface).delete(with(any(Delete.class)));
}
});
MutationProto mutation = ProtobufUtil.toMutation(MutationProto.MutationType.DELETE, new Delete(Bytes.toBytes("fakeRow")));
RegionActionResult actions = hRegionBridge.processRegionAction(new RegionAction(regionSpecifier,
false,
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));
}
HRegionBridgeTest.java 文件源码
项目:c5
阅读 20
收藏 0
点赞 0
评论 0
@Test
public void shouldBeAbleToProcessMultiRowNonAtomicPut() throws Exception {
ByteBuffer regionLocation = ByteBuffer.wrap(Bytes.toBytes("testTable"));
RegionSpecifier regionSpecifier = new RegionSpecifier(RegionSpecifier.RegionSpecifierType.REGION_NAME,
regionLocation);
MutationProto mutation = ProtobufUtil.toMutation(MutationProto.MutationType.PUT, new Put(Bytes.toBytes("fakeRow")));
MutationProto mutation2 = ProtobufUtil.toMutation(MutationProto.MutationType.PUT, new Put(Bytes.toBytes("fakeRow2")));
context.checking(new Expectations() {
{
exactly(3).of(hRegionInterface).put(with(any(Put.class)));
}
});
RegionActionResult actions = hRegionBridge.processRegionAction(new RegionAction(regionSpecifier,
false,
Arrays.asList(
new Action(0, mutation, null),
new Action(1, mutation, null),
new Action(2, mutation2, null))
));
assertThat(actions.getException(), IsNull.nullValue());
assertThat(actions.getResultOrExceptionList().size(), is(3));
}
HRegionBridgeTest.java 文件源码
项目:c5
阅读 18
收藏 0
点赞 0
评论 0
@Test
public void shouldFailWhenWeTryToMutateAndGet() 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));
}
TaskTest.java 文件源码
项目:ews-java-api
阅读 32
收藏 0
点赞 0
评论 0
/**
* Test for checking if the value changes in case of a thrown exception
*
* @throws Exception
*/
@Test
public void testDontChangeValueOnException() throws Exception {
// set valid value
final Double targetValue = 50.5;
taskMock.setPercentComplete(targetValue);
assertThat(taskMock.getPercentComplete(), IsNot.not(IsNull.nullValue()));
assertThat(taskMock.getPercentComplete(), IsInstanceOf.instanceOf(Double.class));
assertThat(taskMock.getPercentComplete(), IsEqual.equalTo(targetValue));
final Double invalidValue = -0.1;
try {
taskMock.setPercentComplete(invalidValue);
} catch (IllegalArgumentException ex) {
// ignored
}
assertThat(taskMock.getPercentComplete(), IsNot.not(IsNull.nullValue()));
assertThat(taskMock.getPercentComplete(), IsInstanceOf.instanceOf(Double.class));
assertThat(taskMock.getPercentComplete(), IsEqual.equalTo(targetValue));
}
BaseNodeRestControllerTest.java 文件源码
项目:your-all-in-one
阅读 22
收藏 0
点赞 0
评论 0
/**
* service-function to test the response for creating a node as child of the parentId
* @param parentId parentId of the new task
* @param node the node to create
* @return the sysUID of the new node
* @throws Exception io-Exceptions possible
*/
public String testCreateNode(final String parentId, final BaseNode node) throws Exception {
// request
MockHttpServletRequestBuilder req =
MockMvcRequestBuilders.post("/nodes/create/"
+ node.getClassName()
+ "/" + parentId);
// set params
req.content(convertObjectToJsonBytes(node));
// set contenttype;
req.contentType(APPLICATION_JSON_UTF8);
ResultActions res = testBaseRequest(req);
// check data
res.andExpect(jsonPath("$.node.name", is(node.getName())))
.andExpect(jsonPath("$.node.sysUID", IsNull.notNullValue()));
// create JSON from String
String response = res.andReturn().getResponse().getContentAsString();
String sysUID = JsonPath.read(response, "$.node.sysUID");
return sysUID;
}
SolrTemplateTests.java 文件源码
项目:spring-data-solr
阅读 21
收藏 0
点赞 0
评论 0
/**
* @throws IOException
* @throws SolrServerException
* @see DATASOLR-72
*/
@Test
public void schemaShouldBeUpdatedPriorToSavingEntity() throws SolrServerException, IOException {
NamedList<Object> nl = new NamedList<Object>();
nl.add("json", "{ \"schema\" : {\"name\" : \"core1\" }, \"version\" : 1.5 }");
Mockito.when(solrServerMock.request(Mockito.any(SolrSchemaRequest.class))).thenReturn(nl);
Mockito.when(solrServerMock.request(Mockito.any(SolrSchemaRequest.class))).thenReturn(nl);
solrTemplate = new SolrTemplate(solrServerMock, "core1");
solrTemplate.setSchemaCreationFeatures(Collections.singletonList(Feature.CREATE_MISSING_FIELDS));
solrTemplate.afterPropertiesSet();
solrTemplate.saveBean(new DocumentWithIndexAnnotations());
ArgumentCaptor<SolrRequest> requestCaptor = ArgumentCaptor.forClass(SolrRequest.class);
Mockito.verify(solrServerMock, Mockito.times(3)).request(requestCaptor.capture());
SolrRequest capturedRequest = requestCaptor.getValue();
Assert.assertThat(capturedRequest.getMethod(), IsEqual.equalTo(SolrRequest.METHOD.POST));
Assert.assertThat(capturedRequest.getPath(), IsEqual.equalTo("/schema/fields"));
Assert.assertThat(capturedRequest.getContentStreams(), IsNull.notNullValue());
}
ITestSolrTemplate.java 文件源码
项目:spring-data-solr
阅读 45
收藏 0
点赞 0
评论 0
@Test
public void testFunctionQueryInFieldProjection() {
ExampleSolrBean bean1 = new ExampleSolrBean("id-1", "one", null);
bean1.setStore("45.17614,-93.87341");
ExampleSolrBean bean2 = new ExampleSolrBean("id-2", "one two", null);
bean2.setStore("40.7143,-74.006");
solrTemplate.saveBeans(Arrays.asList(bean1, bean2));
solrTemplate.commit();
Query q = new SimpleQuery("*:*");
q.addProjectionOnField(new DistanceField("distance", "store", new Point(45.15, -93.85)));
Page<ExampleSolrBean> result = solrTemplate.queryForPage(q, ExampleSolrBean.class);
for (ExampleSolrBean bean : result) {
Assert.assertThat(bean.getDistance(), IsNull.notNullValue());
}
}
ITestSolrTemplate.java 文件源码
项目:spring-data-solr
阅读 20
收藏 0
点赞 0
评论 0
/**
* @see DATASOLR-142
*/
@Test
public void testDistaneFunctionWithGeoLocationQueryInFieldProjection() {
ExampleSolrBean bean1 = new ExampleSolrBean("id-1", "one", null);
bean1.setStore("45.17614,-93.87341");
ExampleSolrBean bean2 = new ExampleSolrBean("id-2", "one two", null);
bean2.setStore("40.7143,-74.006");
solrTemplate.saveBeans(Arrays.asList(bean1, bean2));
solrTemplate.commit();
Query q = new SimpleQuery("*:*");
q.addProjectionOnField(new DistanceField("distance", "store", new GeoLocation(45.15, -93.85)));
Page<ExampleSolrBean> result = solrTemplate.queryForPage(q, ExampleSolrBean.class);
for (ExampleSolrBean bean : result) {
Assert.assertThat(bean.getDistance(), IsNull.notNullValue());
}
}
ClusterServiceTest.java 文件源码
项目:easyrec
阅读 20
收藏 0
点赞 0
评论 0
@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());
}
PackageXmlViewModelTest.java 文件源码
项目:gocd
阅读 21
收藏 0
点赞 0
评论 0
@Test
public void shouldPopulateModificationDetailsForPackageMaterial() {
String userName = "user";
String comment = "comments";
Date checkinDate = new Date(System.currentTimeMillis());
String revision = "package-1.0.0.rpm";
Element modificationsTag = DocumentHelper.createDocument().addElement("modifications");
Modifications modifications = new Modifications(new Modification(userName, comment, null, checkinDate, revision));
XmlWriterContext writerContext = mock(XmlWriterContext.class);
when(writerContext.getBaseUrl()).thenReturn("http://someurl:8153/go");
new PipelineXmlViewModel.PackageXmlViewModel(MaterialsMother.packageMaterial()).populateXmlForModifications(modifications, writerContext, modificationsTag);
Element changeSet = modificationsTag.element("changeset");
assertThat(changeSet, is(not(IsNull.nullValue())));
assertThat(changeSet.attributeValue("changesetUri"), is("http://someurl:8153/go/api/materials/1/changeset/package-1.0.0.rpm.xml"));
assertThat(changeSet.element("user").getText(), is(userName));
assertThat(changeSet.element("revision").getText(), is(revision));
assertThat(changeSet.element("checkinTime").getText(), is(DateUtils.formatISO8601(checkinDate)));
assertThat(changeSet.element("message").getText(), is(comment));
}
InstanceFactoryTest.java 文件源码
项目:gocd
阅读 21
收藏 0
点赞 0
评论 0
@Test
public void shouldCreateASingleJobIfRunOnAllAgentsIsFalse() throws Exception {
JobConfig jobConfig = new JobConfig("foo");
SchedulingContext context = mock(SchedulingContext.class);
when(context.getEnvironmentVariablesConfig()).thenReturn(new EnvironmentVariablesConfig());
when(context.overrideEnvironmentVariables(any(EnvironmentVariablesConfig.class))).thenReturn(context);
RunOnAllAgents.CounterBasedJobNameGenerator jobNameGenerator = new RunOnAllAgents.CounterBasedJobNameGenerator(CaseInsensitiveString.str(jobConfig.name()));
JobInstances jobs = instanceFactory.createJobInstance(new CaseInsensitiveString("someStage"), jobConfig, new DefaultSchedulingContext(), new TimeProvider(), jobNameGenerator);
assertThat(jobs.toArray(), hasItemInArray(hasProperty("name", is("foo"))));
assertThat(jobs.toArray(), hasItemInArray(hasProperty("agentUuid", IsNull.nullValue())));
assertThat(jobs.toArray(), hasItemInArray(hasProperty("runOnAllAgents", is(false))));
assertThat(jobs.size(), is(1));
}
AnalyzeActionIT.java 文件源码
项目:elasticsearch_my
阅读 20
收藏 0
点赞 0
评论 0
public void testDetailAnalyze() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias"))
.setSettings(
Settings.builder()
.put("index.analysis.char_filter.my_mapping.type", "mapping")
.putArray("index.analysis.char_filter.my_mapping.mappings", "PH=>F")
.put("index.analysis.analyzer.test_analyzer.type", "custom")
.put("index.analysis.analyzer.test_analyzer.position_increment_gap", "100")
.put("index.analysis.analyzer.test_analyzer.tokenizer", "standard")
.putArray("index.analysis.analyzer.test_analyzer.char_filter", "my_mapping")
.putArray("index.analysis.analyzer.test_analyzer.filter", "snowball")));
ensureGreen();
for (int i = 0; i < 10; i++) {
AnalyzeResponse analyzeResponse = admin().indices().prepareAnalyze().setIndex(indexOrAlias()).setText("THIS IS A PHISH")
.setExplain(true).addCharFilter("my_mapping").setTokenizer("keyword").addTokenFilter("lowercase").get();
assertThat(analyzeResponse.detail().analyzer(), IsNull.nullValue());
//charfilters
assertThat(analyzeResponse.detail().charfilters().length, equalTo(1));
assertThat(analyzeResponse.detail().charfilters()[0].getName(), equalTo("my_mapping"));
assertThat(analyzeResponse.detail().charfilters()[0].getTexts().length, equalTo(1));
assertThat(analyzeResponse.detail().charfilters()[0].getTexts()[0], equalTo("THIS IS A 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("THIS IS A FISH"));
assertThat(analyzeResponse.detail().tokenizer().getTokens()[0].getStartOffset(), equalTo(0));
assertThat(analyzeResponse.detail().tokenizer().getTokens()[0].getEndOffset(), equalTo(15));
//tokenfilters
assertThat(analyzeResponse.detail().tokenfilters().length, equalTo(1));
assertThat(analyzeResponse.detail().tokenfilters()[0].getName(), equalTo("lowercase"));
assertThat(analyzeResponse.detail().tokenfilters()[0].getTokens().length, equalTo(1));
assertThat(analyzeResponse.detail().tokenfilters()[0].getTokens()[0].getTerm(), equalTo("this is a fish"));
assertThat(analyzeResponse.detail().tokenfilters()[0].getTokens()[0].getPosition(), equalTo(0));
assertThat(analyzeResponse.detail().tokenfilters()[0].getTokens()[0].getStartOffset(), equalTo(0));
assertThat(analyzeResponse.detail().tokenfilters()[0].getTokens()[0].getEndOffset(), equalTo(15));
}
}
AnalyzeActionIT.java 文件源码
项目:elasticsearch_my
阅读 20
收藏 0
点赞 0
评论 0
public void testDetailAnalyzeWithNoIndex() throws Exception {
//analyzer only
AnalyzeResponse analyzeResponse = client().admin().indices().prepareAnalyze("THIS IS A TEST")
.setExplain(true).setAnalyzer("simple").get();
assertThat(analyzeResponse.detail().tokenizer(), IsNull.nullValue());
assertThat(analyzeResponse.detail().tokenfilters(), IsNull.nullValue());
assertThat(analyzeResponse.detail().charfilters(), IsNull.nullValue());
assertThat(analyzeResponse.detail().analyzer().getName(), equalTo("simple"));
assertThat(analyzeResponse.detail().analyzer().getTokens().length, equalTo(4));
}