|
|
|
@ -15,21 +15,20 @@ |
|
|
|
*/ |
|
|
|
package org.thingsboard.server.msa.ui.tests.devicessmoke; |
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
|
import io.qameta.allure.Description; |
|
|
|
import io.qameta.allure.Epic; |
|
|
|
import org.testng.annotations.AfterClass; |
|
|
|
import org.testng.annotations.BeforeClass; |
|
|
|
import org.testng.annotations.Test; |
|
|
|
import org.thingsboard.common.util.JacksonUtil; |
|
|
|
import org.thingsboard.server.common.data.Device; |
|
|
|
import org.thingsboard.server.common.data.DeviceProfile; |
|
|
|
import org.thingsboard.server.common.data.security.DeviceCredentials; |
|
|
|
import org.thingsboard.server.msa.ui.utils.DataProviderCredential; |
|
|
|
import org.thingsboard.server.msa.ui.utils.EntityPrototypes; |
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; |
|
|
|
import static org.thingsboard.server.msa.ui.utils.Const.DEVICE_ACTIVE_STATE; |
|
|
|
import static org.thingsboard.server.msa.ui.utils.Const.DEVICE_INACTIVE_STATE; |
|
|
|
import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; |
|
|
|
|
|
|
|
@Epic("Filter devices (By device profile and state)") |
|
|
|
@ -40,7 +39,7 @@ public class DeviceFilterTest extends AbstractDeviceTest { |
|
|
|
private String activeDeviceWithProfileName; |
|
|
|
|
|
|
|
@BeforeClass |
|
|
|
public void createTestEntities() throws JsonProcessingException { |
|
|
|
public void createTestEntities() { |
|
|
|
DeviceProfile deviceProfile = testRestClient.postDeviceProfile(EntityPrototypes.defaultDeviceProfile(ENTITY_NAME + random())); |
|
|
|
Device deviceWithProfile = testRestClient.postDevice("", EntityPrototypes.defaultDevicePrototype(ENTITY_NAME + random(), deviceProfile.getId())); |
|
|
|
Device activeDevice = testRestClient.postDevice("", EntityPrototypes.defaultDevicePrototype(ENTITY_NAME + random())); |
|
|
|
@ -48,8 +47,8 @@ public class DeviceFilterTest extends AbstractDeviceTest { |
|
|
|
|
|
|
|
DeviceCredentials deviceCredentials = testRestClient.getDeviceCredentialsByDeviceId(activeDevice.getId()); |
|
|
|
DeviceCredentials deviceCredentials1 = testRestClient.getDeviceCredentialsByDeviceId(activeDeviceWithProfile.getId()); |
|
|
|
testRestClient.postTelemetry(deviceCredentials.getCredentialsId(), mapper.readTree(createPayload().toString())); |
|
|
|
testRestClient.postTelemetry(deviceCredentials1.getCredentialsId(), mapper.readTree(createPayload().toString())); |
|
|
|
testRestClient.postTelemetry(deviceCredentials.getCredentialsId(), JacksonUtil.toJsonNode(createPayload().toString())); |
|
|
|
testRestClient.postTelemetry(deviceCredentials1.getCredentialsId(), JacksonUtil.toJsonNode(createPayload().toString())); |
|
|
|
|
|
|
|
deviceProfileTitle = deviceProfile.getName(); |
|
|
|
deviceWithProfileName = deviceWithProfile.getName(); |
|
|
|
@ -71,61 +70,34 @@ public class DeviceFilterTest extends AbstractDeviceTest { |
|
|
|
devicePage.filterDeviceByDeviceProfile(deviceProfileTitle); |
|
|
|
|
|
|
|
devicePage.listOfDevicesProfile().forEach(d -> assertThat(d.getText()) |
|
|
|
.as("There are only devices with the selected profile on the page") |
|
|
|
.as("There are only devices with the selected profile(%s) on the page", deviceProfileTitle) |
|
|
|
.isEqualTo(deviceProfileTitle)); |
|
|
|
} |
|
|
|
|
|
|
|
@Test(groups = "smoke") |
|
|
|
@Description("Filter by state (Active)") |
|
|
|
public void filterDevicesByActiveState() { |
|
|
|
sideBarMenuView.goToDevicesPage(); |
|
|
|
devicePage.filterBtn().click(); |
|
|
|
devicePage.filterDeviceByState(DEVICE_ACTIVE_STATE); |
|
|
|
|
|
|
|
devicePage.listOfDevicesState().forEach(d -> assertThat(d.getText()) |
|
|
|
.as("There are only devices with active state on the page") |
|
|
|
.isEqualTo(DEVICE_ACTIVE_STATE)); |
|
|
|
} |
|
|
|
|
|
|
|
@Test(groups = "smoke") |
|
|
|
@Description("Filter by state (Inactive)") |
|
|
|
public void filterDevicesByInactiveState() { |
|
|
|
sideBarMenuView.goToDevicesPage(); |
|
|
|
devicePage.filterBtn().click(); |
|
|
|
devicePage.filterDeviceByState(DEVICE_INACTIVE_STATE); |
|
|
|
|
|
|
|
devicePage.listOfDevicesState().forEach(d -> assertThat(d.getText()) |
|
|
|
.as("There are only devices with inactive state on the page") |
|
|
|
.isEqualTo(DEVICE_INACTIVE_STATE)); |
|
|
|
} |
|
|
|
|
|
|
|
@Test(groups = "smoke") |
|
|
|
@Description("Filter device by device profile and active state") |
|
|
|
public void filterDevicesByDeviceProfileAndActiveState() { |
|
|
|
@Test(groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "filterData") |
|
|
|
@Description("Filter by state") |
|
|
|
public void filterDevicesByState(String state) { |
|
|
|
sideBarMenuView.goToDevicesPage(); |
|
|
|
devicePage.filterBtn().click(); |
|
|
|
devicePage.filterDeviceByDeviceProfileAndState(deviceProfileTitle, DEVICE_ACTIVE_STATE); |
|
|
|
devicePage.filterDeviceByState(state); |
|
|
|
|
|
|
|
devicePage.listOfDevicesProfile().forEach(d -> assertThat(d.getText()) |
|
|
|
.as("There are only devices with the selected profile on the page") |
|
|
|
.isEqualTo(deviceProfileTitle)); |
|
|
|
devicePage.listOfDevicesState().forEach(d -> assertThat(d.getText()) |
|
|
|
.as("There are only devices with active state on the page") |
|
|
|
.isEqualTo(DEVICE_ACTIVE_STATE)); |
|
|
|
.as("There are only devices with '%s' state on the page", state) |
|
|
|
.isEqualTo(state)); |
|
|
|
} |
|
|
|
|
|
|
|
@Test(groups = "smoke") |
|
|
|
@Description("Filter device by device profile and inactive state") |
|
|
|
public void filterDevicesByDeviceProfileAndInactiveState() { |
|
|
|
@Test(groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "filterData") |
|
|
|
@Description("Filter device by device profile and state") |
|
|
|
public void filterDevicesByDeviceProfileAndState(String state) { |
|
|
|
sideBarMenuView.goToDevicesPage(); |
|
|
|
devicePage.filterBtn().click(); |
|
|
|
devicePage.filterDeviceByDeviceProfileAndState(deviceProfileTitle, DEVICE_INACTIVE_STATE); |
|
|
|
devicePage.filterDeviceByDeviceProfileAndState(deviceProfileTitle, state); |
|
|
|
|
|
|
|
devicePage.listOfDevicesProfile().forEach(d -> assertThat(d.getText()) |
|
|
|
.as("There are only devices with the selected profile on the page") |
|
|
|
.as("There are only devices with the selected profile(%s) on the page", deviceProfileTitle) |
|
|
|
.isEqualTo(deviceProfileTitle)); |
|
|
|
devicePage.listOfDevicesState().forEach(d -> assertThat(d.getText()) |
|
|
|
.as("There are only devices with inactive state on the page") |
|
|
|
.isEqualTo(DEVICE_INACTIVE_STATE)); |
|
|
|
.as("There are only devices with '%s' state on the page", state) |
|
|
|
.isEqualTo(state)); |
|
|
|
} |
|
|
|
} |
|
|
|
|