Skip to content

Commit

Permalink
Fix Test
Browse files Browse the repository at this point in the history
Upgrade to latest test version
Introduce new tests
  • Loading branch information
nqhoan-axonivy committed Jul 31, 2024
1 parent 96079a0 commit 6c3f599
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ui-path-connector-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<dependency>
<groupId>com.axonivy.ivy.test</groupId>
<artifactId>unit-tester</artifactId>
<version>10.0.0</version>
<version>10.0.16</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@Hidden
public class UiPathMock {

static final String PATH_SUFFIX = "rpaMock";
static final String PATH_SUFFIX = "rpaMock/orchestrator_/";
// URI where this mock can be reached: to be referenced in tests that use it!
public static final String URI = "{ivy.app.baseurl}/api/" + PATH_SUFFIX;

Expand All @@ -54,6 +54,20 @@ public String getJobs() {
return json;
}

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("odata/Folders")
public String getFolders() {
return load("json/folders.json");
}

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("odata/Machines")
public String getMachines() {
return load("json/machines.json");
}

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("odata/Robots")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"@odata.context": "https://platform.uipath.com/odata/$metadata#Folders",
"@odata.count": 1,
"value": [
{
"Key": "1a374a79-9bdd-4055-a0cc-95488ae006a0",
"DisplayName": "MyTest",
"FullyQualifiedName": "MyTest",
"FullyQualifiedNameOrderable": "MyTest",
"Description": null,
"FolderType": "Standard",
"ProvisionType": "Automatic",
"PermissionModel": "FineGrained",
"ParentId": null,
"ParentKey": null,
"IsActive": true,
"FeedType": "Processes",
"ReservedOptions": null,
"Id": 89973
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"@odata.context": "https://cloud.uipath.com/orchestrator_/odata/$metadata#Machines/UiPath.Server.Configuration.OData.ExtendedMachineDto",
"@odata.count": 4,
"value": [
{
"@odata.type": "#UiPath.Server.Configuration.OData.ExtendedMachineDto",
"ServerlessLicensingModel": null,
"LicenseKey": null,
"Name": "My workspace machine",
"Description": null,
"Type": "Template",
"Scope": "PersonalWorkspace",
"NonProductionSlots": 0,
"UnattendedSlots": 0,
"HeadlessSlots": 0,
"TestAutomationSlots": 0,
"AutomationCloudSlots": 0,
"AutomationCloudTestAutomationSlots": 0,
"Key": "480f27b8-09c8-4476-b01b-db2d1bd0f5d5",
"EndpointDetectionStatus": "NotAvailable",
"AutomationType": "Any",
"TargetFramework": "Any",
"ClientSecret": null,
"Id": 55490,
"RobotVersions": [
{
"Count": 2,
"Version": "24.10.1"
}
],
"RobotUsers": [],
"UpdatePolicy": null,
"Tags": [],
"MaintenanceWindow": null,
"VpnSettings": null
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

import java.util.List;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import com.axonivy.connector.uipath.TenantHeaderFeature;
import com.axonivy.connector.uipath.ui.path.connector.UiPathJobData;
import com.axonivy.connector.uipath.ui.path.connector.UiPathRpa;

import ch.ivyteam.ivy.application.IApplication;
Expand All @@ -25,25 +26,32 @@
/**
* Service functionality is mocked out here: {@link UiPathMock}
*/
@IvyProcessTest
public class TestUiPathRPA {
@IvyProcessTest(enableWebServer = true)
public class UiPathTest {

private static final BpmElement UI_PATH_END = BpmElement.pid("175F58F3612E10B1-f15");
private static final String UI_PATH_REST_CLIENT = "UIPathRPA (UiPath.WebApi 18.0)";
private static final BpmElement UI_PATH_JOB_ALL_ACTIVE_JOBS_END = BpmElement.pid("190E93ECBBC86C6F-f1");
private static final BpmElement UI_PATH_JOB_START_JOB_END = BpmElement.pid("190E93ECBBC86C6F-f50");
private static final BpmElement UI_PATH_RPA_END = BpmElement.pid("175F58F3612E10B1-f15");

@BeforeEach
void beforeEach(AppFixture fixture, IApplication app) {
fixture.config("RestClients.UIPathRPA.Url", UiPathMock.URI);
fixture.config("RestClients.UIPathRPA.Features", "");

@BeforeAll
static void beforeAll(AppFixture fixture, IApplication app) {
fixture.config("RestClients." + UI_PATH_REST_CLIENT + ".Url", UiPathMock.URI);
fixture.config("RestClients." + UI_PATH_REST_CLIENT + ".Features", "");

RestClients clients = RestClients.of(app);
RestClient uiPathRpa = clients.find("UIPathRPA");
RestClient uiPathRpa = clients.find(UI_PATH_REST_CLIENT);
var testClient = uiPathRpa.toBuilder()
.features(List.of( // exclude oauth-feature
JsonFeature.class.getName(),
TenantHeaderFeature.class.getName(),
CsrfHeaderFeature.class.getName()))
.property("AUTH.clientId", "notMyId")
.property("AUTH.userKey", "notMyKey")
.property("AUTH.tenant", "notMyTenant")
.property("PATH.tenant", "tenant")
.property("PATH.organization", "organization")
.toRestClient();
clients.set(testClient);
}
Expand All @@ -54,9 +62,20 @@ public void rpaDemo(BpmClient bpmClient, ISession session) {
.process("uiPathDemo/robotGetOrders.ivp")
.as().session(session)
.execute();
UiPathRpa data = result.data().lastOnElement(UI_PATH_END);
UiPathRpa data = result.data().lastOnElement(UI_PATH_RPA_END);
assertThat(data.getLicense()).isNotNull();
assertThat(data.getReleases()).isNotEmpty();
assertThat(data.getRobots()).isNotEmpty();
}

@Test
public void jobDemo(BpmClient bpmClient, ISession session) {
ExecutionResult result = bpmClient.start().process("uiPathDemo/triggerAllActiveJobs.ivp").as().session(session)
.execute();
UiPathJobData data = result.data().lastOnElement(UI_PATH_JOB_ALL_ACTIVE_JOBS_END);
assertThat(data.getOrganizationunitId()).isNotNull();
data = result.data().lastOnElement(UI_PATH_JOB_START_JOB_END);
assertThat(data.getMachines()).isNotEmpty();
assertThat(data.getStartInfo()).isNotNull();
}
}

0 comments on commit 6c3f599

Please sign in to comment.