Search in sources :

Example 16 with TreeRule

use of net.opentsdb.tree.TreeRule in project opentsdb by OpenTSDB.

the class TestTreeRule method storeRuleInvalidType.

@Test(expected = IllegalArgumentException.class)
public void storeRuleInvalidType() throws Exception {
    setupStorage();
    final TreeRule rule = new TreeRule(1);
    rule.setLevel(1);
    rule.setOrder(0);
    rule.setNotes("Just some notes");
    rule.syncToStorage(storage.getTSDB(), false).joinUninterruptibly();
}
Also used : TreeRule(net.opentsdb.tree.TreeRule) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 17 with TreeRule

use of net.opentsdb.tree.TreeRule in project opentsdb by OpenTSDB.

the class TestTreeRule method copyConstructor.

@Test
public void copyConstructor() {
    rule = new TreeRule(1);
    rule.setCustomField("Custom");
    rule.setDescription("Hello World!");
    rule.setDisplayFormat("Display");
    rule.setField("Field");
    rule.setLevel(1);
    rule.setNotes("Notes");
    rule.setOrder(2);
    rule.setRegexGroupIdx(4);
    rule.setSeparator("\\.");
    final TreeRule copy = new TreeRule(rule);
    assertEquals(1, copy.getTreeId());
    assertEquals("Custom", copy.getCustomField());
    assertEquals("Hello World!", copy.getDescription());
    assertEquals("Display", copy.getDisplayFormat());
    assertEquals("Field", copy.getField());
    assertEquals(1, copy.getLevel());
    assertEquals("Notes", copy.getNotes());
    assertEquals(2, copy.getOrder());
    assertEquals(4, copy.getRegexGroupIdx());
    assertEquals("\\.", copy.getSeparator());
}
Also used : TreeRule(net.opentsdb.tree.TreeRule) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 18 with TreeRule

use of net.opentsdb.tree.TreeRule in project opentsdb by OpenTSDB.

the class TestTreeRule method storeRuleInvalidRegexIdx.

@Test(expected = IllegalArgumentException.class)
public void storeRuleInvalidRegexIdx() throws Exception {
    setupStorage();
    final TreeRule rule = new TreeRule(1);
    rule.setLevel(1);
    rule.setOrder(0);
    rule.setType(TreeRuleType.TAGK);
    rule.setRegex("^.*$");
    rule.setRegexGroupIdx(-1);
    rule.syncToStorage(storage.getTSDB(), false).joinUninterruptibly();
}
Also used : TreeRule(net.opentsdb.tree.TreeRule) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 19 with TreeRule

use of net.opentsdb.tree.TreeRule in project opentsdb by OpenTSDB.

the class TestTreeRule method before.

@Before
public void before() throws Exception {
    final Config config = new Config(false);
    tsdb = new TSDB(client, config);
    rule = new TreeRule();
}
Also used : TreeRule(net.opentsdb.tree.TreeRule) Config(net.opentsdb.utils.Config) TSDB(net.opentsdb.core.TSDB) Before(org.junit.Before)

Example 20 with TreeRule

use of net.opentsdb.tree.TreeRule in project opentsdb by OpenTSDB.

the class TestTreeRule method fetchRuleDoesNotExist.

@Test
public void fetchRuleDoesNotExist() throws Exception {
    setupStorage();
    final TreeRule rule = TreeRule.fetchRule(storage.getTSDB(), 1, 2, 2).joinUninterruptibly();
    assertNull(rule);
}
Also used : TreeRule(net.opentsdb.tree.TreeRule) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

TreeRule (net.opentsdb.tree.TreeRule)22 Test (org.junit.Test)17 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)17 DeferredGroupException (com.stumbleupon.async.DeferredGroupException)2 IOException (java.io.IOException)2 PatternSyntaxException (java.util.regex.PatternSyntaxException)2 Tree (net.opentsdb.tree.Tree)2 ArrayList (java.util.ArrayList)1 TreeMap (java.util.TreeMap)1 TSDB (net.opentsdb.core.TSDB)1 MockBase (net.opentsdb.storage.MockBase)1 Branch (net.opentsdb.tree.Branch)1 Leaf (net.opentsdb.tree.Leaf)1 TestTree (net.opentsdb.tree.TestTree)1 Config (net.opentsdb.utils.Config)1 Before (org.junit.Before)1