Commit a6e9ca9eb11ac58c7169db7a494a9642c4fe9c4e
1 parent
83f179e8
JPA DAO Basic Implementation & Tests
Showing
55 changed files
with
827 additions
and
218 deletions
@@ -16,6 +16,9 @@ | @@ -16,6 +16,9 @@ | ||
16 | package org.thingsboard.server.actors.plugin; | 16 | package org.thingsboard.server.actors.plugin; |
17 | 17 | ||
18 | import akka.actor.ActorRef; | 18 | import akka.actor.ActorRef; |
19 | +import com.datastax.driver.core.ResultSet; | ||
20 | +import com.datastax.driver.core.ResultSetFuture; | ||
21 | +import com.datastax.driver.core.Row; | ||
19 | import com.google.common.base.Function; | 22 | import com.google.common.base.Function; |
20 | import com.google.common.util.concurrent.FutureCallback; | 23 | import com.google.common.util.concurrent.FutureCallback; |
21 | import com.google.common.util.concurrent.Futures; | 24 | import com.google.common.util.concurrent.Futures; |
@@ -66,6 +66,16 @@ | @@ -66,6 +66,16 @@ | ||
66 | <scope>test</scope> | 66 | <scope>test</scope> |
67 | </dependency> | 67 | </dependency> |
68 | <dependency> | 68 | <dependency> |
69 | + <groupId>org.dbunit</groupId> | ||
70 | + <artifactId>dbunit</artifactId> | ||
71 | + <scope>test</scope> | ||
72 | + </dependency> | ||
73 | + <dependency> | ||
74 | + <groupId>com.github.springtestdbunit</groupId> | ||
75 | + <artifactId>spring-test-dbunit</artifactId> | ||
76 | + <scope>test</scope> | ||
77 | + </dependency> | ||
78 | + <dependency> | ||
69 | <groupId>org.mockito</groupId> | 79 | <groupId>org.mockito</groupId> |
70 | <artifactId>mockito-all</artifactId> | 80 | <artifactId>mockito-all</artifactId> |
71 | <scope>test</scope> | 81 | <scope>test</scope> |
@@ -154,6 +164,24 @@ | @@ -154,6 +164,24 @@ | ||
154 | <groupId>org.springframework.boot</groupId> | 164 | <groupId>org.springframework.boot</groupId> |
155 | <artifactId>spring-boot-starter-data-jpa</artifactId> | 165 | <artifactId>spring-boot-starter-data-jpa</artifactId> |
156 | </dependency> | 166 | </dependency> |
167 | + <dependency> | ||
168 | + <groupId>org.springframework</groupId> | ||
169 | + <artifactId>spring-test</artifactId> | ||
170 | + <scope>test</scope> | ||
171 | + </dependency> | ||
172 | + <dependency> | ||
173 | + <groupId>org.springframework</groupId> | ||
174 | + <artifactId>spring-test</artifactId> | ||
175 | + <scope>compile</scope> | ||
176 | + </dependency> | ||
177 | + <dependency> | ||
178 | + <groupId>com.h2database</groupId> | ||
179 | + <artifactId>h2</artifactId> | ||
180 | + </dependency> | ||
181 | + <dependency> | ||
182 | + <groupId>org.springframework.boot</groupId> | ||
183 | + <artifactId>spring-boot-starter-data-jpa</artifactId> | ||
184 | + </dependency> | ||
157 | </dependencies> | 185 | </dependencies> |
158 | <build> | 186 | <build> |
159 | <plugins> | 187 | <plugins> |
@@ -16,27 +16,33 @@ | @@ -16,27 +16,33 @@ | ||
16 | package org.thingsboard.server.dao; | 16 | package org.thingsboard.server.dao; |
17 | 17 | ||
18 | import org.springframework.beans.factory.annotation.Value; | 18 | import org.springframework.beans.factory.annotation.Value; |
19 | +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
19 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | 20 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
21 | +import org.springframework.boot.autoconfigure.domain.EntityScan; | ||
20 | import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; | 22 | import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; |
23 | +import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder; | ||
24 | +import org.springframework.context.annotation.Bean; | ||
25 | +import org.springframework.context.annotation.ComponentScan; | ||
21 | import org.springframework.context.annotation.Configuration; | 26 | import org.springframework.context.annotation.Configuration; |
27 | +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; | ||
28 | +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; | ||
29 | +import org.springframework.test.context.TestPropertySource; | ||
30 | +import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
22 | 31 | ||
32 | +import javax.persistence.EntityManager; | ||
33 | +import javax.persistence.EntityManagerFactory; | ||
23 | import javax.sql.DataSource; | 34 | import javax.sql.DataSource; |
24 | 35 | ||
25 | /** | 36 | /** |
26 | * @author Valerii Sosliuk | 37 | * @author Valerii Sosliuk |
27 | */ | 38 | */ |
28 | @Configuration | 39 | @Configuration |
40 | +@EnableAutoConfiguration | ||
29 | @ConditionalOnProperty(prefix="sql", value="enabled",havingValue = "true", matchIfMissing = false) | 41 | @ConditionalOnProperty(prefix="sql", value="enabled",havingValue = "true", matchIfMissing = false) |
42 | +@ComponentScan("org.thingsboard.server.dao.sql") | ||
43 | +@EnableJpaRepositories("org.thingsboard.server.dao.sql") | ||
44 | +@EntityScan("org.thingsboard.server.dao.model.sql") | ||
45 | +@EnableTransactionManagement | ||
30 | public class JpaDaoConfig { | 46 | public class JpaDaoConfig { |
31 | 47 | ||
32 | - @Value("sql.datasource.url") | ||
33 | - private String url; | ||
34 | - @Value("sql.datasource.username") | ||
35 | - private String username; | ||
36 | - @Value("sql.datasource.password") | ||
37 | - private String password; | ||
38 | - | ||
39 | - public DataSource dataSource() { | ||
40 | - return DataSourceBuilder.create().url(url).username(username).password(password).build(); | ||
41 | - } | ||
42 | } | 48 | } |
@@ -15,6 +15,8 @@ | @@ -15,6 +15,8 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.attributes; | 16 | package org.thingsboard.server.dao.attributes; |
17 | 17 | ||
18 | +import com.datastax.driver.core.ResultSet; | ||
19 | +import com.datastax.driver.core.ResultSetFuture; | ||
18 | import com.google.common.util.concurrent.ListenableFuture; | 20 | import com.google.common.util.concurrent.ListenableFuture; |
19 | import org.thingsboard.server.common.data.id.EntityId; | 21 | import org.thingsboard.server.common.data.id.EntityId; |
20 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; | 22 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
@@ -15,8 +15,12 @@ | @@ -15,8 +15,12 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.attributes; | 16 | package org.thingsboard.server.dao.attributes; |
17 | 17 | ||
18 | +import com.datastax.driver.core.ResultSet; | ||
19 | +import com.datastax.driver.core.ResultSetFuture; | ||
18 | import com.google.common.util.concurrent.ListenableFuture; | 20 | import com.google.common.util.concurrent.ListenableFuture; |
21 | +import org.thingsboard.server.common.data.id.DeviceId; | ||
19 | import org.thingsboard.server.common.data.id.EntityId; | 22 | import org.thingsboard.server.common.data.id.EntityId; |
23 | +import org.thingsboard.server.common.data.id.UUIDBased; | ||
20 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; | 24 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
21 | 25 | ||
22 | import java.util.Collection; | 26 | import java.util.Collection; |
@@ -15,6 +15,8 @@ | @@ -15,6 +15,8 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.attributes; | 16 | package org.thingsboard.server.dao.attributes; |
17 | 17 | ||
18 | +import com.datastax.driver.core.ResultSet; | ||
19 | +import com.datastax.driver.core.ResultSetFuture; | ||
18 | import com.google.common.collect.Lists; | 20 | import com.google.common.collect.Lists; |
19 | import com.google.common.util.concurrent.Futures; | 21 | import com.google.common.util.concurrent.Futures; |
20 | import com.google.common.util.concurrent.ListenableFuture; | 22 | import com.google.common.util.concurrent.ListenableFuture; |
@@ -30,7 +30,7 @@ import java.util.UUID; | @@ -30,7 +30,7 @@ import java.util.UUID; | ||
30 | 30 | ||
31 | import static org.thingsboard.server.dao.model.ModelConstants.*; | 31 | import static org.thingsboard.server.dao.model.ModelConstants.*; |
32 | 32 | ||
33 | -@Entity | 33 | +//@Entity |
34 | @Table(name = ADMIN_SETTINGS_COLUMN_FAMILY_NAME) | 34 | @Table(name = ADMIN_SETTINGS_COLUMN_FAMILY_NAME) |
35 | public final class AdminSettingsEntity implements BaseEntity<AdminSettings> { | 35 | public final class AdminSettingsEntity implements BaseEntity<AdminSettings> { |
36 | 36 |
@@ -30,7 +30,10 @@ import org.thingsboard.server.dao.model.SearchTextEntity; | @@ -30,7 +30,10 @@ import org.thingsboard.server.dao.model.SearchTextEntity; | ||
30 | 30 | ||
31 | import java.util.UUID; | 31 | import java.util.UUID; |
32 | 32 | ||
33 | -@Entity | 33 | +/** |
34 | + * @author Andrew Shvayka | ||
35 | + */ | ||
36 | +//@Entity | ||
34 | @Table(name = ModelConstants.COMPONENT_DESCRIPTOR_COLUMN_FAMILY_NAME) | 37 | @Table(name = ModelConstants.COMPONENT_DESCRIPTOR_COLUMN_FAMILY_NAME) |
35 | public class ComponentDescriptorEntity implements SearchTextEntity<ComponentDescriptor> { | 38 | public class ComponentDescriptorEntity implements SearchTextEntity<ComponentDescriptor> { |
36 | 39 |
@@ -30,7 +30,7 @@ import org.thingsboard.server.dao.model.SearchTextEntity; | @@ -30,7 +30,7 @@ import org.thingsboard.server.dao.model.SearchTextEntity; | ||
30 | 30 | ||
31 | import java.util.UUID; | 31 | import java.util.UUID; |
32 | 32 | ||
33 | -@Entity | 33 | +//@Entity |
34 | @Table(name = ModelConstants.CUSTOMER_COLUMN_FAMILY_NAME) | 34 | @Table(name = ModelConstants.CUSTOMER_COLUMN_FAMILY_NAME) |
35 | public final class CustomerEntity implements SearchTextEntity<Customer> { | 35 | public final class CustomerEntity implements SearchTextEntity<Customer> { |
36 | 36 |
@@ -31,7 +31,7 @@ import org.thingsboard.server.dao.model.SearchTextEntity; | @@ -31,7 +31,7 @@ import org.thingsboard.server.dao.model.SearchTextEntity; | ||
31 | 31 | ||
32 | import java.util.UUID; | 32 | import java.util.UUID; |
33 | 33 | ||
34 | -@Entity | 34 | +//@Entity |
35 | @Table(name = ModelConstants.DASHBOARD_COLUMN_FAMILY_NAME) | 35 | @Table(name = ModelConstants.DASHBOARD_COLUMN_FAMILY_NAME) |
36 | public final class DashboardEntity implements SearchTextEntity<Dashboard> { | 36 | public final class DashboardEntity implements SearchTextEntity<Dashboard> { |
37 | 37 |
@@ -30,7 +30,7 @@ import org.thingsboard.server.dao.model.SearchTextEntity; | @@ -30,7 +30,7 @@ import org.thingsboard.server.dao.model.SearchTextEntity; | ||
30 | 30 | ||
31 | import java.util.UUID; | 31 | import java.util.UUID; |
32 | 32 | ||
33 | -@Entity | 33 | +//@Entity |
34 | @Table(name = ModelConstants.DASHBOARD_COLUMN_FAMILY_NAME) | 34 | @Table(name = ModelConstants.DASHBOARD_COLUMN_FAMILY_NAME) |
35 | public class DashboardInfoEntity implements SearchTextEntity<DashboardInfo> { | 35 | public class DashboardInfoEntity implements SearchTextEntity<DashboardInfo> { |
36 | 36 |
@@ -30,7 +30,7 @@ import org.thingsboard.server.dao.model.ModelConstants; | @@ -30,7 +30,7 @@ import org.thingsboard.server.dao.model.ModelConstants; | ||
30 | 30 | ||
31 | import java.util.UUID; | 31 | import java.util.UUID; |
32 | 32 | ||
33 | -@Entity | 33 | +//@Entity |
34 | @Table(name = ModelConstants.DEVICE_CREDENTIALS_COLUMN_FAMILY_NAME) | 34 | @Table(name = ModelConstants.DEVICE_CREDENTIALS_COLUMN_FAMILY_NAME) |
35 | public final class DeviceCredentialsEntity implements BaseEntity<DeviceCredentials> { | 35 | public final class DeviceCredentialsEntity implements BaseEntity<DeviceCredentials> { |
36 | 36 |
@@ -31,7 +31,7 @@ import org.thingsboard.server.dao.model.SearchTextEntity; | @@ -31,7 +31,7 @@ import org.thingsboard.server.dao.model.SearchTextEntity; | ||
31 | 31 | ||
32 | import java.util.UUID; | 32 | import java.util.UUID; |
33 | 33 | ||
34 | -@Entity | 34 | +//@Entity |
35 | @Table(name = ModelConstants.DEVICE_COLUMN_FAMILY_NAME) | 35 | @Table(name = ModelConstants.DEVICE_COLUMN_FAMILY_NAME) |
36 | public final class DeviceEntity implements SearchTextEntity<Device> { | 36 | public final class DeviceEntity implements SearchTextEntity<Device> { |
37 | 37 |
@@ -34,7 +34,7 @@ import java.util.UUID; | @@ -34,7 +34,7 @@ import java.util.UUID; | ||
34 | 34 | ||
35 | @Data | 35 | @Data |
36 | @NoArgsConstructor | 36 | @NoArgsConstructor |
37 | -@Entity | 37 | +//@Entity |
38 | @Table(name = ModelConstants.DEVICE_COLUMN_FAMILY_NAME) | 38 | @Table(name = ModelConstants.DEVICE_COLUMN_FAMILY_NAME) |
39 | public class EventEntity implements BaseEntity<Event> { | 39 | public class EventEntity implements BaseEntity<Event> { |
40 | 40 |
@@ -32,7 +32,7 @@ import org.thingsboard.server.dao.model.SearchTextEntity; | @@ -32,7 +32,7 @@ import org.thingsboard.server.dao.model.SearchTextEntity; | ||
32 | import java.util.Objects; | 32 | import java.util.Objects; |
33 | import java.util.UUID; | 33 | import java.util.UUID; |
34 | 34 | ||
35 | -@Entity | 35 | +//@Entity |
36 | @Table(name = ModelConstants.PLUGIN_COLUMN_FAMILY_NAME) | 36 | @Table(name = ModelConstants.PLUGIN_COLUMN_FAMILY_NAME) |
37 | public class PluginMetaDataEntity implements SearchTextEntity<PluginMetaData> { | 37 | public class PluginMetaDataEntity implements SearchTextEntity<PluginMetaData> { |
38 | 38 |
@@ -33,7 +33,7 @@ import org.thingsboard.server.dao.model.SearchTextEntity; | @@ -33,7 +33,7 @@ import org.thingsboard.server.dao.model.SearchTextEntity; | ||
33 | import java.util.Objects; | 33 | import java.util.Objects; |
34 | import java.util.UUID; | 34 | import java.util.UUID; |
35 | 35 | ||
36 | -@Entity | 36 | +//@Entity |
37 | @Table(name = ModelConstants.RULE_COLUMN_FAMILY_NAME) | 37 | @Table(name = ModelConstants.RULE_COLUMN_FAMILY_NAME) |
38 | public class RuleMetaDataEntity implements SearchTextEntity<RuleMetaData> { | 38 | public class RuleMetaDataEntity implements SearchTextEntity<RuleMetaData> { |
39 | 39 |
@@ -29,7 +29,7 @@ import com.fasterxml.jackson.databind.JsonNode; | @@ -29,7 +29,7 @@ import com.fasterxml.jackson.databind.JsonNode; | ||
29 | 29 | ||
30 | import java.util.UUID; | 30 | import java.util.UUID; |
31 | 31 | ||
32 | -@Entity | 32 | +//@Entity |
33 | @Table(name = ModelConstants.TENANT_COLUMN_FAMILY_NAME) | 33 | @Table(name = ModelConstants.TENANT_COLUMN_FAMILY_NAME) |
34 | public final class TenantEntity implements SearchTextEntity<Tenant> { | 34 | public final class TenantEntity implements SearchTextEntity<Tenant> { |
35 | 35 |
@@ -16,11 +16,14 @@ | @@ -16,11 +16,14 @@ | ||
16 | package org.thingsboard.server.dao.model.sql; | 16 | package org.thingsboard.server.dao.model.sql; |
17 | 17 | ||
18 | import com.datastax.driver.core.utils.UUIDs; | 18 | import com.datastax.driver.core.utils.UUIDs; |
19 | + | ||
19 | import javax.persistence.Column; | 20 | import javax.persistence.Column; |
20 | import javax.persistence.Entity; | 21 | import javax.persistence.Entity; |
21 | import javax.persistence.Id; | 22 | import javax.persistence.Id; |
22 | import javax.persistence.Table; | 23 | import javax.persistence.Table; |
23 | import javax.persistence.Transient; | 24 | import javax.persistence.Transient; |
25 | + | ||
26 | +import lombok.Data; | ||
24 | import org.thingsboard.server.common.data.id.UserCredentialsId; | 27 | import org.thingsboard.server.common.data.id.UserCredentialsId; |
25 | import org.thingsboard.server.common.data.id.UserId; | 28 | import org.thingsboard.server.common.data.id.UserId; |
26 | import org.thingsboard.server.common.data.security.UserCredentials; | 29 | import org.thingsboard.server.common.data.security.UserCredentials; |
@@ -29,18 +32,19 @@ import org.thingsboard.server.dao.model.ModelConstants; | @@ -29,18 +32,19 @@ import org.thingsboard.server.dao.model.ModelConstants; | ||
29 | 32 | ||
30 | import java.util.UUID; | 33 | import java.util.UUID; |
31 | 34 | ||
35 | +@Data | ||
32 | @Entity | 36 | @Entity |
33 | @Table(name = ModelConstants.USER_CREDENTIALS_COLUMN_FAMILY_NAME) | 37 | @Table(name = ModelConstants.USER_CREDENTIALS_COLUMN_FAMILY_NAME) |
34 | public final class UserCredentialsEntity implements BaseEntity<UserCredentials> { | 38 | public final class UserCredentialsEntity implements BaseEntity<UserCredentials> { |
35 | 39 | ||
36 | @Transient | 40 | @Transient |
37 | - private static final long serialVersionUID = 1348221414123438374L; | 41 | + private static final long serialVersionUID = -3989724854149114846L; |
38 | 42 | ||
39 | @Id | 43 | @Id |
40 | - @Column(name = ModelConstants.ID_PROPERTY) | 44 | + @Column(name = ModelConstants.ID_PROPERTY, columnDefinition = "BINARY(16)") |
41 | private UUID id; | 45 | private UUID id; |
42 | - | ||
43 | - @Column(name = ModelConstants.USER_CREDENTIALS_USER_ID_PROPERTY) | 46 | + |
47 | + @Column(name = ModelConstants.USER_CREDENTIALS_USER_ID_PROPERTY, columnDefinition = "BINARY(16)", unique = true) | ||
44 | private UUID userId; | 48 | private UUID userId; |
45 | 49 | ||
46 | @Column(name = ModelConstants.USER_CREDENTIALS_ENABLED_PROPERTY) | 50 | @Column(name = ModelConstants.USER_CREDENTIALS_ENABLED_PROPERTY) |
@@ -49,10 +53,10 @@ public final class UserCredentialsEntity implements BaseEntity<UserCredentials> | @@ -49,10 +53,10 @@ public final class UserCredentialsEntity implements BaseEntity<UserCredentials> | ||
49 | @Column(name = ModelConstants.USER_CREDENTIALS_PASSWORD_PROPERTY) | 53 | @Column(name = ModelConstants.USER_CREDENTIALS_PASSWORD_PROPERTY) |
50 | private String password; | 54 | private String password; |
51 | 55 | ||
52 | - @Column(name = ModelConstants.USER_CREDENTIALS_ACTIVATE_TOKEN_PROPERTY) | 56 | + @Column(name = ModelConstants.USER_CREDENTIALS_ACTIVATE_TOKEN_PROPERTY, unique = true) |
53 | private String activateToken; | 57 | private String activateToken; |
54 | 58 | ||
55 | - @Column(name = ModelConstants.USER_CREDENTIALS_RESET_TOKEN_PROPERTY) | 59 | + @Column(name = ModelConstants.USER_CREDENTIALS_RESET_TOKEN_PROPERTY, unique = true) |
56 | private String resetToken; | 60 | private String resetToken; |
57 | 61 | ||
58 | public UserCredentialsEntity() { | 62 | public UserCredentialsEntity() { |
@@ -71,54 +75,6 @@ public final class UserCredentialsEntity implements BaseEntity<UserCredentials> | @@ -71,54 +75,6 @@ public final class UserCredentialsEntity implements BaseEntity<UserCredentials> | ||
71 | this.activateToken = userCredentials.getActivateToken(); | 75 | this.activateToken = userCredentials.getActivateToken(); |
72 | this.resetToken = userCredentials.getResetToken(); | 76 | this.resetToken = userCredentials.getResetToken(); |
73 | } | 77 | } |
74 | - | ||
75 | - public UUID getId() { | ||
76 | - return id; | ||
77 | - } | ||
78 | - | ||
79 | - public void setId(UUID id) { | ||
80 | - this.id = id; | ||
81 | - } | ||
82 | - | ||
83 | - public UUID getUserId() { | ||
84 | - return userId; | ||
85 | - } | ||
86 | - | ||
87 | - public void setUserId(UUID userId) { | ||
88 | - this.userId = userId; | ||
89 | - } | ||
90 | - | ||
91 | - public boolean isEnabled() { | ||
92 | - return enabled; | ||
93 | - } | ||
94 | - | ||
95 | - public void setEnabled(boolean enabled) { | ||
96 | - this.enabled = enabled; | ||
97 | - } | ||
98 | - | ||
99 | - public String getPassword() { | ||
100 | - return password; | ||
101 | - } | ||
102 | - | ||
103 | - public void setPassword(String password) { | ||
104 | - this.password = password; | ||
105 | - } | ||
106 | - | ||
107 | - public String getActivateToken() { | ||
108 | - return activateToken; | ||
109 | - } | ||
110 | - | ||
111 | - public void setActivateToken(String activateToken) { | ||
112 | - this.activateToken = activateToken; | ||
113 | - } | ||
114 | - | ||
115 | - public String getResetToken() { | ||
116 | - return resetToken; | ||
117 | - } | ||
118 | - | ||
119 | - public void setResetToken(String resetToken) { | ||
120 | - this.resetToken = resetToken; | ||
121 | - } | ||
122 | 78 | ||
123 | @Override | 79 | @Override |
124 | public int hashCode() { | 80 | public int hashCode() { |
@@ -186,4 +142,13 @@ public final class UserCredentialsEntity implements BaseEntity<UserCredentials> | @@ -186,4 +142,13 @@ public final class UserCredentialsEntity implements BaseEntity<UserCredentials> | ||
186 | return userCredentials; | 142 | return userCredentials; |
187 | } | 143 | } |
188 | 144 | ||
145 | + @Override | ||
146 | + public UUID getId() { | ||
147 | + return id; | ||
148 | + } | ||
149 | + | ||
150 | + @Override | ||
151 | + public void setId(UUID id) { | ||
152 | + this.id = id; | ||
153 | + } | ||
189 | } | 154 | } |
@@ -17,45 +17,44 @@ package org.thingsboard.server.dao.model.sql; | @@ -17,45 +17,44 @@ package org.thingsboard.server.dao.model.sql; | ||
17 | 17 | ||
18 | import com.datastax.driver.core.utils.UUIDs; | 18 | import com.datastax.driver.core.utils.UUIDs; |
19 | import com.fasterxml.jackson.databind.JsonNode; | 19 | import com.fasterxml.jackson.databind.JsonNode; |
20 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
21 | +import lombok.Data; | ||
20 | import org.thingsboard.server.common.data.User; | 22 | import org.thingsboard.server.common.data.User; |
21 | import org.thingsboard.server.common.data.id.CustomerId; | 23 | import org.thingsboard.server.common.data.id.CustomerId; |
22 | import org.thingsboard.server.common.data.id.TenantId; | 24 | import org.thingsboard.server.common.data.id.TenantId; |
23 | import org.thingsboard.server.common.data.id.UserId; | 25 | import org.thingsboard.server.common.data.id.UserId; |
24 | import org.thingsboard.server.common.data.security.Authority; | 26 | import org.thingsboard.server.common.data.security.Authority; |
25 | -import org.thingsboard.server.dao.model.SearchTextEntity; | ||
26 | import org.thingsboard.server.dao.model.ModelConstants; | 27 | import org.thingsboard.server.dao.model.ModelConstants; |
28 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
27 | 29 | ||
28 | -import javax.persistence.Column; | ||
29 | -import javax.persistence.Entity; | ||
30 | -import javax.persistence.Id; | ||
31 | -import javax.persistence.Table; | ||
32 | -import javax.persistence.Transient; | 30 | +import javax.persistence.*; |
31 | +import java.io.IOException; | ||
33 | import java.util.UUID; | 32 | import java.util.UUID; |
34 | 33 | ||
35 | /** | 34 | /** |
36 | - * @author Valerii Sosliuk | 35 | + * Created by Valerii Sosliuk on 4/21/2017. |
37 | */ | 36 | */ |
37 | +@Data | ||
38 | @Entity | 38 | @Entity |
39 | -@Table(name= ModelConstants.USER_COLUMN_FAMILY_NAME) | 39 | +@Table(name = ModelConstants.USER_COLUMN_FAMILY_NAME) |
40 | public class UserEntity implements SearchTextEntity<User> { | 40 | public class UserEntity implements SearchTextEntity<User> { |
41 | - | ||
42 | @Transient | 41 | @Transient |
43 | - private static final long serialVersionUID = 4349485207981226785L; | 42 | + private static final long serialVersionUID = -271106508790582977L; |
44 | 43 | ||
45 | @Id | 44 | @Id |
46 | - @Column(name=ModelConstants.ID_PROPERTY) | 45 | + @Column(name = ModelConstants.ID_PROPERTY, columnDefinition = "BINARY(16)") |
47 | private UUID id; | 46 | private UUID id; |
48 | 47 | ||
49 | - @Column(name = ModelConstants.USER_TENANT_ID_PROPERTY) | 48 | + @Column(name = ModelConstants.USER_TENANT_ID_PROPERTY, columnDefinition = "BINARY(16)") |
50 | private UUID tenantId; | 49 | private UUID tenantId; |
51 | 50 | ||
52 | - @Column(name = ModelConstants.USER_CUSTOMER_ID_PROPERTY) | 51 | + @Column(name = ModelConstants.USER_CUSTOMER_ID_PROPERTY, columnDefinition = "BINARY(16)") |
53 | private UUID customerId; | 52 | private UUID customerId; |
54 | 53 | ||
55 | @Column(name = ModelConstants.USER_AUTHORITY_PROPERTY) | 54 | @Column(name = ModelConstants.USER_AUTHORITY_PROPERTY) |
56 | private Authority authority; | 55 | private Authority authority; |
57 | 56 | ||
58 | - @Column(name = ModelConstants.USER_EMAIL_PROPERTY) | 57 | + @Column(name = ModelConstants.USER_EMAIL_PROPERTY, unique = true) |
59 | private String email; | 58 | private String email; |
60 | 59 | ||
61 | @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) | 60 | @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) |
@@ -68,7 +67,10 @@ public class UserEntity implements SearchTextEntity<User> { | @@ -68,7 +67,10 @@ public class UserEntity implements SearchTextEntity<User> { | ||
68 | private String lastName; | 67 | private String lastName; |
69 | 68 | ||
70 | @Column(name = ModelConstants.USER_ADDITIONAL_INFO_PROPERTY) | 69 | @Column(name = ModelConstants.USER_ADDITIONAL_INFO_PROPERTY) |
71 | - private JsonNode additionalInfo; | 70 | + private String additionalInfo; |
71 | + | ||
72 | + public UserEntity() { | ||
73 | + } | ||
72 | 74 | ||
73 | public UserEntity(User user) { | 75 | public UserEntity(User user) { |
74 | if (user.getId() != null) { | 76 | if (user.getId() != null) { |
@@ -84,11 +86,7 @@ public class UserEntity implements SearchTextEntity<User> { | @@ -84,11 +86,7 @@ public class UserEntity implements SearchTextEntity<User> { | ||
84 | this.email = user.getEmail(); | 86 | this.email = user.getEmail(); |
85 | this.firstName = user.getFirstName(); | 87 | this.firstName = user.getFirstName(); |
86 | this.lastName = user.getLastName(); | 88 | this.lastName = user.getLastName(); |
87 | - this.additionalInfo = user.getAdditionalInfo(); | ||
88 | - } | ||
89 | - | ||
90 | - public String getSearchText() { | ||
91 | - return searchText; | 89 | + this.additionalInfo = user.getAdditionalInfo().toString(); |
92 | } | 90 | } |
93 | 91 | ||
94 | @Override | 92 | @Override |
@@ -111,62 +109,6 @@ public class UserEntity implements SearchTextEntity<User> { | @@ -111,62 +109,6 @@ public class UserEntity implements SearchTextEntity<User> { | ||
111 | this.id = id; | 109 | this.id = id; |
112 | } | 110 | } |
113 | 111 | ||
114 | - public UUID getTenantId() { | ||
115 | - return tenantId; | ||
116 | - } | ||
117 | - | ||
118 | - public void setTenantId(UUID tenantId) { | ||
119 | - this.tenantId = tenantId; | ||
120 | - } | ||
121 | - | ||
122 | - public UUID getCustomerId() { | ||
123 | - return customerId; | ||
124 | - } | ||
125 | - | ||
126 | - public void setCustomerId(UUID customerId) { | ||
127 | - this.customerId = customerId; | ||
128 | - } | ||
129 | - | ||
130 | - public Authority getAuthority() { | ||
131 | - return authority; | ||
132 | - } | ||
133 | - | ||
134 | - public void setAuthority(Authority authority) { | ||
135 | - this.authority = authority; | ||
136 | - } | ||
137 | - | ||
138 | - public String getEmail() { | ||
139 | - return email; | ||
140 | - } | ||
141 | - | ||
142 | - public void setEmail(String email) { | ||
143 | - this.email = email; | ||
144 | - } | ||
145 | - | ||
146 | - public String getFirstName() { | ||
147 | - return firstName; | ||
148 | - } | ||
149 | - | ||
150 | - public void setFirstName(String firstName) { | ||
151 | - this.firstName = firstName; | ||
152 | - } | ||
153 | - | ||
154 | - public String getLastName() { | ||
155 | - return lastName; | ||
156 | - } | ||
157 | - | ||
158 | - public void setLastName(String lastName) { | ||
159 | - this.lastName = lastName; | ||
160 | - } | ||
161 | - | ||
162 | - public JsonNode getAdditionalInfo() { | ||
163 | - return additionalInfo; | ||
164 | - } | ||
165 | - | ||
166 | - public void setAdditionalInfo(JsonNode additionalInfo) { | ||
167 | - this.additionalInfo = additionalInfo; | ||
168 | - } | ||
169 | - | ||
170 | @Override | 112 | @Override |
171 | public String toString() { | 113 | public String toString() { |
172 | StringBuilder builder = new StringBuilder(); | 114 | StringBuilder builder = new StringBuilder(); |
@@ -204,9 +146,18 @@ public class UserEntity implements SearchTextEntity<User> { | @@ -204,9 +146,18 @@ public class UserEntity implements SearchTextEntity<User> { | ||
204 | user.setEmail(email); | 146 | user.setEmail(email); |
205 | user.setFirstName(firstName); | 147 | user.setFirstName(firstName); |
206 | user.setLastName(lastName); | 148 | user.setLastName(lastName); |
207 | - user.setAdditionalInfo(additionalInfo); | 149 | + ObjectMapper mapper = new ObjectMapper(); |
150 | + if (additionalInfo != null) { | ||
151 | + try { | ||
152 | + JsonNode jsonNode = mapper.readTree(additionalInfo); | ||
153 | + user.setAdditionalInfo(jsonNode); | ||
154 | + } catch (IOException e) { | ||
155 | + e.printStackTrace(); | ||
156 | + } | ||
157 | + } | ||
208 | return user; | 158 | return user; |
209 | } | 159 | } |
160 | + | ||
210 | @Override | 161 | @Override |
211 | public int hashCode() { | 162 | public int hashCode() { |
212 | final int prime = 31; | 163 | final int prime = 31; |
@@ -270,5 +221,4 @@ public class UserEntity implements SearchTextEntity<User> { | @@ -270,5 +221,4 @@ public class UserEntity implements SearchTextEntity<User> { | ||
270 | return false; | 221 | return false; |
271 | return true; | 222 | return true; |
272 | } | 223 | } |
273 | - | ||
274 | } | 224 | } |
@@ -32,7 +32,7 @@ import org.thingsboard.server.dao.model.ModelConstants; | @@ -32,7 +32,7 @@ import org.thingsboard.server.dao.model.ModelConstants; | ||
32 | 32 | ||
33 | import java.util.UUID; | 33 | import java.util.UUID; |
34 | 34 | ||
35 | -@Entity | 35 | +//@Entity |
36 | @Table(name = ModelConstants.WIDGET_TYPE_COLUMN_FAMILY_NAME) | 36 | @Table(name = ModelConstants.WIDGET_TYPE_COLUMN_FAMILY_NAME) |
37 | public final class WidgetTypeEntity implements BaseEntity<WidgetType> { | 37 | public final class WidgetTypeEntity implements BaseEntity<WidgetType> { |
38 | 38 |
@@ -22,6 +22,8 @@ import javax.persistence.Entity; | @@ -22,6 +22,8 @@ import javax.persistence.Entity; | ||
22 | import javax.persistence.Id; | 22 | import javax.persistence.Id; |
23 | import javax.persistence.Table; | 23 | import javax.persistence.Table; |
24 | import javax.persistence.Transient; | 24 | import javax.persistence.Transient; |
25 | + | ||
26 | +import lombok.Data; | ||
25 | import org.thingsboard.server.common.data.id.TenantId; | 27 | import org.thingsboard.server.common.data.id.TenantId; |
26 | import org.thingsboard.server.common.data.id.WidgetsBundleId; | 28 | import org.thingsboard.server.common.data.id.WidgetsBundleId; |
27 | import org.thingsboard.server.common.data.widget.WidgetsBundle; | 29 | import org.thingsboard.server.common.data.widget.WidgetsBundle; |
@@ -31,6 +33,7 @@ import org.thingsboard.server.dao.model.SearchTextEntity; | @@ -31,6 +33,7 @@ import org.thingsboard.server.dao.model.SearchTextEntity; | ||
31 | import java.nio.ByteBuffer; | 33 | import java.nio.ByteBuffer; |
32 | import java.util.UUID; | 34 | import java.util.UUID; |
33 | 35 | ||
36 | +@Data | ||
34 | @Entity | 37 | @Entity |
35 | @Table(name = ModelConstants.WIDGETS_BUNDLE_COLUMN_FAMILY_NAME) | 38 | @Table(name = ModelConstants.WIDGETS_BUNDLE_COLUMN_FAMILY_NAME) |
36 | public final class WidgetsBundleEntity implements SearchTextEntity<WidgetsBundle> { | 39 | public final class WidgetsBundleEntity implements SearchTextEntity<WidgetsBundle> { |
@@ -39,10 +42,10 @@ public final class WidgetsBundleEntity implements SearchTextEntity<WidgetsBundle | @@ -39,10 +42,10 @@ public final class WidgetsBundleEntity implements SearchTextEntity<WidgetsBundle | ||
39 | private static final long serialVersionUID = 6897035686422298096L; | 42 | private static final long serialVersionUID = 6897035686422298096L; |
40 | 43 | ||
41 | @Id | 44 | @Id |
42 | - @Column(name = ModelConstants.ID_PROPERTY) | 45 | + @Column(name = ModelConstants.ID_PROPERTY, columnDefinition = "BINARY(16)") |
43 | private UUID id; | 46 | private UUID id; |
44 | 47 | ||
45 | - @Column(name = ModelConstants.WIDGETS_BUNDLE_TENANT_ID_PROPERTY) | 48 | + @Column(name = ModelConstants.WIDGETS_BUNDLE_TENANT_ID_PROPERTY, columnDefinition = "BINARY(16)") |
46 | private UUID tenantId; | 49 | private UUID tenantId; |
47 | 50 | ||
48 | @Column(name = ModelConstants.WIDGETS_BUNDLE_ALIAS_PROPERTY) | 51 | @Column(name = ModelConstants.WIDGETS_BUNDLE_ALIAS_PROPERTY) |
@@ -55,7 +58,7 @@ public final class WidgetsBundleEntity implements SearchTextEntity<WidgetsBundle | @@ -55,7 +58,7 @@ public final class WidgetsBundleEntity implements SearchTextEntity<WidgetsBundle | ||
55 | private String searchText; | 58 | private String searchText; |
56 | 59 | ||
57 | @Column(name = ModelConstants.WIDGETS_BUNDLE_IMAGE_PROPERTY) | 60 | @Column(name = ModelConstants.WIDGETS_BUNDLE_IMAGE_PROPERTY) |
58 | - private ByteBuffer image; | 61 | + private byte[] image; |
59 | 62 | ||
60 | public WidgetsBundleEntity() { | 63 | public WidgetsBundleEntity() { |
61 | super(); | 64 | super(); |
@@ -71,7 +74,7 @@ public final class WidgetsBundleEntity implements SearchTextEntity<WidgetsBundle | @@ -71,7 +74,7 @@ public final class WidgetsBundleEntity implements SearchTextEntity<WidgetsBundle | ||
71 | this.alias = widgetsBundle.getAlias(); | 74 | this.alias = widgetsBundle.getAlias(); |
72 | this.title = widgetsBundle.getTitle(); | 75 | this.title = widgetsBundle.getTitle(); |
73 | if (widgetsBundle.getImage() != null) { | 76 | if (widgetsBundle.getImage() != null) { |
74 | - this.image = ByteBuffer.wrap(widgetsBundle.getImage()); | 77 | + this.image = widgetsBundle.getImage(); |
75 | } | 78 | } |
76 | } | 79 | } |
77 | 80 | ||
@@ -85,38 +88,6 @@ public final class WidgetsBundleEntity implements SearchTextEntity<WidgetsBundle | @@ -85,38 +88,6 @@ public final class WidgetsBundleEntity implements SearchTextEntity<WidgetsBundle | ||
85 | this.id = id; | 88 | this.id = id; |
86 | } | 89 | } |
87 | 90 | ||
88 | - public UUID getTenantId() { | ||
89 | - return tenantId; | ||
90 | - } | ||
91 | - | ||
92 | - public void setTenantId(UUID tenantId) { | ||
93 | - this.tenantId = tenantId; | ||
94 | - } | ||
95 | - | ||
96 | - public String getAlias() { | ||
97 | - return alias; | ||
98 | - } | ||
99 | - | ||
100 | - public void setAlias(String alias) { | ||
101 | - this.alias = alias; | ||
102 | - } | ||
103 | - | ||
104 | - public String getTitle() { | ||
105 | - return title; | ||
106 | - } | ||
107 | - | ||
108 | - public void setTitle(String title) { | ||
109 | - this.title = title; | ||
110 | - } | ||
111 | - | ||
112 | - public ByteBuffer getImage() { | ||
113 | - return image; | ||
114 | - } | ||
115 | - | ||
116 | - public void setImage(ByteBuffer image) { | ||
117 | - this.image = image; | ||
118 | - } | ||
119 | - | ||
120 | @Override | 91 | @Override |
121 | public String getSearchTextSource() { | 92 | public String getSearchTextSource() { |
122 | return title; | 93 | return title; |
@@ -127,10 +98,6 @@ public final class WidgetsBundleEntity implements SearchTextEntity<WidgetsBundle | @@ -127,10 +98,6 @@ public final class WidgetsBundleEntity implements SearchTextEntity<WidgetsBundle | ||
127 | this.searchText = searchText; | 98 | this.searchText = searchText; |
128 | } | 99 | } |
129 | 100 | ||
130 | - public String getSearchText() { | ||
131 | - return searchText; | ||
132 | - } | ||
133 | - | ||
134 | @Override | 101 | @Override |
135 | public int hashCode() { | 102 | public int hashCode() { |
136 | int result = id != null ? id.hashCode() : 0; | 103 | int result = id != null ? id.hashCode() : 0; |
@@ -155,7 +122,6 @@ public final class WidgetsBundleEntity implements SearchTextEntity<WidgetsBundle | @@ -155,7 +122,6 @@ public final class WidgetsBundleEntity implements SearchTextEntity<WidgetsBundle | ||
155 | if (title != null ? !title.equals(that.title) : that.title != null) return false; | 122 | if (title != null ? !title.equals(that.title) : that.title != null) return false; |
156 | if (searchText != null ? !searchText.equals(that.searchText) : that.searchText != null) return false; | 123 | if (searchText != null ? !searchText.equals(that.searchText) : that.searchText != null) return false; |
157 | return image != null ? image.equals(that.image) : that.image == null; | 124 | return image != null ? image.equals(that.image) : that.image == null; |
158 | - | ||
159 | } | 125 | } |
160 | 126 | ||
161 | @Override | 127 | @Override |
@@ -180,11 +146,7 @@ public final class WidgetsBundleEntity implements SearchTextEntity<WidgetsBundle | @@ -180,11 +146,7 @@ public final class WidgetsBundleEntity implements SearchTextEntity<WidgetsBundle | ||
180 | } | 146 | } |
181 | widgetsBundle.setAlias(alias); | 147 | widgetsBundle.setAlias(alias); |
182 | widgetsBundle.setTitle(title); | 148 | widgetsBundle.setTitle(title); |
183 | - if (image != null) { | ||
184 | - byte[] imageByteArray = new byte[image.remaining()]; | ||
185 | - image.get(imageByteArray); | ||
186 | - widgetsBundle.setImage(imageByteArray); | ||
187 | - } | 149 | + widgetsBundle.setImage(image); |
188 | return widgetsBundle; | 150 | return widgetsBundle; |
189 | } | 151 | } |
190 | } | 152 | } |
@@ -18,11 +18,11 @@ package org.thingsboard.server.dao.sql; | @@ -18,11 +18,11 @@ package org.thingsboard.server.dao.sql; | ||
18 | import com.google.common.collect.Lists; | 18 | import com.google.common.collect.Lists; |
19 | import com.google.common.util.concurrent.ListenableFuture; | 19 | import com.google.common.util.concurrent.ListenableFuture; |
20 | import lombok.extern.slf4j.Slf4j; | 20 | import lombok.extern.slf4j.Slf4j; |
21 | +import org.springframework.data.repository.CrudRepository; | ||
21 | import org.thingsboard.server.dao.Dao; | 22 | import org.thingsboard.server.dao.Dao; |
22 | import org.thingsboard.server.dao.DaoUtil; | 23 | import org.thingsboard.server.dao.DaoUtil; |
23 | import org.thingsboard.server.dao.model.BaseEntity; | 24 | import org.thingsboard.server.dao.model.BaseEntity; |
24 | import org.thingsboard.server.dao.model.SearchTextEntity; | 25 | import org.thingsboard.server.dao.model.SearchTextEntity; |
25 | -import org.thingsboard.server.dao.sql.user.JpaRepository; | ||
26 | 26 | ||
27 | import java.util.List; | 27 | import java.util.List; |
28 | import java.util.UUID; | 28 | import java.util.UUID; |
@@ -37,7 +37,7 @@ public abstract class JpaAbstractDao<E extends BaseEntity<D>, D> implements Dao< | @@ -37,7 +37,7 @@ public abstract class JpaAbstractDao<E extends BaseEntity<D>, D> implements Dao< | ||
37 | 37 | ||
38 | protected abstract String getColumnFamilyName(); | 38 | protected abstract String getColumnFamilyName(); |
39 | 39 | ||
40 | - protected abstract JpaRepository<E, UUID> getCrudRepository(); | 40 | + protected abstract CrudRepository<E, UUID> getCrudRepository(); |
41 | 41 | ||
42 | protected boolean isSearchTextDao() { | 42 | protected boolean isSearchTextDao() { |
43 | return false; | 43 | return false; |
@@ -69,7 +69,7 @@ public abstract class JpaAbstractDao<E extends BaseEntity<D>, D> implements Dao< | @@ -69,7 +69,7 @@ public abstract class JpaAbstractDao<E extends BaseEntity<D>, D> implements Dao< | ||
69 | @Override | 69 | @Override |
70 | public ListenableFuture<D> findByIdAsync(UUID key) { | 70 | public ListenableFuture<D> findByIdAsync(UUID key) { |
71 | log.debug("Get entity by key {}", key); | 71 | log.debug("Get entity by key {}", key); |
72 | - org.springframework.util.concurrent.ListenableFuture<E> entityFuture = getCrudRepository().findByIdAsync(key); | 72 | + // org.springframework.util.concurrent.ListenableFuture<E> entityFuture = getCrudRepository().findByIdAsync(key); |
73 | // TODO: vsosliuk implement | 73 | // TODO: vsosliuk implement |
74 | return null; | 74 | return null; |
75 | } | 75 | } |
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.dao.sql.user; | ||
17 | + | ||
18 | +import org.springframework.beans.factory.annotation.Autowired; | ||
19 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
20 | +import org.springframework.data.repository.CrudRepository; | ||
21 | +import org.springframework.stereotype.Component; | ||
22 | +import org.thingsboard.server.common.data.User; | ||
23 | +import org.thingsboard.server.common.data.security.UserCredentials; | ||
24 | +import org.thingsboard.server.dao.DaoUtil; | ||
25 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
26 | +import org.thingsboard.server.dao.model.sql.UserCredentialsEntity; | ||
27 | +import org.thingsboard.server.dao.sql.JpaAbstractDao; | ||
28 | +import org.thingsboard.server.dao.user.UserCredentialsDao; | ||
29 | + | ||
30 | +import java.util.UUID; | ||
31 | + | ||
32 | +/** | ||
33 | + * Created by Valerii Sosliuk on 4/22/2017. | ||
34 | + */ | ||
35 | +@Component | ||
36 | +@ConditionalOnProperty(prefix="sql", value="enabled",havingValue = "true", matchIfMissing = false) | ||
37 | +public class JpaUserCredentialsDao extends JpaAbstractDao<UserCredentialsEntity, UserCredentials> implements UserCredentialsDao { | ||
38 | + | ||
39 | + @Autowired | ||
40 | + private UserCredentialsRepository userCredentialsRepository; | ||
41 | + | ||
42 | + @Override | ||
43 | + protected Class<UserCredentialsEntity> getEntityClass() { | ||
44 | + return UserCredentialsEntity.class; | ||
45 | + } | ||
46 | + | ||
47 | + @Override | ||
48 | + protected String getColumnFamilyName() { | ||
49 | + return ModelConstants.USER_CREDENTIALS_COLUMN_FAMILY_NAME; | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + protected CrudRepository<UserCredentialsEntity, UUID> getCrudRepository() { | ||
54 | + return userCredentialsRepository; | ||
55 | + } | ||
56 | + | ||
57 | + @Override | ||
58 | + public UserCredentials findByUserId(UUID userId) { | ||
59 | + return DaoUtil.getData(userCredentialsRepository.findByUserId(userId)); | ||
60 | + } | ||
61 | + | ||
62 | + @Override | ||
63 | + public UserCredentials findByActivateToken(String activateToken) { | ||
64 | + return DaoUtil.getData(userCredentialsRepository.findByActivateToken(activateToken)); | ||
65 | + } | ||
66 | + | ||
67 | + @Override | ||
68 | + public UserCredentials findByResetToken(String resetToken) { | ||
69 | + return DaoUtil.getData(userCredentialsRepository.findByResetToken(resetToken)); | ||
70 | + } | ||
71 | +} |
@@ -17,6 +17,7 @@ package org.thingsboard.server.dao.sql.user; | @@ -17,6 +17,7 @@ package org.thingsboard.server.dao.sql.user; | ||
17 | 17 | ||
18 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
19 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | 19 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
20 | +import org.springframework.data.repository.CrudRepository; | ||
20 | import org.springframework.stereotype.Component; | 21 | import org.springframework.stereotype.Component; |
21 | import org.thingsboard.server.common.data.User; | 22 | import org.thingsboard.server.common.data.User; |
22 | import org.thingsboard.server.common.data.page.TextPageLink; | 23 | import org.thingsboard.server.common.data.page.TextPageLink; |
@@ -50,7 +51,7 @@ public class JpaUserDao extends JpaAbstractDao<UserEntity, User> implements User | @@ -50,7 +51,7 @@ public class JpaUserDao extends JpaAbstractDao<UserEntity, User> implements User | ||
50 | } | 51 | } |
51 | 52 | ||
52 | @Override | 53 | @Override |
53 | - protected JpaRepository<UserEntity, UUID> getCrudRepository() { | 54 | + protected CrudRepository<UserEntity, UUID> getCrudRepository() { |
54 | return userRepository; | 55 | return userRepository; |
55 | } | 56 | } |
56 | 57 | ||
@@ -61,11 +62,11 @@ public class JpaUserDao extends JpaAbstractDao<UserEntity, User> implements User | @@ -61,11 +62,11 @@ public class JpaUserDao extends JpaAbstractDao<UserEntity, User> implements User | ||
61 | 62 | ||
62 | @Override | 63 | @Override |
63 | public List<User> findTenantAdmins(UUID tenantId, TextPageLink pageLink) { | 64 | public List<User> findTenantAdmins(UUID tenantId, TextPageLink pageLink) { |
64 | - return null; | 65 | + throw new RuntimeException("Not Implemented"); |
65 | } | 66 | } |
66 | 67 | ||
67 | @Override | 68 | @Override |
68 | public List<User> findCustomerUsers(UUID tenantId, UUID customerId, TextPageLink pageLink) { | 69 | public List<User> findCustomerUsers(UUID tenantId, UUID customerId, TextPageLink pageLink) { |
69 | - return null; | 70 | + throw new RuntimeException("Not Implemented"); |
70 | } | 71 | } |
71 | } | 72 | } |
dao/src/main/java/org/thingsboard/server/dao/sql/user/UserCredentialsRepository.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/sql/user/JpaRepository.java
@@ -15,17 +15,21 @@ | @@ -15,17 +15,21 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.sql.user; | 16 | package org.thingsboard.server.dao.sql.user; |
17 | 17 | ||
18 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
18 | import org.springframework.data.repository.CrudRepository; | 19 | import org.springframework.data.repository.CrudRepository; |
19 | -import org.springframework.scheduling.annotation.Async; | ||
20 | -import org.springframework.util.concurrent.ListenableFuture; | 20 | +import org.thingsboard.server.dao.model.sql.UserCredentialsEntity; |
21 | 21 | ||
22 | -import java.io.Serializable; | 22 | +import java.util.UUID; |
23 | 23 | ||
24 | /** | 24 | /** |
25 | - * @author Valerii Sosliuk | 25 | + * Created by Valerii Sosliuk on 4/22/2017. |
26 | */ | 26 | */ |
27 | -public interface JpaRepository<E, ID extends Serializable> extends CrudRepository<E, ID> { | 27 | +@ConditionalOnProperty(prefix="sql", value="enabled",havingValue = "true", matchIfMissing = false) |
28 | +public interface UserCredentialsRepository extends CrudRepository<UserCredentialsEntity, UUID> { | ||
28 | 29 | ||
29 | - @Async | ||
30 | - ListenableFuture<E> findByIdAsync(ID key); | 30 | + UserCredentialsEntity findByUserId(UUID userId); |
31 | + | ||
32 | + UserCredentialsEntity findByActivateToken(String activateToken); | ||
33 | + | ||
34 | + UserCredentialsEntity findByResetToken(String resetToken); | ||
31 | } | 35 | } |
@@ -15,17 +15,17 @@ | @@ -15,17 +15,17 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.sql.user; | 16 | package org.thingsboard.server.dao.sql.user; |
17 | 17 | ||
18 | -import org.thingsboard.server.common.data.User; | ||
19 | -import org.thingsboard.server.common.data.page.TextPageLink; | 18 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
19 | +import org.springframework.data.repository.CrudRepository; | ||
20 | import org.thingsboard.server.dao.model.sql.UserEntity; | 20 | import org.thingsboard.server.dao.model.sql.UserEntity; |
21 | 21 | ||
22 | -import java.util.List; | ||
23 | import java.util.UUID; | 22 | import java.util.UUID; |
24 | 23 | ||
25 | /** | 24 | /** |
26 | * @author Valerii Sosliuk | 25 | * @author Valerii Sosliuk |
27 | */ | 26 | */ |
28 | -public interface UserRepository extends JpaRepository<UserEntity, UUID> { | 27 | +@ConditionalOnProperty(prefix="sql", value="enabled",havingValue = "true", matchIfMissing = false) |
28 | +public interface UserRepository extends CrudRepository<UserEntity, UUID> { | ||
29 | 29 | ||
30 | UserEntity findByEmail(String email); | 30 | UserEntity findByEmail(String email); |
31 | 31 |
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.dao.sql.widget; | ||
17 | + | ||
18 | +import org.springframework.beans.factory.annotation.Autowired; | ||
19 | +import org.springframework.data.domain.PageRequest; | ||
20 | +import org.springframework.data.domain.Pageable; | ||
21 | +import org.springframework.data.repository.CrudRepository; | ||
22 | +import org.springframework.stereotype.Component; | ||
23 | +import org.thingsboard.server.common.data.page.TextPageLink; | ||
24 | +import org.thingsboard.server.common.data.widget.WidgetsBundle; | ||
25 | +import org.thingsboard.server.dao.DaoUtil; | ||
26 | +import org.thingsboard.server.dao.model.sql.WidgetsBundleEntity; | ||
27 | +import org.thingsboard.server.dao.sql.JpaAbstractDao; | ||
28 | +import org.thingsboard.server.dao.widget.WidgetsBundleDao; | ||
29 | + | ||
30 | +import java.util.List; | ||
31 | +import java.util.UUID; | ||
32 | + | ||
33 | +import static org.thingsboard.server.dao.model.ModelConstants.WIDGETS_BUNDLE_COLUMN_FAMILY_NAME; | ||
34 | + | ||
35 | +/** | ||
36 | + * Created by Valerii Sosliuk on 4/23/2017. | ||
37 | + */ | ||
38 | +@Component | ||
39 | +public class JpaWidgetsBundleDao extends JpaAbstractDao<WidgetsBundleEntity, WidgetsBundle> implements WidgetsBundleDao { | ||
40 | + | ||
41 | + @Autowired | ||
42 | + private WidgetsBundleRepository widgetsBundleRepository; | ||
43 | + | ||
44 | + @Override | ||
45 | + protected Class<WidgetsBundleEntity> getEntityClass() { | ||
46 | + return WidgetsBundleEntity.class; | ||
47 | + } | ||
48 | + | ||
49 | + @Override | ||
50 | + protected String getColumnFamilyName() { | ||
51 | + return WIDGETS_BUNDLE_COLUMN_FAMILY_NAME; | ||
52 | + } | ||
53 | + | ||
54 | + @Override | ||
55 | + protected CrudRepository<WidgetsBundleEntity, UUID> getCrudRepository() { | ||
56 | + return widgetsBundleRepository; | ||
57 | + } | ||
58 | + | ||
59 | + @Override | ||
60 | + public WidgetsBundle findWidgetsBundleByTenantIdAndAlias(UUID tenantId, String alias) { | ||
61 | + return DaoUtil.getData(widgetsBundleRepository.findWidgetsBundleByTenantIdAndAlias(tenantId, alias)); | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public List<WidgetsBundle> findSystemWidgetsBundles(TextPageLink pageLink) { | ||
66 | + if (pageLink.getIdOffset() == null) { | ||
67 | + return DaoUtil.convertDataList(widgetsBundleRepository.findSystemWidgetsBundlesFirstPage(pageLink.getLimit() | ||
68 | + , pageLink.getTextSearch())); | ||
69 | + } else { | ||
70 | + return DaoUtil.convertDataList(widgetsBundleRepository.findSystemWidgetsBundlesNextPage(pageLink.getLimit() | ||
71 | + , pageLink.getTextSearch(), pageLink.getIdOffset())); | ||
72 | + } | ||
73 | + //return DaoUtil.convertDataList(widgetsBundleRepository.findBySearchTextStartsWithIgnoreCase(pageLink.getTextSearch().toLowerCase())); | ||
74 | + //return DaoUtil.convertDataList(widgetsBundleRepository.findBySearchTextStartsWithIgnoreCase(pageLink.getTextSearch().toLowerCase() ,pageable)); | ||
75 | + } | ||
76 | + | ||
77 | + @Override | ||
78 | + public List<WidgetsBundle> findTenantWidgetsBundlesByTenantId(UUID tenantId, TextPageLink pageLink) { | ||
79 | + throw new RuntimeException("Not implemented"); | ||
80 | + } | ||
81 | + | ||
82 | + @Override | ||
83 | + public List<WidgetsBundle> findAllTenantWidgetsBundlesByTenantId(UUID tenantId, TextPageLink pageLink) { | ||
84 | + throw new RuntimeException("Not implemented"); | ||
85 | + } | ||
86 | + | ||
87 | + @Override | ||
88 | + protected boolean isSearchTextDao() { | ||
89 | + return true; | ||
90 | + } | ||
91 | +} |
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.dao.sql.widget; | ||
17 | + | ||
18 | +import org.springframework.data.domain.Pageable; | ||
19 | +import org.springframework.data.jpa.repository.JpaRepository; | ||
20 | +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
21 | +import org.springframework.data.jpa.repository.Query; | ||
22 | +import org.springframework.data.repository.CrudRepository; | ||
23 | +import org.springframework.data.repository.query.Param; | ||
24 | +import org.thingsboard.server.common.data.page.TextPageLink; | ||
25 | +import org.thingsboard.server.dao.model.ToData; | ||
26 | +import org.thingsboard.server.dao.model.sql.WidgetsBundleEntity; | ||
27 | + | ||
28 | +import java.util.Collection; | ||
29 | +import java.util.List; | ||
30 | +import java.util.UUID; | ||
31 | + | ||
32 | +/** | ||
33 | + * Created by Valerii Sosliuk on 4/23/2017. | ||
34 | + */ | ||
35 | +//public interface WidgetsBundleRepository extends CrudRepository<WidgetsBundleEntity, UUID> { | ||
36 | +public interface WidgetsBundleRepository extends JpaRepository<WidgetsBundleEntity, UUID>, JpaSpecificationExecutor { | ||
37 | + | ||
38 | + WidgetsBundleEntity findWidgetsBundleByTenantIdAndAlias(UUID tenantId, String alias); | ||
39 | + | ||
40 | + @Query(nativeQuery = true, value = "SELECT * FROM WIDGETS_BUNDLE WHERE TENANT_ID IS NULL " + | ||
41 | + "AND LOWER(SEARCH_TEXT) LIKE LOWER(CONCAT(?2, '%')) " + | ||
42 | + "ORDER BY ID LIMIT ?1") | ||
43 | + List<WidgetsBundleEntity> findSystemWidgetsBundlesFirstPage(Integer limit, String searchText); | ||
44 | + | ||
45 | + @Query(nativeQuery = true, value = "SELECT * FROM WIDGETS_BUNDLE WHERE TENANT_ID IS NULL " + | ||
46 | + "AND LOWER(SEARCH_TEXT) LIKE LOWER(CONCAT(?2, '%')) " + | ||
47 | + "AND ID > ?3 ORDER BY ID LIMIT ?1") | ||
48 | + List<WidgetsBundleEntity> findSystemWidgetsBundlesNextPage(Integer limit, String searchText, UUID idOffset); | ||
49 | + | ||
50 | +} |
@@ -15,6 +15,9 @@ | @@ -15,6 +15,9 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.timeseries; | 16 | package org.thingsboard.server.dao.timeseries; |
17 | 17 | ||
18 | +import com.datastax.driver.core.ResultSet; | ||
19 | +import com.datastax.driver.core.ResultSetFuture; | ||
20 | +import com.datastax.driver.core.Row; | ||
18 | import com.google.common.collect.Lists; | 21 | import com.google.common.collect.Lists; |
19 | import com.google.common.util.concurrent.Futures; | 22 | import com.google.common.util.concurrent.Futures; |
20 | import com.google.common.util.concurrent.ListenableFuture; | 23 | import com.google.common.util.concurrent.ListenableFuture; |
@@ -15,6 +15,8 @@ | @@ -15,6 +15,8 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.timeseries; | 16 | package org.thingsboard.server.dao.timeseries; |
17 | 17 | ||
18 | +import com.datastax.driver.core.ResultSetFuture; | ||
19 | +import com.datastax.driver.core.Row; | ||
18 | import com.google.common.util.concurrent.ListenableFuture; | 20 | import com.google.common.util.concurrent.ListenableFuture; |
19 | import org.thingsboard.server.common.data.kv.TsKvEntry; | 21 | import org.thingsboard.server.common.data.kv.TsKvEntry; |
20 | import org.thingsboard.server.common.data.kv.TsKvQuery; | 22 | import org.thingsboard.server.common.data.kv.TsKvQuery; |
@@ -15,6 +15,9 @@ | @@ -15,6 +15,9 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.timeseries; | 16 | package org.thingsboard.server.dao.timeseries; |
17 | 17 | ||
18 | +import com.datastax.driver.core.ResultSet; | ||
19 | +import com.datastax.driver.core.ResultSetFuture; | ||
20 | +import com.datastax.driver.core.Row; | ||
18 | import com.google.common.util.concurrent.ListenableFuture; | 21 | import com.google.common.util.concurrent.ListenableFuture; |
19 | import org.thingsboard.server.common.data.id.UUIDBased; | 22 | import org.thingsboard.server.common.data.id.UUIDBased; |
20 | import org.thingsboard.server.common.data.kv.TsKvEntry; | 23 | import org.thingsboard.server.common.data.kv.TsKvEntry; |
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.dao; | ||
17 | + | ||
18 | +import com.github.springtestdbunit.DbUnitTestExecutionListener; | ||
19 | +import org.junit.runner.RunWith; | ||
20 | +import org.springframework.test.context.ContextConfiguration; | ||
21 | +import org.springframework.test.context.TestExecutionListeners; | ||
22 | +import org.springframework.test.context.TestPropertySource; | ||
23 | +import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests; | ||
24 | +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
25 | +import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; | ||
26 | +import org.springframework.test.context.support.DirtiesContextTestExecutionListener; | ||
27 | + | ||
28 | +/** | ||
29 | + * Created by Valerii Sosliuk on 4/22/2017. | ||
30 | + */ | ||
31 | +@RunWith(SpringJUnit4ClassRunner.class) | ||
32 | +@ContextConfiguration(classes = {JpaDaoConfig.class}) | ||
33 | +@TestPropertySource("classpath:jpa-test.properties") | ||
34 | +@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, | ||
35 | + DirtiesContextTestExecutionListener.class, | ||
36 | + DbUnitTestExecutionListener.class }) | ||
37 | +public class AbstractJpaDaoTest extends AbstractTransactionalJUnit4SpringContextTests { | ||
38 | + | ||
39 | +} |
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.attributes; | 16 | package org.thingsboard.server.dao.attributes; |
17 | 17 | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
18 | import org.thingsboard.server.common.data.DataConstants; | 19 | import org.thingsboard.server.common.data.DataConstants; |
19 | import org.thingsboard.server.common.data.id.DeviceId; | 20 | import org.thingsboard.server.common.data.id.DeviceId; |
20 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; | 21 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.event; | 16 | package org.thingsboard.server.dao.event; |
17 | 17 | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
18 | import org.junit.Assert; | 19 | import org.junit.Assert; |
19 | import org.junit.Test; | 20 | import org.junit.Test; |
20 | import org.thingsboard.server.common.data.DataConstants; | 21 | import org.thingsboard.server.common.data.DataConstants; |
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.plugin; | 16 | package org.thingsboard.server.dao.plugin; |
17 | 17 | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
18 | import lombok.extern.slf4j.Slf4j; | 19 | import lombok.extern.slf4j.Slf4j; |
19 | import org.junit.Assert; | 20 | import org.junit.Assert; |
20 | import org.junit.Test; | 21 | import org.junit.Test; |
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.rule; | 16 | package org.thingsboard.server.dao.rule; |
17 | 17 | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
18 | import org.junit.Assert; | 19 | import org.junit.Assert; |
19 | import org.junit.Test; | 20 | import org.junit.Test; |
20 | import org.thingsboard.server.common.data.id.TenantId; | 21 | import org.thingsboard.server.common.data.id.TenantId; |
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.service; | 16 | package org.thingsboard.server.dao.service; |
17 | 17 | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
18 | import com.fasterxml.jackson.databind.JsonNode; | 19 | import com.fasterxml.jackson.databind.JsonNode; |
19 | import com.fasterxml.jackson.databind.ObjectMapper; | 20 | import com.fasterxml.jackson.databind.ObjectMapper; |
20 | import com.fasterxml.jackson.databind.node.ObjectNode; | 21 | import com.fasterxml.jackson.databind.node.ObjectNode; |
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.service; | 16 | package org.thingsboard.server.dao.service; |
17 | 17 | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
18 | import org.apache.commons.lang3.RandomStringUtils; | 19 | import org.apache.commons.lang3.RandomStringUtils; |
19 | import org.junit.After; | 20 | import org.junit.After; |
20 | import org.junit.Assert; | 21 | import org.junit.Assert; |
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.service; | 16 | package org.thingsboard.server.dao.service; |
17 | 17 | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
18 | import org.apache.commons.lang3.RandomStringUtils; | 19 | import org.apache.commons.lang3.RandomStringUtils; |
19 | import org.junit.After; | 20 | import org.junit.After; |
20 | import org.junit.Assert; | 21 | import org.junit.Assert; |
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.service; | 16 | package org.thingsboard.server.dao.service; |
17 | 17 | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
18 | import com.hazelcast.core.HazelcastInstance; | 19 | import com.hazelcast.core.HazelcastInstance; |
19 | import org.apache.commons.lang3.RandomStringUtils; | 20 | import org.apache.commons.lang3.RandomStringUtils; |
20 | import org.junit.After; | 21 | import org.junit.After; |
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.service; | 16 | package org.thingsboard.server.dao.service; |
17 | 17 | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
18 | import org.apache.commons.lang3.RandomStringUtils; | 19 | import org.apache.commons.lang3.RandomStringUtils; |
19 | import org.junit.After; | 20 | import org.junit.After; |
20 | import org.junit.Assert; | 21 | import org.junit.Assert; |
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.service; | 16 | package org.thingsboard.server.dao.service; |
17 | 17 | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
18 | import org.apache.commons.lang3.RandomStringUtils; | 19 | import org.apache.commons.lang3.RandomStringUtils; |
19 | import org.junit.After; | 20 | import org.junit.After; |
20 | import org.junit.Assert; | 21 | import org.junit.Assert; |
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.service; | 16 | package org.thingsboard.server.dao.service; |
17 | 17 | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
18 | import com.fasterxml.jackson.databind.JsonNode; | 19 | import com.fasterxml.jackson.databind.JsonNode; |
19 | import com.fasterxml.jackson.databind.ObjectMapper; | 20 | import com.fasterxml.jackson.databind.ObjectMapper; |
20 | import org.junit.After; | 21 | import org.junit.After; |
@@ -15,6 +15,7 @@ | @@ -15,6 +15,7 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.service; | 16 | package org.thingsboard.server.dao.service; |
17 | 17 | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
18 | import org.junit.After; | 19 | import org.junit.After; |
19 | import org.junit.Assert; | 20 | import org.junit.Assert; |
20 | import org.junit.Before; | 21 | import org.junit.Before; |
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.dao.sql.user; | ||
17 | + | ||
18 | +import com.github.springtestdbunit.annotation.DatabaseSetup; | ||
19 | +import org.junit.Test; | ||
20 | +import org.springframework.beans.factory.annotation.Autowired; | ||
21 | +import org.thingsboard.server.common.data.security.UserCredentials; | ||
22 | +import org.thingsboard.server.dao.AbstractJpaDaoTest; | ||
23 | +import org.thingsboard.server.dao.user.UserCredentialsDao; | ||
24 | + | ||
25 | +import java.util.List; | ||
26 | +import java.util.UUID; | ||
27 | + | ||
28 | +import static org.junit.Assert.assertEquals; | ||
29 | +import static org.junit.Assert.assertNotNull; | ||
30 | + | ||
31 | +/** | ||
32 | + * Created by Valerii Sosliuk on 4/22/2017. | ||
33 | + */ | ||
34 | +public class JpaUserCredentialsDaoTest extends AbstractJpaDaoTest { | ||
35 | + | ||
36 | + @Autowired | ||
37 | + private UserCredentialsDao userCredentialsDao; | ||
38 | + | ||
39 | + @Test | ||
40 | + @DatabaseSetup("classpath:dbunit/user_credentials.xml") | ||
41 | + public void testFindAll() { | ||
42 | + List<UserCredentials> userCredentials = userCredentialsDao.find(); | ||
43 | + assertEquals(2, userCredentials.size()); | ||
44 | + } | ||
45 | + | ||
46 | + @Test | ||
47 | + @DatabaseSetup("classpath:dbunit/user_credentials.xml") | ||
48 | + public void testFindByUserId() { | ||
49 | + UserCredentials userCredentials = userCredentialsDao.findByUserId(UUID.fromString("787827e6-27d7-11e7-93ae-92361f002671")); | ||
50 | + assertNotNull(userCredentials); | ||
51 | + assertEquals("4b9e010c-27d5-11e7-93ae-92361f002671", userCredentials.getId().toString()); | ||
52 | + assertEquals(true, userCredentials.isEnabled()); | ||
53 | + assertEquals("password", userCredentials.getPassword()); | ||
54 | + assertEquals("ACTIVATE_TOKEN_2", userCredentials.getActivateToken()); | ||
55 | + assertEquals("RESET_TOKEN_2", userCredentials.getResetToken()); | ||
56 | + } | ||
57 | + | ||
58 | + @Test | ||
59 | + @DatabaseSetup("classpath:dbunit/user_credentials.xml") | ||
60 | + public void testFindByActivateToken() { | ||
61 | + UserCredentials userCredentials = userCredentialsDao.findByActivateToken("ACTIVATE_TOKEN_1"); | ||
62 | + assertNotNull(userCredentials); | ||
63 | + assertEquals("3ed10af0-27d5-11e7-93ae-92361f002671", userCredentials.getId().toString()); | ||
64 | + } | ||
65 | + | ||
66 | + @Test | ||
67 | + @DatabaseSetup("classpath:dbunit/user_credentials.xml") | ||
68 | + public void testFindByResetToken() { | ||
69 | + UserCredentials userCredentials = userCredentialsDao.findByResetToken("RESET_TOKEN_2"); | ||
70 | + assertNotNull(userCredentials); | ||
71 | + assertEquals("4b9e010c-27d5-11e7-93ae-92361f002671", userCredentials.getId().toString()); | ||
72 | + } | ||
73 | +} |
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.dao.sql.user; | ||
17 | + | ||
18 | +import com.fasterxml.jackson.databind.JsonNode; | ||
19 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
20 | +import com.github.springtestdbunit.annotation.DatabaseSetup; | ||
21 | +import org.junit.Test; | ||
22 | +import org.springframework.beans.factory.annotation.Autowired; | ||
23 | +import org.thingsboard.server.common.data.User; | ||
24 | +import org.thingsboard.server.common.data.id.CustomerId; | ||
25 | +import org.thingsboard.server.common.data.id.TenantId; | ||
26 | +import org.thingsboard.server.common.data.id.UserId; | ||
27 | +import org.thingsboard.server.common.data.security.Authority; | ||
28 | +import org.thingsboard.server.dao.AbstractJpaDaoTest; | ||
29 | +import org.thingsboard.server.dao.user.UserDao; | ||
30 | + | ||
31 | +import java.io.IOException; | ||
32 | +import java.util.List; | ||
33 | +import java.util.UUID; | ||
34 | + | ||
35 | +import static org.junit.Assert.*; | ||
36 | + | ||
37 | +/** | ||
38 | + * Created by Valerii Sosliuk on 4/18/2017. | ||
39 | + */ | ||
40 | +public class JpaUserDaoTest extends AbstractJpaDaoTest { | ||
41 | + | ||
42 | + @Autowired | ||
43 | + private UserDao userDao; | ||
44 | + | ||
45 | + @Test | ||
46 | + @DatabaseSetup("classpath:dbunit/users.xml") | ||
47 | + public void testFindAll() { | ||
48 | + List<User> users = userDao.find(); | ||
49 | + assertEquals(users.size(), 5); | ||
50 | + } | ||
51 | + | ||
52 | + @Test | ||
53 | + @DatabaseSetup("classpath:dbunit/users.xml") | ||
54 | + public void findByEmail() { | ||
55 | + User user = userDao.findByEmail("sysadm@thingsboard.org"); | ||
56 | + assertNotNull("User is expected to be not null", user); | ||
57 | + assertEquals("9cb58ba0-27c1-11e7-93ae-92361f002671", user.getId().toString()); | ||
58 | + assertEquals("c97ea14e-27c1-11e7-93ae-92361f002671", user.getTenantId().toString()); | ||
59 | + assertEquals("cdf9c79e-27c1-11e7-93ae-92361f002671", user.getCustomerId().toString()); | ||
60 | + assertEquals(Authority.SYS_ADMIN, user.getAuthority()); | ||
61 | + assertEquals("John", user.getFirstName()); | ||
62 | + assertEquals("Doe", user.getLastName()); | ||
63 | + assertEquals("{\"key\":\"value-0\"}", user.getAdditionalInfo().toString()); | ||
64 | + } | ||
65 | + | ||
66 | + @Test | ||
67 | + @DatabaseSetup("classpath:dbunit/users.xml") | ||
68 | + public void testSave() throws IOException { | ||
69 | + User user = new User(); | ||
70 | + user.setId(new UserId(UUID.fromString("cd481534-27cc-11e7-93ae-92361f002671"))); | ||
71 | + user.setTenantId(new TenantId(UUID.fromString("1edcb2c6-27cb-11e7-93ae-92361f002671"))); | ||
72 | + user.setCustomerId(new CustomerId(UUID.fromString("51477cb4-27cb-11e7-93ae-92361f002671"))); | ||
73 | + user.setEmail("user@thingsboard.org"); | ||
74 | + user.setFirstName("Jackson"); | ||
75 | + user.setLastName("Roberts"); | ||
76 | + ObjectMapper mapper = new ObjectMapper(); | ||
77 | + String additionalInfo = "{\"key\":\"value-100\"}"; | ||
78 | + JsonNode jsonNode = mapper.readTree(additionalInfo); | ||
79 | + user.setAdditionalInfo(jsonNode); | ||
80 | + userDao.save(user); | ||
81 | + assertEquals(6, userDao.find().size()); | ||
82 | + User savedUser = userDao.findByEmail("user@thingsboard.org"); | ||
83 | + assertNotNull(savedUser); | ||
84 | + } | ||
85 | +} |
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.dao.sql.widget; | ||
17 | + | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
19 | +import com.github.springtestdbunit.annotation.DatabaseSetup; | ||
20 | +import org.junit.Ignore; | ||
21 | +import org.junit.Test; | ||
22 | +import org.springframework.beans.factory.annotation.Autowired; | ||
23 | +import org.thingsboard.server.common.data.id.WidgetsBundleId; | ||
24 | +import org.thingsboard.server.common.data.page.TextPageLink; | ||
25 | +import org.thingsboard.server.common.data.widget.WidgetsBundle; | ||
26 | +import org.thingsboard.server.dao.AbstractJpaDaoTest; | ||
27 | +import org.thingsboard.server.dao.widget.WidgetsBundleDao; | ||
28 | + | ||
29 | +import java.util.List; | ||
30 | +import java.util.UUID; | ||
31 | + | ||
32 | +import static org.junit.Assert.*; | ||
33 | + | ||
34 | +/** | ||
35 | + * Created by Valerii Sosliuk on 4/23/2017. | ||
36 | + */ | ||
37 | +public class JpaWidgetsBundleDaoTest extends AbstractJpaDaoTest { | ||
38 | + | ||
39 | + @Autowired | ||
40 | + private WidgetsBundleDao widgetsBundleDao; | ||
41 | + | ||
42 | + @Test | ||
43 | + @DatabaseSetup("classpath:dbunit/widgets_bundle.xml") | ||
44 | + public void testFindAll() { | ||
45 | + assertEquals(7, widgetsBundleDao.find().size()); | ||
46 | + } | ||
47 | + | ||
48 | + @Test | ||
49 | + @DatabaseSetup("classpath:dbunit/widgets_bundle.xml") | ||
50 | + public void testFindWidgetsBundleByTenantIdAndAlias() { | ||
51 | + WidgetsBundle widgetsBundle = widgetsBundleDao.findWidgetsBundleByTenantIdAndAlias( | ||
52 | + UUID.fromString("250aca8e-2825-11e7-93ae-92361f002671"), "WB3"); | ||
53 | + assertEquals("44e6af4e-2825-11e7-93ae-92361f002671", widgetsBundle.getId().toString()); | ||
54 | + } | ||
55 | + | ||
56 | + @Test | ||
57 | + @DatabaseSetup("classpath:dbunit/empty_dataset.xml") | ||
58 | + public void testFindSystemWidgetsBundles() { | ||
59 | + for (int i = 0; i < 30; i++) { | ||
60 | + WidgetsBundle widgetsBundle = new WidgetsBundle(); | ||
61 | + widgetsBundle.setAlias("WB" + i); | ||
62 | + widgetsBundle.setTitle("WB" + i); | ||
63 | + widgetsBundle.setId(new WidgetsBundleId(UUIDs.timeBased())); | ||
64 | + widgetsBundleDao.save(widgetsBundle); | ||
65 | + } | ||
66 | + assertEquals(30, widgetsBundleDao.find().size()); | ||
67 | + // Get first page | ||
68 | + TextPageLink textPageLink1 = new TextPageLink(10, "WB"); | ||
69 | + List<WidgetsBundle> widgetsBundles1 = widgetsBundleDao.findSystemWidgetsBundles(textPageLink1); | ||
70 | + assertEquals(10, widgetsBundles1.size()); | ||
71 | + for (WidgetsBundle widgetsBundle : widgetsBundles1) { | ||
72 | + System.out.println(widgetsBundle.getSearchText()); | ||
73 | + } | ||
74 | + TextPageLink textPageLink2 = new TextPageLink(10, "WB", widgetsBundles1.get(9).getId().getId(), null); | ||
75 | + List<WidgetsBundle> widgetsBundles2 = widgetsBundleDao.findSystemWidgetsBundles(textPageLink2); | ||
76 | + assertEquals(10, widgetsBundles1.size()); | ||
77 | + for (WidgetsBundle widgetsBundle : widgetsBundles2) { | ||
78 | + System.out.println(widgetsBundle.getSearchText()); | ||
79 | + } | ||
80 | + | ||
81 | + } | ||
82 | +} |
@@ -15,6 +15,9 @@ | @@ -15,6 +15,9 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.timeseries; | 16 | package org.thingsboard.server.dao.timeseries; |
17 | 17 | ||
18 | +import com.datastax.driver.core.ResultSet; | ||
19 | +import com.datastax.driver.core.ResultSetFuture; | ||
20 | +import com.datastax.driver.core.utils.UUIDs; | ||
18 | import lombok.extern.slf4j.Slf4j; | 21 | import lombok.extern.slf4j.Slf4j; |
19 | import org.junit.Assert; | 22 | import org.junit.Assert; |
20 | import org.junit.Test; | 23 | import org.junit.Test; |
1 | +<dataset></dataset> |
1 | +<dataset> | ||
2 | + <user_credentials | ||
3 | + id="uuid'3ed10af0-27d5-11e7-93ae-92361f002671'" | ||
4 | + user_id="uuid'44ee8552-27d5-11e7-93ae-92361f002671'" | ||
5 | + enabled="true" | ||
6 | + password="password" | ||
7 | + activate_token="ACTIVATE_TOKEN_1" | ||
8 | + reset_token="RESET_TOKEN_1" | ||
9 | + /> | ||
10 | + <user_credentials | ||
11 | + id="uuid'4b9e010c-27d5-11e7-93ae-92361f002671'" | ||
12 | + user_id="uuid'787827e6-27d7-11e7-93ae-92361f002671'" | ||
13 | + enabled="true" | ||
14 | + password="password" | ||
15 | + activate_token="ACTIVATE_TOKEN_2" | ||
16 | + reset_token="RESET_TOKEN_2" | ||
17 | + /> | ||
18 | + <!-- | ||
19 | + <user_credentials | ||
20 | + id="" | ||
21 | + user_id="" | ||
22 | + enabled="true" | ||
23 | + password="password" | ||
24 | + activate_token="" | ||
25 | + reset_token="" | ||
26 | + /> | ||
27 | + --> | ||
28 | +</dataset> |
dao/src/test/resources/dbunit/users.xml
0 → 100644
1 | +<dataset> | ||
2 | + <user id="uuid'9cb58ba0-27c1-11e7-93ae-92361f002671'" | ||
3 | + tenant_id="uuid'c97ea14e-27c1-11e7-93ae-92361f002671'" | ||
4 | + customer_id="uuid'cdf9c79e-27c1-11e7-93ae-92361f002671'" | ||
5 | + authority="0" | ||
6 | + email="sysadm@thingsboard.org" | ||
7 | + search_text="SYSADM SEARCH TEXT" | ||
8 | + first_name="John" | ||
9 | + last_name="Doe" | ||
10 | + additional_info="{"key":"value-0"}" | ||
11 | + /> | ||
12 | + <user id="uuid'1312f328-27c7-11e7-93ae-92361f002671'" | ||
13 | + tenant_id="uuid'1e1cd4c8-27c7-11e7-93ae-92361f002671'" | ||
14 | + customer_id="uuid'22fe91e8-27c7-11e7-93ae-92361f002671'" | ||
15 | + authority="1" | ||
16 | + email="tenantadm1@thingsboard.org" | ||
17 | + search_text="TENANTADM1 SEARCH TEXT" | ||
18 | + first_name="Samuel" | ||
19 | + last_name="Serif" | ||
20 | + additional_info="{"key":"value-11"}" | ||
21 | + /> | ||
22 | + <user id="uuid'2b090dde-27ca-11e7-93ae-92361f002671'" | ||
23 | + tenant_id="uuid'1e1cd4c8-27c7-11e7-93ae-92361f002671'" | ||
24 | + customer_id="uuid'34be535c-27ca-11e7-93ae-92361f002671'" | ||
25 | + authority="1" | ||
26 | + email="tenantadm2@thingsboard.org" | ||
27 | + search_text="TENANTADM2 SEARCH TEXT" | ||
28 | + first_name="Penny" | ||
29 | + last_name="Morgan" | ||
30 | + additional_info="{"key":"value-12"}" | ||
31 | + /> | ||
32 | + <user id="uuid'cc8c1ca8-27c7-11e7-93ae-92361f002671'" | ||
33 | + tenant_id="uuid'd2e27caa-27c7-11e7-93ae-92361f002671'" | ||
34 | + customer_id="uuid'd89e128a-27c7-11e7-93ae-92361f002671'" | ||
35 | + authority="2" | ||
36 | + email="customeruser@thingsboard.org" | ||
37 | + search_text="CUSTOMER USER SEARCH TEXT" | ||
38 | + first_name="Norman" | ||
39 | + last_name="Gordon" | ||
40 | + additional_info="{"key":"value-2"}" | ||
41 | + /> | ||
42 | + <user id="uuid'edb2de58-27c7-11e7-93ae-92361f002671'" | ||
43 | + tenant_id="uuid'f229675e-27c7-11e7-93ae-92361f002671'" | ||
44 | + customer_id="uuid'f7a3d4e4-27c7-11e7-93ae-92361f002671'" | ||
45 | + authority="3" | ||
46 | + email="refreshtoken@thingsboard.org" | ||
47 | + search_text="REFRESH TOKEN SEARCH TEXT" | ||
48 | + first_name="Dianne" | ||
49 | + last_name="Wensleydale" | ||
50 | + additional_info="{"key":"value-3"}" | ||
51 | + /> | ||
52 | +</dataset> |
1 | +<dataset> | ||
2 | + <widgets_bundle | ||
3 | + id="uuid'250ac7b4-2825-11e7-93ae-92361f002671'" | ||
4 | + tenant_id="uuid'250aca8e-2825-11e7-93ae-92361f002671'" | ||
5 | + alias="WB1" | ||
6 | + title="Widgets Bundle 1" | ||
7 | + search_text="WB SEARCH TEXT 1" | ||
8 | + /> | ||
9 | + <widgets_bundle | ||
10 | + id="uuid'3269c18a-2825-11e7-93ae-92361f002671'" | ||
11 | + tenant_id="uuid'3269c18a-2825-11e7-93ae-92361f002671'" | ||
12 | + alias="WB2" | ||
13 | + title="Widgets Bundle 2" | ||
14 | + search_text="WB SEARCH TEXT 2" | ||
15 | + /> | ||
16 | + <widgets_bundle | ||
17 | + id="uuid'44e6af4e-2825-11e7-93ae-92361f002671'" | ||
18 | + tenant_id="uuid'250aca8e-2825-11e7-93ae-92361f002671'" | ||
19 | + alias="WB3" | ||
20 | + title="Widgets Bundle 3" | ||
21 | + search_text="WB SEARCH TEXT 3" | ||
22 | + /> | ||
23 | + <widgets_bundle | ||
24 | + id="uuid'696dc9b4-2830-11e7-93ae-92361f002671'" | ||
25 | + alias="WB4" | ||
26 | + title="Widgets Bundle 4" | ||
27 | + search_text="SYSTEM BUNDLE 1" | ||
28 | + /> | ||
29 | + <widgets_bundle | ||
30 | + id="uuid'1a83fc50-2840-11e7-93ae-92361f002671'" | ||
31 | + alias="WB5" | ||
32 | + title="Widgets Bundle 5" | ||
33 | + search_text="SYSTEM BUNDLE 2" | ||
34 | + /> | ||
35 | + <widgets_bundle | ||
36 | + id="uuid'6a593dde-2841-11e7-93ae-92361f002671'" | ||
37 | + alias="WB6" | ||
38 | + title="Widgets Bundle 6" | ||
39 | + search_text="SYSTEM BUNDLE 1" | ||
40 | + /> | ||
41 | + <widgets_bundle | ||
42 | + id="uuid'3beb4b1a-294d-11e7-93ae-92361f002671'" | ||
43 | + alias="WB6" | ||
44 | + title="Widgets Bundle 7" | ||
45 | + search_text="ABC DEF" | ||
46 | + /> | ||
47 | + <!-- | ||
48 | + <widgets_bundle | ||
49 | + id="" | ||
50 | + tenant_id="" | ||
51 | + alias="" | ||
52 | + title="" | ||
53 | + search_text="" | ||
54 | + /> | ||
55 | + --> | ||
56 | +</dataset> |
dao/src/test/resources/jpa-test.properties
0 → 100644
@@ -71,6 +71,9 @@ | @@ -71,6 +71,9 @@ | ||
71 | <springfox-swagger.version>2.6.1</springfox-swagger.version> | 71 | <springfox-swagger.version>2.6.1</springfox-swagger.version> |
72 | <bouncycastle.version>1.56</bouncycastle.version> | 72 | <bouncycastle.version>1.56</bouncycastle.version> |
73 | <winsw.version>2.0.1</winsw.version> | 73 | <winsw.version>2.0.1</winsw.version> |
74 | + <h2.version>1.4.194</h2.version> | ||
75 | + <dbunit.version>2.5.3</dbunit.version> | ||
76 | + <spring-test-dbunit.version>1.2.1</spring-test-dbunit.version> | ||
74 | </properties> | 77 | </properties> |
75 | 78 | ||
76 | <modules> | 79 | <modules> |
@@ -443,6 +446,11 @@ | @@ -443,6 +446,11 @@ | ||
443 | <scope>test</scope> | 446 | <scope>test</scope> |
444 | </dependency> | 447 | </dependency> |
445 | <dependency> | 448 | <dependency> |
449 | + <groupId>com.github.springtestdbunit</groupId> | ||
450 | + <artifactId>spring-test-dbunit</artifactId> | ||
451 | + <version>${spring-test-dbunit.version}</version> | ||
452 | + </dependency> | ||
453 | + <dependency> | ||
446 | <groupId>io.jsonwebtoken</groupId> | 454 | <groupId>io.jsonwebtoken</groupId> |
447 | <artifactId>jjwt</artifactId> | 455 | <artifactId>jjwt</artifactId> |
448 | <version>${jjwt.version}</version> | 456 | <version>${jjwt.version}</version> |
@@ -641,6 +649,12 @@ | @@ -641,6 +649,12 @@ | ||
641 | <scope>test</scope> | 649 | <scope>test</scope> |
642 | </dependency> | 650 | </dependency> |
643 | <dependency> | 651 | <dependency> |
652 | + <groupId>org.dbunit</groupId> | ||
653 | + <artifactId>dbunit</artifactId> | ||
654 | + <version>${dbunit.version}</version> | ||
655 | + <scope>test</scope> | ||
656 | + </dependency> | ||
657 | + <dependency> | ||
644 | <groupId>org.mockito</groupId> | 658 | <groupId>org.mockito</groupId> |
645 | <artifactId>mockito-all</artifactId> | 659 | <artifactId>mockito-all</artifactId> |
646 | <version>${mockito.version}</version> | 660 | <version>${mockito.version}</version> |
@@ -713,6 +727,11 @@ | @@ -713,6 +727,11 @@ | ||
713 | <version>${bouncycastle.version}</version> | 727 | <version>${bouncycastle.version}</version> |
714 | </dependency> | 728 | </dependency> |
715 | <dependency> | 729 | <dependency> |
730 | + <groupId>com.h2database</groupId> | ||
731 | + <artifactId>h2</artifactId> | ||
732 | + <version>${h2.version}</version> | ||
733 | + </dependency> | ||
734 | + <dependency> | ||
716 | <groupId>com.sun.winsw</groupId> | 735 | <groupId>com.sun.winsw</groupId> |
717 | <artifactId>winsw</artifactId> | 736 | <artifactId>winsw</artifactId> |
718 | <version>${winsw.version}</version> | 737 | <version>${winsw.version}</version> |