fixes for flaky tests
This commit is contained in:
parent
47cf1eac77
commit
c07eb9e920
@ -79,7 +79,7 @@ public abstract class BaseHomePageApiTest extends AbstractControllerTest {
|
||||
//For system administrator
|
||||
@Test
|
||||
public void testTenantsCountWsCmd() throws Exception {
|
||||
loginSysAdmin();
|
||||
Long initialCount = getInitialEntityCount(EntityType.TENANT);
|
||||
|
||||
List<Tenant> tenants = new ArrayList<>();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
@ -94,7 +94,7 @@ public abstract class BaseHomePageApiTest extends AbstractControllerTest {
|
||||
getWsClient().send(cmd);
|
||||
EntityCountUpdate update = getWsClient().parseCountReply(getWsClient().waitForReply());
|
||||
Assert.assertEquals(1, update.getCmdId());
|
||||
Assert.assertEquals(101, update.getCount());
|
||||
Assert.assertEquals(initialCount + 100, update.getCount());
|
||||
|
||||
for (Tenant tenant : tenants) {
|
||||
doDelete("/api/tenant/" + tenant.getId().toString());
|
||||
@ -103,7 +103,7 @@ public abstract class BaseHomePageApiTest extends AbstractControllerTest {
|
||||
|
||||
@Test
|
||||
public void testTenantProfilesCountWsCmd() throws Exception {
|
||||
loginSysAdmin();
|
||||
Long initialCount = getInitialEntityCount(EntityType.TENANT_PROFILE);
|
||||
|
||||
List<TenantProfile> tenantProfiles = new ArrayList<>();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
@ -118,7 +118,7 @@ public abstract class BaseHomePageApiTest extends AbstractControllerTest {
|
||||
getWsClient().send(cmd);
|
||||
EntityCountUpdate update = getWsClient().parseCountReply(getWsClient().waitForReply());
|
||||
Assert.assertEquals(1, update.getCmdId());
|
||||
Assert.assertEquals(101, update.getCount());
|
||||
Assert.assertEquals(initialCount + 100, update.getCount());
|
||||
|
||||
for (TenantProfile tenantProfile : tenantProfiles) {
|
||||
doDelete("/api/tenantProfile/" + tenantProfile.getId().toString());
|
||||
@ -127,7 +127,7 @@ public abstract class BaseHomePageApiTest extends AbstractControllerTest {
|
||||
|
||||
@Test
|
||||
public void testUsersCountWsCmd() throws Exception {
|
||||
loginSysAdmin();
|
||||
Long initialCount = getInitialEntityCount(EntityType.USER);
|
||||
|
||||
List<User> users = new ArrayList<>();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
@ -144,7 +144,7 @@ public abstract class BaseHomePageApiTest extends AbstractControllerTest {
|
||||
getWsClient().send(cmd);
|
||||
EntityCountUpdate update = getWsClient().parseCountReply(getWsClient().waitForReply());
|
||||
Assert.assertEquals(1, update.getCmdId());
|
||||
Assert.assertEquals(103, update.getCount());
|
||||
Assert.assertEquals(initialCount + 100, update.getCount());
|
||||
|
||||
for (User user : users) {
|
||||
doDelete("/api/user/" + user.getId().toString());
|
||||
@ -153,6 +153,7 @@ public abstract class BaseHomePageApiTest extends AbstractControllerTest {
|
||||
|
||||
@Test
|
||||
public void testCustomersCountWsCmd() throws Exception {
|
||||
Long initialCount = getInitialEntityCount(EntityType.CUSTOMER);
|
||||
loginTenantAdmin();
|
||||
|
||||
List<Customer> customers = new ArrayList<>();
|
||||
@ -169,7 +170,7 @@ public abstract class BaseHomePageApiTest extends AbstractControllerTest {
|
||||
getWsClient().send(cmd);
|
||||
EntityCountUpdate update = getWsClient().parseCountReply(getWsClient().waitForReply());
|
||||
Assert.assertEquals(1, update.getCmdId());
|
||||
Assert.assertEquals(101, update.getCount());
|
||||
Assert.assertEquals(initialCount + 100, update.getCount());
|
||||
|
||||
loginTenantAdmin();
|
||||
for (Customer customer : customers) {
|
||||
@ -179,13 +180,7 @@ public abstract class BaseHomePageApiTest extends AbstractControllerTest {
|
||||
|
||||
@Test
|
||||
public void testDevicesCountWsCmd() throws Exception {
|
||||
loginSysAdmin();
|
||||
|
||||
EntityTypeFilter allDeviceFilter = new EntityTypeFilter();
|
||||
allDeviceFilter.setEntityType(EntityType.DEVICE);
|
||||
EntityCountQuery query = new EntityCountQuery(allDeviceFilter);
|
||||
Long initialCount = doPostWithResponse("/api/entitiesQuery/count", query, Long.class);
|
||||
|
||||
Long initialCount = getInitialEntityCount(EntityType.DEVICE);
|
||||
loginTenantAdmin();
|
||||
|
||||
List<Device> devices = new ArrayList<>();
|
||||
@ -212,6 +207,7 @@ public abstract class BaseHomePageApiTest extends AbstractControllerTest {
|
||||
|
||||
@Test
|
||||
public void testAssetsCountWsCmd() throws Exception {
|
||||
Long initialCount = getInitialEntityCount(EntityType.ASSET);
|
||||
loginTenantAdmin();
|
||||
|
||||
List<Asset> assets = new ArrayList<>();
|
||||
@ -228,7 +224,7 @@ public abstract class BaseHomePageApiTest extends AbstractControllerTest {
|
||||
getWsClient().send(cmd);
|
||||
EntityCountUpdate update = getWsClient().parseCountReply(getWsClient().waitForReply());
|
||||
Assert.assertEquals(1, update.getCmdId());
|
||||
Assert.assertEquals(100, update.getCount());
|
||||
Assert.assertEquals(initialCount + 100, update.getCount());
|
||||
|
||||
loginTenantAdmin();
|
||||
for (Asset asset : assets) {
|
||||
@ -438,6 +434,15 @@ public abstract class BaseHomePageApiTest extends AbstractControllerTest {
|
||||
Assert.assertEquals(dashboards.size(), usageInfo.getDashboards());
|
||||
}
|
||||
|
||||
private Long getInitialEntityCount(EntityType entityType) throws Exception {
|
||||
loginSysAdmin();
|
||||
|
||||
EntityTypeFilter allEntityFilter = new EntityTypeFilter();
|
||||
allEntityFilter.setEntityType(entityType);
|
||||
EntityCountQuery query = new EntityCountQuery(allEntityFilter);
|
||||
return doPostWithResponse("/api/entitiesQuery/count", query, Long.class);
|
||||
}
|
||||
|
||||
private OAuth2Info createDefaultOAuth2Info() {
|
||||
return new OAuth2Info(true, Lists.newArrayList(
|
||||
OAuth2ParamsInfo.builder()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user