* Setups objects in MockBase including two trees, rule sets, root branch,
* child branch, leaves and some collisions and no matches. These are used for
* most of the tests so they're all here.
*/
private void setupStorage() throws Exception {
Tree tree = TestTree.buildTestTree();
// store root
TreeMap<Integer, String> root_path = new TreeMap<Integer, String>();
Branch root = new Branch(tree.getTreeId());
root.setDisplayName("ROOT");
root_path.put(0, "ROOT");
root.prependParentPath(root_path);
storage.addColumn(root.compileBranchId(), Tree.TREE_FAMILY(),
"branch".getBytes(MockBase.ASCII()),
(byte[])branchToStorageJson.invoke(root));
// store the first tree
byte[] key = new byte[] { 0, 1 };
storage.addColumn(key, Tree.TREE_FAMILY(), "tree".getBytes(MockBase.ASCII()),
(byte[])TreetoStorageJson.invoke(TestTree.buildTestTree()));
TreeRule rule = new TreeRule(1);
rule.setField("host");
rule.setDescription("Hostname rule");
rule.setType(TreeRuleType.TAGK);
rule.setDescription("Host Name");
storage.addColumn(key, Tree.TREE_FAMILY(),
"tree_rule:0:0".getBytes(MockBase.ASCII()),
JSON.serializeToBytes(rule));
rule = new TreeRule(1);
rule.setField("");
rule.setLevel(1);
rule.setNotes("Metric rule");
rule.setType(TreeRuleType.METRIC);
storage.addColumn(key, Tree.TREE_FAMILY(),
"tree_rule:1:0".getBytes(MockBase.ASCII()),
JSON.serializeToBytes(rule));
root = new Branch(1);
root.setDisplayName("ROOT");
root_path = new TreeMap<Integer, String>();
root_path.put(0, "ROOT");
root.prependParentPath(root_path);
storage.addColumn(key, Tree.TREE_FAMILY(),
"branch".getBytes(MockBase.ASCII()),
(byte[])branchToStorageJson.invoke(root));
// tree 2
key = new byte[] { 0, 2 };
Tree tree2 = new Tree();
tree2.setTreeId(2);
tree2.setName("2nd Tree");
tree2.setDescription("Other Tree");
storage.addColumn(key, Tree.TREE_FAMILY(), "tree".getBytes(MockBase.ASCII()),
(byte[])TreetoStorageJson.invoke(tree2));
rule = new TreeRule(2);
rule.setField("host");