use of net.opentsdb.core.BaseTsdbTest.UnitTestException in project opentsdb by OpenTSDB.
the class TestUniqueId method getOrCreateIdAssignFilterReturnException.
@Test(expected = RuntimeException.class)
public void getOrCreateIdAssignFilterReturnException() {
uid = new UniqueId(client, table, METRIC, 3);
final Config config = mock(Config.class);
when(config.enable_realtime_uid()).thenReturn(false);
final TSDB tsdb = mock(TSDB.class);
when(tsdb.getConfig()).thenReturn(config);
uid.setTSDB(tsdb);
final UniqueIdFilterPlugin filter = mock(UniqueIdFilterPlugin.class);
when(filter.fillterUIDAssignments()).thenReturn(true);
when(filter.allowUIDAssignment(any(UniqueIdType.class), anyString(), anyString(), anyMapOf(String.class, String.class))).thenReturn(Deferred.<Boolean>fromError(new UnitTestException()));
when(tsdb.getUidFilter()).thenReturn(filter);
// null => ID doesn't exist.
when(client.get(anyGet())).thenReturn(Deferred.<ArrayList<KeyValue>>fromResult(null));
// Watch this! ______,^ I'm writing C++ in Java!
when(client.atomicIncrement(incrementForRow(MAXID))).thenReturn(Deferred.fromResult(5L));
when(client.compareAndSet(anyPut(), emptyArray())).thenReturn(Deferred.fromResult(true)).thenReturn(Deferred.fromResult(true));
uid.getOrCreateId("foo");
}
use of net.opentsdb.core.BaseTsdbTest.UnitTestException in project opentsdb by OpenTSDB.
the class TestUniqueId method getOrCreateIdAsyncAssignFilterReturnException.
@Test(expected = UnitTestException.class)
public void getOrCreateIdAsyncAssignFilterReturnException() throws Exception {
uid = new UniqueId(client, table, METRIC, 3);
final Config config = mock(Config.class);
when(config.enable_realtime_uid()).thenReturn(false);
final TSDB tsdb = mock(TSDB.class);
when(tsdb.getConfig()).thenReturn(config);
uid.setTSDB(tsdb);
final UniqueIdFilterPlugin filter = mock(UniqueIdFilterPlugin.class);
when(filter.fillterUIDAssignments()).thenReturn(true);
when(filter.allowUIDAssignment(any(UniqueIdType.class), anyString(), anyString(), anyMapOf(String.class, String.class))).thenReturn(Deferred.<Boolean>fromError(new UnitTestException()));
when(tsdb.getUidFilter()).thenReturn(filter);
// null => ID doesn't exist.
when(client.get(anyGet())).thenReturn(Deferred.<ArrayList<KeyValue>>fromResult(null));
when(client.atomicIncrement(incrementForRow(MAXID))).thenReturn(Deferred.fromResult(5L));
when(client.compareAndSet(anyPut(), emptyArray())).thenReturn(Deferred.fromResult(true)).thenReturn(Deferred.fromResult(true));
uid.getOrCreateIdAsync("foo").join();
}
use of net.opentsdb.core.BaseTsdbTest.UnitTestException in project opentsdb by OpenTSDB.
the class TestUniqueId method getOrCreateIdAssignFilterThrowsException.
@Test(expected = RuntimeException.class)
public void getOrCreateIdAssignFilterThrowsException() {
uid = new UniqueId(client, table, METRIC, 3);
final Config config = mock(Config.class);
when(config.enable_realtime_uid()).thenReturn(false);
final TSDB tsdb = mock(TSDB.class);
when(tsdb.getConfig()).thenReturn(config);
uid.setTSDB(tsdb);
final UniqueIdFilterPlugin filter = mock(UniqueIdFilterPlugin.class);
when(filter.fillterUIDAssignments()).thenReturn(true);
when(filter.allowUIDAssignment(any(UniqueIdType.class), anyString(), anyString(), anyMapOf(String.class, String.class))).thenThrow(new UnitTestException());
when(tsdb.getUidFilter()).thenReturn(filter);
// null => ID doesn't exist.
when(client.get(anyGet())).thenReturn(Deferred.<ArrayList<KeyValue>>fromResult(null));
// Watch this! ______,^ I'm writing C++ in Java!
when(client.atomicIncrement(incrementForRow(MAXID))).thenReturn(Deferred.fromResult(5L));
when(client.compareAndSet(anyPut(), emptyArray())).thenReturn(Deferred.fromResult(true)).thenReturn(Deferred.fromResult(true));
uid.getOrCreateId("foo");
}
use of net.opentsdb.core.BaseTsdbTest.UnitTestException in project opentsdb by OpenTSDB.
the class TestUniqueId method getOrCreateIdAsyncAssignFilterThrowsException.
@Test(expected = UnitTestException.class)
public void getOrCreateIdAsyncAssignFilterThrowsException() throws Exception {
uid = new UniqueId(client, table, METRIC, 3);
final Config config = mock(Config.class);
when(config.enable_realtime_uid()).thenReturn(false);
final TSDB tsdb = mock(TSDB.class);
when(tsdb.getConfig()).thenReturn(config);
uid.setTSDB(tsdb);
final UniqueIdFilterPlugin filter = mock(UniqueIdFilterPlugin.class);
when(filter.fillterUIDAssignments()).thenReturn(true);
when(filter.allowUIDAssignment(any(UniqueIdType.class), anyString(), anyString(), anyMapOf(String.class, String.class))).thenThrow(new UnitTestException());
when(tsdb.getUidFilter()).thenReturn(filter);
// null => ID doesn't exist.
when(client.get(anyGet())).thenReturn(Deferred.<ArrayList<KeyValue>>fromResult(null));
when(client.atomicIncrement(incrementForRow(MAXID))).thenReturn(Deferred.fromResult(5L));
when(client.compareAndSet(anyPut(), emptyArray())).thenReturn(Deferred.fromResult(true)).thenReturn(Deferred.fromResult(true));
uid.getOrCreateIdAsync("foo").join();
}
Aggregations