diff --git a/ui-path-connector-test/src/com/axonivy/connector/uipath/test/UiPathMock.java b/ui-path-connector-test/src/com/axonivy/connector/uipath/test/UiPathMock.java index be3c910..5732561 100644 --- a/ui-path-connector-test/src/com/axonivy/connector/uipath/test/UiPathMock.java +++ b/ui-path-connector-test/src/com/axonivy/connector/uipath/test/UiPathMock.java @@ -60,6 +60,13 @@ public String getJobs() { 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) diff --git a/ui-path-connector-test/src/com/axonivy/connector/uipath/test/json/machines.json b/ui-path-connector-test/src/com/axonivy/connector/uipath/test/json/machines.json new file mode 100644 index 0000000..a8a7cec --- /dev/null +++ b/ui-path-connector-test/src/com/axonivy/connector/uipath/test/json/machines.json @@ -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 + } + ] +} diff --git a/ui-path-connector-test/src_test/com/axonivy/connector/uipath/test/TestUiPathRPA.java b/ui-path-connector-test/src_test/com/axonivy/connector/uipath/test/UiPathTest.java similarity index 66% rename from ui-path-connector-test/src_test/com/axonivy/connector/uipath/test/TestUiPathRPA.java rename to ui-path-connector-test/src_test/com/axonivy/connector/uipath/test/UiPathTest.java index e90a0ff..58340f8 100644 --- a/ui-path-connector-test/src_test/com/axonivy/connector/uipath/test/TestUiPathRPA.java +++ b/ui-path-connector-test/src_test/com/axonivy/connector/uipath/test/UiPathTest.java @@ -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; @@ -26,13 +27,15 @@ * Service functionality is mocked out here: {@link UiPathMock} */ @IvyProcessTest(enableWebServer = true) -public class TestUiPathRPA { +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) { + @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", ""); @@ -58,9 +61,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(); + } } diff --git a/ui-path-connector/processes/uiPathRpa.p.json b/ui-path-connector/processes/uiPathRpa.p.json index 33ca42a..30a4cc7 100644 --- a/ui-path-connector/processes/uiPathRpa.p.json +++ b/ui-path-connector/processes/uiPathRpa.p.json @@ -34,7 +34,7 @@ } }, "visual" : { - "at" : { "x" : 312, "y" : 64 }, + "at" : { "x" : 256, "y" : 64 }, "size" : { "width" : 128 }, "description" : [ "Simple request against RPA Orchestration Platform provided by UIPath", @@ -43,7 +43,7 @@ "icon" : "res:/webContent/icons/uipath.png" }, "connect" : [ - { "id" : "f6", "to" : "f5" } + { "id" : "f6", "to" : "f37" } ] }, { "id" : "f5", @@ -55,7 +55,10 @@ "config" : { "target" : { "clientId" : "c700c640-4f76-4cbe-8724-dbc663d8bc0a", - "path" : "/odata/Jobs" + "path" : "/odata/Jobs", + "headers" : { + "X-Uipath-Organizationunitid" : "in.organizationunitId" + } }, "response" : { "entity" : { @@ -68,12 +71,12 @@ } }, "visual" : { - "at" : { "x" : 472, "y" : 64 }, + "at" : { "x" : 464, "y" : 144 }, "size" : { "width" : 128 }, "icon" : "res:/webContent/icons/uipath.png" }, "connect" : [ - { "id" : "f1", "to" : "f37" } + { "id" : "f1", "to" : "f0" } ] }, { "id" : "f0", @@ -113,7 +116,7 @@ ] }, "visual" : { - "at" : { "x" : 472, "y" : 224 }, + "at" : { "x" : 464, "y" : 224 }, "size" : { "width" : 128 }, "icon" : "res:/webContent/icons/uipath.png" }, @@ -145,6 +148,9 @@ "path" : "/odata/Releases", "queryParams" : { "$filter" : "\"contains(ProcessKey, 'order')\"" + }, + "headers" : { + "X-Uipath-Organizationunitid" : "in.organizationunitId" } }, "response" : { @@ -158,7 +164,7 @@ } }, "visual" : { - "at" : { "x" : 472, "y" : 304 }, + "at" : { "x" : 464, "y" : 304 }, "size" : { "width" : 128 }, "icon" : "res:/webContent/icons/uipath.png" }, @@ -176,7 +182,10 @@ "method" : "POST", "target" : { "clientId" : "c700c640-4f76-4cbe-8724-dbc663d8bc0a", - "path" : "/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs" + "path" : "/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs", + "headers" : { + "X-Uipath-Organizationunitid" : "in.organizationunitId" + } }, "body" : { "entity" : { @@ -212,7 +221,7 @@ } }, "visual" : { - "at" : { "x" : 472, "y" : 384 }, + "at" : { "x" : 464, "y" : 384 }, "size" : { "width" : 128 }, "icon" : "res:/webContent/icons/uipath.png" }, @@ -282,12 +291,12 @@ } }, "visual" : { - "at" : { "x" : 472, "y" : 144 }, + "at" : { "x" : 464, "y" : 64 }, "size" : { "width" : 128 }, "icon" : "res:/webContent/icons/uipath.png" }, "connect" : [ - { "id" : "f2", "to" : "f0" } + { "id" : "f2", "to" : "f5" } ] } ] } \ No newline at end of file