Search in sources :

Example 26 with NoSuchUniqueName

use of net.opentsdb.uid.NoSuchUniqueName in project opentsdb by OpenTSDB.

the class TestQueryRpc method executeNSU.

@Test
public void executeNSU() throws Exception {
    final DeferredGroupException dge = mock(DeferredGroupException.class);
    when(dge.getCause()).thenReturn(new NoSuchUniqueName("foo", "metrics"));
    when(query_result.configureFromQuery((TSQuery) any(), anyInt())).thenReturn(Deferred.fromError(dge));
    final HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:sys.cpu.user");
    rpc.execute(tsdb, query);
    assertEquals(HttpResponseStatus.BAD_REQUEST, query.response().getStatus());
    final String json = query.response().getContent().toString(Charset.forName("UTF-8"));
    assertTrue(json.contains("No such name for 'foo': 'metrics'"));
}
Also used : DeferredGroupException(com.stumbleupon.async.DeferredGroupException) NoSuchUniqueName(net.opentsdb.uid.NoSuchUniqueName) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

NoSuchUniqueName (net.opentsdb.uid.NoSuchUniqueName)26 Test (org.junit.Test)9 Deferred (com.stumbleupon.async.Deferred)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 HashMap (java.util.HashMap)7 NoSuchUniqueId (net.opentsdb.uid.NoSuchUniqueId)6 DeferredGroupException (com.stumbleupon.async.DeferredGroupException)5 TSDB (net.opentsdb.core.TSDB)5 Config (net.opentsdb.utils.Config)5 Before (org.junit.Before)5 Field (java.lang.reflect.Field)4 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 MockBase (net.opentsdb.storage.MockBase)4 Callback (com.stumbleupon.async.Callback)3 IOException (java.io.IOException)3 HBaseException (org.hbase.async.HBaseException)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 List (java.util.List)2 IncomingDataPoint (net.opentsdb.core.IncomingDataPoint)2