/** * With the introduction of the fluent/builder API in 6.0.x, we could do this: * * RemoteRestRuntimeEngineFactory factory = * RemoteRestRuntimeEngineFactory.newBuilder() * .addUserName("user") * .addPassword("pass") * .addUrl(new URL("http://localhost:8080/business-central")) * .build(); * * RuntimeEngine runtimeEngine = factory.newRuntimeEngine(); * * With the 6.0.x code, we built a factory, that we then used to create the runtime.. * * Why not just build the runtime immediately? :) */ public void createRestRuntimeEngineWithBuilder() throws MalformedURLException { // unfortunately, this breaks backward compatibility, but the improvement and clarity in the API is worth the risk RuntimeEngine runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addUserName("user") .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central")) .build(); } }
public void minimumRestBuilderExample() throws Exception { RuntimeEngine runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addUserName("user") .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central")) .build(); runtimeEngine.getTaskService().claim(23l, "user"); // This will throw a MissingRequiredInfoException because the deployment id is required here runtimeEngine.getKieSession().startProcess("org.test.process"); }
@Test public void testSetHeader() throws Exception { RuntimeEngine runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addPassword("user").addUserName("pass") .addDeploymentId("deploymentId") runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addPassword("user").addUserName("pass") .addDeploymentId("deploymentId")
String authUser = "user"; RuntimeEngine runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addUserName(authUser) .addPassword("pass") runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addUserName(authUser) .addPassword("pass") runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addUserName(authUser) .addPassword("pass")
RuntimeEngine engine = RemoteRuntimeEngineFactory.newRestBuilder() .addUrl(instanceUrl) .addDeploymentId(deploymentId)
@Test public void setHeaderFields() throws Exception { RuntimeEngine runtimeEngine = RemoteRuntimeEngineFactory.newRestBuilder() .addUserName("user") .addPassword("pass") .addUrl(new URL("http://localhost:8080/business-central")) .addHeader("HEADER-NAME", "header-value") .clearHeaderFields() .addCorrelationProperties() .addDeploymentId("dep-id") .build(); try { runtimeEngine.getTaskService().claim(23l, "user"); fail( "This should have failed because there's no server running... "); } catch( org.kie.remote.client.api.exception.RemoteCommunicationException rce ) { // expected } } }
public void multipleDifferentRuntimeExamples(String deploymentId, URL deploymentUrl, boolean useFormBasedAuth) throws Exception { RemoteRestRuntimeEngineBuilder runtimeEngineBuilder = RemoteRuntimeEngineFactory.newRestBuilder() .addDeploymentId(deploymentId) .addUrl(deploymentUrl); RuntimeEngine krisRemoteEngine = runtimeEngineBuilder .addUserName(KRIS_USER) .addPassword(KRIS_PASSWORD) .build(); RuntimeEngine maryRemoteEngine = runtimeEngineBuilder .addUserName(MARY_USER) .addPassword(MARY_PASSWORD) .build(); RuntimeEngine johnRemoteEngine = runtimeEngineBuilder .addUserName(JOHN_USER) .addPassword(JOHN_PASSWORD) .build(); }
public void javaRemoteApiRestExample(String deploymentId, URL baseUrl, String user, String password) { RuntimeEngine engine = RemoteRuntimeEngineFactory.newRestBuilder() .addDeploymentId(deploymentId) .addUrl(baseUrl)