Search in sources :

Example 6 with Pair

use of net.opentsdb.utils.Pair in project opentsdb by OpenTSDB.

the class TestTags method parseWithMetricListNullTagv3.

@Test
public void parseWithMetricListNullTagv3() {
    final List<Pair<String, String>> tags = new ArrayList<Pair<String, String>>(3);
    final String metric = Tags.parseWithMetric("sys.cpu.user{host=web01,dc=,=root}", tags);
    assertEquals("sys.cpu.user", metric);
    assertEquals(3, tags.size());
    assertEquals("host", tags.get(0).getKey());
    assertEquals("web01", tags.get(0).getValue());
    assertEquals("dc", tags.get(1).getKey());
    assertNull(tags.get(1).getValue());
    assertNull(tags.get(2).getKey());
    assertEquals("root", tags.get(2).getValue());
}
Also used : ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Pair(net.opentsdb.utils.Pair) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 7 with Pair

use of net.opentsdb.utils.Pair in project opentsdb by OpenTSDB.

the class TestTags method parseWithMetricListMetricOnly.

@Test
public void parseWithMetricListMetricOnly() {
    final List<Pair<String, String>> tags = new ArrayList<Pair<String, String>>(0);
    final String metric = Tags.parseWithMetric("sys.cpu.user", tags);
    assertEquals("sys.cpu.user", metric);
    assertEquals(0, tags.size());
}
Also used : ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Pair(net.opentsdb.utils.Pair) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 8 with Pair

use of net.opentsdb.utils.Pair in project opentsdb by OpenTSDB.

the class TestTags method parseWithMetricListMetricEmptyCurlies.

@Test
public void parseWithMetricListMetricEmptyCurlies() {
    final List<Pair<String, String>> tags = new ArrayList<Pair<String, String>>(0);
    final String metric = Tags.parseWithMetric("sys.cpu.user{}", tags);
    assertEquals("sys.cpu.user", metric);
    assertEquals(0, tags.size());
}
Also used : ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Pair(net.opentsdb.utils.Pair) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 9 with Pair

use of net.opentsdb.utils.Pair in project opentsdb by OpenTSDB.

the class TestTags method parseWithMetricListNullMetric.

@Test
public void parseWithMetricListNullMetric() {
    final List<Pair<String, String>> tags = new ArrayList<Pair<String, String>>(1);
    final String metric = Tags.parseWithMetric("{host=}", tags);
    assertNull(metric);
    assertEquals(1, tags.size());
    assertEquals("host", tags.get(0).getKey());
    assertNull(tags.get(0).getValue());
}
Also used : ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Pair(net.opentsdb.utils.Pair) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 10 with Pair

use of net.opentsdb.utils.Pair in project opentsdb by OpenTSDB.

the class TestTags method parseWithMetricListNullTagv.

@Test
public void parseWithMetricListNullTagv() {
    final List<Pair<String, String>> tags = new ArrayList<Pair<String, String>>(1);
    final String metric = Tags.parseWithMetric("sys.cpu.user{host=}", tags);
    assertEquals("sys.cpu.user", metric);
    assertEquals(1, tags.size());
    assertEquals("host", tags.get(0).getKey());
    assertNull(tags.get(0).getValue());
}
Also used : ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Pair(net.opentsdb.utils.Pair) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Pair (net.opentsdb.utils.Pair)13 ArrayList (java.util.ArrayList)11 Test (org.junit.Test)10 Matchers.anyString (org.mockito.Matchers.anyString)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)10 SearchQuery (net.opentsdb.search.SearchQuery)2 DataPoints (net.opentsdb.core.DataPoints)1 Query (net.opentsdb.core.Query)1 TSQuery (net.opentsdb.core.TSQuery)1 TSSubQuery (net.opentsdb.core.TSSubQuery)1 TimeSeriesLookup (net.opentsdb.search.TimeSeriesLookup)1