split from aps-public-rest-api
This commit is contained in:
commit
bb95fd6718
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# Maven
|
||||
target
|
||||
pom.xml.versionsBackup
|
||||
|
||||
# Eclipse
|
||||
.project
|
||||
.classpath
|
||||
.settings
|
||||
|
||||
# Visual Studio Code
|
||||
.vscode
|
206
pom.xml
Normal file
206
pom.xml
Normal file
@ -0,0 +1,206 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.inteligr8.alfresco</groupId>
|
||||
<artifactId>aps-public-rest-client</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
<name>Alfresco Process Services ReST API Client for Java</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.debuglevel>lines,vars,source</maven.compiler.debuglevel>
|
||||
|
||||
<!-- If you want to build for your specific version, point to your own
|
||||
installation -->
|
||||
<aps.baseUrl>http://localhost:8080</aps.baseUrl>
|
||||
<aps.app.tag>aps1</aps.app.tag>
|
||||
|
||||
<junit.version>5.7.2</junit.version>
|
||||
<spring.version>5.2.14.RELEASE</spring.version>
|
||||
<jersey.version>2.35</jersey.version>
|
||||
<cxf.version>3.4.7</cxf.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.inteligr8</groupId>
|
||||
<artifactId>common-rest-client</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
<classifier>${jaxrs.impl}</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.inteligr8.alfresco</groupId>
|
||||
<artifactId>aps-public-rest-api</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
<classifier>${aps.app.tag}</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.9</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-jaxrs-src</id>
|
||||
<goals><goal>add-source</goal></goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>src/main/${jaxrs.impl}</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>add-test-src</id>
|
||||
<goals><goal>add-test-source</goal></goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>src/test/${jaxrs.impl}</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<classifier>${jaxrs.impl}</classifier>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>javadoc</id>
|
||||
<phase>package</phase>
|
||||
<goals><goal>jar</goal></goals>
|
||||
<configuration>
|
||||
<show>public</show>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>jaxrs-jersey</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
<property>
|
||||
<name>jaxrs.impl</name>
|
||||
<value>jersey</value>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<jaxrs.impl>jersey</jaxrs.impl>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.inject</groupId>
|
||||
<artifactId>jersey-hk2</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-json-jackson</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>jaxrs-cxf</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>jaxrs.impl</name>
|
||||
<value>cxf</value>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<jaxrs.impl>cxf</jaxrs.impl>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-rs-client</artifactId>
|
||||
<version>${cxf.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>inteligr8-releases</id>
|
||||
<url>https://repos.inteligr8.com/nexus/repository/inteligr8-public</url>
|
||||
<releases><enabled>true</enabled></releases>
|
||||
<snapshots><enabled>false</enabled></snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>inteligr8-snapshots</id>
|
||||
<url>https://repos.inteligr8.com/nexus/repository/inteligr8-snapshots</url>
|
||||
<releases><enabled>false</enabled></releases>
|
||||
<snapshots><enabled>true</enabled></snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>inteligr8-releases</id>
|
||||
<url>https://repos.inteligr8.com/nexus/repository/inteligr8-public</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>inteligr8-snapshots</id>
|
||||
<url>https://repos.inteligr8.com/nexus/repository/inteligr8-snapshots</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</project>
|
@ -0,0 +1,32 @@
|
||||
package com.inteligr8.alfresco.activiti;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.inteligr8.rs.ClientCxfConfiguration;
|
||||
|
||||
/**
|
||||
* This class provides a POJO & Spring-based implementation of the
|
||||
* ClientCxfConfiguration interface. You can use it outside of the Spring
|
||||
* context, but you will need the spring-context and spring-beans libraries in
|
||||
* your non-Spring application.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
public class ApsClientCxfConfiguration extends ApsClientConfiguration implements ClientCxfConfiguration {
|
||||
|
||||
@Value("${process.service.cxf.defaultBusEnabled:true}")
|
||||
private boolean defaultBusEnabled;
|
||||
|
||||
public boolean isDefaultBusEnabled() {
|
||||
return this.defaultBusEnabled;
|
||||
}
|
||||
|
||||
public void setDefaultBusEnabled(boolean defaultBusEnabled) {
|
||||
this.defaultBusEnabled = defaultBusEnabled;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.inteligr8.alfresco.activiti;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.inteligr8.rs.ClientCxfImpl;
|
||||
|
||||
/**
|
||||
* This class provides a POJO & Spring-based implementation of the Apache
|
||||
* CXF client. You can use it outside of the Spring context, but you will need
|
||||
* the spring-context and spring-beans libraries in your non-Spring
|
||||
* application.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
@Component("aps.client.cxf")
|
||||
@Lazy
|
||||
public class ApsClientCxfImpl extends ClientCxfImpl {
|
||||
|
||||
/**
|
||||
* This constructor is for Spring or POJO use
|
||||
*/
|
||||
@Autowired
|
||||
public ApsClientCxfImpl(ApsClientCxfConfiguration config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.inteligr8.alfresco.activiti;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.inteligr8.alfresco.activiti.api.AppDefinitionsCxfApi;
|
||||
|
||||
/**
|
||||
* This class provides the Apache CXF client to the JAX-RS API for the APS
|
||||
* Public ReST API.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
@Component("aps.api.cxf")
|
||||
@Lazy
|
||||
public class ApsPublicRestApiCxfImpl extends ApsPublicRestApiImpl implements ApsPublicRestCxfApi {
|
||||
|
||||
/**
|
||||
* This constructor is for Spring or POJO use
|
||||
*/
|
||||
@Autowired
|
||||
public ApsPublicRestApiCxfImpl(ApsClientCxfImpl client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
public AppDefinitionsCxfApi getAppDefinitionsCxfApi() {
|
||||
return this.getApi(AppDefinitionsCxfApi.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,138 @@
|
||||
package com.inteligr8.alfresco.activiti;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import com.inteligr8.rs.ClientConfiguration;
|
||||
|
||||
/**
|
||||
* This class provides a POJO & Spring-based implementation of the
|
||||
* ClientConfiguration interface. You can use it outside of the Spring
|
||||
* context, but you will need the spring-context and spring-beans libraries in
|
||||
* your non-Spring application.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
public abstract class ApsClientConfiguration implements ClientConfiguration {
|
||||
|
||||
@Value("${process.service.baseUrl:http://localhost:8080/activiti-app}")
|
||||
private String baseUrl;
|
||||
|
||||
@Value("${process.service.security.basicAuth.username:admin@app.activiti.com}")
|
||||
private String basicAuthUsername;
|
||||
|
||||
@Value("${process.service.security.basicAuth.password:admin}")
|
||||
private String basicAuthPassword;
|
||||
|
||||
@Value("${process.service.security.bearerToken:#{null}}")
|
||||
private String bearerToken;
|
||||
|
||||
@Value("${process.service.security.oauth.tokenUrl:#{null}}")
|
||||
private String oAuthTokenUrl;
|
||||
|
||||
@Value("${process.service.security.oauth.clientId:#{null}}")
|
||||
private String oAuthClientId;
|
||||
|
||||
@Value("${process.service.security.oauth.clientSecret:#{null}}")
|
||||
private String oAuthClientSecret;
|
||||
|
||||
@Value("${process.service.security.oauth.authCode:#{null}}")
|
||||
private String oAuthAuthCode;
|
||||
|
||||
@Value("${process.service.security.oauth.authRedirectUri:#{null}}")
|
||||
private String oAuthAuthRedirectUri;
|
||||
|
||||
@Value("${process.service.security.oauth.grantUsername:#{null}}")
|
||||
private String oAuthUsername;
|
||||
|
||||
@Value("${process.service.security.oauth.grantPassword:#{null}}")
|
||||
private String oAuthPassword;
|
||||
|
||||
public String getBaseUrl() {
|
||||
return this.baseUrl;
|
||||
}
|
||||
|
||||
public void setBaseUrl(String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
public String getBasicAuthUsername() {
|
||||
return this.basicAuthUsername;
|
||||
}
|
||||
|
||||
public void setBasicAuthUsername(String basicAuthUsername) {
|
||||
this.basicAuthUsername = basicAuthUsername;
|
||||
}
|
||||
|
||||
public String getBasicAuthPassword() {
|
||||
return this.basicAuthPassword;
|
||||
}
|
||||
|
||||
public void setBasicAuthPassword(String basicAuthPassword) {
|
||||
this.basicAuthPassword = basicAuthPassword;
|
||||
}
|
||||
|
||||
public String getBearerToken() {
|
||||
return this.bearerToken;
|
||||
}
|
||||
|
||||
public void setBearerToken(String bearerToken) {
|
||||
this.bearerToken = bearerToken;
|
||||
}
|
||||
|
||||
public String getOAuthTokenUrl() {
|
||||
return this.oAuthTokenUrl;
|
||||
}
|
||||
|
||||
public void setOAuthTokenUrl(String oAuthTokenUrl) {
|
||||
this.oAuthTokenUrl = oAuthTokenUrl;
|
||||
}
|
||||
|
||||
public String getOAuthClientId() {
|
||||
return this.oAuthClientId;
|
||||
}
|
||||
|
||||
public void setOAuthClientId(String oAuthClientId) {
|
||||
this.oAuthClientId = oAuthClientId;
|
||||
}
|
||||
|
||||
public String getOAuthClientSecret() {
|
||||
return this.oAuthClientSecret;
|
||||
}
|
||||
|
||||
public void setOAuthClientSecret(String oAuthClientSecret) {
|
||||
this.oAuthClientSecret = oAuthClientSecret;
|
||||
}
|
||||
|
||||
public String getOAuthAuthCode() {
|
||||
return this.oAuthAuthCode;
|
||||
}
|
||||
|
||||
public void setOAuthAuthCode(String oAuthAuthCode) {
|
||||
this.oAuthAuthCode = oAuthAuthCode;
|
||||
}
|
||||
|
||||
public String getOAuthAuthRedirectUri() {
|
||||
return this.oAuthAuthRedirectUri;
|
||||
}
|
||||
|
||||
public void setOAuthAuthRedirectUri(String oAuthAuthRedirectUri) {
|
||||
this.oAuthAuthRedirectUri = oAuthAuthRedirectUri;
|
||||
}
|
||||
|
||||
public String getOAuthUsername() {
|
||||
return this.oAuthUsername;
|
||||
}
|
||||
|
||||
public void setOAuthUsername(String oAuthUsername) {
|
||||
this.oAuthUsername = oAuthUsername;
|
||||
}
|
||||
|
||||
public String getOAuthPassword() {
|
||||
return this.oAuthPassword;
|
||||
}
|
||||
|
||||
public void setOAuthPassword(String oAuthPassword) {
|
||||
this.oAuthPassword = oAuthPassword;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.inteligr8.alfresco.activiti;
|
||||
|
||||
import com.inteligr8.alfresco.activiti.api.AdminApi;
|
||||
import com.inteligr8.alfresco.activiti.api.AppDefinitionsApi;
|
||||
import com.inteligr8.alfresco.activiti.api.AppVersionApi;
|
||||
import com.inteligr8.alfresco.activiti.api.ModelsApi;
|
||||
import com.inteligr8.alfresco.activiti.api.ProcessInstancesApi;
|
||||
import com.inteligr8.alfresco.activiti.api.ProfileApi;
|
||||
import com.inteligr8.alfresco.activiti.api.TasksApi;
|
||||
import com.inteligr8.rs.Client;
|
||||
|
||||
/**
|
||||
* This class serves as the entrypoint to the JAX-RS API for the APS Public
|
||||
* ReST API.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
public class ApsPublicRestApiImpl implements ApsPublicRestApi {
|
||||
|
||||
private Client client;
|
||||
|
||||
public ApsPublicRestApiImpl(Client client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
public Client getClient() {
|
||||
return this.client;
|
||||
}
|
||||
|
||||
protected final <T> T getApi(Class<T> apiClass) {
|
||||
return this.client.getApi(apiClass);
|
||||
}
|
||||
|
||||
public AdminApi getAdminApi() {
|
||||
return this.getApi(AdminApi.class);
|
||||
}
|
||||
|
||||
public AppDefinitionsApi getAppDefinitionsApi() {
|
||||
return this.getApi(AppDefinitionsApi.class);
|
||||
}
|
||||
|
||||
public AppVersionApi getAppVersionApi() {
|
||||
return this.getApi(AppVersionApi.class);
|
||||
}
|
||||
|
||||
public ModelsApi getModelsApi() {
|
||||
return this.getApi(ModelsApi.class);
|
||||
}
|
||||
|
||||
public ProcessInstancesApi getProcessInstancesApi() {
|
||||
return this.getApi(ProcessInstancesApi.class);
|
||||
}
|
||||
|
||||
public ProfileApi getProfileApi() {
|
||||
return this.getApi(ProfileApi.class);
|
||||
}
|
||||
|
||||
public TasksApi getTasksApi() {
|
||||
return this.getApi(TasksApi.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.inteligr8.alfresco.activiti;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.inteligr8.rs.ClientJerseyConfiguration;
|
||||
|
||||
/**
|
||||
* This class provides a POJO & Spring-based implementation of the
|
||||
* ClientJerseyConfiguration interface. You can use it outside of the Spring
|
||||
* context, but you will need the spring-context and spring-beans libraries in
|
||||
* your non-Spring application.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
public class ApsClientJerseyConfiguration extends ApsClientConfiguration implements ClientJerseyConfiguration {
|
||||
|
||||
@Value("${process.service.jersey.putBodyRequired:true}")
|
||||
private boolean putBodyRequired;
|
||||
|
||||
public boolean isPutBodyRequired() {
|
||||
return this.putBodyRequired;
|
||||
}
|
||||
|
||||
public void setPutBodyRequired(boolean putBodyRequired) {
|
||||
this.putBodyRequired = putBodyRequired;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.inteligr8.alfresco.activiti;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.inteligr8.rs.ClientJerseyImpl;
|
||||
|
||||
/**
|
||||
* This class provides a POJO & Spring-based implementation of the Jersey
|
||||
* client configured for APS. You can use it outside of the Spring context,
|
||||
* but you will need the spring-context and spring-beans libraries in your
|
||||
* non-Spring application.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
@Component("aps.client.jersey")
|
||||
@Lazy
|
||||
public class ApsClientJerseyImpl extends ClientJerseyImpl {
|
||||
|
||||
/**
|
||||
* This constructor is for Spring and POJO use
|
||||
*/
|
||||
@Autowired
|
||||
public ApsClientJerseyImpl(ApsClientJerseyConfiguration config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.inteligr8.alfresco.activiti;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.inteligr8.alfresco.activiti.api.AppDefinitionsJerseyApi;
|
||||
|
||||
/**
|
||||
* This class provides the Jersey client to the JAX-RS API for the APS Public
|
||||
* ReST API.
|
||||
*
|
||||
* @author brian@inteligr8.com
|
||||
*/
|
||||
@Component("aps.api.jersey")
|
||||
@Lazy
|
||||
public class ApsPublicRestApiJerseyImpl extends ApsPublicRestApiImpl implements ApsPublicRestJerseyApi {
|
||||
|
||||
/**
|
||||
* This constructor is for Spring or POJO use
|
||||
*/
|
||||
@Autowired
|
||||
public ApsPublicRestApiJerseyImpl(ApsClientJerseyImpl client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
public AppDefinitionsJerseyApi getAppDefinitionsJerseyApi() {
|
||||
return this.getApi(AppDefinitionsJerseyApi.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.inteligr8.alfresco.activiti;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
||||
import com.inteligr8.rs.ClientConfiguration;
|
||||
|
||||
public class ConnectionCxfClientPojoIT extends ConnectionClientIT {
|
||||
|
||||
private static ApsPublicRestApiImpl api;
|
||||
|
||||
@BeforeAll
|
||||
public static void initClient() {
|
||||
ApsClientCxfConfiguration config = new ApsClientCxfConfiguration();
|
||||
config.setBaseUrl("http://localhost:8080/activiti-app");
|
||||
config.setBasicAuthUsername("admin");
|
||||
config.setBasicAuthPassword("admin");
|
||||
|
||||
api = new ApsPublicRestApiCxfImpl(
|
||||
new ApsClientCxfImpl(config));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApsPublicRestApiImpl getApi() {
|
||||
return api;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientConfiguration getConfiguration() {
|
||||
return api.getClient().getConfig();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.inteligr8.alfresco.activiti;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import com.inteligr8.rs.ClientConfiguration;
|
||||
|
||||
@TestPropertySource(locations = {"/local-oauth.properties"})
|
||||
@SpringJUnitConfig(classes = {ApsClientCxfConfiguration.class, ApsPublicRestApiCxfImpl.class, ApsClientCxfImpl.class})
|
||||
public class ConnectionCxfClientSpringIT extends ConnectionClientIT {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("aps.api.cxf")
|
||||
private ApsPublicRestApiImpl api;
|
||||
|
||||
@Override
|
||||
public ApsPublicRestApiImpl getApi() {
|
||||
return this.api;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientConfiguration getConfiguration() {
|
||||
return this.api.getClient().getConfig();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.inteligr8.alfresco.activiti;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.client.methods.RequestBuilder;
|
||||
import org.apache.http.impl.client.DefaultRedirectStrategy;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
|
||||
import com.inteligr8.rs.ClientConfiguration;
|
||||
|
||||
public abstract class ConditionalIT {
|
||||
|
||||
public abstract ClientConfiguration getConfiguration();
|
||||
|
||||
public boolean hostExists() {
|
||||
String uri = this.getConfiguration().getBaseUrl();
|
||||
|
||||
HttpUriRequest request = RequestBuilder.get()
|
||||
.setUri(uri)
|
||||
.build();
|
||||
|
||||
HttpClient client = HttpClientBuilder.create()
|
||||
.setRedirectStrategy(DefaultRedirectStrategy.INSTANCE)
|
||||
.build();
|
||||
|
||||
try {
|
||||
HttpResponse response = client.execute(request);
|
||||
return response.getStatusLine().getStatusCode() < 300;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.inteligr8.alfresco.activiti;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIf;
|
||||
|
||||
import com.inteligr8.alfresco.activiti.model.AppVersion;
|
||||
import com.inteligr8.alfresco.activiti.model.CreateProcessInstance;
|
||||
import com.inteligr8.alfresco.activiti.model.ProcessInstance;
|
||||
import com.inteligr8.alfresco.activiti.model.User;
|
||||
import com.inteligr8.alfresco.activiti.model.Variable;
|
||||
|
||||
public abstract class ConnectionClientIT extends ConditionalIT {
|
||||
|
||||
public abstract ApsPublicRestApiImpl getApi();
|
||||
|
||||
@Test
|
||||
@EnabledIf("hostExists")
|
||||
public void testAppVersion() {
|
||||
AppVersion obj = this.getApi().getAppVersionApi().get();
|
||||
|
||||
Assertions.assertNotNull(obj);
|
||||
Assertions.assertEquals("1", obj.getMajorVersion());
|
||||
Assertions.assertEquals("bpmSuite", obj.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledIf("hostExists")
|
||||
public void testProfile() {
|
||||
User obj = this.getApi().getProfileApi().get();
|
||||
|
||||
Assertions.assertNotNull(obj);
|
||||
Assertions.assertEquals("admin@app.activiti.com", obj.getEmail());
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledIf("hostExists")
|
||||
public void testStartProcess() {
|
||||
CreateProcessInstance request = new CreateProcessInstance();
|
||||
request.setProcessDefinitionKey("qcDocument");
|
||||
request.setVariables(Arrays.asList(new Variable("acsNodeId", null, null, UUID.randomUUID().toString())));
|
||||
|
||||
ProcessInstance response = this.getApi().getProcessInstancesApi().create(request);
|
||||
|
||||
Assertions.assertNotNull(response);
|
||||
Assertions.assertNotNull(response.getId());
|
||||
Assertions.assertNotNull(response.getId().length() > 0);
|
||||
Assertions.assertEquals("qcDocument", response.getProcessDefinitionKey());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.inteligr8.alfresco.activiti;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIf;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import com.inteligr8.alfresco.activiti.model.Tenant;
|
||||
import com.inteligr8.rs.ClientConfiguration;
|
||||
|
||||
@TestPropertySource(locations = {"/local.properties"})
|
||||
@SpringJUnitConfig(classes = {ApsClientJerseyConfiguration.class, ApsPublicRestApiJerseyImpl.class, ApsClientJerseyImpl.class})
|
||||
public class ArrayResponseUnitTest extends ConditionalIT {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("aps.api.jersey")
|
||||
private ApsPublicRestApiImpl api;
|
||||
|
||||
@Override
|
||||
public ClientConfiguration getConfiguration() {
|
||||
return this.api.getClient().getConfig();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledIf("hostExists")
|
||||
public void testTenants() {
|
||||
List<Tenant> objs = this.api.getAdminApi().getTenants();
|
||||
|
||||
Assertions.assertNotNull(objs);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.inteligr8.alfresco.activiti;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
|
||||
import com.inteligr8.rs.ClientConfiguration;
|
||||
|
||||
public class ConnectionJerseyClientPojoIT extends ConnectionClientIT {
|
||||
|
||||
private static ApsPublicRestApiImpl api;
|
||||
|
||||
@BeforeAll
|
||||
public static void initClient() {
|
||||
ApsClientJerseyConfiguration config = new ApsClientJerseyConfiguration();
|
||||
config.setBaseUrl("http://localhost:8080/activiti-app");
|
||||
config.setBasicAuthUsername("admin");
|
||||
config.setBasicAuthPassword("admin");
|
||||
|
||||
api = new ApsPublicRestApiJerseyImpl(
|
||||
new ApsClientJerseyImpl(config));
|
||||
}
|
||||
|
||||
public ApsPublicRestApiImpl getApi() {
|
||||
return api;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientConfiguration getConfiguration() {
|
||||
return api.getClient().getConfig();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.inteligr8.alfresco.activiti;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import com.inteligr8.rs.ClientConfiguration;
|
||||
|
||||
@TestPropertySource(locations = {"/local.properties"})
|
||||
@SpringJUnitConfig(classes = {ApsClientJerseyConfiguration.class, ApsPublicRestApiJerseyImpl.class, ApsClientJerseyImpl.class})
|
||||
public class ConnectionJerseyClientSpringIT extends ConnectionClientIT {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("aps.api.jersey")
|
||||
private ApsPublicRestApiImpl api;
|
||||
|
||||
public ApsPublicRestApiImpl getApi() {
|
||||
return this.api;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientConfiguration getConfiguration() {
|
||||
return this.api.getClient().getConfig();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.inteligr8.alfresco.activiti;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.EnabledIf;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import com.inteligr8.alfresco.activiti.model.GroupLight;
|
||||
import com.inteligr8.alfresco.activiti.model.ResultList;
|
||||
import com.inteligr8.alfresco.activiti.model.UserLight;
|
||||
import com.inteligr8.rs.ClientConfiguration;
|
||||
|
||||
@TestPropertySource(locations = {"/local.properties"})
|
||||
@SpringJUnitConfig(classes = {ApsClientJerseyConfiguration.class, ApsPublicRestApiJerseyImpl.class, ApsClientJerseyImpl.class})
|
||||
public class ResultListResponseUnitTest extends ConditionalIT {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("aps.api.jersey")
|
||||
private ApsPublicRestApiImpl api;
|
||||
|
||||
@Override
|
||||
public ClientConfiguration getConfiguration() {
|
||||
return this.api.getClient().getConfig();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledIf("hostExists")
|
||||
public void testGroupMembers() {
|
||||
List<GroupLight> groups = this.api.getAdminApi().getGroups(1L, false, false);
|
||||
Assertions.assertFalse(groups.isEmpty());
|
||||
|
||||
for (GroupLight group : groups) {
|
||||
ResultList<UserLight> users = this.api.getAdminApi().getMembers(group.getId(), null, null, null);
|
||||
Assertions.assertNotNull(users);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
5
src/test/resources/local-oauth.properties
Normal file
5
src/test/resources/local-oauth.properties
Normal file
@ -0,0 +1,5 @@
|
||||
process.service.baseUrl=http://localhost:8080/activiti-app
|
||||
process.service.security.oauth.tokenUrl=http://auth.example.org:8080/auth/realms/alfresco/protocol/openid-connect/token
|
||||
process.service.security.oauth.clientId=api
|
||||
process.service.security.oauth.grantUsername=admin
|
||||
process.service.security.oauth.grantPassword=admin
|
3
src/test/resources/local.properties
Normal file
3
src/test/resources/local.properties
Normal file
@ -0,0 +1,3 @@
|
||||
process.service.baseUrl=http://localhost:8080/activiti-app
|
||||
process.service.security.basicAuth.username=admin@app.activiti.com
|
||||
process.service.security.basicAuth.password=admin
|
Loading…
x
Reference in New Issue
Block a user