3 changed files with 100 additions and 0 deletions
@ -0,0 +1,78 @@ |
|||||
|
/** |
||||
|
* ThingsBoard, Inc. ("COMPANY") CONFIDENTIAL |
||||
|
* |
||||
|
* Copyright © 2016-2021 ThingsBoard, Inc. All Rights Reserved. |
||||
|
* |
||||
|
* NOTICE: All information contained herein is, and remains |
||||
|
* the property of ThingsBoard, Inc. and its suppliers, |
||||
|
* if any. The intellectual and technical concepts contained |
||||
|
* herein are proprietary to ThingsBoard, Inc. |
||||
|
* and its suppliers and may be covered by U.S. and Foreign Patents, |
||||
|
* patents in process, and are protected by trade secret or copyright law. |
||||
|
* |
||||
|
* Dissemination of this information or reproduction of this material is strictly forbidden |
||||
|
* unless prior written permission is obtained from COMPANY. |
||||
|
* |
||||
|
* Access to the source code contained herein is hereby forbidden to anyone except current COMPANY employees, |
||||
|
* managers or contractors who have executed Confidentiality and Non-disclosure agreements |
||||
|
* explicitly covering such access. |
||||
|
* |
||||
|
* The copyright notice above does not evidence any actual or intended publication |
||||
|
* or disclosure of this source code, which includes |
||||
|
* information that is confidential and/or proprietary, and is a trade secret, of COMPANY. |
||||
|
* ANY REPRODUCTION, MODIFICATION, DISTRIBUTION, PUBLIC PERFORMANCE, |
||||
|
* OR PUBLIC DISPLAY OF OR THROUGH USE OF THIS SOURCE CODE WITHOUT |
||||
|
* THE EXPRESS WRITTEN CONSENT OF COMPANY IS STRICTLY PROHIBITED, |
||||
|
* AND IN VIOLATION OF APPLICABLE LAWS AND INTERNATIONAL TREATIES. |
||||
|
* THE RECEIPT OR POSSESSION OF THIS SOURCE CODE AND/OR RELATED INFORMATION |
||||
|
* DOES NOT CONVEY OR IMPLY ANY RIGHTS TO REPRODUCE, DISCLOSE OR DISTRIBUTE ITS CONTENTS, |
||||
|
* OR TO MANUFACTURE, USE, OR SELL ANYTHING THAT IT MAY DESCRIBE, IN WHOLE OR IN PART. |
||||
|
*/ |
||||
|
package org.thingsboard.server.dao.timeseries; |
||||
|
|
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.junit.Test; |
||||
|
import org.junit.runner.RunWith; |
||||
|
import org.mockito.Answers; |
||||
|
import org.springframework.beans.factory.annotation.Qualifier; |
||||
|
import org.springframework.boot.test.context.SpringBootTest; |
||||
|
import org.springframework.boot.test.mock.mockito.MockBean; |
||||
|
import org.springframework.boot.test.mock.mockito.SpyBean; |
||||
|
import org.springframework.test.context.TestPropertySource; |
||||
|
import org.springframework.test.context.junit4.SpringRunner; |
||||
|
import org.thingsboard.server.dao.cassandra.CassandraCluster; |
||||
|
import org.thingsboard.server.dao.nosql.CassandraBufferedRateExecutor; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
import static org.assertj.core.api.Assertions.assertThat; |
||||
|
|
||||
|
@RunWith(SpringRunner.class) |
||||
|
@SpringBootTest(classes = CassandraBaseTimeseriesDao.class) |
||||
|
@TestPropertySource(properties = { |
||||
|
"cassandra.query.ts_key_value_partitioning=MONTHS", |
||||
|
"cassandra.query.ts_key_value_partitioning_always_exist_in_reading=true", |
||||
|
"cassandra.query.ts_key_value_partitions_max_cache_size=100000", |
||||
|
"cassandra.query.ts_key_value_partitions_cache_stats_enabled=true", |
||||
|
"cassandra.query.ts_key_value_partitions_cache_stats_interval=60", |
||||
|
"cassandra.query.ts_key_value_ttl=0", |
||||
|
"cassandra.query.set_null_values_enabled=false", |
||||
|
}) |
||||
|
@Slf4j |
||||
|
public class CassandraBaseTimeseriesDaoTest { |
||||
|
|
||||
|
@SpyBean |
||||
|
CassandraBaseTimeseriesDao tsDao; |
||||
|
|
||||
|
@MockBean(answer = Answers.RETURNS_MOCKS) |
||||
|
@Qualifier("CassandraCluster") |
||||
|
CassandraCluster cassandraCluster; |
||||
|
@MockBean |
||||
|
CassandraBufferedRateExecutor cassandraBufferedRateExecutor; |
||||
|
|
||||
|
@Test |
||||
|
public void testCalculatePartitions() { |
||||
|
assertThat(tsDao.calculatePartitions(0, 0)).isEqualTo(List.of(0L)); |
||||
|
assertThat(tsDao.calculatePartitions(0, 1)).isEqualTo(List.of(0L, 1L)); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue