本文整理汇总了Java中org.elasticsearch.common.Strings.toString方法的典型用法代码示例。如果您正苦于以下问题:Java Strings.toString方法的具体用法?Java Strings.toString怎么用?Java Strings.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.common.Strings
的用法示例。
在下文中一共展示了Strings.toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testClusterStateSerialization
import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
public void testClusterStateSerialization() throws Exception {
MetaData metaData = MetaData.builder()
.put(IndexMetaData.builder("test_idx").settings(settings(Version.CURRENT)).numberOfShards(10).numberOfReplicas(1))
.put(IndexTemplateMetaData.builder("test_template").build())
.build();
RoutingTable routingTable = RoutingTable.builder()
.addAsNew(metaData.index("test_idx"))
.build();
DiscoveryNodes nodes = DiscoveryNodes.builder().add(new DiscoveryNode("node_foo", buildNewFakeTransportAddress(),
emptyMap(), emptySet(), Version.CURRENT)).localNodeId("node_foo").masterNodeId("node_foo").build();
ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)).nodes(nodes)
.metaData(metaData).routingTable(routingTable).build();
AllocationService strategy = createAllocationService();
clusterState = ClusterState.builder(clusterState).routingTable(strategy.reroute(clusterState, "reroute").routingTable()).build();
String clusterStateString = Strings.toString(clusterState);
assertNotNull(clusterStateString);
assertThat(clusterStateString, containsString("test_idx"));
assertThat(clusterStateString, containsString("test_template"));
assertThat(clusterStateString, containsString("node_foo"));
}
示例2: toString
import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
@Override
public String toString() {
return Strings.toString(this);
}
示例3: testToXContent
import org.elasticsearch.common.Strings; //导入方法依赖的package包/类
public void testToXContent() {
GetField getField = new GetField("field", Arrays.asList("value1", "value2"));
String output = Strings.toString(getField);
assertEquals("{\"field\":[\"value1\",\"value2\"]}", output);
}