Skip to content

Commit

Permalink
Fix issue (#39)
Browse files Browse the repository at this point in the history
* Fix AUTH.Client issue
* Introduced new demo
  • Loading branch information
nqhoan-axonivy authored Aug 2, 2024
1 parent ba3af26 commit 370ea61
Show file tree
Hide file tree
Showing 25 changed files with 788 additions and 33 deletions.
10 changes: 9 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<groupId>com.axonivy.connector.uipath</groupId>
<name>ui-path-connector</name>
<artifactId>ui-path-connector-modules</artifactId>
<version>10.0.2-SNAPSHOT</version>
<version>10.0.1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
Expand Down Expand Up @@ -38,6 +38,14 @@
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.axonivy.ivy.ci</groupId>
<artifactId>project-build-plugin</artifactId>
<version>10.0.16</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_DATA_CLASS=com.axonivy.connector.uipath.ui.path.connector.demo.Data
ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_NAMESPACE=com.axonivy.connector.uipath.ui.path.connector.demo
ch.ivyteam.ivy.project.preferences\:PRIMEFACES_VERSION=11
ch.ivyteam.ivy.project.preferences\:PROJECT_VERSION=100000
eclipse.preferences.version=1
eclipse.preferences.version=1
4 changes: 2 additions & 2 deletions ui-path-connector-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.axonivy.connector.uipath</groupId>
<artifactId>ui-path-connector-demo</artifactId>
<version>10.0.2-SNAPSHOT</version>
<version>10.0.1.0-SNAPSHOT</version>
<packaging>iar</packaging>
<dependencies>
<dependency>
Expand All @@ -18,7 +18,7 @@
<plugin>
<groupId>com.axonivy.ivy.ci</groupId>
<artifactId>project-build-plugin</artifactId>
<version>10.0.6</version>
<version>10.0.16</version>
<extensions>true</extensions>
</plugin>
</plugins>
Expand Down
85 changes: 80 additions & 5 deletions ui-path-connector-demo/processes/uiPathDemo.p.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"id" : "f9",
"type" : "RequestStart",
"name" : [
" robot:",
"robot:",
"GetOrders.ivp"
],
"config" : {
Expand All @@ -25,7 +25,7 @@
},
"visual" : {
"at" : { "x" : 96, "y" : 64 },
"labelOffset" : { "x" : -22, "y" : 39 }
"labelOffset" : { "x" : 17, "y" : 41 }
},
"connect" : { "id" : "f2", "to" : "f0" }
}, {
Expand All @@ -44,7 +44,8 @@
}
},
"visual" : {
"at" : { "x" : 224, "y" : 64 }
"at" : { "x" : 224, "y" : 64 },
"icon" : "res:/webContent/icons/uipath.png"
},
"connect" : { "id" : "f3", "to" : "f1" }
}, {
Expand All @@ -61,7 +62,7 @@
}
},
"visual" : {
"at" : { "x" : 96, "y" : 256 },
"at" : { "x" : 512, "y" : 64 },
"labelOffset" : { "x" : 11, "y" : 35 }
}
}, {
Expand All @@ -77,9 +78,83 @@
"docs" : "https://docs.uipath.com/orchestrator/reference/consuming-cloud-api"
},
"visual" : {
"at" : { "x" : 328, "y" : 256 },
"at" : { "x" : 744, "y" : 64 },
"size" : { "width" : 336, "height" : 80 }
},
"connect" : { "id" : "f5", "to" : "f4" }
}, {
"id" : "f6",
"type" : "RequestStart",
"name" : "triggerAllActiveJobs.ivp",
"config" : {
"callSignature" : "triggerAllActiveJobs",
"outLink" : "triggerAllActiveJobs.ivp",
"startName" : "Trigger to start all active Jobs in Orcherstator"
},
"visual" : {
"at" : { "x" : 96, "y" : 192 }
},
"connect" : { "id" : "f11", "to" : "f10" }
}, {
"id" : "f7",
"type" : "TaskEnd",
"visual" : {
"at" : { "x" : 352, "y" : 192 }
}
}, {
"id" : "f10",
"type" : "SubProcessCall",
"name" : "Start all active Jobs",
"config" : {
"processCall" : "uiPathJob:startAllActiveJobs()"
},
"visual" : {
"at" : { "x" : 224, "y" : 192 },
"icon" : "res:/webContent/icons/uipath.png"
},
"connect" : { "id" : "f8", "to" : "f7" }
}, {
"id" : "f13",
"type" : "RequestStart",
"name" : "startJobByName.ivp",
"config" : {
"callSignature" : "startJobByName",
"outLink" : "startJobByName.ivp",
"startName" : "Trigger to start job by name in Orcherstator"
},
"visual" : {
"at" : { "x" : 96, "y" : 320 }
},
"connect" : { "id" : "f16", "to" : "f15" }
}, {
"id" : "f14",
"type" : "TaskEnd",
"visual" : {
"at" : { "x" : 352, "y" : 320 }
}
}, {
"id" : "f15",
"type" : "SubProcessCall",
"name" : [
"Start active Jobs",
"By Name"
],
"config" : {
"processCall" : "uiPathJob:startJobByName(String,String)",
"call" : {
"params" : [
{ "name" : "jobName", "type" : "String" },
{ "name" : "jobArguments", "type" : "String" }
],
"map" : {
"param.jobName" : "\"SendEmailFromGmail\""
}
}
},
"visual" : {
"at" : { "x" : 224, "y" : 320 },
"icon" : "res:/webContent/icons/uipath.png"
},
"connect" : { "id" : "f17", "to" : "f14" }
} ]
}
2 changes: 0 additions & 2 deletions ui-path-connector-product/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ processes. This connector:
- Enables you to steer robotic work from your workflow process.
- Makes the UiPath RPA API features easy and attractive to use in business
processes.
- Supports you with an easy-to-copy demo implementation to reduce your
integration effort.

## Demo

Expand Down
Binary file modified ui-path-connector-product/images/copyAuth_idKeyTenant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ui-path-connector-product/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.axonivy.connector.uipath</groupId>
<artifactId>ui-path-connector-product</artifactId>
<version>10.0.2-SNAPSHOT</version>
<version>10.0.1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_DATA_CLASS=com.axonivy.connector.uipath.test.Data
ch.ivyteam.ivy.designer.preferences.DataClassPreferencePage\:DEFAULT_NAMESPACE=com.axonivy.connector.uipath.test
ch.ivyteam.ivy.project.preferences\:PRIMEFACES_VERSION=11
ch.ivyteam.ivy.project.preferences\:PROJECT_VERSION=100000
eclipse.preferences.version=1
eclipse.preferences.version=1
6 changes: 3 additions & 3 deletions ui-path-connector-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.axonivy.connector.uipath</groupId>
<artifactId>ui-path-connector-test</artifactId>
<version>10.0.2-SNAPSHOT</version>
<version>10.0.1.0-SNAPSHOT</version>
<packaging>iar</packaging>
<dependencies>
<dependency>
Expand All @@ -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 All @@ -36,7 +36,7 @@
<plugin>
<groupId>com.axonivy.ivy.ci</groupId>
<artifactId>project-build-plugin</artifactId>
<version>10.0.6</version>
<version>10.0.16</version>
<extensions>true</extensions>
</plugin>
</plugins>
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
@@ -0,0 +1,81 @@
package com.axonivy.connector.uipath.test;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.List;

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;
import ch.ivyteam.ivy.bpm.engine.client.BpmClient;
import ch.ivyteam.ivy.bpm.engine.client.ExecutionResult;
import ch.ivyteam.ivy.bpm.engine.client.element.BpmElement;
import ch.ivyteam.ivy.bpm.exec.client.IvyProcessTest;
import ch.ivyteam.ivy.environment.AppFixture;
import ch.ivyteam.ivy.rest.client.RestClient;
import ch.ivyteam.ivy.rest.client.RestClients;
import ch.ivyteam.ivy.rest.client.mapper.JsonFeature;
import ch.ivyteam.ivy.rest.client.security.CsrfHeaderFeature;
import ch.ivyteam.ivy.security.ISession;

/**
* Service functionality is mocked out here: {@link UiPathMock}
*/
@IvyProcessTest(enableWebServer = true)
public class UiPathTest {

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");


@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(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);
}

@Test
public void rpaDemo(BpmClient bpmClient, ISession session) {
ExecutionResult result = bpmClient.start()
.process("uiPathDemo/robotGetOrders.ivp")
.as().session(session)
.execute();
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();
}
}
Loading

0 comments on commit 370ea61

Please sign in to comment.