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