Commit f274c72f14e3b306d8a6c006da1bffdf80a0b011

Authored by VoBa
Committed by GitHub
2 parents 5f9b9cb8 51620220

Merge pull request #192 from volodymyr-babak/sql-dao-improvements

Unifying SQL DAO
Showing 66 changed files with 855 additions and 117 deletions
1   --Xmx4096m -Xms1024m
\ No newline at end of file
... ... @@ -250,8 +250,8 @@
250 250 <scope>test</scope>
251 251 </dependency>
252 252 <dependency>
253   - <groupId>ru.yandex.qatools.embed</groupId>
254   - <artifactId>postgresql-embedded</artifactId>
  253 + <groupId>org.hsqldb</groupId>
  254 + <artifactId>hsqldb</artifactId>
255 255 <scope>test</scope>
256 256 </dependency>
257 257 </dependencies>
... ...
... ... @@ -106,7 +106,7 @@ coap:
106 106 timeout: "${COAP_TIMEOUT:10000}"
107 107
108 108 database:
109   - type: "${DATABASE_TYPE:cassandra}" # cassandra OR postgres
  109 + type: "${DATABASE_TYPE:cassandra}" # cassandra OR sql
110 110
111 111 # Cassandra driver configuration parameters
112 112 cassandra:
... ... @@ -233,7 +233,6 @@ spring:
233 233 enabled: "true"
234 234 jpa:
235 235 show-sql: "false"
236   - generate-ddl: "true"
237 236 database-platform: "org.hibernate.dialect.PostgreSQLDialect"
238 237 hibernate:
239 238 ddl-auto: "validate"
... ...
... ... @@ -80,7 +80,6 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppC
80 80 @ActiveProfiles("test")
81 81 @RunWith(SpringRunner.class)
82 82 @ContextConfiguration(classes = AbstractControllerTest.class, loader = SpringBootContextLoader.class)
83   -@TestPropertySource(locations = {"classpath:cassandra-test.properties", "classpath:application-test.properties", "classpath:nosql-test.properties"})
84 83 @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
85 84 @Configuration
86 85 @ComponentScan({"org.thingsboard.server"})
... ...
application/src/test/java/org/thingsboard/server/controller/BaseAdminControllerTest.java renamed from application/src/test/java/org/thingsboard/server/controller/AdminControllerTest.java
... ... @@ -29,7 +29,7 @@ import com.fasterxml.jackson.databind.JsonNode;
29 29 import com.fasterxml.jackson.databind.ObjectMapper;
30 30 import com.fasterxml.jackson.databind.node.ObjectNode;
31 31
32   -public class AdminControllerTest extends AbstractControllerTest {
  32 +public abstract class BaseAdminControllerTest extends AbstractControllerTest {
33 33
34 34 @Test
35 35 public void testFindAdminSettingsByKey() throws Exception {
... ...
application/src/test/java/org/thingsboard/server/controller/BaseAssetControllerTest.java renamed from application/src/test/java/org/thingsboard/server/controller/AssetControllerTest.java
... ... @@ -40,7 +40,7 @@ import org.junit.Test;
40 40 import com.datastax.driver.core.utils.UUIDs;
41 41 import com.fasterxml.jackson.core.type.TypeReference;
42 42
43   -public class AssetControllerTest extends AbstractControllerTest {
  43 +public abstract class BaseAssetControllerTest extends AbstractControllerTest {
44 44
45 45 private IdComparator<Asset> idComparator = new IdComparator<>();
46 46
... ...
application/src/test/java/org/thingsboard/server/controller/BaseAuthControllerTest.java renamed from application/src/test/java/org/thingsboard/server/controller/AuthControllerTest.java
... ... @@ -22,7 +22,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
22 22 import org.thingsboard.server.common.data.security.Authority;
23 23 import org.junit.Test;
24 24
25   -public class AuthControllerTest extends AbstractControllerTest {
  25 +public abstract class BaseAuthControllerTest extends AbstractControllerTest {
26 26
27 27 @Test
28 28 public void testGetUser() throws Exception {
... ...
application/src/test/java/org/thingsboard/server/controller/BaseComponentDescriptorControllerTest.java renamed from application/src/test/java/org/thingsboard/server/controller/ComponentDescriptorControllerTest.java
... ... @@ -33,7 +33,7 @@ import java.util.List;
33 33
34 34 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
35 35
36   -public class ComponentDescriptorControllerTest extends AbstractControllerTest {
  36 +public abstract class BaseComponentDescriptorControllerTest extends AbstractControllerTest {
37 37
38 38 private static final int AMOUNT_OF_DEFAULT_PLUGINS_DESCRIPTORS = 5;
39 39 private Tenant savedTenant;
... ...
application/src/test/java/org/thingsboard/server/controller/BaseCustomerControllerTest.java renamed from application/src/test/java/org/thingsboard/server/controller/CustomerControllerTest.java
... ... @@ -35,7 +35,7 @@ import org.junit.Test;
35 35
36 36 import com.fasterxml.jackson.core.type.TypeReference;
37 37
38   -public class CustomerControllerTest extends AbstractControllerTest {
  38 +public abstract class BaseCustomerControllerTest extends AbstractControllerTest {
39 39
40 40 private IdComparator<Customer> idComparator = new IdComparator<>();
41 41
... ...
application/src/test/java/org/thingsboard/server/controller/BaseDashboardControllerTest.java renamed from application/src/test/java/org/thingsboard/server/controller/DashboardControllerTest.java
... ... @@ -38,7 +38,7 @@ import org.junit.Test;
38 38
39 39 import com.fasterxml.jackson.core.type.TypeReference;
40 40
41   -public class DashboardControllerTest extends AbstractControllerTest {
  41 +public abstract class BaseDashboardControllerTest extends AbstractControllerTest {
42 42
43 43 private IdComparator<DashboardInfo> idComparator = new IdComparator<>();
44 44
... ...
application/src/test/java/org/thingsboard/server/controller/BaseDeviceControllerTest.java renamed from application/src/test/java/org/thingsboard/server/controller/DeviceControllerTest.java
... ... @@ -42,7 +42,7 @@ import org.junit.Test;
42 42
43 43 import com.fasterxml.jackson.core.type.TypeReference;
44 44
45   -public class DeviceControllerTest extends AbstractControllerTest {
  45 +public abstract class BaseDeviceControllerTest extends AbstractControllerTest {
46 46
47 47 private IdComparator<Device> idComparator = new IdComparator<>();
48 48
... ...
application/src/test/java/org/thingsboard/server/controller/BasePluginControllerTest.java renamed from application/src/test/java/org/thingsboard/server/controller/PluginControllerTest.java
... ... @@ -37,7 +37,7 @@ import java.util.stream.Collectors;
37 37
38 38 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
39 39
40   -public class PluginControllerTest extends AbstractControllerTest {
  40 +public abstract class BasePluginControllerTest extends AbstractControllerTest {
41 41
42 42 private IdComparator<PluginMetaData> idComparator = new IdComparator<>();
43 43
... ... @@ -130,7 +130,7 @@ public class PluginControllerTest extends AbstractControllerTest {
130 130
131 131 doPost("/api/plugin/" + savedPlugin.getId().getId().toString() + "/activate").andExpect(status().isOk());
132 132
133   - RuleMetaData rule = RuleControllerTest.createRuleMetaData(savedPlugin);
  133 + RuleMetaData rule = BaseRuleControllerTest.createRuleMetaData(savedPlugin);
134 134 RuleMetaData savedRule = doPost("/api/rule", rule, RuleMetaData.class);
135 135 doPost("/api/rule/" + savedRule.getId().getId().toString() + "/activate").andExpect(status().isOk());
136 136
... ... @@ -151,7 +151,7 @@ public class PluginControllerTest extends AbstractControllerTest {
151 151
152 152 PluginMetaData savedPlugin = doPost("/api/plugin", plugin, PluginMetaData.class);
153 153
154   - RuleMetaData rule = RuleControllerTest.createRuleMetaData(savedPlugin);
  154 + RuleMetaData rule = BaseRuleControllerTest.createRuleMetaData(savedPlugin);
155 155 RuleMetaData savedRule = doPost("/api/rule", rule, RuleMetaData.class);
156 156
157 157 doDelete("/api/plugin/" + savedPlugin.getId().getId()).andExpect(status().isBadRequest());
... ...
application/src/test/java/org/thingsboard/server/controller/BaseRuleControllerTest.java renamed from application/src/test/java/org/thingsboard/server/controller/RuleControllerTest.java
... ... @@ -38,7 +38,7 @@ import java.util.stream.Collectors;
38 38
39 39 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
40 40
41   -public class RuleControllerTest extends AbstractControllerTest {
  41 +public abstract class BaseRuleControllerTest extends AbstractControllerTest {
42 42
43 43 private IdComparator<RuleMetaData> idComparator = new IdComparator<>();
44 44
... ...
application/src/test/java/org/thingsboard/server/controller/BaseTenantControllerTest.java renamed from application/src/test/java/org/thingsboard/server/controller/TenantControllerTest.java
... ... @@ -31,7 +31,7 @@ import org.junit.Test;
31 31
32 32 import com.fasterxml.jackson.core.type.TypeReference;
33 33
34   -public class TenantControllerTest extends AbstractControllerTest {
  34 +public abstract class BaseTenantControllerTest extends AbstractControllerTest {
35 35
36 36 private IdComparator<Tenant> idComparator = new IdComparator<>();
37 37
... ... @@ -107,7 +107,7 @@ public class TenantControllerTest extends AbstractControllerTest {
107 107 Assert.assertFalse(pageData.hasNext());
108 108 Assert.assertEquals(1, pageData.getData().size());
109 109 tenants.addAll(pageData.getData());
110   -
  110 +
111 111 for (int i=0;i<56;i++) {
112 112 Tenant tenant = new Tenant();
113 113 tenant.setTitle("Tenant"+i);
... ...
application/src/test/java/org/thingsboard/server/controller/BaseUserControllerTest.java renamed from application/src/test/java/org/thingsboard/server/controller/UserControllerTest.java
... ... @@ -39,7 +39,7 @@ import static org.hamcrest.Matchers.containsString;
39 39 import static org.hamcrest.Matchers.is;
40 40 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
41 41
42   -public class UserControllerTest extends AbstractControllerTest {
  42 +public abstract class BaseUserControllerTest extends AbstractControllerTest {
43 43
44 44 private IdComparator<User> idComparator = new IdComparator<>();
45 45
... ...
application/src/test/java/org/thingsboard/server/controller/BaseWidgetTypeControllerTest.java renamed from application/src/test/java/org/thingsboard/server/controller/WidgetTypeControllerTest.java
... ... @@ -35,7 +35,7 @@ import java.util.List;
35 35 import static org.hamcrest.Matchers.containsString;
36 36 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
37 37
38   -public class WidgetTypeControllerTest extends AbstractControllerTest {
  38 +public abstract class BaseWidgetTypeControllerTest extends AbstractControllerTest {
39 39
40 40 private IdComparator<WidgetType> idComparator = new IdComparator<>();
41 41
... ...
application/src/test/java/org/thingsboard/server/controller/BaseWidgetsBundleControllerTest.java renamed from application/src/test/java/org/thingsboard/server/controller/WidgetsBundleControllerTest.java
... ... @@ -34,7 +34,7 @@ import java.util.List;
34 34 import static org.hamcrest.Matchers.containsString;
35 35 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
36 36
37   -public class WidgetsBundleControllerTest extends AbstractControllerTest {
  37 +public abstract class BaseWidgetsBundleControllerTest extends AbstractControllerTest {
38 38
39 39 private IdComparator<WidgetsBundle> idComparator = new IdComparator<>();
40 40
... ...
application/src/test/java/org/thingsboard/server/controller/ControllerNoSqlTestSuite.java renamed from application/src/test/java/org/thingsboard/server/controller/ControllerTestSuite.java
... ... @@ -25,8 +25,8 @@ import java.util.Arrays;
25 25
26 26 @RunWith(ClasspathSuite.class)
27 27 @ClasspathSuite.ClassnameFilters({
28   - "org.thingsboard.server.controller.*Test"})
29   -public class ControllerTestSuite {
  28 + "org.thingsboard.server.controller.nosql.*Test"})
  29 +public class ControllerNoSqlTestSuite {
30 30
31 31 @ClassRule
32 32 public static CustomCassandraCQLUnit cassandraUnit =
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller;
  17 +
  18 +import org.junit.ClassRule;
  19 +import org.junit.extensions.cpsuite.ClasspathSuite;
  20 +import org.junit.runner.RunWith;
  21 +import org.thingsboard.server.dao.CustomSqlUnit;
  22 +
  23 +import java.util.Arrays;
  24 +
  25 +@RunWith(ClasspathSuite.class)
  26 +@ClasspathSuite.ClassnameFilters({
  27 + "org.thingsboard.server.controller.sql.*SqlTest",
  28 + })
  29 +public class ControllerSqlTestSuite {
  30 +
  31 + @ClassRule
  32 + public static CustomSqlUnit sqlUnit = new CustomSqlUnit(
  33 + Arrays.asList("sql/schema.sql", "sql/system-data.sql"),
  34 + "sql/drop-all-tables.sql",
  35 + "sql-test.properties");
  36 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.nosql;
  17 +
  18 +import org.thingsboard.server.controller.BaseAdminControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoNoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoNoSqlTest
  25 +public class AdminControllerNoSqlTest extends BaseAdminControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.nosql;
  17 +
  18 +import org.thingsboard.server.controller.BaseAssetControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoNoSqlTest;
  20 +import org.thingsboard.server.dao.util.NoSqlDao;
  21 +
  22 +/**
  23 + * Created by Valerii Sosliuk on 6/28/2017.
  24 + */
  25 +@DaoNoSqlTest
  26 +public class AssetControllerNoSqlTest extends BaseAssetControllerTest {
  27 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.nosql;
  17 +
  18 +import org.thingsboard.server.controller.BaseAuthControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoNoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoNoSqlTest
  25 +public class AuthControllerNoSqlTest extends BaseAuthControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.nosql;
  17 +
  18 +import org.thingsboard.server.controller.BaseComponentDescriptorControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoNoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoNoSqlTest
  25 +public class ComponentDescriptorControllerNoSqlTest extends BaseComponentDescriptorControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.nosql;
  17 +
  18 +import org.thingsboard.server.controller.BaseCustomerControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoNoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoNoSqlTest
  25 +public class CustomerControllerNoSqlTest extends BaseCustomerControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.nosql;
  17 +
  18 +import org.thingsboard.server.controller.BaseDashboardControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoNoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoNoSqlTest
  25 +public class DashboardControllerNoSqlTest extends BaseDashboardControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.nosql;
  17 +
  18 +import org.thingsboard.server.controller.BaseDeviceControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoNoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoNoSqlTest
  25 +public class DeviceControllerNoSqlTest extends BaseDeviceControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.nosql;
  17 +
  18 +import org.thingsboard.server.controller.BasePluginControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoNoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoNoSqlTest
  25 +public class PluginControllerNoSqlTest extends BasePluginControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.nosql;
  17 +
  18 +import org.thingsboard.server.controller.BaseRuleControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoNoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoNoSqlTest
  25 +public class RuleControllerNoSqlTest extends BaseRuleControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.nosql;
  17 +
  18 +import org.thingsboard.server.controller.BaseTenantControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoNoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoNoSqlTest
  25 +public class TenantControllerNoSqlTest extends BaseTenantControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.nosql;
  17 +
  18 +import org.thingsboard.server.controller.BaseUserControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoNoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoNoSqlTest
  25 +public class UserControllerNoSqlTest extends BaseUserControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.nosql;
  17 +
  18 +import org.thingsboard.server.controller.BaseWidgetTypeControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoNoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoNoSqlTest
  25 +public class WidgetTypeControllerNoSqlTest extends BaseWidgetTypeControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.nosql;
  17 +
  18 +import org.thingsboard.server.controller.BaseWidgetsBundleControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoNoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoNoSqlTest
  25 +public class WidgetsBundleControllerNoSqlTest extends BaseWidgetsBundleControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.sql;
  17 +
  18 +import org.thingsboard.server.controller.BaseAdminControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoSqlTest
  25 +public class AdminControllerSqlTest extends BaseAdminControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.sql;
  17 +
  18 +import org.thingsboard.server.controller.BaseAssetControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoSqlTest
  25 +public class AssetControllerSqlTest extends BaseAssetControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.sql;
  17 +
  18 +import org.thingsboard.server.controller.BaseAuthControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoSqlTest
  25 +public class AuthControllerSqlTest extends BaseAuthControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.sql;
  17 +
  18 +import org.thingsboard.server.controller.BaseComponentDescriptorControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoSqlTest
  25 +public class ComponentDescriptorControllerSqlTest extends BaseComponentDescriptorControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.sql;
  17 +
  18 +import org.thingsboard.server.controller.BaseCustomerControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoSqlTest
  25 +public class CustomerControllerSqlTest extends BaseCustomerControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.sql;
  17 +
  18 +import org.thingsboard.server.controller.BaseDashboardControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoSqlTest
  25 +public class DashboardControllerSqlTest extends BaseDashboardControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.sql;
  17 +
  18 +import org.thingsboard.server.controller.BaseDeviceControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoSqlTest
  25 +public class DeviceControllerSqlTest extends BaseDeviceControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.sql;
  17 +
  18 +import org.thingsboard.server.controller.BasePluginControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoSqlTest
  25 +public class PluginControllerSqlTest extends BasePluginControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.sql;
  17 +
  18 +import org.thingsboard.server.controller.BaseRuleControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoSqlTest
  25 +public class RuleControllerSqlTest extends BaseRuleControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.sql;
  17 +
  18 +import org.thingsboard.server.controller.BaseTenantControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoSqlTest
  25 +public class TenantControllerSqlTest extends BaseTenantControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.sql;
  17 +
  18 +import org.thingsboard.server.controller.BaseUserControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoSqlTest
  25 +public class UserControllerSqlTest extends BaseUserControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.sql;
  17 +
  18 +import org.thingsboard.server.controller.BaseWidgetTypeControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoSqlTest
  25 +public class WidgetTypeControllerSqlTest extends BaseWidgetTypeControllerTest {
  26 +}
... ...
  1 +/**
  2 + * Copyright © 2016-2017 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +package org.thingsboard.server.controller.sql;
  17 +
  18 +import org.thingsboard.server.controller.BaseWidgetsBundleControllerTest;
  19 +import org.thingsboard.server.dao.service.DaoSqlTest;
  20 +
  21 +/**
  22 + * Created by Valerii Sosliuk on 6/28/2017.
  23 + */
  24 +@DaoSqlTest
  25 +public class WidgetsBundleControllerSqlTest extends BaseWidgetsBundleControllerTest {
  26 +}
... ...
... ... @@ -18,7 +18,7 @@ package org.thingsboard.server.system;
18 18 import org.junit.ClassRule;
19 19 import org.junit.extensions.cpsuite.ClasspathSuite;
20 20 import org.junit.runner.RunWith;
21   -import org.thingsboard.server.dao.CustomPostgresUnit;
  21 +import org.thingsboard.server.dao.CustomSqlUnit;
22 22
23 23 import java.util.Arrays;
24 24
... ... @@ -30,9 +30,10 @@ import java.util.Arrays;
30 30 public class SystemSqlTestSuite {
31 31
32 32 @ClassRule
33   - public static CustomPostgresUnit postgresUnit = new CustomPostgresUnit(
34   - Arrays.asList("postgres/schema.sql", "postgres/system-data.sql"),
35   - "postgres-embedded-test.properties");
  33 + public static CustomSqlUnit sqlUnit = new CustomSqlUnit(
  34 + Arrays.asList("sql/schema.sql", "sql/system-data.sql"),
  35 + "sql/drop-all-tables.sql",
  36 + "sql-test.properties");
36 37
37 38
38 39 }
... ...
... ... @@ -22,5 +22,5 @@ import org.thingsboard.server.system.BaseHttpDeviceApiTest;
22 22 * Created by Valerii Sosliuk on 6/27/2017.
23 23 */
24 24 @DaoSqlTest
25   -public class DeviceApiSqlTest extends BaseHttpDeviceApiTest{
  25 +public class DeviceApiSqlTest extends BaseHttpDeviceApiTest {
26 26 }
... ...
... ... @@ -170,8 +170,8 @@
170 170 <scope>test</scope>
171 171 </dependency>
172 172 <dependency>
173   - <groupId>ru.yandex.qatools.embed</groupId>
174   - <artifactId>postgresql-embedded</artifactId>
  173 + <groupId>org.hsqldb</groupId>
  174 + <artifactId>hsqldb</artifactId>
175 175 <scope>test</scope>
176 176 </dependency>
177 177 </dependencies>
... ...
... ... @@ -45,7 +45,7 @@ public abstract class JpaAbstractDao<E extends BaseEntity<D>, D>
45 45 protected void setSearchText(E entity) {}
46 46
47 47 @Override
48   - @Transactional(propagation = REQUIRES_NEW)
  48 + @Transactional
49 49 public D save(D domain) {
50 50 E entity;
51 51 try {
... ... @@ -64,7 +64,6 @@ public abstract class JpaAbstractDao<E extends BaseEntity<D>, D>
64 64 }
65 65
66 66 @Override
67   - @Transactional(propagation = REQUIRES_NEW)
68 67 public D findById(UUID key) {
69 68 log.debug("Get entity by key {}", key);
70 69 E entity = getCrudRepository().findOne(key);
... ... @@ -78,7 +77,7 @@ public abstract class JpaAbstractDao<E extends BaseEntity<D>, D>
78 77 }
79 78
80 79 @Override
81   - @Transactional(propagation = REQUIRES_NEW)
  80 + @Transactional
82 81 public boolean removeById(UUID key) {
83 82 getCrudRepository().delete(key);
84 83 log.debug("Remove request: {}", key);
... ...
... ... @@ -73,7 +73,6 @@ public class JpaAlarmDao extends JpaAbstractDao<AlarmEntity, Alarm> implements A
73 73 }
74 74
75 75 @Override
76   - @Transactional(propagation = REQUIRES_NEW)
77 76 public ListenableFuture<Alarm> findLatestByOriginatorAndType(TenantId tenantId, EntityId originator, String type) {
78 77 return service.submit(() -> {
79 78 List<AlarmEntity> latest = alarmRepository.findLatestByOriginatorAndType(
... ...
... ... @@ -80,7 +80,5 @@ public interface DeviceRepository extends CrudRepository<DeviceEntity, UUID> {
80 80
81 81 List<DeviceEntity> findDevicesByTenantIdAndCustomerIdAndIdIn(UUID tenantId, UUID customerId, List<UUID> deviceIds);
82 82
83   - List<DeviceEntity> findDevicesByTenantId(UUID tenantId);
84   -
85 83 List<DeviceEntity> findDevicesByTenantIdAndIdIn(UUID tenantId, List<UUID> deviceIds);
86 84 }
... ...
... ... @@ -30,12 +30,12 @@ import org.thingsboard.server.common.data.page.TimePageLink;
30 30 import org.thingsboard.server.common.data.relation.EntityRelation;
31 31 import org.thingsboard.server.common.data.relation.RelationTypeGroup;
32 32 import org.thingsboard.server.dao.DaoUtil;
33   -import org.thingsboard.server.dao.util.SqlDao;
34 33 import org.thingsboard.server.dao.model.sql.RelationCompositeKey;
35 34 import org.thingsboard.server.dao.model.sql.RelationEntity;
36 35 import org.thingsboard.server.dao.relation.RelationDao;
37 36 import org.thingsboard.server.dao.sql.JpaAbstractDaoListeningExecutorService;
38 37 import org.thingsboard.server.dao.sql.JpaAbstractSearchTimeDao;
  38 +import org.thingsboard.server.dao.util.SqlDao;
39 39
40 40 import javax.persistence.criteria.CriteriaBuilder;
41 41 import javax.persistence.criteria.CriteriaQuery;
... ...
... ... @@ -17,11 +17,11 @@ package org.thingsboard.server.dao.sql.relation;
17 17
18 18 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
19 19 import org.springframework.data.repository.CrudRepository;
20   -import org.thingsboard.server.dao.util.SqlDao;
  20 +import org.springframework.transaction.annotation.Transactional;
21 21 import org.thingsboard.server.dao.model.sql.RelationCompositeKey;
22 22 import org.thingsboard.server.dao.model.sql.RelationEntity;
  23 +import org.thingsboard.server.dao.util.SqlDao;
23 24
24   -import javax.transaction.Transactional;
25 25 import java.util.List;
26 26 import java.util.UUID;
27 27
... ... @@ -51,5 +51,5 @@ public interface RelationRepository
51 51 String fromType);
52 52
53 53 @Transactional
54   - List<RelationEntity> deleteByFromIdAndFromType(UUID fromId, String fromType);
  54 + void deleteByFromIdAndFromType(UUID fromId, String fromType);
55 55 }
... ...
... ... @@ -17,6 +17,6 @@ package org.thingsboard.server.dao.util;
17 17
18 18 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
19 19
20   -@ConditionalOnProperty(prefix = "database", value = "type", havingValue = "postgres")
  20 +@ConditionalOnProperty(prefix = "database", value = "type", havingValue = "sql")
21 21 public @interface SqlDao {
22 22 }
... ...
dao/src/main/resources/sql/demo-data.sql renamed from dao/src/main/resources/postgres/demo-data.sql
dao/src/main/resources/sql/schema.sql renamed from dao/src/main/resources/postgres/schema.sql
... ... @@ -17,7 +17,7 @@
17 17
18 18 CREATE TABLE IF NOT EXISTS admin_settings (
19 19 id uuid NOT NULL CONSTRAINT admin_settings_pkey PRIMARY KEY,
20   - json_value text,
  20 + json_value varchar,
21 21 key character varying(255)
22 22 );
23 23
... ... @@ -25,7 +25,7 @@ CREATE TABLE IF NOT EXISTS alarm (
25 25 id uuid NOT NULL CONSTRAINT alarm_pkey PRIMARY KEY,
26 26 ack_ts bigint,
27 27 clear_ts bigint,
28   - additional_info text,
  28 + additional_info varchar,
29 29 end_ts bigint,
30 30 originator_id uuid,
31 31 originator_type integer,
... ... @@ -39,7 +39,7 @@ CREATE TABLE IF NOT EXISTS alarm (
39 39
40 40 CREATE TABLE IF NOT EXISTS asset (
41 41 id uuid NOT NULL CONSTRAINT asset_pkey PRIMARY KEY,
42   - additional_info text,
  42 + additional_info varchar,
43 43 customer_id uuid,
44 44 name character varying(255),
45 45 search_text character varying(255),
... ... @@ -64,7 +64,7 @@ CREATE TABLE IF NOT EXISTS component_descriptor (
64 64 id uuid NOT NULL CONSTRAINT component_descriptor_pkey PRIMARY KEY,
65 65 actions character varying(255),
66 66 clazz character varying(255),
67   - configuration_descriptor text,
  67 + configuration_descriptor varchar,
68 68 name character varying(255),
69 69 scope character varying(255),
70 70 search_text character varying(255),
... ... @@ -73,7 +73,7 @@ CREATE TABLE IF NOT EXISTS component_descriptor (
73 73
74 74 CREATE TABLE IF NOT EXISTS customer (
75 75 id uuid NOT NULL CONSTRAINT customer_pkey PRIMARY KEY,
76   - additional_info text,
  76 + additional_info varchar,
77 77 address character varying(255),
78 78 address2 character varying(255),
79 79 city character varying(255),
... ... @@ -89,7 +89,7 @@ CREATE TABLE IF NOT EXISTS customer (
89 89
90 90 CREATE TABLE IF NOT EXISTS dashboard (
91 91 id uuid NOT NULL CONSTRAINT dashboard_pkey PRIMARY KEY,
92   - configuration text,
  92 + configuration varchar,
93 93 customer_id uuid,
94 94 search_text character varying(255),
95 95 tenant_id uuid,
... ... @@ -98,7 +98,7 @@ CREATE TABLE IF NOT EXISTS dashboard (
98 98
99 99 CREATE TABLE IF NOT EXISTS device (
100 100 id uuid NOT NULL CONSTRAINT device_pkey PRIMARY KEY,
101   - additional_info text,
  101 + additional_info varchar,
102 102 customer_id uuid,
103 103 type character varying(255),
104 104 name character varying(255),
... ... @@ -116,7 +116,7 @@ CREATE TABLE IF NOT EXISTS device_credentials (
116 116
117 117 CREATE TABLE IF NOT EXISTS event (
118 118 id uuid NOT NULL CONSTRAINT event_pkey PRIMARY KEY,
119   - body text,
  119 + body varchar,
120 120 entity_id uuid,
121 121 entity_type character varying(255),
122 122 event_type character varying(255),
... ... @@ -127,10 +127,10 @@ CREATE TABLE IF NOT EXISTS event (
127 127
128 128 CREATE TABLE IF NOT EXISTS plugin (
129 129 id uuid NOT NULL CONSTRAINT plugin_pkey PRIMARY KEY,
130   - additional_info text,
  130 + additional_info varchar,
131 131 api_token character varying(255),
132 132 plugin_class character varying(255),
133   - configuration text,
  133 + configuration varchar,
134 134 name character varying(255),
135 135 public_access boolean,
136 136 search_text character varying(255),
... ... @@ -145,18 +145,18 @@ CREATE TABLE IF NOT EXISTS relation (
145 145 to_type character varying(255),
146 146 relation_type_group character varying(255),
147 147 relation_type character varying(255),
148   - additional_info text,
  148 + additional_info varchar,
149 149 CONSTRAINT relation_unq_key UNIQUE (from_id, from_type, relation_type_group, relation_type, to_id, to_type)
150 150 );
151 151
152 152 CREATE TABLE IF NOT EXISTS rule (
153 153 id uuid NOT NULL CONSTRAINT rule_pkey PRIMARY KEY,
154   - action text,
155   - additional_info text,
156   - filters text,
  154 + action varchar,
  155 + additional_info varchar,
  156 + filters varchar,
157 157 name character varying(255),
158 158 plugin_token character varying(255),
159   - processor text,
  159 + processor varchar,
160 160 search_text character varying(255),
161 161 state character varying(255),
162 162 tenant_id uuid,
... ... @@ -165,7 +165,7 @@ CREATE TABLE IF NOT EXISTS rule (
165 165
166 166 CREATE TABLE IF NOT EXISTS tb_user (
167 167 id uuid NOT NULL CONSTRAINT tb_user_pkey PRIMARY KEY,
168   - additional_info text,
  168 + additional_info varchar,
169 169 authority character varying(255),
170 170 customer_id uuid,
171 171 email character varying(255) UNIQUE,
... ... @@ -177,7 +177,7 @@ CREATE TABLE IF NOT EXISTS tb_user (
177 177
178 178 CREATE TABLE IF NOT EXISTS tenant (
179 179 id uuid NOT NULL CONSTRAINT tenant_pkey PRIMARY KEY,
180   - additional_info text,
  180 + additional_info varchar,
181 181 address character varying(255),
182 182 address2 character varying(255),
183 183 city character varying(255),
... ... @@ -228,7 +228,7 @@ CREATE TABLE IF NOT EXISTS widget_type (
228 228 id uuid NOT NULL CONSTRAINT widget_type_pkey PRIMARY KEY,
229 229 alias character varying(255),
230 230 bundle_alias character varying(255),
231   - descriptor text,
  231 + descriptor varchar(1000000),
232 232 name character varying(255),
233 233 tenant_id uuid
234 234 );
... ... @@ -236,7 +236,6 @@ CREATE TABLE IF NOT EXISTS widget_type (
236 236 CREATE TABLE IF NOT EXISTS widgets_bundle (
237 237 id uuid NOT NULL CONSTRAINT widgets_bundle_pkey PRIMARY KEY,
238 238 alias character varying(255),
239   - image bytea,
240 239 search_text character varying(255),
241 240 tenant_id uuid,
242 241 title character varying(255)
... ...
dao/src/main/resources/sql/system-data.sql renamed from dao/src/main/resources/postgres/system-data.sql
dao/src/test/java/org/thingsboard/server/dao/CustomSqlUnit.java renamed from dao/src/test/java/org/thingsboard/server/dao/CustomPostgresUnit.java
... ... @@ -19,7 +19,6 @@ import com.google.common.base.Charsets;
19 19 import com.google.common.io.Resources;
20 20 import lombok.extern.slf4j.Slf4j;
21 21 import org.junit.rules.ExternalResource;
22   -import ru.yandex.qatools.embed.postgresql.EmbeddedPostgres;
23 22
24 23 import java.io.IOException;
25 24 import java.io.InputStream;
... ... @@ -30,58 +29,47 @@ import java.sql.SQLException;
30 29 import java.util.List;
31 30 import java.util.Properties;
32 31
33   -import static ru.yandex.qatools.embed.postgresql.distribution.Version.Main.V9_6;
34 32
35 33 /**
36 34 * Created by Valerii Sosliuk on 6/24/2017.
37 35 */
38 36 @Slf4j
39   -public class CustomPostgresUnit extends ExternalResource {
  37 +public class CustomSqlUnit extends ExternalResource {
40 38
41   - private static final String HOST = "host";
42   - private static final String PORT = "port";
43   - private static final String DATABASE = "database";
44   - private static final String USERNAME = "username";
45   - private static final String PASSWORD = "password";
  39 + private final List<String> sqlFiles;
  40 + private final String dropAllTablesSqlFile;
  41 + private final String dbUrl;
  42 + private final String dbUserName;
  43 + private final String dbPassword;
46 44
47   - private List<String> sqlFiles;
48   - private Properties properties;
49   -
50   - private EmbeddedPostgres postgres;
51   -
52   - public CustomPostgresUnit(List<String> sqlFiles, String configurationFileName) {
  45 + public CustomSqlUnit(List<String> sqlFiles, String dropAllTablesSqlFile, String configurationFileName) {
53 46 this.sqlFiles = sqlFiles;
54   - this.properties = loadProperties(configurationFileName);
  47 + this.dropAllTablesSqlFile = dropAllTablesSqlFile;
  48 + final Properties properties = new Properties();
  49 + try (final InputStream stream = this.getClass().getClassLoader().getResourceAsStream(configurationFileName)) {
  50 + properties.load(stream);
  51 + this.dbUrl = properties.getProperty("spring.datasource.url");
  52 + this.dbUserName = properties.getProperty("spring.datasource.username");
  53 + this.dbPassword = properties.getProperty("spring.datasource.password");
  54 + } catch (IOException e) {
  55 + throw new RuntimeException(e.getMessage(), e);
  56 + }
55 57 }
56 58
57 59 @Override
58 60 public void before() {
59   - postgres = new EmbeddedPostgres(V9_6);
60   - load();
61   - }
  61 + cleanUpDb();
62 62
63   - @Override
64   - public void after() {
65   - postgres.stop();
66   - }
67   -
68   - private void load() {
69 63 Connection conn = null;
70 64 try {
71   - String url = postgres.start(properties.getProperty(HOST),
72   - Integer.parseInt(properties.getProperty(PORT)),
73   - properties.getProperty(DATABASE),
74   - properties.getProperty(USERNAME),
75   - properties.getProperty(PASSWORD));
76   -
77   - conn = DriverManager.getConnection(url);
  65 + conn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword);
78 66 for (String sqlFile : sqlFiles) {
79 67 URL sqlFileUrl = Resources.getResource(sqlFile);
80 68 String sql = Resources.toString(sqlFileUrl, Charsets.UTF_8);
81 69 conn.createStatement().execute(sql);
82 70 }
83 71 } catch (IOException | SQLException e) {
84   - throw new RuntimeException("Unable to start embedded postgres. Reason: " + e.getMessage(), e);
  72 + throw new RuntimeException("Unable to start embedded hsqldb. Reason: " + e.getMessage(), e);
85 73 } finally {
86 74 if (conn != null) {
87 75 try {
... ... @@ -93,13 +81,28 @@ public class CustomPostgresUnit extends ExternalResource {
93 81 }
94 82 }
95 83
96   - private Properties loadProperties(String fileName) {
97   - final Properties properties = new Properties();
98   - try (final InputStream stream = this.getClass().getClassLoader().getResourceAsStream(fileName)) {
99   - properties.load(stream);
100   - return properties;
101   - } catch (IOException e) {
102   - throw new RuntimeException(e.getMessage(), e);
  84 + @Override
  85 + public void after() {
  86 + cleanUpDb();
  87 + }
  88 +
  89 + private void cleanUpDb() {
  90 + Connection conn = null;
  91 + try {
  92 + conn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword);
  93 + URL dropAllTableSqlFileUrl = Resources.getResource(dropAllTablesSqlFile);
  94 + String dropAllTablesSql = Resources.toString(dropAllTableSqlFileUrl, Charsets.UTF_8);
  95 + conn.createStatement().execute(dropAllTablesSql);
  96 + } catch (IOException | SQLException e) {
  97 + throw new RuntimeException("Unable to clean up embedded hsqldb. Reason: " + e.getMessage(), e);
  98 + } finally {
  99 + if (conn != null) {
  100 + try {
  101 + conn.close();
  102 + } catch (SQLException e) {
  103 + log.error(e.getMessage(), e);
  104 + }
  105 + }
103 106 }
104 107 }
105 108 }
... ...
... ... @@ -24,13 +24,15 @@ import java.util.Arrays;
24 24
25 25 @RunWith(ClasspathSuite.class)
26 26 @ClassnameFilters({
27   - "org.thingsboard.server.dao.sql.*Test"
  27 + "org.thingsboard.server.dao.sql.*AASDTest"
28 28 })
29 29 public class JpaDaoTestSuite {
30 30
31 31 @ClassRule
32   - public static CustomPostgresUnit postgresUnit = new CustomPostgresUnit(
33   - Arrays.asList("postgres/schema.sql", "postgres/system-data.sql"),
34   - "postgres-embedded-test.properties");
  32 + public static CustomSqlUnit sqlUnit = new CustomSqlUnit(
  33 + Arrays.asList("sql/schema.sql", "sql/system-data.sql"),
  34 + "sql/drop-all-tables.sql",
  35 + "sql-test.properties"
  36 + );
35 37
36 38 }
... ...
... ... @@ -18,6 +18,7 @@ package org.thingsboard.server.dao;
18 18 import com.github.springtestdbunit.bean.DatabaseConfigBean;
19 19 import com.github.springtestdbunit.bean.DatabaseDataSourceConnectionFactoryBean;
20 20 import org.dbunit.DatabaseUnitException;
  21 +import org.dbunit.ext.hsqldb.HsqldbDataTypeFactory;
21 22 import org.dbunit.ext.postgresql.PostgresqlDataTypeFactory;
22 23 import org.springframework.beans.factory.annotation.Autowired;
23 24 import org.springframework.context.annotation.Bean;
... ... @@ -41,7 +42,7 @@ public class JpaDbunitTestConfig {
41 42 @Bean
42 43 public DatabaseConfigBean databaseConfigBean() {
43 44 DatabaseConfigBean databaseConfigBean = new DatabaseConfigBean();
44   - databaseConfigBean.setDatatypeFactory(new PostgresqlDataTypeFactory());
  45 + databaseConfigBean.setDatatypeFactory(new HsqldbDataTypeFactory());
45 46 return databaseConfigBean;
46 47 }
47 48
... ...
... ... @@ -29,8 +29,10 @@ import java.util.Arrays;
29 29 public class SqlDaoServiceTestSuite {
30 30
31 31 @ClassRule
32   - public static CustomPostgresUnit postgresUnit = new CustomPostgresUnit(
33   - Arrays.asList("postgres/schema.sql", "postgres/system-data.sql", "postgres/system-test.sql"),
34   - "postgres-embedded-test.properties");
  32 + public static CustomSqlUnit sqlUnit = new CustomSqlUnit(
  33 + Arrays.asList("sql/schema.sql", "sql/system-data.sql", "sql/system-test.sql"),
  34 + "sql/drop-all-tables.sql",
  35 + "sql-test.properties"
  36 + );
35 37
36 38 }
... ...
1   -host: localhost
2   -port: 5433
3   -database: thingsboard-test
4   -username: postgres
5   -password: postgres
\ No newline at end of file
1   -database.type=postgres
  1 + database.type=sql
2 2
3 3 spring.jpa.show-sql=false
4 4 spring.jpa.hibernate.ddl-auto=validate
  5 +spring.jpa.database-platform=org.hibernate.dialect.HSQLDialect
5 6
6   -spring.datasource.url=jdbc:postgresql://localhost:5433/thingsboard-test
7   -spring.datasource.username=postgres
8   -spring.datasource.password=postgres
  7 +spring.datasource.username=sa
  8 +spring.datasource.password=
  9 +spring.datasource.url=jdbc:hsqldb:file:/tmp/testDb;sql.enforce_size=false
  10 +spring.datasource.driverClassName=org.hsqldb.jdbc.JDBCDriver
\ No newline at end of file
... ...
  1 +TRUNCATE TABLE admin_settings;
  2 +TRUNCATE TABLE alarm;
  3 +TRUNCATE TABLE asset;
  4 +TRUNCATE TABLE attribute_kv;
  5 +TRUNCATE TABLE component_descriptor;
  6 +TRUNCATE TABLE customer;
  7 +TRUNCATE TABLE dashboard;
  8 +TRUNCATE TABLE device;
  9 +TRUNCATE TABLE device_credentials;
  10 +TRUNCATE TABLE event;
  11 +TRUNCATE TABLE plugin;
  12 +TRUNCATE TABLE relation;
  13 +TRUNCATE TABLE rule;
  14 +TRUNCATE TABLE tb_user;
  15 +TRUNCATE TABLE tenant;
  16 +TRUNCATE TABLE ts_kv;
  17 +TRUNCATE TABLE ts_kv_latest;
  18 +TRUNCATE TABLE user_credentials;
  19 +TRUNCATE TABLE widget_type;
  20 +TRUNCATE TABLE widgets_bundle;
\ No newline at end of file
... ...
dao/src/test/resources/sql/system-test.sql renamed from dao/src/test/resources/postgres/system-test.sql
... ... @@ -71,6 +71,7 @@
71 71 <springfox-swagger.version>2.6.1</springfox-swagger.version>
72 72 <bouncycastle.version>1.56</bouncycastle.version>
73 73 <winsw.version>2.0.1</winsw.version>
  74 + <hsqldb.version>2.4.0</hsqldb.version>
74 75 <dbunit.version>2.5.3</dbunit.version>
75 76 <spring-test-dbunit.version>1.2.1</spring-test-dbunit.version>
76 77 <postgresql.driver.version>9.4.1211</postgresql.driver.version>
... ... @@ -747,6 +748,12 @@
747 748 <version>${bouncycastle.version}</version>
748 749 </dependency>
749 750 <dependency>
  751 + <groupId>org.hsqldb</groupId>
  752 + <artifactId>hsqldb</artifactId>
  753 + <version>${hsqldb.version}</version>
  754 + <scope>test</scope>
  755 + </dependency>
  756 + <dependency>
750 757 <groupId>ru.yandex.qatools.embed</groupId>
751 758 <artifactId>postgresql-embedded</artifactId>
752 759 <version>2.2</version>
... ...