added tests
This commit is contained in:
parent
3f936ef6fc
commit
f5eabdca3c
@ -144,7 +144,7 @@ public abstract class AbstractChunkedAggregationTimeseriesDao extends AbstractSq
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReadTsKvQueryResult findAllAsyncWithLimit(EntityId entityId, ReadTsKvQuery query) {
|
ReadTsKvQueryResult findAllAsyncWithLimit(EntityId entityId, ReadTsKvQuery query) {
|
||||||
Integer keyId = keyDictionaryDao.getOrSaveKeyId(query.getKey());
|
Integer keyId = keyDictionaryDao.getOrSaveKeyId(query.getKey());
|
||||||
List<TsKvEntity> tsKvEntities = tsKvRepository.findAllWithLimit(
|
List<TsKvEntity> tsKvEntities = tsKvRepository.findAllWithLimit(
|
||||||
entityId.getId(),
|
entityId.getId(),
|
||||||
|
|||||||
@ -51,6 +51,7 @@ public class AbstractChunkedAggregationTimeseriesDaoTest {
|
|||||||
Optional<TsKvEntry> optionalListenableFuture = Optional.of(mock(TsKvEntry.class));
|
Optional<TsKvEntry> optionalListenableFuture = Optional.of(mock(TsKvEntry.class));
|
||||||
willReturn(Futures.immediateFuture(optionalListenableFuture)).given(tsDao).findAndAggregateAsync(any(), anyString(), anyLong(), anyLong(), anyLong(), any());
|
willReturn(Futures.immediateFuture(optionalListenableFuture)).given(tsDao).findAndAggregateAsync(any(), anyString(), anyLong(), anyLong(), anyLong(), any());
|
||||||
willReturn(Futures.immediateFuture(mock(ReadTsKvQueryResult.class))).given(tsDao).getReadTsKvQueryResultFuture(any(), any());
|
willReturn(Futures.immediateFuture(mock(ReadTsKvQueryResult.class))).given(tsDao).getReadTsKvQueryResultFuture(any(), any());
|
||||||
|
willReturn(mock(ReadTsKvQueryResult.class)).given(tsDao).findAllAsyncWithLimit(any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -146,6 +147,24 @@ public class AbstractChunkedAggregationTimeseriesDaoTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenZeroInterval_whenAggregateCount_thenFindAllWithoutAggregation() {
|
||||||
|
ReadTsKvQuery query = new BaseReadTsKvQuery(TEMP, 1, 3000, 0, LIMIT, COUNT, DESC);
|
||||||
|
willCallRealMethod().given(tsDao).findAllAsync(SYS_TENANT_ID, SYS_TENANT_ID, query);
|
||||||
|
tsDao.findAllAsync(SYS_TENANT_ID, SYS_TENANT_ID, query);
|
||||||
|
verify(tsDao, times(1)).findAllAsyncWithLimit(any(), any());
|
||||||
|
verify(tsDao, times(0)).findAndAggregateAsync(any(), any(), anyLong(), anyLong(), anyLong(), any());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenNegativeInterval_whenAggregateCount_thenFindAllWithoutAggregation() {
|
||||||
|
ReadTsKvQuery query = new BaseReadTsKvQuery(TEMP, 1, 3000, 0, LIMIT, COUNT, DESC);
|
||||||
|
willCallRealMethod().given(tsDao).findAllAsync(SYS_TENANT_ID, SYS_TENANT_ID, query);
|
||||||
|
tsDao.findAllAsync(SYS_TENANT_ID, SYS_TENANT_ID, query);
|
||||||
|
verify(tsDao, times(1)).findAllAsyncWithLimit(any(), any());
|
||||||
|
verify(tsDao, times(0)).findAndAggregateAsync(any(), any(), anyLong(), anyLong(), anyLong(), any());
|
||||||
|
}
|
||||||
|
|
||||||
long getTsForReadTsKvQuery(long startTs, long endTs) {
|
long getTsForReadTsKvQuery(long startTs, long endTs) {
|
||||||
return startTs + (endTs - startTs) / 2L;
|
return startTs + (endTs - startTs) / 2L;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user