diff --git a/application/src/test/java/org/thingsboard/server/controller/CustomerControllerTest.java b/application/src/test/java/org/thingsboard/server/controller/CustomerControllerTest.java
index 896c549..b1076e0 100644
--- a/application/src/test/java/org/thingsboard/server/controller/CustomerControllerTest.java
+++ b/application/src/test/java/org/thingsboard/server/controller/CustomerControllerTest.java
@@ -288,7 +288,7 @@ public class CustomerControllerTest extends AbstractControllerTest {
for (int i=0;i<143;i++) {
Customer customer = new Customer();
customer.setTenantId(tenantId);
- String suffix = RandomStringUtils.randomAlphanumeric((int)(Math.random()*15));
+ String suffix = RandomStringUtils.randomAlphanumeric((int)(5 + Math.random()*10));
String title = title1+suffix;
title = i % 2 == 0 ? title.toLowerCase() : title.toUpperCase();
customer.setTitle(title);
@@ -299,7 +299,7 @@ public class CustomerControllerTest extends AbstractControllerTest {
for (int i=0;i<175;i++) {
Customer customer = new Customer();
customer.setTenantId(tenantId);
- String suffix = RandomStringUtils.randomAlphanumeric((int)(Math.random()*15));
+ String suffix = RandomStringUtils.randomAlphanumeric((int)(5 + Math.random()*10));
String title = title2+suffix;
title = i % 2 == 0 ? title.toLowerCase() : title.toUpperCase();
customer.setTitle(title);
diff --git a/application/src/test/java/org/thingsboard/server/controller/TenantControllerTest.java b/application/src/test/java/org/thingsboard/server/controller/TenantControllerTest.java
index ca4abfe..5d72076 100644
--- a/application/src/test/java/org/thingsboard/server/controller/TenantControllerTest.java
+++ b/application/src/test/java/org/thingsboard/server/controller/TenantControllerTest.java
@@ -149,7 +149,7 @@ public class TenantControllerTest extends AbstractControllerTest {
List<Tenant> tenantsTitle1 = new ArrayList<>();
for (int i=0;i<134;i++) {
Tenant tenant = new Tenant();
- String suffix = RandomStringUtils.randomAlphanumeric((int)(Math.random()*15));
+ String suffix = RandomStringUtils.randomAlphanumeric((int)(5 + Math.random()*10));
String title = title1+suffix;
title = i % 2 == 0 ? title.toLowerCase() : title.toUpperCase();
tenant.setTitle(title);
@@ -159,7 +159,7 @@ public class TenantControllerTest extends AbstractControllerTest {
List<Tenant> tenantsTitle2 = new ArrayList<>();
for (int i=0;i<127;i++) {
Tenant tenant = new Tenant();
- String suffix = RandomStringUtils.randomAlphanumeric((int)(Math.random()*15));
+ String suffix = RandomStringUtils.randomAlphanumeric((int)(5 + Math.random()*10));
String title = title2+suffix;
title = i % 2 == 0 ? title.toLowerCase() : title.toUpperCase();
tenant.setTitle(title);
diff --git a/dao/src/test/java/org/thingsboard/server/dao/service/CustomerServiceImplTest.java b/dao/src/test/java/org/thingsboard/server/dao/service/CustomerServiceImplTest.java
index fd0b20f..723be79 100644
--- a/dao/src/test/java/org/thingsboard/server/dao/service/CustomerServiceImplTest.java
+++ b/dao/src/test/java/org/thingsboard/server/dao/service/CustomerServiceImplTest.java
@@ -34,11 +34,11 @@ import org.junit.Test;
import com.datastax.driver.core.utils.UUIDs;
public class CustomerServiceImplTest extends AbstractServiceTest {
-
+
private IdComparator<Customer> idComparator = new IdComparator<>();
-
+
private TenantId tenantId;
-
+
@Before
public void before() {
Tenant tenant = new Tenant();
@@ -59,23 +59,23 @@ public class CustomerServiceImplTest extends AbstractServiceTest {
customer.setTenantId(tenantId);
customer.setTitle("My customer");
Customer savedCustomer = customerService.saveCustomer(customer);
-
+
Assert.assertNotNull(savedCustomer);
Assert.assertNotNull(savedCustomer.getId());
Assert.assertTrue(savedCustomer.getCreatedTime() > 0);
Assert.assertEquals(customer.getTenantId(), savedCustomer.getTenantId());
Assert.assertEquals(customer.getTitle(), savedCustomer.getTitle());
-
-
+
+
savedCustomer.setTitle("My new customer");
-
+
customerService.saveCustomer(savedCustomer);
Customer foundCustomer = customerService.findCustomerById(savedCustomer.getId());
Assert.assertEquals(foundCustomer.getTitle(), savedCustomer.getTitle());
-
+
customerService.deleteCustomer(savedCustomer.getId());
}
-
+
@Test
public void testFindCustomerById() {
Customer customer = new Customer();
@@ -87,21 +87,21 @@ public class CustomerServiceImplTest extends AbstractServiceTest {
Assert.assertEquals(savedCustomer, foundCustomer);
customerService.deleteCustomer(savedCustomer.getId());
}
-
+
@Test(expected = DataValidationException.class)
public void testSaveCustomerWithEmptyTitle() {
Customer customer = new Customer();
customer.setTenantId(tenantId);
customerService.saveCustomer(customer);
}
-
+
@Test(expected = DataValidationException.class)
public void testSaveCustomerWithEmptyTenant() {
Customer customer = new Customer();
customer.setTitle("My customer");
customerService.saveCustomer(customer);
}
-
+
@Test(expected = DataValidationException.class)
public void testSaveCustomerWithInvalidTenant() {
Customer customer = new Customer();
@@ -109,7 +109,7 @@ public class CustomerServiceImplTest extends AbstractServiceTest {
customer.setTenantId(new TenantId(UUIDs.timeBased()));
customerService.saveCustomer(customer);
}
-
+
@Test(expected = DataValidationException.class)
public void testSaveCustomerWithInvalidEmail() {
Customer customer = new Customer();
@@ -118,7 +118,7 @@ public class CustomerServiceImplTest extends AbstractServiceTest {
customer.setEmail("invalid@mail");
customerService.saveCustomer(customer);
}
-
+
@Test
public void testDeleteCustomer() {
Customer customer = new Customer();
@@ -129,23 +129,23 @@ public class CustomerServiceImplTest extends AbstractServiceTest {
Customer foundCustomer = customerService.findCustomerById(savedCustomer.getId());
Assert.assertNull(foundCustomer);
}
-
+
@Test
public void testFindCustomersByTenantId() {
Tenant tenant = new Tenant();
tenant.setTitle("Test tenant");
tenant = tenantService.saveTenant(tenant);
-
+
TenantId tenantId = tenant.getId();
-
+
List<Customer> customers = new ArrayList<>();
- for (int i=0;i<135;i++) {
+ for (int i = 0; i < 135; i++) {
Customer customer = new Customer();
customer.setTenantId(tenantId);
- customer.setTitle("Customer"+i);
+ customer.setTitle("Customer" + i);
customers.add(customerService.saveCustomer(customer));
}
-
+
List<Customer> loadedCustomers = new ArrayList<>();
TextPageLink pageLink = new TextPageLink(23);
TextPageData<Customer> pageData = null;
@@ -156,47 +156,47 @@ public class CustomerServiceImplTest extends AbstractServiceTest {
pageLink = pageData.getNextPageLink();
}
} while (pageData.hasNext());
-
+
Collections.sort(customers, idComparator);
Collections.sort(loadedCustomers, idComparator);
-
+
Assert.assertEquals(customers, loadedCustomers);
-
+
customerService.deleteCustomersByTenantId(tenantId);
pageLink = new TextPageLink(33);
pageData = customerService.findCustomersByTenantId(tenantId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertTrue(pageData.getData().isEmpty());
-
+
tenantService.deleteTenant(tenantId);
}
-
+
@Test
public void testFindCustomersByTenantIdAndTitle() {
String title1 = "Customer title 1";
List<Customer> customersTitle1 = new ArrayList<>();
- for (int i=0;i<143;i++) {
+ for (int i = 0; i < 143; i++) {
Customer customer = new Customer();
customer.setTenantId(tenantId);
- String suffix = RandomStringUtils.randomAlphanumeric((int)(Math.random()*15));
- String title = title1+suffix;
+ String suffix = RandomStringUtils.randomAlphanumeric((int)(5 + Math.random()*10));
+ String title = title1 + suffix;
title = i % 2 == 0 ? title.toLowerCase() : title.toUpperCase();
customer.setTitle(title);
customersTitle1.add(customerService.saveCustomer(customer));
}
String title2 = "Customer title 2";
List<Customer> customersTitle2 = new ArrayList<>();
- for (int i=0;i<175;i++) {
+ for (int i = 0; i < 175; i++) {
Customer customer = new Customer();
customer.setTenantId(tenantId);
- String suffix = RandomStringUtils.randomAlphanumeric((int)(Math.random()*15));
- String title = title2+suffix;
+ String suffix = RandomStringUtils.randomAlphanumeric((int)(5 + Math.random()*10));
+ String title = title2 + suffix;
title = i % 2 == 0 ? title.toLowerCase() : title.toUpperCase();
customer.setTitle(title);
customersTitle2.add(customerService.saveCustomer(customer));
}
-
+
List<Customer> loadedCustomersTitle1 = new ArrayList<>();
TextPageLink pageLink = new TextPageLink(15, title1);
TextPageData<Customer> pageData = null;
@@ -207,12 +207,12 @@ public class CustomerServiceImplTest extends AbstractServiceTest {
pageLink = pageData.getNextPageLink();
}
} while (pageData.hasNext());
-
+
Collections.sort(customersTitle1, idComparator);
Collections.sort(loadedCustomersTitle1, idComparator);
-
+
Assert.assertEquals(customersTitle1, loadedCustomersTitle1);
-
+
List<Customer> loadedCustomersTitle2 = new ArrayList<>();
pageLink = new TextPageLink(4, title2);
do {
@@ -225,22 +225,22 @@ public class CustomerServiceImplTest extends AbstractServiceTest {
Collections.sort(customersTitle2, idComparator);
Collections.sort(loadedCustomersTitle2, idComparator);
-
+
Assert.assertEquals(customersTitle2, loadedCustomersTitle2);
for (Customer customer : loadedCustomersTitle1) {
customerService.deleteCustomer(customer.getId());
}
-
+
pageLink = new TextPageLink(4, title1);
pageData = customerService.findCustomersByTenantId(tenantId, pageLink);
Assert.assertFalse(pageData.hasNext());
Assert.assertEquals(0, pageData.getData().size());
-
+
for (Customer customer : loadedCustomersTitle2) {
customerService.deleteCustomer(customer.getId());
}
-
+
pageLink = new TextPageLink(4, title2);
pageData = customerService.findCustomersByTenantId(tenantId, pageLink);
Assert.assertFalse(pageData.hasNext());