mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Initial commit
This commit is contained in:
60
packaging/tests/tas-restapi/.gitignore
vendored
60
packaging/tests/tas-restapi/.gitignore
vendored
@@ -1,23 +1,37 @@
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
*.class
|
||||
|
||||
# Eclipse
|
||||
.classpath
|
||||
.settings
|
||||
.project
|
||||
|
||||
# Intellij
|
||||
.idea/
|
||||
*.iml
|
||||
*.iws
|
||||
|
||||
# Mac
|
||||
.DS_Store
|
||||
|
||||
# Maven
|
||||
target
|
||||
*.log
|
||||
*.log.*
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
|
||||
.mtj
|
||||
.tmp/
|
||||
|
||||
# Package Files #
|
||||
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
|
||||
hs_err_pid*
|
||||
alf_data
|
||||
/src/main/resources/alfresco-global.properties
|
||||
/src/main/resources/alfresco/extension/custom-log4j.properties
|
||||
|
13
packaging/tests/tas-restapi/CODE_OF_CONDUCT.md
Normal file
13
packaging/tests/tas-restapi/CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Contributor Code of Conduct
|
||||
|
||||
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
||||
|
||||
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
||||
|
||||
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
@@ -1,2 +1,564 @@
|
||||
# alfresco-tas-restapi
|
||||
Common classes for REST APIs TAS tests for ACS projects
|
||||

|
||||
|
||||
Back to [TAS Master Documentation](https://git.alfresco.com/tas/alfresco-tas-utility/wikis/home)
|
||||
|
||||
---
|
||||
## Table of Contents
|
||||
* [Synopsis](#synopsis)
|
||||
* [Prerequisite](#prerequisite)
|
||||
* [Installation](#installation-if-you-want-to-contribute)
|
||||
* [Package Presentation](#package-presentation)
|
||||
* [Sample Usage](#sample-usage)
|
||||
* [How to write a test](#how-to-write-a-test)
|
||||
* [How to generate models or check coverage](#how-to-generate-models-or-check-coverage)
|
||||
* [How to run tests?](#how-to-run-tests)
|
||||
* [from IDE](#from-ide)
|
||||
* [from command line](#from-command-line)
|
||||
* [Listeners](#listeners)
|
||||
* [Test Results](#test-results)
|
||||
* [Test Rail Integration](#test-rail-integration)
|
||||
* [Configuration](#configuration)
|
||||
* [How to enable Test Rail Integration?](#how-to-enable-test-rail-integration)
|
||||
* [Reference](#reference)
|
||||
* [Change Log](docs/CHANGELOG.md) :glowing_star:
|
||||
* [Contributors](#contributors)
|
||||
* [Releasing](#releasing)
|
||||
* [License](#license)
|
||||
|
||||
## Synopsis
|
||||
|
||||
**TAS**( **T**est **A**utomation **S**ystem)- **RESTAPI** is the project that handles the automated tests related only to [Alfresco REST API](http://docs.alfresco.com/5.1/pra/1/topics/pra-welcome.html).
|
||||
|
||||
It is based on Apache Maven, compatible with major IDEs and is using also Spring capabilities for dependency injection.
|
||||
|
||||
As a high level overview, this project makes use of the following functionality useful in automation testing as:
|
||||
* reading/defining test environment settings (e.g. alfresco server details, authentication, etc.)
|
||||
* managing resource (i.e. creating files and folders)
|
||||
* test data generators (for site, users, content, etc)
|
||||
* helpers (i.e. randomizers, test environment information)
|
||||
* test logging generated on runtime and test reporting capabilities
|
||||
* test management tool integration (at this point we support integration with [Test Rail](https://alfresco.testrail.net) (v5.2.1)
|
||||
* health checks (verify if server is reachable, if server is online)
|
||||
* generic Internal-DSL (Domain Specific Language)
|
||||
|
||||
Using Nexus -Release Repository, everyone will be able to use individual interfaces in their projects by extending the automation core functionalities.
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Prerequisite
|
||||
(tested on unix/non-unix destribution)
|
||||
* [Java SE 1.8](http://www.oracle.com/technetwork/java/javase/downloads/index.html).
|
||||
* [Maven 3.3](https://maven.apache.org/download.cgi) installed and configure according to [Windows OS](https://maven.apache.org/guides/getting-started/windows-prerequisites.html) or [Mac OS](https://maven.apache.org/install.html).
|
||||
* Configure Maven to use Alfresco alfresco-internal repository following this [Guide](https://ts.alfresco.com/share/page/site/eng/wiki-page?title=Maven_Setup).
|
||||
* Your favorite IDE as [Eclipse](https://eclipse.org/downloads/) or [InteliJ](https://www.jetbrains.com/idea).
|
||||
* Access to [Nexus](https://nexus.alfresco.com/nexus/) repository.
|
||||
* Access to Gitlab [TAS](https://gitlab.alfresco.com/tas/) repository.
|
||||
* GitLab client for your operating system. (we recommend [SourceTree](https://www.sourcetreeapp.com) - use your google account for initial setup).
|
||||
* Getting familiar with [Basic Git Commands](http://docs.gitlab.com/ee/gitlab-basics/basic-git-commands.html).
|
||||
* Getting familiar with [Maven](https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html).
|
||||
* Getting familiar with [Spring](http://docs.spring.io).
|
||||
* Getting familiar with [TestNG](http://testng.org/doc/index.html)
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Installation (if you want to contribute)
|
||||
|
||||
* Open your Gitlab client and clone the repository of this project.
|
||||
* You can do this also from command line (or in your terminal) adding:
|
||||
|
||||
```bash
|
||||
$ git clone https://git.alfresco.com/tas/alfresco-tas-restapi-test.git
|
||||
# this clone will have the latest changes from repository. If you want to checkout a specific version released, take a look at the [Change Log](docs/CHANGELOG.md) page
|
||||
$ cd alfresco-tas-tester
|
||||
# this command will checkout the remove v2.0.0 tagged repository and create locally a new branch v2.0.0
|
||||
$ git checkout tags/v2.0.0 -b v2.0.0
|
||||
|
||||
```
|
||||
|
||||
* Install and check if all dependencies are downloaded
|
||||
|
||||
```bash
|
||||
> cd alfresco-tas-restapi-test
|
||||
> mvn clean install -DskipTests
|
||||
# you should see one [INFO] BUILD SUCCESS message displayed
|
||||
```
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Package Presentation
|
||||
|
||||
The project uses a maven layout [archetype](https://maven.apache.org/plugins-archives/maven-archetype-plugin-1.0-alpha-7/examples/simple.html):
|
||||
```ruby
|
||||
├── pom.xml
|
||||
├── report.html
|
||||
├── src
|
||||
│ ├── main
|
||||
│ │ └── java
|
||||
│ │ └── org
|
||||
│ │ └── alfresco
|
||||
│ │ └── rest
|
||||
│ │ ├── core
|
||||
│ │ │ ├── assertion
|
||||
│ │ │ │ ├── IModelAssertion.java
|
||||
│ │ │ │ ├── IModelsCollectionAssertion.java
|
||||
│ │ │ │ ├── (...)
|
||||
│ │ │ │ └── PaginationAssertionVerbs.java
|
||||
│ │ │ ├── swagger
|
||||
│ │ │ │ ├── Generator.java
|
||||
│ │ │ │ ├── RestModelProperty.java
|
||||
│ │ │ │ ├── (...)
|
||||
│ │ │ │ └── SwaggerYamlParser.java
|
||||
│ │ │ ├── IRestModel.java
|
||||
│ │ │ ├── IRestModelsCollection.java
|
||||
│ │ │ ├── (...)
|
||||
│ │ │ ├── RestResponse.java
|
||||
│ │ │ └── RestWrapper.java
|
||||
│ │ ├── exception
|
||||
│ │ │ ├── EmptyJsonResponseException.java
|
||||
│ │ │ ├── EmptyRestModelCollectionException.java
|
||||
│ │ │ └── JsonToModelConversionException.java
|
||||
│ │ ├── model
|
||||
│ │ │ ├── builder
|
||||
│ │ │ │ └── NodesBuilder.java
|
||||
│ │ │ ├── RestActivityModel.java
|
||||
│ │ │ ├── RestActivityModelsCollection.java
|
||||
│ │ │ ├── (...)
|
||||
│ │ │ └── RestVariableModelsCollection.java
|
||||
│ │ ├── requests
|
||||
│ │ │ ├── authAPI
|
||||
│ │ │ │ └── RestAuthAPI.java
|
||||
│ │ │ ├── coreAPI
|
||||
│ │ │ │ └── RestCoreAPI.java
|
||||
│ │ │ ├── workflowAPI
|
||||
│ │ │ │ └── RestWorkflowAPI.java
|
||||
│ │ │ ├── Deployments.java
|
||||
│ │ │ ├── (...)
|
||||
│ │ │ └── Tenant.java
|
||||
│ │
|
||||
│ ├── test
|
||||
│ │ ├── java
|
||||
│ │ │ └── org
|
||||
│ │ │ └── alfresco
|
||||
│ │ │ └── rest
|
||||
│ │ │ ├── auth
|
||||
│ │ │ │ └── AuthTests.java
|
||||
│ │ │ ├── comments
|
||||
│ │ │ │ ├── AddCommentCoreTests.java
|
||||
│ │ │ │ ├── (...)
|
||||
│ │ │ ├── (...)
|
||||
│ │ │ ├── workflow
|
||||
│ │ │ │ ├── deployments
|
||||
│ │ │ │ │ ├── DeleteDeploymentCoreFullTests.java
|
||||
│ │ │ │ │ ├── (...)
|
||||
│ │ │ │ ├── processDefinitions
|
||||
│ │ │ │ │ ├── GetProcessDefinitionCoreTests.java
|
||||
│ │ │ │ │ ├── (...)
|
||||
│ │ │ │ ├── (...)
|
||||
│ │ │ ├── FunctionalCasesTests.java
|
||||
│ │ │ └── RestTest.java
|
||||
│ │ └── resources
|
||||
│ │ ├── alfresco-restapi-context.xml
|
||||
│ │ ├── default.properties
|
||||
│ │ └── log4j.properties
|
||||
```
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Sample Usage
|
||||
|
||||
Following the standard layout for Maven projects, the application sources locate in src/main/java and test sources locate in src/test/java.
|
||||
Application sources consist in defining the REST API object that simulates the calls: get, post, put, delete.
|
||||
The tests are based on an abstract object: Rest.java that handles the common behavior: checking the health status of the test server, configuration settings, getting the general properties, etc.
|
||||
|
||||
Please take a look at [RestDemoTests.java](src/test/java/org/alfresco/rest/demo/RestDemoTests.java) class for an example.
|
||||
|
||||
Common configuration settings required for this project are stored in properties file, see [default.properties](src/test/resources/default.properties).
|
||||
Please analyze and update it accordingly with Alfresco test server IP, port, credentials, etc.
|
||||
|
||||
Example:
|
||||
```java
|
||||
# Alfresco HTTP Server Settings
|
||||
alfresco.scheme=http
|
||||
alfresco.server=<add-here-the-ip-of-your-test-server>
|
||||
alfresco.port=<default-port-for-alfresco-not-share>
|
||||
```
|
||||
|
||||
* optional update the logging level in [log4j](src/test/resources/log4j.properties) file (you can increase/decrease the deails of the [logging file](https://logging.apache.org/log4j/1.2/manual.html), setting the ```log4j.rootLogger=DEBUG``` if you want.)
|
||||
* go to [running](#how-to-run-tests) section for more information on how to run this tests.
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
### How to write a test
|
||||
|
||||
* Please also take a look at the [Rest-API desing and implementation](https://ts.alfresco.com/share/page/site/eng/document-details?nodeRef=workspace://SpacesStore/9f7823e7-0597-4435-9fd1-6ec8a4791259) guidelines.
|
||||
* Tests are organized in java classes and located on src/test/java as per maven layout.
|
||||
* One test class should contain the tests that cover one functionality as we want to have a clear separation of test scope: tests for sanity/core/full, tests that verify manage of folder/files etc.
|
||||
* These are the conventions that need to follow when you write a test:
|
||||
* The test class has @Test annotation with the group defined: rest-api. You can add more groups like sanity, regression
|
||||
|
||||
```java
|
||||
@Test(groups={ TestGroup.COMMENTS}
|
||||
```
|
||||
|
||||
* The test has @TestRail annotation in order to assure that the details and results will be submitted on TestRail. The fields for TestRail annotation will be explained on next chapter.
|
||||
|
||||
|
||||
```java
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.PEOPLE}, executionType= ExecutionType.SANITY,
|
||||
description = "Verify admin user gets person with Rest API and response is not empty")
|
||||
public void adminShouldRetrievePerson() throws Exception
|
||||
{
|
||||
peopleAPI.getPerson(userModel.getUsername())
|
||||
.assertResponseIsNotEmpty();
|
||||
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK.toString());
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
* Use Spring capabilities to initialize the objects(Models, Wrappers) with @Autowired
|
||||
|
||||
* To view a simple class that is using this utility, just browse on [RestDemoTests.java]((src/test/java/org/alfresco/rest/demo/RestDemoTests.java)
|
||||
Notice the class definition and inheritance value:
|
||||
|
||||
```java
|
||||
public class RestDemoTest extends RestTest
|
||||
```
|
||||
|
||||
* as a convention, before running your test, check if the test environment is reachable and your alfresco test server is online.
|
||||
(this will stop the test if the server defined in your property file is not healthy - method available in parent class)
|
||||
|
||||
```java
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setupRestTest() throws Exception{
|
||||
serverHealth.assertServerIsOnline();
|
||||
}
|
||||
```
|
||||
* the test name are self explanatory:
|
||||
|
||||
```java
|
||||
@TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.SANITY,
|
||||
description = "Verify admin user gets sites with Rest API and status code is 200")
|
||||
public void adminShouldRetrieveSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
siteAPI.getSites();
|
||||
restClient()
|
||||
.assertStatusCodeIs(HttpStatus.OK.toString());
|
||||
}
|
||||
```
|
||||
* Asserting on imbricated keys:
|
||||
|
||||
Let's say your response is something like:
|
||||
|
||||
```json
|
||||
{"entry": {
|
||||
"createdAt": "2017-08-01T12:01:24.979+0000",
|
||||
"edited": false,
|
||||
"modifiedBy": {
|
||||
"firstName": "Administrator"
|
||||
}
|
||||
}}
|
||||
```
|
||||
|
||||
if you want to assert that firstName is "Administrator" you can do that using the following DSL:
|
||||
|
||||
```java
|
||||
restClient.onResponse().assertThat().body("entry.modifiedBy.firstName", org.hamcrest.Matchers.is("Administrator"));
|
||||
```
|
||||
|
||||
(notice that i'm using Hamcrest Matcher to finalize this assertion)
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
### How to generate models or check coverage
|
||||
|
||||
There are some simple generators that could parse [Swagger YAML](http://docs.alfresco.com/community/concepts/alfresco-sdk-tutorials-using-rest-api-explorer.html) files and provide some usefull information to you like:
|
||||
|
||||
a) Show on screen the actual coverage of TAS vs requests that exists in each YAML file - defined in pom.xml)
|
||||
|
||||
```bash
|
||||
mvn exec:java -Dcoverage
|
||||
```
|
||||
Any missing request are saved under "missing-requests```<yaml-file-name>```.txt" file for further analysis
|
||||
All current implementation are saved under "implemented-requests```<yaml-file-name>```.txt"
|
||||

|
||||
|
||||
b) Generate all missing models
|
||||
|
||||
```bash
|
||||
mvn exec:java -Dmodels
|
||||
```
|
||||
|
||||
This command will read all definitions of models from swagger YAML file predefined in pom.xml file.
|
||||
It will compare with this file pattern: 'Rest```<model-definition-name>```Model.java', file created under ```/src/main/java/org/alfresco/rest/model``` ignoring the ones that are specified in [ignore-models](src/main/java/org/alfresco/rest/model/ignore-models) file.
|
||||
|
||||

|
||||
|
||||
At this time you you will be prompted to select (based on displayed ID) what models you want to generate (separate each one by comma).
|
||||
(you can also skip the generation of models from select yaml file or generate all missing models)
|
||||
|
||||
|
||||
c) Generate specific models
|
||||
Maybe you want to generate/regenerate just one model or multiple ones.
|
||||
|
||||
```bash
|
||||
mvn exec:java -Dmodels=Error,SiteModel
|
||||
```
|
||||
|
||||
This command will parse the Swagger YAML file, and will generate the definition of only those specified models, even if those models exist locally (in this case you will be prompted to override that file or not)
|
||||
|
||||
_NOTE_: there are some fields that are marked as ```required``` in swagger file. We also generate those fields with annotation ```@JsonProperty(required = true)```
|
||||
|
||||
All models are generated based on a [freemarker](http://freemarker.org) template found [here](src/main/resources/rest-model.ftl).
|
||||
|
||||
### How to run tests
|
||||
|
||||
#### from IDE
|
||||
|
||||
* The project can be imported into a development environment tool (Eclipse or IntelliJ). You have the possibility to execute tests or suite of tests using [TestNG plugin](http://testng.org/doc/eclipse.html) previously installed in IDE.
|
||||
|
||||
* In case you are using the default settings that points to localhost (127.0.0.1) and you don't have Alfresco installed on your machine, you will see one exception thrown (as expected):
|
||||
```java
|
||||
org.alfresco.utility.exception.ServerUnreachableException: Server {127.0.0.1} is unreachable.
|
||||
```
|
||||
|
||||
#### from command line
|
||||
|
||||
* In terminal or CMD, navigate (with CD) to root folder of your project (you can use the sample project):
|
||||
|
||||
|
||||
|
||||
The tests can be executed on command line/terminal using Maven command
|
||||
|
||||
```bash
|
||||
mvn test
|
||||
```
|
||||
|
||||
This command with trigger the tests specified in the default testng suite from POM file: <suiteXmlFile>src/main/resources/shared-resources/restapi-acs-community-suite.xml</suiteXmlFile>
|
||||
|
||||
You can use -Dtest parameter to run the test/suites through command line (http://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html).
|
||||
|
||||
You can also specify a different suiteXMLFile like:
|
||||
|
||||
```bash
|
||||
mvn test -DsuiteXmlFile=src/resources/your-custom-suite.xml
|
||||
```
|
||||
|
||||
Or even a single test:
|
||||
|
||||
```bash
|
||||
mvn test -Dtest=org.alfresco.rest.RestDemoTest
|
||||
```
|
||||
But pay attention that you will not have enabled all the [listeners](#listeners) in this case (the Reporting listener or TestRail integration one)
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Listeners
|
||||
|
||||
With the help of Listeners we can modify the behavior of TestNG framework. There are a lot of testNG listener interfaces that we can override in order to provide new functionalities.
|
||||
The TAS framework provides out of the box a couple of listeners that you could use. These could be enabled and added at the class level or suite level.
|
||||
|
||||
### a) org.alfresco.utility.report.ReportListenerAdapter
|
||||
|
||||
* if added at the class level:
|
||||
|
||||
```java
|
||||
@Listeners(value=ReportListenerAdapter.class)
|
||||
public class MyTestClass extends RestTest
|
||||
{
|
||||
(...)
|
||||
}
|
||||
```
|
||||
|
||||
* or suite xml level
|
||||
|
||||
```java
|
||||
<suite name="Your Suite test" parallel="classes">
|
||||
<listeners>
|
||||
<listener class-name="org.alfresco.utility.report.ReportListenerAdapter"></listener>
|
||||
</listeners>
|
||||
(...)
|
||||
</suite>
|
||||
```
|
||||
It will automatically generate one html named "report.html" in ./target/report folder.
|
||||
Please also take a look at [Test Results](#test-results) section.
|
||||
|
||||
### b) org.alfresco.utility.testrail.TestRailExecutorListener
|
||||
It will automatically update Test Rail application with the test cases that you've automated.
|
||||
Please take a look at [Test Rail Integration](#test-rail-integration) section for more details.
|
||||
|
||||
### c) org.alfresco.utility.report.log.LogsListener
|
||||
This is a new listener that will generate further details in one XML format of the automated test steps that you will write.
|
||||
|
||||
Example:
|
||||
|
||||
```java
|
||||
public void myDSLMethod1()
|
||||
{
|
||||
STEP("Lorem ipsum dolor sit amet");
|
||||
//code for first step
|
||||
|
||||
STEP("consectetur adipiscing elit");
|
||||
//code for the next description
|
||||
}
|
||||
|
||||
public void myDSLMethod2()
|
||||
{
|
||||
STEP("sed do eiusmod tempor incididunt ut labore");
|
||||
//code for first step
|
||||
|
||||
STEP("et dolore magna aliqua");
|
||||
//code for the next description
|
||||
}
|
||||
```
|
||||
|
||||
If these methods will be executed insite a test method, all those steps will be automatically logged in the XML report generated.
|
||||
Example:
|
||||
|
||||
```java
|
||||
@Test
|
||||
public void adminShouldCreateFileInSite()
|
||||
{
|
||||
myDSLMethod1();
|
||||
myDSLMethod2()
|
||||
}
|
||||
```
|
||||
|
||||
So if "testingSomething" will be executed this is what you will see on the XML file generated. (please take a look at [Test Results](#test-results) section for defining the defaul location)
|
||||
|
||||
Here is one example of XML file generated with these steps:
|
||||
|
||||

|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Test Results
|
||||
We already executed a couple of tests using command line as indicated above. Sweet! Please take a look at [rest-suites.xml](src/main/resources/shared-resources/restapi-acs-community-suite.xml) one more time.
|
||||
You will see there that we have one listener added:
|
||||
|
||||
```java
|
||||
<listener class-name="org.alfresco.utility.report.HtmlReportListener"></listener>
|
||||
```
|
||||
This will tell our framework, after we run all tests, to generate one HTML report file with graphs and metrics.
|
||||
|
||||
Take a look at the target/reports folder (created after running the tests) and open the report.html file.
|
||||
|
||||

|
||||
|
||||
Playing with this report, you will notice that you will be able to:
|
||||
* search tests cases by name
|
||||
* filter test cases by errors, labels, groups, test types, date when it was executed, protocol used, etc.
|
||||
* view overall pass/fail metrics of current test suite, history of tests execution, etc.
|
||||
|
||||
The report path can be configured in default.properties):
|
||||
|
||||
```
|
||||
# The location of the reports path
|
||||
reports.path=your-new-location-of-reports
|
||||
```
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Test Rail Integration
|
||||
|
||||
Alfresco is using now https://alfresco.testrail.net (v5.3.0.3601).
|
||||
|
||||
We aim to accelerate the delivery of automated test by minimizing the interaction with the test management tool - TestRail. In this scope we developed the following capabilities:
|
||||
* creating automatically the manual tests in TestRail
|
||||
* submitting the test results (with stack trace) after each execution into TestRail Test Runs
|
||||
* adding the test steps for each test.
|
||||
|
||||
### Configuration
|
||||
In order to use Test Rail Integration you will need to add a couple of information in [default.properties](src/test/resources/default.properties) file:
|
||||
(the document is pretty self explanatory)
|
||||
|
||||
```java
|
||||
# Example of configuration:
|
||||
# ------------------------------------------------------
|
||||
# testManagement.enabled=<true/false>
|
||||
# testManagement.endPoint=https://alfresco.testrail.com/
|
||||
# testManagement.username=<yourusername-that-you-connect-to-testrail>
|
||||
# testManagement.apiKey=<api-key>
|
||||
# testManagement.project=<id-of-your-project
|
||||
# testManagement.includeOnlyTestCasesExecuted=<true/false>
|
||||
# testManagement.rateLimitInSeconds= 1
|
||||
# testManagement.testRun=<test-run-name>
|
||||
# testManagement.suiteId=<suite-id>
|
||||
```
|
||||
!This settings are already defined in default.properties for you.
|
||||
|
||||
|
||||
For generating a new API Key take a look at the official documentation, TestRail [APIv2](http://docs.gurock.com/testrail-api2)
|
||||
* _testManagement.project= **<id-of-your-project**_ this is the ID of the project where you want to store your test cases.
|
||||
If you want to use [Alfresco ONE](https://alfresco.testrail.net/index.php?/projects/overview/1) project in TestRail, open that project and notice the URL, after "/overview/**1**" link you will see the ID of the project (1 in this case)
|
||||
If you want to use [TAS Project](https://alfresco.testrail.net/index.php?/projects/overview/7) you will notice the ID 7, so _"testManagement.project=7"_
|
||||
* "_testManagement.testRun=<test-run-name>_" this represents the name of the Test Run from your project.
|
||||
* In Test Rail, navigating to Test Runs & Results, create a new Test Run and include all/particular test cases. If this test run name is "Automation", update _testManagement.testRun= **Automation**_.
|
||||
All test results will be updated only on this test run at runtime as each test is executed by TAS framework.
|
||||
|
||||
### How to enable Test Rail Integration?
|
||||
|
||||
We wanted to simplify the Test Rail integration, so we used listeners in order to enable/disable the integration of Test Rail.
|
||||
* first configure your default.properties as indicated above
|
||||
|
||||
* now on your TestNG test, add the @TestRail annotation, so let's say you will have this test:
|
||||
|
||||
```java
|
||||
@Test(groups="sample-tests")
|
||||
public void thisAutomatedTestWillBePublishedInTestRail()
|
||||
{
|
||||
}
|
||||
```
|
||||
add now @TestRail integration with mandatory field ```section```. This means that this tests annotated, will be uploaded in TestRail:
|
||||
|
||||
```java
|
||||
@Test(groups= TestGroup.REST_API, TestGroup.FULL,)
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.PROCESSES })
|
||||
public void thisAutomatedTestWillBePublishedInTestRail()
|
||||
{
|
||||
}
|
||||
```
|
||||
The section field, represents an array of strings, the hierarchy of sections that SHOULD be found on TestRail under the project you've selected in default.properties. Follow the TestRail [user-guide](http://docs.gurock.com/testrail-userguide/start) for more information regarding sections.
|
||||
In our example we created in Test Rail one root section "restAPI" with a child section: "processes" (you can go further and add multiple section as you wish)
|
||||
|
||||
* now, lets add the listener, the TestRailExecutorListener that will handle this TC Management interaction.
|
||||
This listener can be added at the class level or suite level (approach that we embrace)
|
||||
Take a look at [restapi-acs-community-suite.xml](src/main/resources/shared-resources/restapi-acs-community-suite.xml) for further example.
|
||||
|
||||
```xml
|
||||
<listeners>
|
||||
<listener class-name="org.alfresco.utility.report.HtmlReportListener"></listener>
|
||||
(...)
|
||||
</listeners>
|
||||
```
|
||||
|
||||
Right click on sanity-suite.xml file and run it, or just "mvn test" from root if this sample project.
|
||||
After everything passes, go in Test Rail, open your project and navigate to "Test Cases" section. Notice that under restApi/processes section, you will see your test case published.
|
||||
|
||||
If you defined also the "testManagement.testRun" correctly, you will see under Test Runs, the status of this case marked as passed.
|
||||
|
||||
The @TestRail annotation offers also other options like:
|
||||
- "description" this is the description that will be updated in Test Rail for your test case
|
||||
- "testType", the default value is set to Functional test
|
||||
- "executionType", default value is set to ExecutionType.REGRESSION, but you can also use ExecutionType.SMOKE, ExecutionType.SANITY, etc
|
||||
|
||||
Take a look at the demo scenarios in this project for further examples.
|
||||
|
||||
**[Back to Top ^](#table-of-contents)**
|
||||
|
||||
## Reference
|
||||
|
||||
* For any improvements, bugs, please use Jira - [TAS](https://issues.alfresco.com/jira/browse/TAS) project.
|
||||
* Setup the environment using [docker](https://gitlab.alfresco.com/tas/alfresco-docker-provisioning/blob/master/Readme.md).
|
||||
* [Bamboo Test Plan](https://bamboo.alfresco.com/bamboo/browse/TAS-RESTAPI)
|
||||
|
||||
## Contributors
|
||||
|
||||
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other... [more](CODE_OF_CONDUCT.md)
|
||||
|
||||
## Releasing
|
||||
|
||||
Any commit done on this project should be automatically executed by [TAS Build Plan](https://bamboo.alfresco.com/bamboo/browse/TAS-TAS)
|
||||
If the build passes, then you didn't broke anything.
|
||||
|
||||
If you want to perform a release, open [TAS-RestAPI](https://bamboo.alfresco.com/bamboo/browse/TAS-RESTAPI) Bamboo Build.
|
||||
Run the Default stage and if it passes, then manually perform the Release stage (this will auto-increment the version in pom.xml)
|
||||
|
1
packaging/tests/tas-restapi/TASRegression.cvs
Normal file
1
packaging/tests/tas-restapi/TASRegression.cvs
Normal file
@@ -0,0 +1 @@
|
||||
TASRegression,total,totalbugs,sanity,sanitybugs,core,curebugs,full,fullbugs
|
BIN
packaging/tests/tas-restapi/docs/pics/coverage.png
Normal file
BIN
packaging/tests/tas-restapi/docs/pics/coverage.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 142 KiB |
BIN
packaging/tests/tas-restapi/docs/pics/html-report-sample.png
Normal file
BIN
packaging/tests/tas-restapi/docs/pics/html-report-sample.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 116 KiB |
BIN
packaging/tests/tas-restapi/docs/pics/models-all.png
Normal file
BIN
packaging/tests/tas-restapi/docs/pics/models-all.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
374
packaging/tests/tas-restapi/pom.xml
Normal file
374
packaging/tests/tas-restapi/pom.xml
Normal file
@@ -0,0 +1,374 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.alfresco.tas</groupId>
|
||||
<artifactId>restapi</artifactId>
|
||||
<name>alfresco-tas-restapi</name>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<organization>
|
||||
<name>Alfresco Software</name>
|
||||
<url>http://www.alfresco.com/</url>
|
||||
</organization>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Paul Brodner</name>
|
||||
<roles>
|
||||
<role>Test Automation Architect</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<properties>
|
||||
<!-- please run mvn clean install -DSkipTests in order to have shared-resources available -->
|
||||
<suiteXmlFile>src/main/resources/shared-resources/testCount.xml</suiteXmlFile>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<tas.utility.version>2.0.12</tas.utility.version>
|
||||
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
|
||||
<rest-assured.version>3.3.0</rest-assured.version>
|
||||
<httpclient-osgi-version>4.5.2</httpclient-osgi-version>
|
||||
<json-path.version>3.3.0</json-path.version>
|
||||
<xml-path.version>3.3.0</xml-path.version>
|
||||
<json-schema-validator.version>3.3.0</json-schema-validator.version>
|
||||
<jackson-databind.version>2.9.8</jackson-databind.version>
|
||||
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||
<maven-release.version>2.5.3</maven-release.version>
|
||||
<org.glassfish.version>1.0.4</org.glassfish.version>
|
||||
<maven-remote-resources.version>1.6.0</maven-remote-resources.version>
|
||||
<commons-lang3.version>3.8</commons-lang3.version>
|
||||
<scribejava-apis.version>6.5.1</scribejava-apis.version>
|
||||
<test.exclude />
|
||||
<test.include />
|
||||
<java.version>11</java.version>
|
||||
</properties>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:Alfresco/alfresco-tas-restapi.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:Alfresco/alfresco-tas-restapi.git</developerConnection>
|
||||
<url>https://github.com/Alfresco/alfresco-tas-restapi</url>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<issueManagement>
|
||||
<system>JIRA</system>
|
||||
<url>https://issues.alfresco.com/jira/browse/</url>
|
||||
</issueManagement>
|
||||
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>alfresco-public-snapshots</id>
|
||||
<url>https://nexus.alfresco.com/nexus/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>alfresco-public-releases</id>
|
||||
<url>https://nexus.alfresco.com/nexus/content/repositories/releases/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-remote-resources-plugin</artifactId>
|
||||
<version>${maven-remote-resources.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>${maven-jar-plugin.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<release>${java.version}</release>
|
||||
<showWarnings>true</showWarnings>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>${maven-release.version}</version>
|
||||
<configuration>
|
||||
<tagNameFormat>v@{project.version}</tagNameFormat>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-remote-resources-plugin</artifactId>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>shared-resources/**/*</include>
|
||||
</includes>
|
||||
<resourceBundles>
|
||||
<resourceBundle>org.alfresco.tas:utility:${tas.utility.version}</resourceBundle>
|
||||
</resourceBundles>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>process</goal>
|
||||
<goal>bundle</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>java</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<arguments>
|
||||
<argument>https://raw.githubusercontent.com/Alfresco/rest-api-explorer/5.2.N/src/main/webapp/definitions/alfresco-auth.yaml</argument>
|
||||
<argument>https://raw.githubusercontent.com/Alfresco/rest-api-explorer/5.2.N/src/main/webapp/definitions/alfresco-core.yaml</argument>
|
||||
<argument>https://raw.githubusercontent.com/Alfresco/rest-api-explorer/5.2.N/src/main/webapp/definitions/alfresco-discovery.yaml</argument>
|
||||
<argument>https://raw.githubusercontent.com/Alfresco/rest-api-explorer/5.2.N/src/main/webapp/definitions/alfresco-search.yaml</argument>
|
||||
<argument>https://raw.githubusercontent.com/Alfresco/rest-api-explorer/5.2.N/src/main/webapp/definitions/alfresco-workflow.yaml</argument>
|
||||
</arguments>
|
||||
<mainClass>org.alfresco.rest.core.swagger.Generator</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>3.0.0-M2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce-maven</id>
|
||||
<goals>
|
||||
<goal>enforce</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<rules>
|
||||
<requireMavenVersion>
|
||||
<version>3.3</version>
|
||||
</requireMavenVersion>
|
||||
</rules>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>shared-resources/**/*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<!-- fix the info log messages related to Could not instantiate TestExecutionListener
|
||||
[org.springframework.test.context.web.ServletTestExecutionListener -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- alfresco tester settings -->
|
||||
<dependency>
|
||||
<groupId>org.alfresco.tas</groupId>
|
||||
<artifactId>utility</artifactId>
|
||||
<version>${tas.utility.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<groupId>commons-lang</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- REST ASSURED -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient-osgi</artifactId>
|
||||
<version>${httpclient-osgi-version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>${rest-assured.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
<version>${json-path.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>xml-path</artifactId>
|
||||
<version>${xml-path.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>json-schema-validator</artifactId>
|
||||
<version>${json-schema-validator.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.scribejava</groupId>
|
||||
<artifactId>scribejava-apis</artifactId>
|
||||
<version>${scribejava-apis.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JSON to Object -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson-databind.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.glassfish/javax.json -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>javax.json</artifactId>
|
||||
<version>${org.glassfish.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- needed for swagger parser bellow -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- swagger parser -->
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-parser</artifactId>
|
||||
<version>1.0.23</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- Alfresco Solr JDBC Driver needed for Solr SQL Test-->
|
||||
<dependency>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-insight-jdbc</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.tika</groupId>
|
||||
<artifactId>tika-parsers</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
<version>2.11.0-alfresco-patched-20180402</version>
|
||||
</dependency>
|
||||
|
||||
<!--fixing java.lang.ClassCastException: class [B cannot be cast to class [C ([B and [C are in module java.base of loader 'bootstrap') -->
|
||||
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy</artifactId>
|
||||
<version>2.5.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-json-->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-json</artifactId>
|
||||
<version>2.5.5</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<report>dependencies</report>
|
||||
<report>issue-tracking</report>
|
||||
<report>scm</report>
|
||||
</reports>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
|
||||
</project>
|
@@ -0,0 +1,45 @@
|
||||
package org.alfresco.rest;
|
||||
|
||||
import org.alfresco.rest.model.RestNetworkModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
|
||||
public abstract class NetworkDataPrep extends RestTest
|
||||
{
|
||||
protected static UserModel adminUserModel;
|
||||
protected static UserModel adminTenantUser, secondAdminTenantUser;
|
||||
protected static UserModel tenantUser, secondTenantUser, differentNetworkTenantUser;
|
||||
protected static UserModel tenantUserWithBad;
|
||||
protected static UserModel userModel;
|
||||
protected static RestNetworkModel restNetworkModel;
|
||||
protected static String tenantDomain;
|
||||
private static boolean isInitialized = false;
|
||||
|
||||
public void init() throws Exception
|
||||
{
|
||||
if(!isInitialized)
|
||||
{
|
||||
isInitialized = true;
|
||||
initialization();
|
||||
}
|
||||
}
|
||||
|
||||
public void initialization() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
//create first tenant Admin User.
|
||||
adminTenantUser = UserModel.getAdminTenantUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
restClient.usingTenant().createTenant(adminTenantUser);
|
||||
|
||||
tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant");
|
||||
secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("sTenant");
|
||||
//create second tenant Admin User.
|
||||
secondAdminTenantUser = UserModel.getAdminTenantUser();
|
||||
restClient.usingTenant().createTenant(secondAdminTenantUser);
|
||||
|
||||
tenantDomain = tenantUser.getDomain();
|
||||
differentNetworkTenantUser = dataUser.usingUser(secondAdminTenantUser).createUserWithTenant("dTenant");
|
||||
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
}
|
||||
}
|
@@ -0,0 +1,85 @@
|
||||
package org.alfresco.rest;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.alfresco.dataprep.WorkflowService;
|
||||
import org.alfresco.rest.core.RestProperties;
|
||||
import org.alfresco.rest.core.RestWrapper;
|
||||
import org.alfresco.utility.LogFactory;
|
||||
import org.alfresco.utility.TasProperties;
|
||||
import org.alfresco.utility.data.DataContent;
|
||||
import org.alfresco.utility.data.DataGroup;
|
||||
import org.alfresco.utility.data.DataLink;
|
||||
import org.alfresco.utility.data.DataSite;
|
||||
import org.alfresco.utility.data.DataUserAIS;
|
||||
import org.alfresco.utility.data.DataWorkflow;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.network.ServerHealth;
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
|
||||
@ContextConfiguration("classpath:alfresco-restapi-context.xml")
|
||||
public abstract class RestTest extends AbstractTestNGSpringContextTests
|
||||
{
|
||||
private static Logger LOG = LogFactory.getLogger();
|
||||
|
||||
@Autowired
|
||||
protected RestProperties restProperties;
|
||||
|
||||
@Autowired
|
||||
protected TasProperties properties;
|
||||
|
||||
@Autowired
|
||||
protected ServerHealth serverHealth;
|
||||
|
||||
@Autowired
|
||||
protected RestWrapper restClient;
|
||||
|
||||
@Autowired
|
||||
protected DataUserAIS dataUser;
|
||||
|
||||
@Autowired
|
||||
protected DataSite dataSite;
|
||||
|
||||
@Autowired
|
||||
protected DataContent dataContent;
|
||||
|
||||
@Autowired
|
||||
protected DataGroup dataGroup;
|
||||
|
||||
@Autowired
|
||||
protected DataWorkflow dataWorkflow;
|
||||
|
||||
@Autowired
|
||||
protected DataLink dataLink;
|
||||
|
||||
@Autowired
|
||||
protected WorkflowService workflow;
|
||||
|
||||
protected SiteModel testSite;
|
||||
|
||||
@BeforeSuite(alwaysRun = true)
|
||||
public void checkServerHealth() throws Exception
|
||||
{
|
||||
super.springTestContextPrepareTestInstance();
|
||||
serverHealth.assertServerIsOnline();
|
||||
testSite = dataSite.createPublicRandomSite();
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun=true)
|
||||
public void showStartTestInfo(Method method)
|
||||
{
|
||||
LOG.info(String.format("*** STARTING Test: [%s] ***",method.getName()));
|
||||
}
|
||||
|
||||
@AfterMethod(alwaysRun=true)
|
||||
public void showEndTestInfo(Method method)
|
||||
{
|
||||
LOG.info(String.format("*** ENDING Test: [%s] ***", method.getName()));
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package org.alfresco.rest.core;
|
||||
|
||||
import org.alfresco.rest.core.assertion.IModelAssertion;
|
||||
|
||||
public interface IRestModel<Model> extends IModelAssertion<Model> {
|
||||
|
||||
public Model onModel();
|
||||
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package org.alfresco.rest.core;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.exception.EmptyRestModelCollectionException;
|
||||
import org.alfresco.rest.model.RestPaginationModel;
|
||||
|
||||
public interface IRestModelsCollection<Model> {
|
||||
|
||||
public List<Model> getEntries();
|
||||
|
||||
public Model getOneRandomEntry() throws EmptyRestModelCollectionException;
|
||||
|
||||
/**
|
||||
* @return boolean value if entry is empty
|
||||
*/
|
||||
public boolean isEmpty();
|
||||
|
||||
public RestPaginationModel getPagination();
|
||||
|
||||
}
|
@@ -0,0 +1,268 @@
|
||||
package org.alfresco.rest.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonArrayBuilder;
|
||||
import javax.json.JsonBuilderFactory;
|
||||
import javax.json.JsonObject;
|
||||
import javax.json.JsonObjectBuilder;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.Priority;
|
||||
import org.alfresco.rest.model.RestProcessVariableModel;
|
||||
import org.alfresco.rest.model.RestVariableModel;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.RepoTestModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
|
||||
/**
|
||||
* Json builder for small post calls
|
||||
*/
|
||||
public class JsonBodyGenerator
|
||||
{
|
||||
private static JsonBuilderFactory jsonBuilder;
|
||||
|
||||
/**
|
||||
* @return {@link JsonObjectBuilder}
|
||||
*/
|
||||
public static JsonObjectBuilder defineJSON()
|
||||
{
|
||||
return jsonBuilder().createObjectBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link JsonArrayBuilder}
|
||||
*/
|
||||
public static JsonArrayBuilder defineJSONArray()
|
||||
{
|
||||
return jsonBuilder().createArrayBuilder();
|
||||
}
|
||||
/**
|
||||
* {
|
||||
* "tag":"test-tag-1"
|
||||
* }
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static String keyValueJson(String key, String value)
|
||||
{
|
||||
return defineJSON().add(key, value).build().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "target": {
|
||||
* "site": {
|
||||
* "guid": "abcde-01234"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @param siteModel
|
||||
* @return
|
||||
*/
|
||||
public static String targetSiteWithGuid(SiteModel siteModel)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("target", defineJSON()
|
||||
.add("site", defineJSON()
|
||||
.add("guid", siteModel.getGuid()))).build();
|
||||
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "target": {
|
||||
* "file": {
|
||||
* "guid": "abcde-01234"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @param siteModel
|
||||
* @return
|
||||
*/
|
||||
public static String targetFileWithGuid(FileModel fileModel)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("target", defineJSON()
|
||||
.add("file", defineJSON()
|
||||
.add("guid", fileModel.getNodeRef().replace(";1.0", "")))).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "target": {
|
||||
* "folder": {
|
||||
* "guid": "abcde-01234"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @param siteModel
|
||||
* @return
|
||||
*/
|
||||
public static String targetFolderWithGuid(FolderModel folderModel)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("target", defineJSON()
|
||||
.add("folder", defineJSON()
|
||||
.add("guid", folderModel.getNodeRef()))).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the initialized JSON builder
|
||||
*/
|
||||
private static JsonBuilderFactory jsonBuilder()
|
||||
{
|
||||
if (jsonBuilder == null)
|
||||
return Json.createBuilderFactory(null);
|
||||
else
|
||||
{
|
||||
return jsonBuilder;
|
||||
}
|
||||
}
|
||||
|
||||
public static String likeRating(boolean likeOrNot)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("id", "likes")
|
||||
.add("myRating", likeOrNot).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String fiveStarRating(int stars)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("id", "fiveStar")
|
||||
.add("myRating", stars).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
|
||||
public static String siteMember(UserModel userModel) throws Exception
|
||||
{
|
||||
Utility.checkObjectIsInitialized(userModel.getUserRole(), "userModel.getUserRole()");
|
||||
JsonObject value = defineJSON()
|
||||
.add("role", userModel.getUserRole().name())
|
||||
.add("id", userModel.getUsername()).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String siteMemberhipRequest(String message, SiteModel siteModel, String title)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("message", message)
|
||||
.add("id", siteModel.getId())
|
||||
.add("title", title).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String process(String processDefinitionKey, UserModel assignee, boolean sendEmailNotifications, Priority priority)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("processDefinitionKey", processDefinitionKey)
|
||||
.add("variables", jsonBuilder().createObjectBuilder()
|
||||
.add("bpm_assignee", assignee.getUsername())
|
||||
.add("bpm_sendEMailNotifications", sendEmailNotifications)
|
||||
.add("bpm_workflowPriority", priority.getLevel())).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String processVariable(RestProcessVariableModel variableModel)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("name", variableModel.getName())
|
||||
.add("value", variableModel.getValue())
|
||||
.add("type", variableModel.getType()).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
public static String taskVariable(RestVariableModel taskVariableModel)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("scope", taskVariableModel.getScope())
|
||||
.add("name", taskVariableModel.getName())
|
||||
.add("type", taskVariableModel.getType())
|
||||
.add("value", taskVariableModel.getValue().toString()).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "actionDefinitionId": "copy",
|
||||
* "targetId": "4c4b3c43-f18b-43ff-af84-751f16f1ddfd",
|
||||
* "params": {
|
||||
"destination-folder": "34219f79-66fa-4ebf-b371-118598af898c"
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* @param actionDefinitionId
|
||||
* @param targetNode
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public static String executeActionPostBody(String actionDefinitionId, RepoTestModel targetNode, Map<String, String> params)
|
||||
{
|
||||
JsonObjectBuilder objectBuilder = jsonBuilder().createObjectBuilder();
|
||||
for(Map.Entry<String, String> param : params.entrySet())
|
||||
{
|
||||
objectBuilder.add(param.getKey(), param.getValue());
|
||||
}
|
||||
JsonObject value = defineJSON()
|
||||
.add("actionDefinitionId", actionDefinitionId)
|
||||
.add("targetId", targetNode.getNodeRefWithoutVersion())
|
||||
.add("params", objectBuilder).build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "actionDefinitionId": "check-out",
|
||||
* "targetId": "4c4b3c43-f18b-43ff-af84-751f16f1ddfd",
|
||||
* }
|
||||
*
|
||||
* @param actionDefinitionId
|
||||
* @param targetNode
|
||||
* @return
|
||||
*/
|
||||
public static String executeActionPostBody(String actionDefinitionId, RepoTestModel targetNode)
|
||||
{
|
||||
JsonObject value = defineJSON()
|
||||
.add("actionDefinitionId", actionDefinitionId)
|
||||
.add("targetId", targetNode.getNodeRefWithoutVersion())
|
||||
.build();
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {
|
||||
* "key1":"key1",
|
||||
* "key2":"key2",
|
||||
* "key3":"key3"
|
||||
* }
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static String keyValueJson(HashMap<String, String> mapJson)
|
||||
{
|
||||
JsonObjectBuilder builder= defineJSON();
|
||||
|
||||
for (Map.Entry<String, String> entry : mapJson.entrySet())
|
||||
{
|
||||
builder.add(entry.getKey().toString(), entry.getValue().toString());
|
||||
}
|
||||
return builder.build().toString();
|
||||
}
|
||||
}
|
@@ -0,0 +1,83 @@
|
||||
package org.alfresco.rest.core;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import org.alfresco.utility.data.AisToken;
|
||||
import org.alfresco.utility.data.auth.DataAIS;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.keycloak.authorization.client.util.HttpResponseException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class RestAisAuthentication
|
||||
{
|
||||
public static String STEP_PREFIX = "RestAisAuthProvider:";
|
||||
public static String USER_DISABLED_MSG = "Account disabled";
|
||||
|
||||
@Autowired
|
||||
private DataAIS dataAIS;
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the AIS access token for the specified user model.
|
||||
*
|
||||
* @param userModel
|
||||
* @return
|
||||
*/
|
||||
public String getAisAuthenticationToken(UserModel userModel)
|
||||
{
|
||||
STEP(String.format("%s Retrieving AIS authentication.", STEP_PREFIX));
|
||||
AisToken aisToken = getAisAccessToken(userModel);
|
||||
|
||||
return aisToken.getToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Alfresco Identity Service is enabled
|
||||
* @return True if Alfresco Identity Service is enabled (the identity service URL is not null or empty)
|
||||
*/
|
||||
public Boolean isAisAuthenticationEnabled()
|
||||
{
|
||||
return dataAIS.isEnabled() ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a valid access token for valid user credentials in userModel. An
|
||||
* invalid access token is returned for invalid user credentials, which can
|
||||
* be used for tests involving non existing or unauthorized users.
|
||||
*
|
||||
* @param userModel
|
||||
* @return
|
||||
*/
|
||||
private AisToken getAisAccessToken(UserModel userModel)
|
||||
{
|
||||
String badToken = "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJUazFPZ2JqVlo1UEw2bmtsNWFvTUlacTZ4cW9PZzc5WGtzdnJTTUcxLUFZIn0.eyJqdGkiOiI3NTVkMGZiOS03NzI5LTQ1NzYtYWM4Ny1hZWZjZWNiZDE0ZGEiLCJleHAiOjE1NTM2MjQ1NDgsIm5iZiI6MCwiaWF0IjoxNTUzNjI0MjQ4LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0L2F1dGgvcmVhbG1zL2FsZnJlc2NvIiwiYXVkIjoiYWNjb3VudCIsInN1YiI6Ijk4NDE0Njg4LTUwMDUtNDVmOS05YTVjLTlkMDRlODMyYTNkMiIsInR5cCI6IkJlYXJlciIsImF6cCI6ImFsZnJlc2NvIiwiYXV0aF90aW1lIjowLCJzZXNzaW9uX3N0YXRlIjoiNjJlN2U5YzktZmFlNS00N2RhLTk5MDItMTZjYTJhZWUwMWMwIiwiYWNyIjoiMSIsImFsbG93ZWQtb3JpZ2lucyI6WyJodHRwOi8vbG9jYWxob3N0KiIsImh0dHBzOi8vbG9jYWxob3N0KiJdLCJyZWFsbV9hY2Nlc3MiOnsicm9sZXMiOlsib2ZmbGluZV9hY2Nlc3MiLCJ1bWFfYXV0aG9yaXphdGlvbiJdfSwicmVzb3VyY2VfYWNjZXNzIjp7ImFjY291bnQiOnsicm9sZXMiOlsibWFuYWdlLWFjY291bnQiLCJtYW5hZ2UtYWNjb3VudC1saW5rcyIsInZpZXctcHJvZmlsZSJdfX0sInNjb3BlIjoicHJvZmlsZSBlbWFpbCIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwicHJlZmVycmVkX3VzZXJuYW1lIjoidXNlci12eGlrcXd3cG5jYmpzeHgifQ.PeLGCNCzj-P2m0knwUU9Vfx4dzLLQER9IdV7GyLel9LRN-3J9nh7GBDRQsyDJ0pqhObQyMg4V3wSsrsXRQ6gKhmUyDemmD-w1YMC2a2HKX6GlxsTEF_f1K_R15lIQOawNVErlWjZWORJGCvCYZOJ99SOmeOC6PGY79zLL94MMnf6dXcegePPMOKG-59eNjBkOylTipYebvM40nbbKrS5vzNHQlvUh4ALFeBoMSKGnLSjQd06Dj4SWojG0p1BrxurqDjW0zz6pQlEAm4vcWApRZ6qBLZcMH8adYix07zCDb87GOn1pmfEBWpwd3BEgC_LLu06guaCPHC9tpeIaDTHLg";
|
||||
String badRefreshToken = "eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJmM2YyMjhjYS1jMzg5LTQ5MGUtOGU1Zi02YWI1MmJhZDVjZGEifQ.eyJqdGkiOiIyNmExZWNhYy00Zjk0LTQwYzctYjJjNS04NTlhZmQ3NjBiYWMiLCJleHAiOjE1NTM2MjYwNDgsIm5iZiI6MCwiaWF0IjoxNTUzNjI0MjQ4LCJpc3MiOiJodHRwOi8vbG9jYWxob3N0L2F1dGgvcmVhbG1zL2FsZnJlc2NvIiwiYXVkIjoiaHR0cDovL2xvY2FsaG9zdC9hdXRoL3JlYWxtcy9hbGZyZXNjbyIsInN1YiI6Ijk4NDE0Njg4LTUwMDUtNDVmOS05YTVjLTlkMDRlODMyYTNkMiIsInR5cCI6IlJlZnJlc2giLCJhenAiOiJhbGZyZXNjbyIsImF1dGhfdGltZSI6MCwic2Vzc2lvbl9zdGF0ZSI6IjYyZTdlOWM5LWZhZTUtNDdkYS05OTAyLTE2Y2EyYWVlMDFjMCIsInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJvZmZsaW5lX2FjY2VzcyIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwidmlldy1wcm9maWxlIl19fSwic2NvcGUiOiJwcm9maWxlIGVtYWlsIn0.lRBJQc7tj0rk7JBC0zpM0dDdZgDKjm9wcxP8nzLnXe4";
|
||||
|
||||
AisToken aisToken;
|
||||
try
|
||||
{
|
||||
// Attempt to get an access token for userModel from AIS
|
||||
aisToken = dataAIS.perform().getAccessToken(userModel);
|
||||
}
|
||||
catch (HttpResponseException e)
|
||||
{
|
||||
// Trying to authenticate with invalid user credentials or disabled
|
||||
// user so return an invalid access token
|
||||
String httpResponse = new String(e.getBytes());
|
||||
if (e.getStatusCode() == 401 || httpResponse.contains(USER_DISABLED_MSG))
|
||||
{
|
||||
STEP(String.format("%s User disabled or invalid user credentials were provided %s:%s. Using invalid token for request.", STEP_PREFIX,
|
||||
userModel.getUsername(), userModel.getPassword()));
|
||||
aisToken = new AisToken(badToken, badRefreshToken, System.currentTimeMillis(), 300000);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return aisToken;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,137 @@
|
||||
package org.alfresco.rest.core;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.alfresco.rest.core.assertion.IModelsCollectionAssertion;
|
||||
import org.alfresco.rest.core.assertion.ModelsCollectionAssertion;
|
||||
import org.alfresco.rest.exception.EmptyRestModelCollectionException;
|
||||
import org.alfresco.rest.model.RestPaginationModel;
|
||||
import org.alfresco.rest.model.RestSiteModelsCollection;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Map multiple entries of JSON response to a class <T>
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* "entries": [
|
||||
{
|
||||
"entry": {
|
||||
"visibility": "PUBLIC",
|
||||
"guid": "79e140e1-5039-4efa-acaf-c22b5ba7c947",
|
||||
"description": "Description1470255221170",
|
||||
"id": "0-C2291-1470255221170",
|
||||
"title": "0-C2291-1470255221170"
|
||||
}
|
||||
},
|
||||
*
|
||||
* Having this JSON Entry, we can auto-map this to {@link RestSiteModelsCollection} class having a List of <SiteModel> based on this example
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public abstract class RestModels<Model, ModelCollection> implements IRestModelsCollection<Model>, IModelsCollectionAssertion<ModelCollection>
|
||||
{
|
||||
@JsonProperty(value = "entries")
|
||||
private List<Model> modelEntries;
|
||||
|
||||
private RestPaginationModel pagination;
|
||||
|
||||
@Override
|
||||
public List<Model> getEntries()
|
||||
{
|
||||
return modelEntries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a random entry from entries list
|
||||
* @throws EmptyRestModelCollectionException
|
||||
*/
|
||||
@Override
|
||||
public Model getOneRandomEntry() throws EmptyRestModelCollectionException
|
||||
{
|
||||
STEP("REST API: Get random one entry from response");
|
||||
Random random = new Random();
|
||||
List<Model> models = getEntries();
|
||||
if(models.isEmpty())
|
||||
throw new EmptyRestModelCollectionException(models);
|
||||
|
||||
int index = random.nextInt(models.size());
|
||||
return models.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Example
|
||||
* <code>
|
||||
* siteMembershipRequests.getEntryByIndex(0)
|
||||
.assertThat().field("site.visibility").is(moderatedSite.getVisibility())
|
||||
.assertThat().field("site.description").is(moderatedSite.getDescription())
|
||||
.assertThat().field("site.id").is(moderatedSite.getId())
|
||||
.assertThat().field("site.title").is(moderatedSite.getTitle());
|
||||
* </code>
|
||||
* @param index
|
||||
* @return
|
||||
* @throws EmptyRestModelCollectionException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Model getEntryByIndex(int index) throws EmptyRestModelCollectionException{
|
||||
STEP("REST API: Get index entry from response");
|
||||
|
||||
List<Model> models = getEntries();
|
||||
if(models.isEmpty())
|
||||
throw new EmptyRestModelCollectionException(models);
|
||||
|
||||
if(models.size() > index){
|
||||
return (Model) ((IRestModel<?>)models.get(index)).onModel();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelsCollectionAssertion<RestModels<Model, ModelCollection>> assertThat()
|
||||
{
|
||||
return new ModelsCollectionAssertion<RestModels<Model, ModelCollection>>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelsCollectionAssertion<RestModels<Model, ModelCollection>> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public ModelCollection when()
|
||||
{
|
||||
return (ModelCollection)this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean value if entry is empty
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
if (getEntries() != null)
|
||||
return getEntries().isEmpty();
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestPaginationModel getPagination()
|
||||
{
|
||||
return pagination;
|
||||
}
|
||||
|
||||
public void setPagination(RestPaginationModel pagination)
|
||||
{
|
||||
this.pagination = pagination;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package org.alfresco.rest.core;
|
||||
|
||||
import org.alfresco.utility.TasProperties;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@Configuration
|
||||
@PropertySource("classpath:default.properties")
|
||||
@PropertySource(value = "classpath:${environment}.properties", ignoreResourceNotFound = true)
|
||||
public class RestProperties
|
||||
{
|
||||
@Autowired
|
||||
private TasProperties properties;
|
||||
|
||||
public TasProperties envProperty()
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
}
|
@@ -0,0 +1,146 @@
|
||||
package org.alfresco.rest.core;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
import io.restassured.RestAssured;
|
||||
|
||||
/**
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class RestRequest
|
||||
{
|
||||
private String body = "";
|
||||
private HttpMethod httpMethod;
|
||||
private String path;
|
||||
private Object[] pathParams;
|
||||
private String contentType = "UTF-8";
|
||||
|
||||
private RestRequest(HttpMethod httpMethod, String path, String... pathParams)
|
||||
{
|
||||
setHttpMethod(httpMethod);
|
||||
setPath(path);
|
||||
setPathParams(pathParams);
|
||||
STEP(toString());
|
||||
}
|
||||
|
||||
private RestRequest(HttpMethod httpMethod, String body, String path, String... pathParams)
|
||||
{
|
||||
setHttpMethod(httpMethod);
|
||||
setPath(path);
|
||||
setPathParams(pathParams);
|
||||
setBody(body);
|
||||
STEP(toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this request when no body is needed
|
||||
*
|
||||
* @param httpMethod
|
||||
* @param path
|
||||
* @param pathParams
|
||||
* @return
|
||||
*/
|
||||
public static RestRequest simpleRequest(HttpMethod httpMethod, String path, String... pathParams)
|
||||
{
|
||||
return new RestRequest(httpMethod, path, pathParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this request when a body has to be provided
|
||||
*
|
||||
* @param httpMethod
|
||||
* @param body
|
||||
* @param path
|
||||
* @param pathParams
|
||||
* @return
|
||||
*/
|
||||
public static RestRequest requestWithBody(HttpMethod httpMethod, String body, String path, String... pathParams)
|
||||
{
|
||||
return new RestRequest(httpMethod, body, path, pathParams);
|
||||
}
|
||||
|
||||
public String getBody()
|
||||
{
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(String body)
|
||||
{
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public HttpMethod getHttpMethod()
|
||||
{
|
||||
return httpMethod;
|
||||
}
|
||||
|
||||
public void setHttpMethod(HttpMethod httpMethod)
|
||||
{
|
||||
this.httpMethod = httpMethod;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public Object[] getPathParams()
|
||||
{
|
||||
return pathParams;
|
||||
}
|
||||
|
||||
public void setPathParams(Object[] pathParams)
|
||||
{
|
||||
this.pathParams = pathParams;
|
||||
}
|
||||
|
||||
public String getContentType()
|
||||
{
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public void setContentType(String contentType)
|
||||
{
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder()
|
||||
.append("Request: ")
|
||||
.append(getHttpMethod())
|
||||
.append(" ")
|
||||
.append(RestAssured.baseURI)
|
||||
.append(":")
|
||||
.append(RestAssured.port)
|
||||
.append("/")
|
||||
.append(RestAssured.basePath)
|
||||
.append("/");
|
||||
|
||||
String getPathFormatted = getPath();
|
||||
if(getPath().contains("{"))
|
||||
{
|
||||
getPathFormatted = getPath().replaceAll("\\{.*?}", "%s");
|
||||
getPathFormatted = String.format(getPathFormatted, getPathParams());
|
||||
}
|
||||
sb.append(getPathFormatted);
|
||||
|
||||
if(!getBody().isEmpty())
|
||||
{
|
||||
sb.append("\nbody:")
|
||||
.append(getBody());
|
||||
}
|
||||
sb.append("\n");
|
||||
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
package org.alfresco.rest.core;
|
||||
|
||||
import io.restassured.response.Response;
|
||||
import io.restassured.response.ValidatableResponse;
|
||||
|
||||
/**
|
||||
* Defines a Rest Response
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class RestResponse
|
||||
{
|
||||
private Response response;
|
||||
|
||||
public RestResponse(Response response)
|
||||
{
|
||||
this.setResponse(response);
|
||||
}
|
||||
|
||||
public String getStatusCode()
|
||||
{
|
||||
return String.valueOf(response.getStatusCode());
|
||||
}
|
||||
|
||||
public Response getResponse()
|
||||
{
|
||||
return response;
|
||||
}
|
||||
|
||||
public void setResponse(Response response)
|
||||
{
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public <T> T toModel(Class<T> classz)
|
||||
{
|
||||
return response.as(classz);
|
||||
|
||||
}
|
||||
|
||||
public ValidatableResponse assertThat()
|
||||
{
|
||||
return response.then();
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,8 @@
|
||||
package org.alfresco.rest.core.assertion;
|
||||
|
||||
public interface IModelAssertion<Model>
|
||||
{
|
||||
public ModelAssertion<Model> and();
|
||||
|
||||
public ModelAssertion<Model> assertThat();
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package org.alfresco.rest.core.assertion;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public interface IModelsCollectionAssertion<ModelCollection> {
|
||||
public ModelsCollectionAssertion and();
|
||||
|
||||
public ModelsCollectionAssertion assertThat();
|
||||
|
||||
public ModelCollection when();
|
||||
}
|
@@ -0,0 +1,336 @@
|
||||
package org.alfresco.rest.core.assertion;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
import org.testng.Assert;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.restassured.path.json.JsonPath;
|
||||
|
||||
/**
|
||||
* Assertion on Rest Model
|
||||
* Just pass your rest model as constructor
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
|
||||
public class ModelAssertion<T>
|
||||
{
|
||||
protected static void checkFieldIsPresent(Object fieldNameToBeRetuned, Object fieldValueToBeRetuned)
|
||||
{
|
||||
if (fieldValueToBeRetuned == null)
|
||||
{
|
||||
Assert.fail(String.format("Field {%s} was not found in returned response.",fieldNameToBeRetuned));
|
||||
}
|
||||
}
|
||||
private Object model;
|
||||
|
||||
public ModelAssertion(Object model)
|
||||
{
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this DSL for asserting particular fields of your model if your model
|
||||
* is like this (basic POJO) public class Person extends
|
||||
* ModelAssertion<Person> { private String id = "1234"; you can use assert
|
||||
* the id of this person as:
|
||||
* Person p = new Person(); p.assertField("id").is("1234")
|
||||
*
|
||||
* @param fieldName
|
||||
* @return
|
||||
* @throws IllegalStateException If the field cannot be converted to JSON.
|
||||
*/
|
||||
public AssertionVerbs field(String fieldName)
|
||||
{
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
String jsonInString = null;
|
||||
try
|
||||
{
|
||||
jsonInString = mapper.writeValueAsString(model);
|
||||
}
|
||||
catch (JsonProcessingException e)
|
||||
{
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
||||
Object fieldValue = JsonPath.with(jsonInString).get(fieldName);
|
||||
|
||||
return new AssertionVerbs(model, fieldValue, fieldName);
|
||||
}
|
||||
|
||||
public AssertionItemVerbs fieldsCount() throws Exception
|
||||
{
|
||||
|
||||
int actualSize = 0;
|
||||
List<Field> allFields = getAllDeclaredFields(new LinkedList<Field>(), model.getClass());
|
||||
|
||||
for (Field field : allFields)
|
||||
{
|
||||
|
||||
field.setAccessible(true);
|
||||
Object fieldValue = field.get(model);
|
||||
if (fieldValue != null)
|
||||
actualSize++;
|
||||
}
|
||||
return new AssertionItemVerbs(model, actualSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all fields declared from all classes hierarchy
|
||||
*
|
||||
* @param fields
|
||||
* @param classz
|
||||
* @return
|
||||
*/
|
||||
private List<Field> getAllDeclaredFields(List<Field> fields, Class<?> classz)
|
||||
{
|
||||
if (classz.isAssignableFrom(TestModel.class))
|
||||
{
|
||||
return fields;
|
||||
}
|
||||
|
||||
fields.addAll(Arrays.asList(classz.getDeclaredFields()));
|
||||
|
||||
if (classz.getSuperclass() != null)
|
||||
{
|
||||
fields = getAllDeclaredFields(fields, classz.getSuperclass());
|
||||
}
|
||||
|
||||
return fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* DSL assertion on Rest Model fields
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class AssertionVerbs
|
||||
{
|
||||
private String fieldName;
|
||||
private Object model;
|
||||
private Object fieldValue;
|
||||
|
||||
public AssertionVerbs(Object model, Object fieldValue, String fieldName)
|
||||
{
|
||||
this.model = model;
|
||||
this.fieldValue = fieldValue;
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
|
||||
private String errorMessage(String info)
|
||||
{
|
||||
return String.format("The value of field [%s -> from %s] %s", fieldName, model.getClass().getCanonicalName(), info);
|
||||
}
|
||||
|
||||
public T isNot(Object expected)
|
||||
{
|
||||
checkFieldIsPresent(fieldName, fieldValue);
|
||||
Assert.assertNotEquals(fieldValue, expected, errorMessage("is correct,"));
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
throw new UnsupportedOperationException("You probably want to use is() rather than equals()");
|
||||
}
|
||||
|
||||
public T is(Object expected)
|
||||
{
|
||||
checkFieldIsPresent(fieldName, fieldValue);
|
||||
Assert.assertEquals(fieldValue.toString(), expected.toString(), errorMessage("is NOT correct,"));
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the supplied field is a non-empty String, Collection or Map.
|
||||
*
|
||||
* @throws AssertionError if the field is empty.
|
||||
* @throws UnsupportedOperationException if the field cannot be checked for emptiness.
|
||||
*/
|
||||
public T isNotEmpty()
|
||||
{
|
||||
checkFieldIsPresent(fieldName, fieldValue);
|
||||
if (fieldValue instanceof Collection)
|
||||
{
|
||||
Assert.assertNotEquals(fieldValue, Collections.emptyList(), errorMessage("is empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof String)
|
||||
{
|
||||
Assert.assertNotEquals(fieldValue, "", errorMessage("is empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof Map)
|
||||
{
|
||||
Assert.assertNotEquals(fieldValue, Collections.emptyMap(), errorMessage("is empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof Integer)
|
||||
{
|
||||
Assert.assertNotEquals(fieldValue.toString(), "", errorMessage("is empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof Long)
|
||||
{
|
||||
Assert.assertNotEquals(fieldValue.toString(), "", errorMessage("is empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof Boolean)
|
||||
{
|
||||
Assert.assertNotEquals(String.valueOf(fieldValue), "", errorMessage("is empty,"));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UnsupportedOperationException("Cannot check for emptiness of " + fieldValue.getClass());
|
||||
}
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
public T isNotNull()
|
||||
{
|
||||
checkFieldIsPresent(fieldName, fieldValue);
|
||||
Assert.assertNotNull(fieldValue, errorMessage("is null,"));
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
public T isNull()
|
||||
{
|
||||
Assert.assertNull(fieldValue, errorMessage("is not null,"));
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the supplied field is an empty String, Collection or Map.
|
||||
*
|
||||
* @throws AssertionError if the field is not empty.
|
||||
* @throws UnsupportedOperationException if the field cannot be checked for emptiness.
|
||||
*/
|
||||
public T isEmpty()
|
||||
{
|
||||
checkFieldIsPresent(fieldName, fieldValue);
|
||||
if (fieldValue instanceof Collection)
|
||||
{
|
||||
Assert.assertEquals((Collection<?>) fieldValue, Collections.emptyList(), errorMessage("is NOT empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof String)
|
||||
{
|
||||
Assert.assertEquals(fieldValue, "", errorMessage("is NOT empty,"));
|
||||
}
|
||||
else if (fieldValue instanceof Map)
|
||||
{
|
||||
Assert.assertEquals(fieldValue, Collections.emptyMap(), errorMessage("is NOT empty,"));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UnsupportedOperationException("Cannot check for emptiness of " + fieldValue.getClass());
|
||||
}
|
||||
return (T) model;
|
||||
}
|
||||
|
||||
public T contains(String value)
|
||||
{
|
||||
if (!fieldValue.toString().contains(value))
|
||||
Assert.fail(errorMessage("does NOT contain expected value: " + value + ", Current Value: " + fieldValue.toString()));
|
||||
|
||||
return (T) model;
|
||||
}
|
||||
/**
|
||||
* Assert if predicate value is greater than the field value
|
||||
* @author Michael Suzuki
|
||||
* @param value the predicate
|
||||
* @return
|
||||
* @throws TestConfigurationException
|
||||
*
|
||||
*/
|
||||
public T isGreaterThan(Integer value) throws TestConfigurationException
|
||||
{
|
||||
return validateSize(value, Operation.Greater);
|
||||
}
|
||||
|
||||
private T validateSize(Integer value, Operation operation) throws TestConfigurationException
|
||||
{
|
||||
try
|
||||
{
|
||||
if(value == null)
|
||||
{
|
||||
throw new TestConfigurationException("Input must be valid");
|
||||
}
|
||||
Integer b = Integer.valueOf(fieldValue.toString());
|
||||
switch (operation)
|
||||
{
|
||||
case Greater:
|
||||
if(value > b)
|
||||
{
|
||||
Assert.fail(errorMessage(String.format("The expected value %s is not greater than the actual value %s ",
|
||||
value, fieldValue.toString())));
|
||||
}
|
||||
break;
|
||||
case Less:
|
||||
if(value < b)
|
||||
{
|
||||
Assert.fail(errorMessage(String.format("The expected value %s is not less than the actual value %s ",
|
||||
value, fieldValue.toString())));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Assert.fail(errorMessage("No operation type provided"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(NumberFormatException e)
|
||||
{
|
||||
Assert.fail(errorMessage("The field is not numeric " + fieldValue.toString()));
|
||||
}
|
||||
catch (NullPointerException ne)
|
||||
{
|
||||
Assert.fail(errorMessage("The input value must be numeric " + value));
|
||||
}
|
||||
return (T) model;
|
||||
}
|
||||
/**
|
||||
* Assert if predicate value is less than the field value
|
||||
* @author Michael Suzuki
|
||||
* @param value the predicate
|
||||
* @return
|
||||
* @throws TestConfigurationException
|
||||
*
|
||||
*/
|
||||
public T isLessThan(Integer value) throws TestConfigurationException
|
||||
{
|
||||
return validateSize(value, Operation.Less);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class AssertionItemVerbs
|
||||
{
|
||||
private Object model;
|
||||
private Object actual;
|
||||
|
||||
public AssertionItemVerbs(Object model, Object actual) throws Exception
|
||||
{
|
||||
this.model = model;
|
||||
this.actual = actual;
|
||||
}
|
||||
|
||||
public T is(Object expected) {
|
||||
Assert.assertEquals(actual, expected, String.format("For model [%s], the expected value is not correct ",
|
||||
model.getClass().getSimpleName(), expected.toString(), actual.toString()));
|
||||
return (T) model;
|
||||
}
|
||||
}
|
||||
public static enum Operation
|
||||
{
|
||||
Less,Greater
|
||||
}
|
||||
}
|
@@ -0,0 +1,246 @@
|
||||
package org.alfresco.rest.core.assertion;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.core.IRestModelsCollection;
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
import org.alfresco.utility.model.Model;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.testng.Assert;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.collect.Ordering;
|
||||
import io.restassured.path.json.JsonPath;
|
||||
|
||||
/**
|
||||
* Assertion on Rest Model Collection
|
||||
* Just pass your rest model collection as constructor
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class ModelsCollectionAssertion<C>
|
||||
{
|
||||
@SuppressWarnings("rawtypes")
|
||||
private IRestModelsCollection modelCollection;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public ModelsCollectionAssertion(IRestModelsCollection modelCollection)
|
||||
{
|
||||
this.modelCollection = modelCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if "entries" list from JSON is not empty
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListIsNotEmpty()
|
||||
{
|
||||
STEP("REST API: Assert that entries list from response is not empty");
|
||||
Assert.assertFalse(modelCollection.isEmpty(), "Entries list from response is empty.Check the logs for more details!");
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* check if "entries" list from JSON is empty
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListIsEmpty()
|
||||
{
|
||||
STEP("REST API: Assert that entries list from response is empty");
|
||||
Assert.assertTrue(modelCollection.isEmpty(), "Entries list from response is not empty.Check the logs for more details!");
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListCountIs(int expectedCount)
|
||||
{
|
||||
STEP(String.format("REST API: Assert that entries list count is %d", expectedCount));
|
||||
int actualSize = modelCollection.getEntries().size();
|
||||
Assert.assertEquals(actualSize, expectedCount);
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListContains(String key, String value) throws Exception
|
||||
{
|
||||
List<Model> modelEntries = modelCollection.getEntries();
|
||||
String fieldValue = "";
|
||||
for (Model m : modelEntries) {
|
||||
Method method = m.getClass().getMethod("onModel", new Class[] {});
|
||||
Object model = method.invoke(m, new Object[] {});
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String jsonInString = mapper.writeValueAsString(model);
|
||||
fieldValue = JsonPath.with(jsonInString).get(key);
|
||||
if (fieldValue != null && fieldValue.equals(value)) {
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new TestConfigurationException(String.format(
|
||||
"You try to assert field [%s] that doesn't exist in class: [%s]. Exception: %s, Please check your code!",
|
||||
key, getClass().getCanonicalName(), e.getMessage()));
|
||||
}
|
||||
}
|
||||
Assert.assertEquals(fieldValue, value, String.format("Entry with key: [%s] with value [%s] not found in list", key, value));
|
||||
|
||||
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListDoesNotContain(String key, String value) throws Exception
|
||||
{
|
||||
boolean exist = false;
|
||||
List<Model> modelEntries = modelCollection.getEntries();
|
||||
for (Model m : modelEntries) {
|
||||
Method method = m.getClass().getMethod("onModel", new Class[] {});
|
||||
Object model = method.invoke(m, new Object[] {});
|
||||
String fieldValue = "";
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String jsonInString = mapper.writeValueAsString(model);
|
||||
fieldValue = JsonPath.with(jsonInString).get(key);
|
||||
if (fieldValue != null && fieldValue.equals(value)) {
|
||||
exist = true;
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
Assert.assertFalse(exist,
|
||||
String.format("Entry with key: %s and value %s was found in list", key, value));
|
||||
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListDoesNotContain(String key) throws Exception
|
||||
{
|
||||
boolean exist = false;
|
||||
List<Model> modelEntries = modelCollection.getEntries();
|
||||
for (Model m : modelEntries) {
|
||||
Method method = m.getClass().getMethod("onModel", new Class[] {});
|
||||
Object model = method.invoke(m, new Object[] {});
|
||||
String fieldValue = "";
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String jsonInString = mapper.writeValueAsString(model);
|
||||
fieldValue = JsonPath.with(jsonInString).get(key);
|
||||
if (fieldValue != null) {
|
||||
exist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Assert.assertFalse(exist,
|
||||
String.format("Entry list contains key: %s", key));
|
||||
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListContains(String key) throws Exception
|
||||
{
|
||||
boolean exist = false;
|
||||
List<Model> modelEntries = modelCollection.getEntries();
|
||||
for (Model m : modelEntries) {
|
||||
Method method = m.getClass().getMethod("onModel", new Class[] {});
|
||||
Object model = method.invoke(m, new Object[] {});
|
||||
Object fieldValue = null;
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String jsonInString = mapper.writeValueAsString(model);
|
||||
fieldValue = JsonPath.with(jsonInString).get(key);
|
||||
if (fieldValue != null) {
|
||||
exist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Assert.assertTrue(exist,
|
||||
String.format("Entry list doesn't contain key: %s", key));
|
||||
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public C paginationExist()
|
||||
{
|
||||
STEP("REST API: Assert that response has pagination");
|
||||
Assert.assertNotNull(modelCollection.getPagination(), "Pagination is was not found in the response");
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check one field from pagination json body
|
||||
*
|
||||
* @param field
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public PaginationAssertionVerbs paginationField(String field)
|
||||
{
|
||||
return new PaginationAssertionVerbs<C>(modelCollection, field, modelCollection.getPagination());
|
||||
}
|
||||
|
||||
/**
|
||||
* check is the entries are ordered ASC by a specific field
|
||||
*
|
||||
* @param field from json response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListIsSortedAscBy(String field) throws Exception
|
||||
{
|
||||
List<Model> modelEntries = modelCollection.getEntries();
|
||||
List<String> fieldValues = new ArrayList<String>();
|
||||
for(Model m: modelEntries)
|
||||
{
|
||||
Method method = m.getClass().getMethod("onModel", new Class[] {});
|
||||
Object model = method.invoke(m, new Object[] {});
|
||||
String fieldValue = "";
|
||||
try {
|
||||
fieldValue = BeanUtils.getProperty(model, field);
|
||||
fieldValues.add(fieldValue);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
Assert.assertTrue(Ordering.natural().isOrdered(fieldValues), String.format("Entries are not ordered ASC by %s", field));
|
||||
return (C) modelCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* check is the entries are ordered DESC by a specific field
|
||||
*
|
||||
* @param field from json response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public C entriesListIsSortedDescBy(String field) throws Exception
|
||||
{
|
||||
List<Model> modelEntries = modelCollection.getEntries();
|
||||
List<String> fieldValues = new ArrayList<String>();
|
||||
for(Model m: modelEntries)
|
||||
{
|
||||
Method method = m.getClass().getMethod("onModel", new Class[] {});
|
||||
Object model = method.invoke(m, new Object[] {});
|
||||
String fieldValue = "";
|
||||
try {
|
||||
fieldValue = BeanUtils.getProperty(model, field);
|
||||
fieldValues.add(fieldValue);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
Assert.assertTrue(Ordering.natural().reverse().isOrdered(fieldValues), String.format("Entries are not ordered DESC by %s", field));
|
||||
return (C) modelCollection;
|
||||
}
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
package org.alfresco.rest.core.assertion;
|
||||
|
||||
import org.alfresco.rest.core.IRestModelsCollection;
|
||||
import org.alfresco.rest.model.RestPaginationModel;
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.testng.Assert;
|
||||
|
||||
/**
|
||||
* Pagination related assertions
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class PaginationAssertionVerbs<C> {
|
||||
private RestPaginationModel pagination;
|
||||
private C modelCollection;
|
||||
private String fieldName;
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public PaginationAssertionVerbs(IRestModelsCollection modelCollection, String fieldName, RestPaginationModel pagination) {
|
||||
this.modelCollection = (C)modelCollection;
|
||||
this.fieldName = fieldName;
|
||||
this.pagination = pagination;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value of the field
|
||||
* @throws Exception
|
||||
*/
|
||||
private String getFieldValue() throws Exception {
|
||||
String value = "";
|
||||
try {
|
||||
value = BeanUtils.getProperty(pagination, fieldName);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new TestConfigurationException(String.format(
|
||||
"You try to assert field [%s] that doesn't exist in class: [%s]. Exception: %s, Please check your code!",
|
||||
fieldName, modelCollection.getClass().getCanonicalName(), e.getMessage()));
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private String errorMessage(String info) {
|
||||
return String.format("The value of field [%s -> from %s] %s", fieldName,
|
||||
modelCollection.getClass().getCanonicalName(), info);
|
||||
}
|
||||
|
||||
public C is(String expected) throws Exception {
|
||||
|
||||
Assert.assertEquals(getFieldValue(), expected, errorMessage("is NOT correct,"));
|
||||
return modelCollection;
|
||||
}
|
||||
|
||||
public C isNot(Object expected) throws Exception {
|
||||
|
||||
Assert.assertNotEquals(getFieldValue(), expected, errorMessage("is correct,"));
|
||||
return modelCollection;
|
||||
}
|
||||
|
||||
public C isNotEmpty() throws Exception {
|
||||
Assert.assertNotEquals(getFieldValue(), "", errorMessage("is empty,"));
|
||||
return modelCollection;
|
||||
}
|
||||
|
||||
public C isNotNull() throws Exception {
|
||||
Assert.assertNotNull(getFieldValue(), errorMessage("is null,"));
|
||||
return modelCollection;
|
||||
}
|
||||
|
||||
public C isNotPresent() throws Exception {
|
||||
Assert.assertNull(getFieldValue(), errorMessage("is present,"));
|
||||
return modelCollection;
|
||||
}
|
||||
|
||||
public C isEmpty() throws Exception {
|
||||
Assert.assertEquals(getFieldValue(), "", errorMessage("is NOT empty,"));
|
||||
return modelCollection;
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
package org.alfresco.rest.core.swagger;
|
||||
|
||||
/**
|
||||
* Executed via command line/terminal from root of this project
|
||||
* Just execute <code>mvn exec:java</code> passing as arguments:
|
||||
* -Dcoverage => this will show on screen the actual coverage of TAS (vs requests that exists in each YAML file - defined in pom.xml)
|
||||
* -Dmodels => this will show all MISSING models that are NOT already implemented in TAS.
|
||||
* -Dmodels=a,b,d => this will generate ONLY the models 'a', 'b' and 'd' passed as parameter
|
||||
* -Dhelp => show help
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class Generator
|
||||
{
|
||||
public static String line = "********\n------------------------------------------------------------------------";
|
||||
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
|
||||
if (!System.getProperties().containsKey("coverage") && !System.getProperties().containsKey("models") || System.getProperties().containsKey("help") )
|
||||
{
|
||||
System.out.println(line);
|
||||
System.out.println("No parameters provided, please use the following values:\n");
|
||||
System.out.println(
|
||||
"mvn exec:java -Dcoverage => this will show on screen the actual coverage of TAS (vs requests that exists in each YAML file - defined in pom.xml).");
|
||||
System.out.println("mvn exec:java -Dmodels => this will show all MISSING models that are NOT already implemented in TAS.");
|
||||
System.out.println("mvn exec:java -Dmodels=a,b,d => this will generate ONLY the models 'a', 'b' and 'd' passed as parameter.");
|
||||
System.out.println(line);
|
||||
|
||||
}
|
||||
|
||||
for (String url : args)
|
||||
{
|
||||
if (System.getProperty("coverage") != null)
|
||||
{
|
||||
/*
|
||||
* <code>mvn exec:java -Dcoverage</code>
|
||||
*/
|
||||
new SwaggerYamlParser(url).computeCoverage();
|
||||
}
|
||||
else if (System.getProperty("models") != null)
|
||||
{
|
||||
/*
|
||||
* <code>mvn exec:java -Dmodels</code>
|
||||
* <code>mvn exec:java -Dmodels=a,c,e</code>
|
||||
*/
|
||||
new SwaggerYamlParser(url).generateMissingModules();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,125 @@
|
||||
package org.alfresco.rest.core.swagger;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.RefProperty;
|
||||
|
||||
/**
|
||||
* Model property used by freemarker template in {@link SwaggerModel}
|
||||
*
|
||||
*/
|
||||
public class RestModelProperty
|
||||
{
|
||||
private String name;
|
||||
private String type;
|
||||
private String description;
|
||||
private Boolean isRequired = false;
|
||||
/** If the property is a ref then this is the type referenced. */
|
||||
private String simpleRef;
|
||||
/** If the property is an array then this is the type of the items in it. */
|
||||
private RestModelProperty itemsType;
|
||||
|
||||
public static RestModelProperty build(Entry<String, io.swagger.models.properties.Property> property)
|
||||
{
|
||||
RestModelProperty model = new RestModelProperty();
|
||||
model.setName(property.getKey());
|
||||
model.setType(property.getValue().getType());
|
||||
model.setDescription(property.getValue().getDescription());
|
||||
model.setIsRequired(property.getValue().getRequired());
|
||||
if (property.getValue() instanceof RefProperty)
|
||||
{
|
||||
RefProperty refProperty = (RefProperty) property.getValue();
|
||||
model.setSimpleRef(refProperty.getSimpleRef());
|
||||
}
|
||||
if (property.getValue() instanceof ArrayProperty)
|
||||
{
|
||||
ArrayProperty arrayProperty = (ArrayProperty) property.getValue();
|
||||
Entry<String, io.swagger.models.properties.Property> itemsEntry = new AbstractMap.SimpleEntry<String, io.swagger.models.properties.Property>(
|
||||
arrayProperty.getName(), arrayProperty.getItems());
|
||||
model.setItemsType(RestModelProperty.build(itemsEntry));
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getNameCapitalized()
|
||||
{
|
||||
return org.apache.commons.lang3.StringUtils.capitalize(name);
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
switch (this.type)
|
||||
{
|
||||
case "string":
|
||||
return "String";
|
||||
case "integer":
|
||||
return "int";
|
||||
case "object":
|
||||
return "Object";
|
||||
case "ref":
|
||||
return "Rest" + getSimpleRef() + "Model";
|
||||
case "array":
|
||||
return "List<" + getItemsType().getType() + ">";
|
||||
default:
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Boolean isRequired()
|
||||
{
|
||||
return isRequired;
|
||||
}
|
||||
|
||||
public void setIsRequired(Boolean isRequired)
|
||||
{
|
||||
this.isRequired = isRequired;
|
||||
}
|
||||
|
||||
protected void setSimpleRef(String simpleRef)
|
||||
{
|
||||
this.simpleRef = simpleRef;
|
||||
}
|
||||
|
||||
public String getSimpleRef()
|
||||
{
|
||||
return simpleRef;
|
||||
}
|
||||
|
||||
protected void setItemsType(RestModelProperty itemsType)
|
||||
{
|
||||
this.itemsType = itemsType;
|
||||
}
|
||||
|
||||
public RestModelProperty getItemsType()
|
||||
{
|
||||
return itemsType;
|
||||
}
|
||||
}
|
@@ -0,0 +1,178 @@
|
||||
package org.alfresco.rest.core.swagger;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.Console;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
|
||||
import freemarker.template.TemplateException;
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.Swagger;
|
||||
|
||||
/**
|
||||
* Handles all
|
||||
* <code>Entry<String, Model> model : swagger.getDefinitions().entrySet()</code>
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class SwaggerDefinitions
|
||||
{
|
||||
private Swagger swagger;
|
||||
List<SwaggerModel> missingSwaggerModels = new ArrayList<SwaggerModel>();
|
||||
Path modelsPath;
|
||||
|
||||
public SwaggerDefinitions(Swagger swagger)
|
||||
{
|
||||
this.swagger = swagger;
|
||||
modelsPath = Paths.get(Paths.get(".").toAbsolutePath().normalize().toFile().getPath(), "src/main/java/org/alfresco/rest/model");
|
||||
}
|
||||
|
||||
public void generateMissingDefinitions() throws Exception
|
||||
{
|
||||
/*
|
||||
* read the content of ignore-moldels file
|
||||
*/
|
||||
List<String> ignoreModel = new ArrayList<String>();
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(Paths.get(modelsPath.toFile().getPath(), "ignore-models").toFile())))
|
||||
{
|
||||
String line;
|
||||
while ((line = br.readLine()) != null)
|
||||
{
|
||||
if (!line.startsWith("#") && !line.equals(""))
|
||||
ignoreModel.add(line);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* filter all models, ignoring the ones from ignore-model or the ones that are already created locally
|
||||
*/
|
||||
for (Entry<String, Model> model : swagger.getDefinitions().entrySet())
|
||||
{
|
||||
SwaggerModel swaggerModel = new SwaggerModel(model, swagger);
|
||||
|
||||
//regexp
|
||||
if(swaggerModel.getName().matches(".*Paging|.*Entry"))
|
||||
{
|
||||
System.out.printf("Ignoring Model: [%s] (based on regular expression: '.*Paging|.*Entry')\n", swaggerModel.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ignoreModel.contains(swaggerModel.getName()))
|
||||
{
|
||||
System.out.printf("Ignoring Model: [%s] (based on 'ignore-models' file)\n", swaggerModel.getName());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!swaggerModel.exist())
|
||||
missingSwaggerModels.add(swaggerModel);
|
||||
}
|
||||
|
||||
System.out.println(Generator.line);
|
||||
int count = 0;
|
||||
/*
|
||||
* iterate on all missing models
|
||||
*/
|
||||
for (SwaggerModel swaggerModel : missingSwaggerModels)
|
||||
{
|
||||
if (count == 0) // table heather
|
||||
{
|
||||
System.out.printf("MISSING MODEL ~ THE NEW FILE THAT WILL BE GENERATED\n");
|
||||
System.out.println(" 0 -[Skip all]");
|
||||
}
|
||||
|
||||
count += 1;
|
||||
StringBuilder info = new StringBuilder();
|
||||
info.append(" ")
|
||||
.append(count)
|
||||
.append(" -")
|
||||
.append("[")
|
||||
.append(swaggerModel.getName())
|
||||
.append("] ~ [")
|
||||
.append(swaggerModel.getPath())
|
||||
.append("]");
|
||||
|
||||
System.out.println(info.toString());
|
||||
}
|
||||
System.out.println("ENTER -[All Models]");
|
||||
|
||||
/*
|
||||
* wait for input
|
||||
*/
|
||||
Console c = System.console();
|
||||
if (c != null && missingSwaggerModels.size() > 0)
|
||||
{
|
||||
c.format("%s\n", Generator.line);
|
||||
c.format("\nPlease select what Models you want to generate (ex: 1,3,4) or press <<ENTER>>to generating all missing models:");
|
||||
String prompt = c.readLine();
|
||||
|
||||
if(prompt.equals("0"))
|
||||
return;
|
||||
|
||||
if (prompt.length() == 0)
|
||||
{
|
||||
System.out.println("\nStart generating all models...");
|
||||
for (SwaggerModel swaggerModel : missingSwaggerModels)
|
||||
{
|
||||
swaggerModel.generate();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (prompt.contains(","))
|
||||
{
|
||||
String[] modelsIDToGen = prompt.split(",");
|
||||
for (int i = 0; i < modelsIDToGen.length; i++)
|
||||
{
|
||||
generateSelectedSwaggerModel(modelsIDToGen[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
generateSelectedSwaggerModel(prompt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the model based on the ID provided
|
||||
*
|
||||
* @param id
|
||||
* @throws Exception
|
||||
*/
|
||||
private void generateSelectedSwaggerModel(String id) throws Exception
|
||||
{
|
||||
int choise = Integer.parseInt(id);
|
||||
if ((choise - 1) >= missingSwaggerModels.size())
|
||||
{
|
||||
throw new TestConfigurationException(
|
||||
"You specified a wrong ID: [" + id + "] please select one value from the list displayed above. Run the command again!");
|
||||
}
|
||||
missingSwaggerModels.get(choise - 1).generate();
|
||||
}
|
||||
|
||||
public boolean generateDefinition(String modelParamValue) throws IOException, TemplateException
|
||||
{
|
||||
for (Entry<String, Model> model : swagger.getDefinitions().entrySet())
|
||||
{
|
||||
SwaggerModel swaggerModel = new SwaggerModel(model, swagger);
|
||||
if (swaggerModel.getName().equals(modelParamValue))
|
||||
{
|
||||
swaggerModel.generate();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
System.err.println("Model that you provided was NOT found!");
|
||||
System.err.printf("Model [%s] not found in Swagger file: %s\n", modelParamValue, swagger.getBasePath());
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,161 @@
|
||||
package org.alfresco.rest.core.swagger;
|
||||
|
||||
import java.io.Console;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import freemarker.template.TemplateException;
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.Swagger;
|
||||
|
||||
/**
|
||||
* Handles swagger definitions <code>Entry<String, Model> model : swagger.getDefinitions().entrySet()</code>
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class SwaggerModel
|
||||
{
|
||||
private Swagger swagger;
|
||||
private Entry<String, Model> model;
|
||||
private Path modelsPath = Paths.get(Paths.get(".").toAbsolutePath().normalize().toFile().getPath(), "src/main/java/org/alfresco/rest/model");
|
||||
private List<RestModelProperty> properties = new ArrayList<RestModelProperty>();
|
||||
private Configuration cfg;
|
||||
|
||||
private Configuration getConfig() throws IOException
|
||||
{
|
||||
if (cfg == null)
|
||||
{
|
||||
cfg = new Configuration(Configuration.VERSION_2_3_23);
|
||||
cfg.setDirectoryForTemplateLoading(new File("src/main/resources"));
|
||||
}
|
||||
return cfg;
|
||||
}
|
||||
|
||||
public SwaggerModel(Entry<String, Model> model, Swagger swagger)
|
||||
{
|
||||
this.model = model;
|
||||
this.swagger = swagger;
|
||||
|
||||
|
||||
if(model.getValue().getProperties()!=null)
|
||||
{
|
||||
/*
|
||||
* compute the properties of this model
|
||||
*/
|
||||
for (Entry<String, io.swagger.models.properties.Property> property : model.getValue().getProperties().entrySet())
|
||||
{
|
||||
if (property.getKey().equals("entry"))
|
||||
continue;
|
||||
|
||||
properties.add(RestModelProperty.build(property));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean value if file is already generated in TAS, under 'models' package
|
||||
*/
|
||||
public boolean exist()
|
||||
{
|
||||
return getPath().exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the location of the model in TAS
|
||||
*/
|
||||
public File getPath()
|
||||
{
|
||||
return Paths.get(modelsPath.toFile().getPath(), getNameInTAS() + ".java").toFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return original model name as defined in Swagger YAML
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return model.getKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name as it will be used in TAS
|
||||
*/
|
||||
public String getNameInTAS()
|
||||
{
|
||||
return String.format("Rest%sModel", getName());
|
||||
}
|
||||
|
||||
public List<RestModelProperty> getProperties()
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(List<RestModelProperty> properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public void generate() throws IOException, TemplateException
|
||||
{
|
||||
Template template = getConfig().getTemplate("rest-model.ftl");
|
||||
|
||||
// here we will store all data passed to template
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("date", new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date()));
|
||||
data.put("author", System.getProperty("user.name"));
|
||||
data.put("yamlTitle", swagger.getInfo().getTitle());
|
||||
data.put("yamlBasePath", swagger.getBasePath());
|
||||
data.put("name", getNameInTAS());
|
||||
|
||||
if (!getProperties().isEmpty())
|
||||
data.put("properties", getProperties());
|
||||
|
||||
Writer append = new StringWriter();
|
||||
template.process(data, append);
|
||||
|
||||
append.close();
|
||||
|
||||
System.out.println("----- " + getPath().getName() + " -----\n");
|
||||
System.out.println(Generator.line);
|
||||
System.out.println(append.toString());
|
||||
System.out.printf("\nGenerating Model: %-10s to ->'%-60s'", getName(), getPath());
|
||||
if (exist())
|
||||
{
|
||||
Console c = System.console();
|
||||
if (c != null)
|
||||
{
|
||||
System.out.printf("There is already one model created locally: \n%s\nDo you want to override it ?(ENTER=yes, any other key=no):", getPath());
|
||||
if (c.readLine().length() == 0)
|
||||
{
|
||||
writeContent(append.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
writeContent(append.toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void writeContent(String content) throws IOException
|
||||
{
|
||||
FileWriter fw = new FileWriter(getPath());
|
||||
fw.write(content);
|
||||
fw.close();
|
||||
}
|
||||
}
|
@@ -0,0 +1,191 @@
|
||||
package org.alfresco.rest.core.swagger;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.DirectoryStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import io.swagger.models.HttpMethod;
|
||||
import io.swagger.models.Operation;
|
||||
import io.swagger.models.Swagger;
|
||||
|
||||
/**
|
||||
* Handles all
|
||||
* <code>Entry<String, io.swagger.models.Path> path : swagger.getPaths().entrySet()</code>
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class SwaggerPaths
|
||||
{
|
||||
private Swagger swagger;
|
||||
private BufferedWriter fileWithMissingRequests;
|
||||
private BufferedWriter fileWithImplementedRequests;
|
||||
private String swaggerFilePath;
|
||||
private int implementedRequestCount = 0;
|
||||
private int missingRequestCount = 0;
|
||||
|
||||
public SwaggerPaths(Swagger swagger, String swaggerFilePath)
|
||||
{
|
||||
this.swagger = swagger;
|
||||
this.swaggerFilePath = swaggerFilePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare requests that exist in swagger yaml file vs request implemented in your code
|
||||
* any findings are saved to a missing-request txt file.
|
||||
* @throws Exception
|
||||
*
|
||||
* @throws TestConfigurationException
|
||||
*/
|
||||
public void computeCoverage() throws Exception
|
||||
{
|
||||
System.out.println("Start computing the coverage of TAS vs Swagger file. Stand by...");
|
||||
File missingReq = new File(String.format("missing-requests-%s.txt", FilenameUtils.getBaseName(swaggerFilePath)));
|
||||
missingReq.delete();
|
||||
fileWithMissingRequests = new BufferedWriter(new FileWriter(missingReq));
|
||||
fileWithMissingRequests.write(String.format("BasePath: {%s}", swagger.getBasePath()));
|
||||
fileWithMissingRequests.newLine();
|
||||
fileWithMissingRequests.write("These requests generated should be analyzed and modified according to your needs.");
|
||||
fileWithMissingRequests.newLine();
|
||||
fileWithMissingRequests.write("PLEASE UPDATE your 'RestReturnedModel' name with the appropiate returned model by your request.");
|
||||
fileWithMissingRequests.newLine();
|
||||
fileWithMissingRequests.newLine();
|
||||
|
||||
File implReq = new File(String.format("implemented-requests-%s.txt", FilenameUtils.getBaseName(swaggerFilePath)));
|
||||
implReq.delete();
|
||||
fileWithImplementedRequests = new BufferedWriter(new FileWriter(implReq));
|
||||
|
||||
for (Entry<String, io.swagger.models.Path> path : swagger.getPaths().entrySet())
|
||||
{
|
||||
for (Map.Entry<HttpMethod, Operation> operation : path.getValue().getOperationMap().entrySet())
|
||||
{
|
||||
searchPattern(path.getKey(),operation);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(toString());
|
||||
|
||||
fileWithImplementedRequests.close();
|
||||
fileWithMissingRequests.close();
|
||||
|
||||
if (missingRequestCount > 0)
|
||||
{
|
||||
System.out.println("[ERROR] PLEASE ANALYSE THE GENERATED <missing-requests> file(s), it seems some request were NOT implemented!");
|
||||
}
|
||||
else
|
||||
missingReq.delete();
|
||||
|
||||
System.out.println("ALSO ANALYZE <implemented-requests.txt> for current implementation, take a look at duplicated requests if any!");
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Use RegExp to check for requests in code, line by line: no further algorithm performance analysis required at this time
|
||||
*
|
||||
* @param httpMethod
|
||||
* @param pathUrl
|
||||
* @param methodName
|
||||
* @throws Exception
|
||||
*/
|
||||
private void searchPattern(String pathUrl, Entry<HttpMethod, Operation> operation) throws Exception
|
||||
{
|
||||
String originalPathUrl = pathUrl;
|
||||
String httpMethod = operation.getKey().name();
|
||||
|
||||
/* update path url, removing first "/" as implemented in TAS requests. */
|
||||
if (pathUrl.startsWith("/"))
|
||||
pathUrl = pathUrl.substring(1, pathUrl.length());
|
||||
|
||||
if (pathUrl.contains("{"))
|
||||
pathUrl = pathUrl.replace("{", "\\{");
|
||||
|
||||
/*
|
||||
* if in code we have something like: <code> "(HttpMethod.GET, "process-definitions?{parameters}" </code>
|
||||
* our regular expression will search for text insider the 'HttpMethod.GET' concatenated with found 'pathUrl" until the optional double brackets
|
||||
* RegExp: .*HttpMethod.%s.*\\\"%s\\\"?.*
|
||||
* Result: .*HttpMethod.GET."process-definition".* - if this line is found we have a match
|
||||
*/
|
||||
String patternRegEx = String.format(".*HttpMethod.%s.*\\\"%s\\\"?.*", httpMethod, pathUrl);
|
||||
|
||||
// all request are saved under this directory, but limited to the rest/request folder
|
||||
File project = Paths.get(".").toAbsolutePath().normalize().toFile();
|
||||
Path requestsPath = Paths.get(project.getPath(), "src/main/java/org/alfresco/rest/requests");
|
||||
|
||||
BufferedReader br;
|
||||
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(requestsPath))
|
||||
{
|
||||
boolean found = false;
|
||||
|
||||
for (Path path : directoryStream)
|
||||
{
|
||||
if (Files.isRegularFile(path) && Files.isReadable(path))
|
||||
{
|
||||
String line;
|
||||
InputStream fis = new FileInputStream(path.toFile());
|
||||
InputStreamReader isr = new InputStreamReader(fis, Charset.forName("UTF-8"));
|
||||
br = new BufferedReader(isr);
|
||||
|
||||
while ((line = br.readLine()) != null)
|
||||
{
|
||||
|
||||
if (line.matches(patternRegEx))
|
||||
{
|
||||
// log("OK - Pattern %-60s found in: {%s} file." , originalPathUrl, path.getFileName());
|
||||
fileWithImplementedRequests.write(String.format("%-10s %-60s %s", httpMethod, pathUrl, path.getFileName()));
|
||||
fileWithImplementedRequests.newLine();
|
||||
fileWithImplementedRequests.flush();
|
||||
implementedRequestCount += 1;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
br.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
fileWithMissingRequests.write(String.format("%-10s %-60s %s", httpMethod, originalPathUrl, patternRegEx));
|
||||
fileWithMissingRequests.newLine();
|
||||
|
||||
SwaggerRequest swaggerReqModel = new SwaggerRequest(httpMethod, pathUrl, operation.getValue());
|
||||
fileWithMissingRequests.write(swaggerReqModel.getRequestSample());
|
||||
fileWithMissingRequests.flush();
|
||||
missingRequestCount += 1;
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("|\n").append("|------------------------------------------------------------------------\n").append("COVERAGE: ")
|
||||
.append(swaggerFilePath).append("\n");
|
||||
|
||||
int percentage = (implementedRequestCount * 100) / (implementedRequestCount + missingRequestCount);
|
||||
sb.append("\t\tImplemented:\t").append(String.valueOf(percentage)).append("% [# ").append(implementedRequestCount).append("]\t Missing: ");
|
||||
|
||||
percentage = (missingRequestCount * 100) / (implementedRequestCount + missingRequestCount);
|
||||
sb.append(String.valueOf(percentage)).append("% [# ").append(missingRequestCount).append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
package org.alfresco.rest.core.swagger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import io.swagger.models.Operation;
|
||||
|
||||
public class SwaggerRequest
|
||||
{
|
||||
private Configuration cfg;
|
||||
private Operation swaggerRequest;
|
||||
private String httpMethod;
|
||||
private String pathUrl;
|
||||
|
||||
private Configuration getConfig() throws IOException
|
||||
{
|
||||
if (cfg == null)
|
||||
{
|
||||
cfg = new Configuration(Configuration.VERSION_2_3_23);
|
||||
cfg.setDirectoryForTemplateLoading(new File("src/main/resources"));
|
||||
}
|
||||
return cfg;
|
||||
}
|
||||
|
||||
public SwaggerRequest(String httpMethod, String pathUrl, Operation swaggerRequest)
|
||||
{
|
||||
this.swaggerRequest = swaggerRequest;
|
||||
this.httpMethod = httpMethod;
|
||||
this.pathUrl = pathUrl;
|
||||
}
|
||||
|
||||
public String getRequestSample() throws Exception
|
||||
{
|
||||
Template template = getConfig().getTemplate("rest-request.ftl");
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("operationId", swaggerRequest.getOperationId());
|
||||
data.put("httpMethod", httpMethod);
|
||||
data.put("pathUrl", pathUrl);
|
||||
|
||||
Writer append = new StringWriter();
|
||||
template.process(data, append);
|
||||
|
||||
append.close();
|
||||
return append.toString();
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
package org.alfresco.rest.core.swagger;
|
||||
|
||||
import org.alfresco.utility.exception.TestConfigurationException;
|
||||
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.parser.SwaggerParser;
|
||||
|
||||
/**
|
||||
* This will handle the Swagger YAML file
|
||||
* It will contain all the models, request or any other properties needed for out generator
|
||||
*
|
||||
* @author Paul Brodner
|
||||
*/
|
||||
public class SwaggerYamlParser
|
||||
{
|
||||
private Swagger swagger;
|
||||
private String swaggerFilePath;
|
||||
|
||||
public SwaggerYamlParser(String swaggerFilePath) throws TestConfigurationException
|
||||
{
|
||||
if (swaggerFilePath == null)
|
||||
throw new TestConfigurationException("'swaggerFilePath' not defined. Please update your pom.xml file with all '<swagger-file-location.yml>'");
|
||||
|
||||
this.swaggerFilePath = swaggerFilePath;
|
||||
this.swagger = new SwaggerParser().read(this.swaggerFilePath);
|
||||
|
||||
}
|
||||
|
||||
public void computeCoverage() throws Exception
|
||||
{
|
||||
new SwaggerPaths(swagger, this.swaggerFilePath).computeCoverage();
|
||||
}
|
||||
|
||||
public void generateMissingModules() throws Exception
|
||||
{
|
||||
String modelParamValue = System.getProperty("models");
|
||||
|
||||
SwaggerDefinitions swaggerDefinitions = new SwaggerDefinitions(swagger);
|
||||
|
||||
System.out.println(Generator.line);
|
||||
System.out.println("Using SWAGGER FILE: " + this.swaggerFilePath);
|
||||
System.out.println(Generator.line);
|
||||
/*
|
||||
* multiple models, separated by comma: 'mvn exec:java -Dmodels=a,b,d'
|
||||
*/
|
||||
if (modelParamValue.contains(","))
|
||||
{
|
||||
String[] models = {};
|
||||
models = modelParamValue.split(",");
|
||||
|
||||
for (int i = 0; i < models.length; i++)
|
||||
{
|
||||
// generate model
|
||||
swaggerDefinitions.generateDefinition(models[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* if no value is added after models "mvn exec:java -Dmodels"
|
||||
* then we assume that we want to generate all models
|
||||
*/
|
||||
if (modelParamValue.equals("true"))
|
||||
{
|
||||
swaggerDefinitions.generateMissingDefinitions();
|
||||
}
|
||||
/*
|
||||
* there is just one model passed as value "mvn exec:java -Dmodels=a"
|
||||
* so only model "a" is generated locally
|
||||
*/
|
||||
else
|
||||
{
|
||||
swaggerDefinitions.generateDefinition(modelParamValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,104 @@
|
||||
package org.alfresco.rest.demo;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.dataprep.SiteService.Visibility;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.exception.DataPreparationException;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class RestDemoTests extends RestTest
|
||||
{
|
||||
private UserModel userModel;
|
||||
private SiteModel siteModel;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws DataPreparationException
|
||||
{
|
||||
userModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(userModel).createPublicRandomSite();
|
||||
restClient.authenticateUser(userModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data preparation – create site with custom details <br/>
|
||||
* Perform GET sites call using admin user<br/>
|
||||
* Check that created site is included in response <br/>
|
||||
* Perform GET site call, validate that site title, description and visibility are correct <br/>
|
||||
*
|
||||
* @throws JsonToModelConversionException
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(groups = { "demo" })
|
||||
public void adminRetrievesCorrectSiteDetails() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.withCoreAPI().getSites().assertThat()
|
||||
.entriesListContains("id", siteModel.getId());
|
||||
|
||||
restClient.withCoreAPI().usingSite(siteModel).getSite()
|
||||
.assertThat().field("id").isNotNull()
|
||||
.assertThat().field("description").is(siteModel.getDescription())
|
||||
.assertThat().field("title").is(siteModel.getTitle())
|
||||
.assertThat().field("visibility").is(Visibility.PUBLIC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data preparation – create site and document on server <br/>
|
||||
* POST one comment to file using admin user <br/>
|
||||
* Perform GET comments, check the new one is listed <br/>
|
||||
* Update existing comment using PUT call, check that comment content is updated <br/>
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test(groups = { "demo" })
|
||||
public void adminCanPostAndUpdateComments() throws Exception
|
||||
{
|
||||
FileModel fileModel = dataContent.usingUser(userModel)
|
||||
.usingResource(FolderModel.getSharedFolderModel())
|
||||
.createContent(DocumentType.TEXT_PLAIN);
|
||||
// add new comment
|
||||
restClient.withCoreAPI().usingResource(fileModel).addComment("This is a new comment");
|
||||
restClient.withCoreAPI().usingResource(fileModel).getNodeComments()
|
||||
.assertThat().entriesListIsNotEmpty().and()
|
||||
.entriesListContains("content", "This is a new comment");
|
||||
}
|
||||
|
||||
/**
|
||||
* Data preparation – create site and a new user <br/>
|
||||
* As admin, add user as Consumer to site as a new site member using POST call <br/>
|
||||
* Update site member role to Manager using PUT call <br/>
|
||||
* Delete site member using DELETE call <br/>
|
||||
*
|
||||
* @throws DataPreparationException
|
||||
* @throws JsonToModelConversionException
|
||||
*/
|
||||
@Test(groups = { "demo" })
|
||||
public void adminCanAddAndUpdateSiteMemberDetails() throws Exception
|
||||
{
|
||||
UserModel testUser = dataUser.createRandomTestUser("testUser");
|
||||
testUser.setUserRole(UserRole.SiteConsumer);
|
||||
|
||||
// add user as Consumer to site
|
||||
restClient.withCoreAPI().usingSite(siteModel).addPerson(testUser);
|
||||
restClient.withCoreAPI().usingSite(siteModel).getSiteMembers().assertThat().entriesListContains("id", testUser.getUsername())
|
||||
.when().getSiteMember(testUser.getUsername())
|
||||
.assertSiteMemberHasRole(UserRole.SiteConsumer);
|
||||
|
||||
// update site member to Manager
|
||||
testUser.setUserRole(UserRole.SiteCollaborator);
|
||||
restClient.withCoreAPI().usingSite(siteModel).updateSiteMember(testUser);
|
||||
restClient.withCoreAPI().usingSite(siteModel).getSiteMembers().and()
|
||||
.entriesListContains("id", testUser.getUsername())
|
||||
.when().getSiteMember(testUser.getUsername())
|
||||
.assertSiteMemberHasRole(UserRole.SiteCollaborator);
|
||||
|
||||
restClient.withCoreAPI().usingSite(siteModel).deleteSiteMember(testUser);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
package org.alfresco.rest.demo;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestCommentModel;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
||||
public class SampleCommentsTests extends RestTest
|
||||
{
|
||||
private UserModel userModel;
|
||||
private FolderModel folderModel;
|
||||
private SiteModel siteModel;
|
||||
private FileModel document;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
userModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(userModel).createPublicRandomSite();
|
||||
folderModel = dataContent.usingUser(userModel).usingSite(siteModel).createFolder();
|
||||
restClient.authenticateUser(userModel);
|
||||
document = dataContent.usingUser(userModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
@Test(groups = { "demo" })
|
||||
public void admiShouldAddComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.withCoreAPI().usingResource(document).addComment("This is a new comment");
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@Test(groups = { "demo" })
|
||||
public void admiShouldRetrieveComments() throws Exception
|
||||
{
|
||||
restClient.withCoreAPI().usingResource(document).getNodeComments();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Test(groups = { "demo" })
|
||||
public void adminShouldUpdateComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
RestCommentModel commentModel = restClient.withCoreAPI().usingResource(document).addComment("This is a new comment");
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).updateComment(commentModel, "This is the updated comment with Collaborator user")
|
||||
.assertThat().field("content").is("This is the updated comment with Collaborator user");
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package org.alfresco.rest.demo;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.utility.exception.DataPreparationException;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
||||
public class SamplePeopleTests extends RestTest
|
||||
{
|
||||
private UserModel userModel;
|
||||
private UserModel adminUser;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws DataPreparationException
|
||||
{
|
||||
userModel = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20));
|
||||
adminUser = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUser);
|
||||
}
|
||||
|
||||
@Test(groups = { "demo" })
|
||||
public void adminShouldRetrievePerson() throws Exception
|
||||
{
|
||||
restClient.withCoreAPI().usingUser(userModel).getPerson().assertThat().field("id").isNotEmpty();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
package org.alfresco.rest.demo;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.exception.DataPreparationException;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
||||
public class SampleSitesTests extends RestTest
|
||||
{
|
||||
private UserModel userModel;
|
||||
private SiteModel siteModel;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws DataPreparationException
|
||||
{
|
||||
userModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(userModel);
|
||||
siteModel = dataSite.usingUser(userModel).createPublicRandomSite();
|
||||
}
|
||||
|
||||
@Test(groups = { "demo" })
|
||||
public void adminShouldGetSiteDetails() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.withCoreAPI().usingSite(siteModel).getSite()
|
||||
.assertThat().field("id").isNotNull();
|
||||
}
|
||||
|
||||
@Test(groups = { "demo" })
|
||||
public void adminShouldGetSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.withCoreAPI().usingSite(siteModel).getSite();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Test(groups = { "demo" })
|
||||
public void adminShouldAccessSites() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.withCoreAPI().getSites().assertThat().entriesListIsNotEmpty();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Test(groups = { "demo" })
|
||||
public void adminShouldAccessResponsePagination() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.withCoreAPI().getSites().assertThat().paginationExist();
|
||||
}
|
||||
|
||||
@Test(groups = { "demo" })
|
||||
public void adminShouldAddNewSiteMember() throws JsonToModelConversionException, DataPreparationException, Exception
|
||||
{
|
||||
UserModel testUser = dataUser.createRandomTestUser("testUser");
|
||||
testUser.setUserRole(UserRole.SiteConsumer);
|
||||
restClient.withCoreAPI().usingSite(siteModel).addPerson(testUser);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@Test(groups = { "demo" })
|
||||
public void adminShouldGetSiteFromSitesList() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.withCoreAPI().getSites().assertThat().entriesListContains("id", siteModel.getId());
|
||||
}
|
||||
|
||||
@Test(groups = { "demo" })
|
||||
public void adminShouldAccessSiteDetails() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.withCoreAPI().usingSite(siteModel).getSite()
|
||||
.assertThat().field("id").isNotNull()
|
||||
.and().field("description").is(siteModel.getDescription())
|
||||
.and().field("title").is(siteModel.getTitle())
|
||||
.and().field("visibility").is(siteModel.getVisibility());
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
package org.alfresco.rest.demo.workshop;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class RestApiDemoTests extends RestTest
|
||||
{
|
||||
/*
|
||||
* Test steps:
|
||||
* 1. create a user
|
||||
* 2. create a site
|
||||
* 3. create a second user
|
||||
* 4. add the second user to site with a user role
|
||||
* 5. call rest api call " GET sites/{siteId}/members" with first user authenticated
|
||||
* Expected: the response contains the user added as a member to the site
|
||||
*/
|
||||
@Test(groups = { "demo" })
|
||||
public void verifyGetSiteMembersRestApiCall() throws Exception
|
||||
{
|
||||
UserModel user = dataUser.createRandomTestUser();
|
||||
SiteModel site = dataSite.usingUser(user).createPublicRandomSite();
|
||||
UserModel member = dataUser.createRandomTestUser();
|
||||
dataUser.usingUser(user).addUserToSite(member, site, UserRole.SiteCollaborator);
|
||||
|
||||
//add here code for step 5
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Test steps:
|
||||
* 1. create a user
|
||||
* 2. create a site
|
||||
* 3. create a second user
|
||||
* 4. add the second user to site with a user role
|
||||
* 5. call rest api call " GET sites/{siteId}/members/{personId}" with first user authenticated
|
||||
* Expected: the response contains the user added as a member to the site
|
||||
*/
|
||||
|
||||
@Test(groups = { "demo" })
|
||||
public void verifyGetASiteMemberApiCall() throws Exception
|
||||
{
|
||||
UserModel user = dataUser.createRandomTestUser();
|
||||
SiteModel site = dataSite.usingUser(user).createPublicRandomSite();
|
||||
UserModel member = dataUser.createRandomTestUser();
|
||||
dataUser.usingUser(user).addUserToSite(member, site, UserRole.SiteCollaborator);
|
||||
|
||||
//add here code for step 5
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package org.alfresco.rest.demo.workshop;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* Demo workshop for RestAPI test
|
||||
*
|
||||
*/
|
||||
public class RestApiWorkshopTests extends RestTest
|
||||
{
|
||||
@Test(groups = { "demo" })
|
||||
public void verifyGetSitesRestApiCall() throws Exception
|
||||
{
|
||||
// creating a random user in repository
|
||||
|
||||
// create a new random site using your UserModel from above
|
||||
|
||||
// using "siteApi", call get "/sites" Rest API and verify created site is present
|
||||
|
||||
// verify status is OK
|
||||
|
||||
}
|
||||
|
||||
@Test(groups = { "demo" })
|
||||
public void verifyGetASiteRestApiCall() throws Exception
|
||||
{
|
||||
// creating a random user in repository
|
||||
|
||||
// create a new random site using your UserModel from above
|
||||
|
||||
// using "siteApi", call get "/sites/{siteId}" Rest API
|
||||
// using "siteApi", verify created site is present
|
||||
|
||||
// verify status is OK
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
package org.alfresco.rest.exception;
|
||||
|
||||
public class EmptyJsonResponseException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public EmptyJsonResponseException(String message)
|
||||
{
|
||||
super(String.format("Empty JSON Response returned. Possible API bug, please investigate this further. Message: %s", message));
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package org.alfresco.rest.exception;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class EmptyRestModelCollectionException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public <E> EmptyRestModelCollectionException(Collection<E> models)
|
||||
{
|
||||
super(String.format("Empty Rest Model Collection of type: %s -> %s", models.getClass(), models.toString()));
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package org.alfresco.rest.exception;
|
||||
|
||||
public class JsonToModelConversionException extends RuntimeException
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public <T> JsonToModelConversionException(Class<T> classz, Exception e)
|
||||
{
|
||||
super(String.format("Could not parse Json Response to model [%s] error: %s", classz.getName(), e.getMessage()));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,121 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import java.util.List;
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class RestActionDefinitionModel extends TestModel implements IRestModel<RestActionDefinitionModel>
|
||||
{
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestActionDefinitionModel actionDefinitionModel;
|
||||
private String id;
|
||||
private String name;
|
||||
private String title;
|
||||
private String description;
|
||||
private List<String> applicableTypes;
|
||||
private boolean adhocPropertiesAllowed;
|
||||
private boolean trackStatus;
|
||||
private List<RestParameterDefinitionModel> parameterDefinitions;
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public List<String> getApplicableTypes()
|
||||
{
|
||||
return applicableTypes;
|
||||
}
|
||||
|
||||
public void setApplicableTypes(List<String> applicableTypes)
|
||||
{
|
||||
this.applicableTypes = applicableTypes;
|
||||
}
|
||||
|
||||
public boolean isAdhocPropertiesAllowed()
|
||||
{
|
||||
return adhocPropertiesAllowed;
|
||||
}
|
||||
|
||||
public void setAdhocPropertiesAllowed(boolean adhocPropertiesAllowed)
|
||||
{
|
||||
this.adhocPropertiesAllowed = adhocPropertiesAllowed;
|
||||
}
|
||||
|
||||
public boolean isTrackStatus()
|
||||
{
|
||||
return trackStatus;
|
||||
}
|
||||
|
||||
public void setTrackStatus(boolean trackStatus)
|
||||
{
|
||||
this.trackStatus = trackStatus;
|
||||
}
|
||||
|
||||
public List<RestParameterDefinitionModel> getParameterDefinitions()
|
||||
{
|
||||
return parameterDefinitions;
|
||||
}
|
||||
|
||||
public void setParameterDefinitions(List<RestParameterDefinitionModel> parameterDefinitions)
|
||||
{
|
||||
this.parameterDefinitions = parameterDefinitions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestActionDefinitionModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestActionDefinitionModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestActionDefinitionModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestActionDefinitionModel onModel()
|
||||
{
|
||||
return actionDefinitionModel;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
public class RestActionDefinitionModelsCollection extends RestModels<RestActionDefinitionModel, RestActionDefinitionModelsCollection>
|
||||
{
|
||||
|
||||
}
|
@@ -0,0 +1,150 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Cristina Axinte
|
||||
*
|
||||
* Handles single Activity JSON responses
|
||||
* Example:
|
||||
{
|
||||
"postedAt": "2016-09-30T12:31:54.088+0000",
|
||||
"feedPersonId": "user-vtcaquckbq",
|
||||
"postPersonId": "user-vtcaquckbq",
|
||||
"siteId": "site-mNygPRuKka",
|
||||
"activitySummary": {
|
||||
"firstName": "User-vtCaqUCKBq FirstName",
|
||||
"lastName": "LN-User-vtCaqUCKBq",
|
||||
"memberFirstName": "User-vtCaqUCKBq FirstName",
|
||||
"role": "SiteManager",
|
||||
"memberLastName": "LN-User-vtCaqUCKBq",
|
||||
"title": "User-vtCaqUCKBq FirstName LN-User-vtCaqUCKBq (User-vtCaqUCKBq)",
|
||||
"memberPersonId": "User-vtCaqUCKBq"
|
||||
},
|
||||
"id": 14689,
|
||||
"activityType": "org.alfresco.site.user-joined"
|
||||
}
|
||||
*
|
||||
*/
|
||||
public class RestActivityModel extends TestModel implements IRestModel<RestActivityModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestActivityModel activityModel;
|
||||
|
||||
@Override
|
||||
public RestActivityModel onModel()
|
||||
{
|
||||
return activityModel;
|
||||
}
|
||||
|
||||
@JsonProperty(required = true)
|
||||
String id;
|
||||
|
||||
/**
|
||||
* The id of the person who performed the activity
|
||||
*/
|
||||
@JsonProperty(required = true)
|
||||
String postPersonId;
|
||||
|
||||
String siteId;
|
||||
String postedAt;
|
||||
|
||||
/**
|
||||
* The feed on which this activity was posted
|
||||
*/
|
||||
@JsonProperty(required = true)
|
||||
String feedPersonId;
|
||||
|
||||
RestActivitySummaryModel activitySummary;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
String activityType;
|
||||
|
||||
public String getActivityType()
|
||||
{
|
||||
return activityType;
|
||||
}
|
||||
|
||||
public void setActivityType(String activityType)
|
||||
{
|
||||
this.activityType = activityType;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPostPersonId()
|
||||
{
|
||||
return postPersonId;
|
||||
}
|
||||
|
||||
public void setPostPersonId(String postPersonId)
|
||||
{
|
||||
this.postPersonId = postPersonId;
|
||||
}
|
||||
|
||||
public String getSiteId()
|
||||
{
|
||||
return siteId;
|
||||
}
|
||||
|
||||
public void setSiteID(String siteId)
|
||||
{
|
||||
this.siteId = siteId;
|
||||
}
|
||||
|
||||
public String getPostedAt()
|
||||
{
|
||||
return postedAt;
|
||||
}
|
||||
|
||||
public void setPostedAt(String postedAt)
|
||||
{
|
||||
this.postedAt = postedAt;
|
||||
}
|
||||
|
||||
public String getFeedPersonId()
|
||||
{
|
||||
return feedPersonId;
|
||||
}
|
||||
|
||||
public void setFeedPersonId(String feedPersonId)
|
||||
{
|
||||
this.feedPersonId = feedPersonId;
|
||||
}
|
||||
|
||||
public RestActivitySummaryModel getActivitySummary()
|
||||
{
|
||||
return activitySummary;
|
||||
}
|
||||
|
||||
public void setActivitySummary(RestActivitySummaryModel activitySummary)
|
||||
{
|
||||
this.activitySummary = activitySummary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestActivityModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestActivityModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestActivityModel>(this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
/**
|
||||
*
|
||||
* @author Cristina Axinte
|
||||
*
|
||||
* /**
|
||||
* Handle collection of <RestActivityModel>
|
||||
* Example:
|
||||
{
|
||||
"list": {
|
||||
"pagination": {
|
||||
"count": 3,
|
||||
"hasMoreItems": false,
|
||||
"skipCount": 0,
|
||||
"maxItems": 100
|
||||
},
|
||||
"entries": [
|
||||
{
|
||||
"entry": {
|
||||
"postedAt": "2016-09-30T12:31:55.923+0000",
|
||||
"feedPersonId": "user-vtcaquckbq",
|
||||
"postPersonId": "user-vtcaquckbq",
|
||||
"siteId": "site-mNygPRuKka",
|
||||
"activitySummary": {
|
||||
"firstName": "User-vtCaqUCKBq FirstName",
|
||||
"lastName": "LN-User-vtCaqUCKBq",
|
||||
"parentObjectId": "e982c6b7-e16e-4a25-ae77-5ed96614e871",
|
||||
"title": "file-bWbaaGycDm.txt",
|
||||
"objectId": "3a647ca9-cef9-45d0-ae4a-49cffa131154"
|
||||
},
|
||||
"id": 14692,
|
||||
"activityType": "org.alfresco.documentlibrary.file-added"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
*
|
||||
*/
|
||||
public class RestActivityModelsCollection extends RestModels<RestActivityModel, RestActivityModelsCollection>
|
||||
{
|
||||
}
|
@@ -0,0 +1,130 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* "activitySummary": {
|
||||
"firstName": "string",
|
||||
"lastName": "string",
|
||||
"parentObjectId": "string",
|
||||
"title": "string",
|
||||
"objectId": "string"
|
||||
}
|
||||
*
|
||||
* @author Cristina Axinte
|
||||
*
|
||||
*/
|
||||
public class RestActivitySummaryModel extends TestModel implements IRestModel<RestActivitySummaryModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestActivitySummaryModel activitySummaryModel;
|
||||
|
||||
|
||||
@Override
|
||||
public RestActivitySummaryModel onModel()
|
||||
{
|
||||
return activitySummaryModel;
|
||||
}
|
||||
|
||||
String firstName;
|
||||
String lastName;
|
||||
String parentObjectId;
|
||||
String title;
|
||||
String objectId;
|
||||
String memberFirstName;
|
||||
UserRole role;
|
||||
String memberLastName;
|
||||
String memberPersonId;
|
||||
|
||||
public String getMemberFirstName()
|
||||
{
|
||||
return memberFirstName;
|
||||
}
|
||||
public void setMemberFirstName(String memberFirstName)
|
||||
{
|
||||
this.memberFirstName = memberFirstName;
|
||||
}
|
||||
public UserRole getRole()
|
||||
{
|
||||
return role;
|
||||
}
|
||||
public void setRole(UserRole role)
|
||||
{
|
||||
this.role = role;
|
||||
}
|
||||
public String getMemberLastName()
|
||||
{
|
||||
return memberLastName;
|
||||
}
|
||||
public void setMemberLastName(String memberLastName)
|
||||
{
|
||||
this.memberLastName = memberLastName;
|
||||
}
|
||||
public String getMemberPersonId()
|
||||
{
|
||||
return memberPersonId;
|
||||
}
|
||||
public void setMemberPersonId(String memberPersonId)
|
||||
{
|
||||
this.memberPersonId = memberPersonId;
|
||||
}
|
||||
|
||||
public String getFirstName()
|
||||
{
|
||||
return firstName;
|
||||
}
|
||||
public void setFirstName(String firstName)
|
||||
{
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName()
|
||||
{
|
||||
return lastName;
|
||||
}
|
||||
public void setLastName(String lastName)
|
||||
{
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getParentObjectId()
|
||||
{
|
||||
return parentObjectId;
|
||||
}
|
||||
public void setParentObjectId(String parentObjectId)
|
||||
{
|
||||
this.parentObjectId = parentObjectId;
|
||||
}
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
public String getObjectId()
|
||||
{
|
||||
return objectId;
|
||||
}
|
||||
public void setObjectId(String objectId)
|
||||
{
|
||||
this.objectId = objectId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestActivitySummaryModel> and() {
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestActivitySummaryModel> assertThat() {
|
||||
return new ModelAssertion<RestActivitySummaryModel>(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class RestAggregateModel extends TestModel implements IRestModel<RestAggregateModel>
|
||||
{
|
||||
@JsonProperty(value = "aggregate")
|
||||
RestAggregateModel model;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private int numberOfRatings;
|
||||
private String average;
|
||||
|
||||
@Override
|
||||
public RestAggregateModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public int getNumberOfRatings()
|
||||
{
|
||||
return numberOfRatings;
|
||||
}
|
||||
|
||||
public void setNumberOfRatings(int numberOfRatings)
|
||||
{
|
||||
this.numberOfRatings = numberOfRatings;
|
||||
}
|
||||
|
||||
public String getAverage()
|
||||
{
|
||||
return average;
|
||||
}
|
||||
|
||||
public void setAverage(String average)
|
||||
{
|
||||
this.average = average;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestAggregateModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestAggregateModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestAggregateModel>(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Generated by 'aepure' on '2017-06-29 15:31' from 'Alfresco Content Services REST API' swagger file
|
||||
* Generated from 'Alfresco Content Services REST API' swagger file
|
||||
* Base Path {@linkplain /alfresco/api/-default-/public/alfresco/versions/1}
|
||||
*/
|
||||
public class RestAuditAppModel extends TestModel implements IRestModel<RestAuditAppModel>
|
||||
{
|
||||
@Override
|
||||
public ModelAssertion<RestAuditAppModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestAuditAppModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestAuditAppModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestAuditAppModel model;
|
||||
|
||||
@Override
|
||||
public RestAuditAppModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean isEnabled;
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean getIsEnabled()
|
||||
{
|
||||
return this.isEnabled;
|
||||
}
|
||||
|
||||
public void setIsEnabled(boolean isEnabled)
|
||||
{
|
||||
this.isEnabled = isEnabled;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
public class RestAuditAppModelsCollection extends RestModels<RestAuditAppModel, RestAuditAppModelsCollection>
|
||||
{
|
||||
|
||||
}
|
@@ -0,0 +1,94 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class RestAuditEntryModel extends TestModel implements IRestModel<RestAuditEntryModel>
|
||||
{
|
||||
@Override
|
||||
public ModelAssertion<RestAuditEntryModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestAuditEntryModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestAuditEntryModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestAuditEntryModel model;
|
||||
|
||||
@Override
|
||||
public RestAuditEntryModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String id;
|
||||
private String auditApplicationId ;
|
||||
private String createdAt;
|
||||
@JsonProperty("createdByUser")
|
||||
private RestByUserModel createdByUser;
|
||||
|
||||
@JsonProperty("values")
|
||||
Map<String, Object> values;
|
||||
|
||||
public Map<String, Object> getValues()
|
||||
{
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(Map<String, Object> values)
|
||||
{
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAuditApplicationId()
|
||||
{
|
||||
return this.auditApplicationId;
|
||||
}
|
||||
|
||||
public void setAuditApplicationId(String auditApplicationId)
|
||||
{
|
||||
this.auditApplicationId = auditApplicationId;
|
||||
}
|
||||
|
||||
public RestByUserModel getCreatedByUser()
|
||||
{
|
||||
return this.createdByUser;
|
||||
}
|
||||
|
||||
public void setCreatedByUser(RestByUserModel createdByUser)
|
||||
{
|
||||
this.createdByUser = createdByUser;
|
||||
}
|
||||
|
||||
public String getCreatedAt()
|
||||
{
|
||||
return this.createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(String createdAt)
|
||||
{
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
public class RestAuditEntryModelsCollection extends RestModels<RestAuditEntryModel, RestAuditEntryModelsCollection>
|
||||
{
|
||||
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
public class RestAuditValuesModel extends TestModel
|
||||
{
|
||||
|
||||
public String getDisplayName()
|
||||
{
|
||||
return displayName;
|
||||
}
|
||||
public void setDisplayName(String displayName)
|
||||
{
|
||||
this.displayName = displayName;
|
||||
}
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
private String displayName;
|
||||
private String id;
|
||||
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
/**
|
||||
* Created by Claudia Agache on 11/11/2016.
|
||||
*/
|
||||
public class RestByUserModel extends TestModel
|
||||
{
|
||||
private String displayName;
|
||||
private String id;
|
||||
|
||||
public String getDisplayName()
|
||||
{
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName)
|
||||
{
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class RestCandidateModel extends TestModel implements IRestModel<RestCandidateModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestCandidateModel model;
|
||||
|
||||
public enum CandidateType
|
||||
{
|
||||
USER, GROUP
|
||||
}
|
||||
|
||||
private String candidateType;
|
||||
private String candidateId;
|
||||
|
||||
@Override
|
||||
public RestCandidateModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getCandidateType()
|
||||
{
|
||||
return candidateType;
|
||||
}
|
||||
|
||||
public void setCandidateType(String candidateType)
|
||||
{
|
||||
this.candidateType = candidateType;
|
||||
}
|
||||
|
||||
public String getCandidateId()
|
||||
{
|
||||
return candidateId;
|
||||
}
|
||||
|
||||
public void setCandidateId(String candidateId)
|
||||
{
|
||||
this.candidateId = candidateId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestCandidateModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestCandidateModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestCandidateModel>(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
public class RestCandidateModelsCollection extends RestModels<RestCandidateModel, RestCandidateModelsCollection>
|
||||
{
|
||||
|
||||
}
|
@@ -0,0 +1,132 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class RestCommentModel extends TestModel implements IRestModel<RestCommentModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestCommentModel model;
|
||||
|
||||
@Override
|
||||
public RestCommentModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
private String createdAt;
|
||||
private RestPersonModel createdBy;
|
||||
private String edited;
|
||||
private String modifiedAt;
|
||||
private boolean canEdit;
|
||||
private RestPersonModel modifiedBy;
|
||||
private boolean canDelete;
|
||||
private String id;
|
||||
private String content;
|
||||
|
||||
public String getCreatedAt()
|
||||
{
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(String createdAt)
|
||||
{
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public String getEdited()
|
||||
{
|
||||
return edited;
|
||||
}
|
||||
|
||||
public void setEdited(String edited)
|
||||
{
|
||||
this.edited = edited;
|
||||
}
|
||||
|
||||
public String getContent()
|
||||
{
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content)
|
||||
{
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public RestPersonModel getCreatedBy()
|
||||
{
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
public void RestPersonModel(RestPersonModel createdBy)
|
||||
{
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
public String getModifiedAt()
|
||||
{
|
||||
return modifiedAt;
|
||||
}
|
||||
|
||||
public void setModifiedAt(String modifiedAt)
|
||||
{
|
||||
this.modifiedAt = modifiedAt;
|
||||
}
|
||||
|
||||
public boolean isCanEdit()
|
||||
{
|
||||
return canEdit;
|
||||
}
|
||||
|
||||
public void setCanEdit(boolean canEdit)
|
||||
{
|
||||
this.canEdit = canEdit;
|
||||
}
|
||||
|
||||
public RestPersonModel getModifiedBy()
|
||||
{
|
||||
return modifiedBy;
|
||||
}
|
||||
|
||||
public void setModifiedBy(RestPersonModel modifiedBy)
|
||||
{
|
||||
this.modifiedBy = modifiedBy;
|
||||
}
|
||||
|
||||
public boolean isCanDelete()
|
||||
{
|
||||
return canDelete;
|
||||
}
|
||||
|
||||
public void setCanDelete(boolean canDelete)
|
||||
{
|
||||
this.canDelete = canDelete;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestCommentModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestCommentModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestCommentModel>(this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
public class RestCommentModelsCollection extends RestModels<RestCommentModel, RestCommentModelsCollection>
|
||||
{
|
||||
}
|
@@ -0,0 +1,119 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
/**
|
||||
"company": {
|
||||
"organization": "myCompany",
|
||||
"address1": "Iasi",
|
||||
"address2": "City",
|
||||
"address3": "trei",
|
||||
"postcode": "1234556",
|
||||
"telephone": "564510213453",
|
||||
"fax": "541",
|
||||
"email": "qLZ41D2QnXQcqySNK09J@yahoo.com"
|
||||
}
|
||||
*/
|
||||
public class RestCompanyModel extends TestModel
|
||||
{
|
||||
private String organization;
|
||||
private String address1;
|
||||
private String address2;
|
||||
private String address3;
|
||||
private String postcode;
|
||||
private String telephone;
|
||||
private String fax;
|
||||
private String email;
|
||||
|
||||
public ModelAssertion<RestCompanyModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestCompanyModel>(this);
|
||||
}
|
||||
|
||||
public ModelAssertion<RestCompanyModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
public String getOrganization()
|
||||
{
|
||||
return organization;
|
||||
}
|
||||
|
||||
public void setOrganization(String organization)
|
||||
{
|
||||
this.organization = organization;
|
||||
}
|
||||
|
||||
public String getAddress1()
|
||||
{
|
||||
return address1;
|
||||
}
|
||||
|
||||
public void setAddress1(String address1)
|
||||
{
|
||||
this.address1 = address1;
|
||||
}
|
||||
|
||||
public String getAddress2()
|
||||
{
|
||||
return address2;
|
||||
}
|
||||
|
||||
public void setAddress2(String address2)
|
||||
{
|
||||
this.address2 = address2;
|
||||
}
|
||||
|
||||
public String getAddress3()
|
||||
{
|
||||
return address3;
|
||||
}
|
||||
|
||||
public void setAddress3(String address3)
|
||||
{
|
||||
this.address3 = address3;
|
||||
}
|
||||
|
||||
public String getPostcode()
|
||||
{
|
||||
return postcode;
|
||||
}
|
||||
|
||||
public void setPostcode(String postcode)
|
||||
{
|
||||
this.postcode = postcode;
|
||||
}
|
||||
|
||||
public String getTelephone()
|
||||
{
|
||||
return telephone;
|
||||
}
|
||||
|
||||
public void setTelephone(String telephone)
|
||||
{
|
||||
this.telephone = telephone;
|
||||
}
|
||||
|
||||
public String getFax()
|
||||
{
|
||||
return fax;
|
||||
}
|
||||
|
||||
public void setFax(String fax)
|
||||
{
|
||||
this.fax = fax;
|
||||
}
|
||||
|
||||
public String getEmail()
|
||||
{
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email)
|
||||
{
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
/**
|
||||
* Created by Claudia Agache on 11/11/2016.
|
||||
*/
|
||||
public class RestContentModel extends TestModel
|
||||
{
|
||||
private int sizeInBytes;
|
||||
private String mimeTypeName;
|
||||
private String mimeType;
|
||||
private String encoding;
|
||||
|
||||
public int getSizeInBytes()
|
||||
{
|
||||
return sizeInBytes;
|
||||
}
|
||||
|
||||
public void setSizeInBytes(int sizeInBytes)
|
||||
{
|
||||
this.sizeInBytes = sizeInBytes;
|
||||
}
|
||||
|
||||
public String getMimeTypeName()
|
||||
{
|
||||
return mimeTypeName;
|
||||
}
|
||||
|
||||
public void setMimeTypeName(String mimeTypeName)
|
||||
{
|
||||
this.mimeTypeName = mimeTypeName;
|
||||
}
|
||||
|
||||
public String getMimeType()
|
||||
{
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
public void setMimeType(String mimeType)
|
||||
{
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
public String getEncoding()
|
||||
{
|
||||
return encoding;
|
||||
}
|
||||
|
||||
public void setEncoding(String encoding)
|
||||
{
|
||||
this.encoding = encoding;
|
||||
}
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.CustomAspectModel;
|
||||
import org.alfresco.utility.model.CustomAspectPropertiesModel;
|
||||
import org.testng.Assert;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* @author Bogdan Bocancea
|
||||
*/
|
||||
public class RestCustomAspectModel extends CustomAspectModel implements IRestModel<RestCustomAspectModel>
|
||||
{
|
||||
@Override
|
||||
public ModelAssertion<RestCustomAspectModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestCustomAspectModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestCustomAspectModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestCustomAspectModel model;
|
||||
|
||||
@Override
|
||||
public RestCustomAspectModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public RestCustomAspectModel assertHasProperties(CustomAspectPropertiesModel... propertiesName)
|
||||
{
|
||||
List<String> propertiesModelName = new ArrayList<String>();
|
||||
List<CustomAspectPropertiesModel> properiesModel = getProperties();
|
||||
for (CustomAspectPropertiesModel model : properiesModel)
|
||||
{
|
||||
propertiesModelName.add(model.getName());
|
||||
}
|
||||
for (CustomAspectPropertiesModel property : propertiesName)
|
||||
{
|
||||
Assert.assertTrue(propertiesModelName.contains(property.getName()), String.format("Property %s was found.", property.getName()));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.CustomContentModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* @author Bogdan Bocancea
|
||||
*/
|
||||
public class RestCustomModel extends CustomContentModel implements IRestModel<RestCustomModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestCustomModel model;
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestCustomModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestCustomModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestCustomModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
}
|
@@ -0,0 +1,98 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Handles single Deployment Entry JSON response
|
||||
* "entry": {
|
||||
* "id": "string",
|
||||
* "name": "string",
|
||||
* "category": "string",
|
||||
* "deployedAt": "2016-10-04T13:15:36.222Z"
|
||||
* }
|
||||
*
|
||||
* Created by Claudia Agache on 10/4/2016.
|
||||
*/
|
||||
public class RestDeploymentModel extends TestModel implements IRestModel<RestDeploymentModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestDeploymentModel model;
|
||||
|
||||
@Override
|
||||
public RestDeploymentModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public RestDeploymentModel()
|
||||
{
|
||||
}
|
||||
|
||||
public RestDeploymentModel(String id)
|
||||
{
|
||||
setId(id);
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String id;
|
||||
private String name;
|
||||
private String category;
|
||||
private String deployedAt;
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCategory()
|
||||
{
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category)
|
||||
{
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public String getDeployedAt()
|
||||
{
|
||||
return deployedAt;
|
||||
}
|
||||
|
||||
public void setDeployedAt(String deployedAt)
|
||||
{
|
||||
this.deployedAt = deployedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestDeploymentModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestDeploymentModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<>(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
/**
|
||||
* "entries": [
|
||||
* {
|
||||
* "entry": {
|
||||
* "name": "parallel-review-group.bpmn20.xml",
|
||||
* "id": "17",
|
||||
* "deployedAt": "2016-03-04T11:28:02.000+0000"
|
||||
* }
|
||||
* },
|
||||
* {
|
||||
* "entry": {
|
||||
* "name": "review.bpmn20.xml",
|
||||
* "id": "5",
|
||||
* "deployedAt": "2016-03-04T11:28:01.000+0000"
|
||||
* }
|
||||
* }
|
||||
* ]
|
||||
* Created by Claudia Agache on 10/4/2016.
|
||||
*/
|
||||
public class RestDeploymentModelsCollection extends RestModels<RestDeploymentModel, RestDeploymentModelsCollection>
|
||||
{
|
||||
|
||||
public RestDeploymentModel getDeploymentByName(String deploymentName)
|
||||
{
|
||||
STEP(String.format("REST API: Get deployment with name '%s'", deploymentName));
|
||||
List<RestDeploymentModel> deploymentsList = getEntries();
|
||||
|
||||
for (RestDeploymentModel deploymentEntry: deploymentsList)
|
||||
{
|
||||
if (deploymentEntry.onModel().getName().equals(deploymentName))
|
||||
{
|
||||
return deploymentEntry.onModel();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class RestDiscoveryModel extends TestModel implements IRestModel<RestDiscoveryModel>
|
||||
{
|
||||
@Override
|
||||
public ModelAssertion<RestDiscoveryModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestDiscoveryModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestDiscoveryModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestDiscoveryModel model;
|
||||
|
||||
@Override
|
||||
public RestDiscoveryModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private RestRepositoryInfoModel repository;
|
||||
|
||||
public RestRepositoryInfoModel getRepository()
|
||||
{
|
||||
return repository;
|
||||
}
|
||||
|
||||
public void setRepository(RestRepositoryInfoModel repository)
|
||||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
}
|
@@ -0,0 +1,135 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/*
|
||||
* Handles responses for GET /downloads/{downloadId} and POST /downloads rest calls
|
||||
* E.g
|
||||
* {
|
||||
* "entry": {
|
||||
* "filesAdded": 1,
|
||||
* "bytesAdded": 4,
|
||||
* "totalBytes": 4,
|
||||
* "id": "6ab1357c-bf13-4ecc-9c6e-3af0b6a7bb34",
|
||||
* "totalFiles": 1,
|
||||
* "status": "DONE"
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
|
||||
public class RestDownloadsModel extends TestModel implements IRestModel<RestDownloadsModel>
|
||||
{
|
||||
@Override
|
||||
public ModelAssertion<RestDownloadsModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestDownloadsModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestDownloadsModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestDownloadsModel model;
|
||||
|
||||
@Override
|
||||
public RestDownloadsModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String filesAdded;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String bytesAdded;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String totalBytes;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String id;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String totalFiles;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String status;
|
||||
|
||||
public RestDownloadsModel getModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(RestDownloadsModel model)
|
||||
{
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public String getFilesAdded()
|
||||
{
|
||||
return filesAdded;
|
||||
}
|
||||
|
||||
public void setFilesAdded(String filesAdded)
|
||||
{
|
||||
this.filesAdded = filesAdded;
|
||||
}
|
||||
|
||||
public String getBytesAdded()
|
||||
{
|
||||
return bytesAdded;
|
||||
}
|
||||
|
||||
public void setBytesAdded(String bytesAdded)
|
||||
{
|
||||
this.bytesAdded = bytesAdded;
|
||||
}
|
||||
|
||||
public String getTotalBytes()
|
||||
{
|
||||
return totalBytes;
|
||||
}
|
||||
|
||||
public void setTotalBytes(String totalBytes)
|
||||
{
|
||||
this.totalBytes = totalBytes;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTotalFiles()
|
||||
{
|
||||
return totalFiles;
|
||||
}
|
||||
|
||||
public void setTotalFiles(String totalFiles)
|
||||
{
|
||||
this.totalFiles = totalFiles;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,66 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
/**
|
||||
* Created by Meenal Bhave
|
||||
* "elements": [
|
||||
* {
|
||||
* "aspectNames": ["cm:titled", "cm:auditable", "app:uifacets"],
|
||||
* "id": "7f0c47ae-d334-4b66-a86b-1a60d2518ad1",
|
||||
* "name": "Folder-oawzdncUXFLgnFe",
|
||||
* "nodeType": "cm:folder"
|
||||
* }
|
||||
* ]
|
||||
*/
|
||||
|
||||
public class RestElementModel extends TestModel
|
||||
{
|
||||
private String name;
|
||||
private String id;
|
||||
private List<String> aspectNames;
|
||||
private String nodeType;
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<String> getAspectNames()
|
||||
{
|
||||
return aspectNames;
|
||||
}
|
||||
|
||||
public void setAspectNames(List<String> aspectNames)
|
||||
{
|
||||
this.aspectNames = aspectNames;
|
||||
}
|
||||
|
||||
public String getNodeType()
|
||||
{
|
||||
return nodeType;
|
||||
}
|
||||
|
||||
public void setNodeType(String nodeType)
|
||||
{
|
||||
this.nodeType = nodeType;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,86 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Generated by 'aforascu' on '2018-01-10 16:02' from 'Alfresco Content Services REST API' swagger file
|
||||
* Generated from 'Alfresco Content Services REST API' swagger file
|
||||
* Base Path {@linkplain /alfresco/api}
|
||||
*/
|
||||
public class RestEntitlementsInfoModel extends TestModel implements IRestModel<RestEntitlementsInfoModel>
|
||||
{
|
||||
@Override
|
||||
public ModelAssertion<RestEntitlementsInfoModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestEntitlementsInfoModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestEntitlementsInfoModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestEntitlementsInfoModel model;
|
||||
|
||||
@Override
|
||||
public RestEntitlementsInfoModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
private int maxUsers;
|
||||
|
||||
private int maxDocs;
|
||||
|
||||
private boolean isClusterEnabled;
|
||||
|
||||
private boolean isCryptodocEnabled;
|
||||
|
||||
public int getMaxUsers()
|
||||
{
|
||||
return this.maxUsers;
|
||||
}
|
||||
|
||||
public void setMaxUsers(int maxUsers)
|
||||
{
|
||||
this.maxUsers = maxUsers;
|
||||
}
|
||||
|
||||
public int getMaxDocs()
|
||||
{
|
||||
return this.maxDocs;
|
||||
}
|
||||
|
||||
public void setMaxDocs(int maxDocs)
|
||||
{
|
||||
this.maxDocs = maxDocs;
|
||||
}
|
||||
|
||||
public boolean getIsClusterEnabled()
|
||||
{
|
||||
return this.isClusterEnabled;
|
||||
}
|
||||
|
||||
public void setIsClusterEnabled(boolean isClusterEnabled)
|
||||
{
|
||||
this.isClusterEnabled = isClusterEnabled;
|
||||
}
|
||||
|
||||
public boolean getIsCryptodocEnabled()
|
||||
{
|
||||
return this.isCryptodocEnabled;
|
||||
}
|
||||
|
||||
public void setIsCryptodocEnabled(boolean isCryptodocEnabled)
|
||||
{
|
||||
this.isCryptodocEnabled = isCryptodocEnabled;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,187 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.Assert;
|
||||
|
||||
public class RestErrorModel
|
||||
{
|
||||
private String errorKey = "";
|
||||
private String logId = "";
|
||||
private int statusCode = 0;
|
||||
|
||||
private String briefSummary = "";
|
||||
private String stackTrace = "";
|
||||
private String descriptionURL = "";
|
||||
public static String PERMISSION_WAS_DENIED = "Permission was denied";
|
||||
public static String ENTITY_NOT_FOUND = "%s was not found";
|
||||
public static String ENTITY_WAS_NOT_FOUND = "The entity with id: %s was not found";
|
||||
public static String RELATIONSHIP_NOT_FOUND = "The relationship resource was not found for the entity with id: %s and a relationship id of %s";
|
||||
public static String AUTHENTICATION_FAILED = "Authentication failed";
|
||||
public static String INVALID_ARGUMENT = "An invalid %s was received";
|
||||
public static String UNABLE_TO_LOCATE = "Unable to locate resource";
|
||||
public static String NULL_ARGUMENT = "Must provide a non-null %s";
|
||||
public static String CANNOT_COMMENT = "Cannot comment on this node";
|
||||
public static String NON_NULL_COMMENT = "Must provide a non-null comment";
|
||||
public static String INVALID_RATING = "Invalid ratingSchemeId %s";
|
||||
public static String NO_CONTENT = "Could not read content from HTTP request body: %s";
|
||||
public static String NULL_LIKE_RATING = "Rating should be non-null and a boolean for 'likes' rating scheme";
|
||||
public static String NULL_FIVESTAR_RATING = "Rating should be non-null and an integer for 'fiveStar' rating scheme";
|
||||
public static String CANNOT_RATE = "Cannot rate this node";
|
||||
public static String CANNOT_TAG = "Cannot tag this node";
|
||||
public static String NOT_SUFFICIENT_PERMISSIONS = "The current user does not have sufficient permissions to delete membership details of the site %s";
|
||||
public static String DELETE_EMPTY_ARGUMENT = "DELETE not supported for Actions";
|
||||
public static String PUT_EMPTY_ARGUMENT = "PUT is executed against the instance URL";
|
||||
public static String TASK_INVALID_STATE = "The task state property has an invalid value: %s";
|
||||
public static String INVALID_MAXITEMS = "Invalid paging parameter maxItems:%s";
|
||||
public static String INVALID_SKIPCOUNT = "Invalid paging parameter skipCount:%s";
|
||||
public static String INVALID_TAG = "Tag name must not contain %s char sequence";
|
||||
public static String EMPTY_TAG = "New tag cannot be null";
|
||||
public static String UNKNOWN_ROLE = "Unknown role '%s'";
|
||||
public static String ALREADY_Site_MEMBER = "%s is already a member of site %s";
|
||||
public static String ALREADY_INVITED = "%s is already invited to site %s";
|
||||
public static String NOT_A_MEMBER = "User is not a member of the site";
|
||||
public static String ONLY_POSITIVE_VALUES_MAXITEMS = "Only positive values supported for maxItems";
|
||||
public static String NEGATIVE_VALUES_SKIPCOUNT = "Negative values not supported for skipCount";
|
||||
public static String PROCESS_ENTITY_NOT_FOUND = "The entity with id: Item %s not found in the process package variable was not found";
|
||||
public static String MUST_PROVIDE_ROLE = "Must provide a role";
|
||||
public static String INVALID_ORDERBY = "OrderBy %s is not supported, supported items are [%s]";
|
||||
public static String ONLY_ONE_ORDERBY = "Only one orderBy parameter is supported";
|
||||
public static String INVALID_WHERE_QUERY = "An invalid WHERE query was received. %s";
|
||||
public static String PROCESS_RUNNING_IN_ANOTHER_TENANT = "Process is running in another tenant";
|
||||
public static String ILLEGAL_SCOPE = "Illegal value for variable scope: '%s'.";
|
||||
public static String UNSUPPORTED_TYPE = "Unsupported type of variable: '%s'.";
|
||||
public static String PROPERTY_DOES_NOT_EXIST = "The property selected for update does not exist for this resource: %s";
|
||||
public static String PROPERTY_IS_NOT_SUPPORTED_EQUALS = "The property '%s' with value '%s' isn't supported for EQUALS comparison";
|
||||
public static String INVALID_VALUE = "The %s property has an invalid value: %s";
|
||||
public static String REQUIRED_TO_ADD = "%s is required to add an attached item";
|
||||
public static String ACCESS_INFORMATION_NOT_ALLOWED = "user is not allowed to access information about process %s";
|
||||
public static String TASK_ALREADY_COMPLETED = "Task with id: %s cannot be updated, it's completed";
|
||||
public static String DELEGATED_TASK_CAN_NOT_BE_COMPLETED = "A delegated task cannot be completed, but should be resolved instead.";
|
||||
public static String UNEXPECTED_TENANT = "Unexpected tenant: %s (contains %s)";
|
||||
public static String DELETE_LAST_MANAGER = "Can't remove last manager of site %s";
|
||||
public static String RATING_OUT_OF_BOUNDS = "Rating is out of bounds.";
|
||||
public static String ACCEPT_ME= "Please accept me";
|
||||
public static String NO_WORKFLOW_DEFINITION_FOUND = "No workflow definition could be found with key '%s'.";
|
||||
public static String INVALID_USER_ID = "%s is not a valid person user id";
|
||||
public static String TASK_ALREADY_CLAIMED = "The task is already claimed by another user.";
|
||||
public static String INVALID_SELECT = "An invalid SELECT query was received";
|
||||
public static String DELEGATING_ASSIGNEE_PROVIDED = "When delegating a task, assignee should be selected and provided in the request.";
|
||||
public static String INVALID_NAMEPACE_PREFIX="Namespace prefix %s is not mapped to a namespace URI";
|
||||
public static String FOR_INPUT_STRING ="For input string: \"%s\"";
|
||||
public static String UNRECOGNIZED_FIELD ="Unrecognized field \"%s\"";
|
||||
|
||||
public static String LOCAL_NAME_CONSISTANCE = "A QName must consist of a local name";
|
||||
public static String INVALID_PARAMETER_WHO = "Parameter who should be one of [me, others]";
|
||||
public static String NOT_FAVOURITE_SITE = "Site %s is not a favourite site";
|
||||
|
||||
public static String RESTAPIEXPLORER = "https://api-explorer.alfresco.com";
|
||||
public static String STACKTRACE = "For security reasons the stack trace is no longer displayed, but the property is kept for previous versions";
|
||||
public static String RELATIONSHIP_NOT_FOUND_ERRORKEY = "framework.exception.RelationshipNotFound";
|
||||
public static String ENTITY_NOT_FOUND_ERRORKEY = "framework.exception.EntityNotFound";
|
||||
public static String PERMISSION_DENIED_ERRORKEY = "framework.exception.PermissionDenied";
|
||||
public static String API_DEFAULT_ERRORKEY = "framework.exception.ApiDefault";
|
||||
public static String INVALID_QUERY_ERRORKEY = "framework.exception.InvalidQuery";
|
||||
public static String INVALID_PROPERTY_ERRORKEY = "framework.exception.InvalidProperty";
|
||||
public static String NOT_FOUND_ERRORKEY = "framework.exception.NotFound";
|
||||
public static String VARIABLE_NAME_REQUIRED = "Variable name is required.";
|
||||
public static String MANDATORY_PARAM = "%s is a mandatory parameter";
|
||||
public static String MANDATORY_COLLECTION = "%s collection must contain at least one item";
|
||||
public static String INVALID_SELECT_ERRORKEY = "framework.exception.InvalidSelect";
|
||||
public static String LOCKED_NODE_OPERATION = "Cannot perform operation since the node (id:%s) is locked.";
|
||||
public static String LOCKED_NODE_SUMMARY = "The node (id: %s) could not be locked since it is already locked by another user.";
|
||||
|
||||
public String getErrorKey()
|
||||
{
|
||||
return errorKey;
|
||||
}
|
||||
|
||||
public void setErrorKey(String errorKey)
|
||||
{
|
||||
this.errorKey = errorKey;
|
||||
}
|
||||
|
||||
public int getStatusCode()
|
||||
{
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public void setStatusCode(int statusCode)
|
||||
{
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
public String getBriefSummary()
|
||||
{
|
||||
return briefSummary;
|
||||
}
|
||||
|
||||
public void setBriefSummary(String briefSummary)
|
||||
{
|
||||
this.briefSummary = briefSummary;
|
||||
}
|
||||
|
||||
public String getStackTrace()
|
||||
{
|
||||
return stackTrace;
|
||||
}
|
||||
|
||||
public void setStackTrace(String stackTrace)
|
||||
{
|
||||
this.stackTrace = stackTrace;
|
||||
}
|
||||
|
||||
public String getDescriptionURL()
|
||||
{
|
||||
return descriptionURL;
|
||||
}
|
||||
|
||||
public void setDescriptionURL(String descriptionURL)
|
||||
{
|
||||
this.descriptionURL = descriptionURL;
|
||||
}
|
||||
|
||||
public String getLogId()
|
||||
{
|
||||
return logId;
|
||||
}
|
||||
|
||||
public void setLogId(String logId)
|
||||
{
|
||||
this.logId = logId;
|
||||
}
|
||||
|
||||
public RestErrorModel containsSummary(String summary)
|
||||
{
|
||||
if (!getBriefSummary().contains(summary))
|
||||
Assert.fail(String.format("Expected [%s] error to be found in actual briefSummary returned by server: %s", summary, getBriefSummary()));
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestErrorModel containsErrorKey(String expected)
|
||||
{
|
||||
if (!getErrorKey().contains(expected))
|
||||
Assert.fail(String.format("Expected [%s] error to be found in actual errorKey returned by server: %s", expected, getErrorKey()));
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestErrorModel statusCodeIs(HttpStatus statusCode)
|
||||
{
|
||||
if (getStatusCode() != statusCode.value())
|
||||
Assert.fail(String.format("Expected [%s] to be found. Actual statusCode returned by server is [%s]", statusCode, getStatusCode()));
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestErrorModel descriptionURLIs(String expected)
|
||||
{
|
||||
if (!getDescriptionURL().equals(expected))
|
||||
Assert.fail(String.format("Expected [%s] to be found. Actual descriptionURL returned by server is [%s]", expected, getDescriptionURL()));
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestErrorModel stackTraceIs(String expected)
|
||||
{
|
||||
if (!getStackTrace().equals(expected))
|
||||
Assert.fail(String.format("Expected [%s] to be found. Actual stackTrace returned by server is [%s]", expected, getStackTrace()));
|
||||
return this;
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class RestFavoriteSiteModel extends TestModel implements IRestModel<RestFavoriteSiteModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestFavoriteSiteModel model;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
String id;
|
||||
|
||||
@Override
|
||||
public RestFavoriteSiteModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestFavoriteSiteModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestFavoriteSiteModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestFavoriteSiteModel>(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,260 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Handles single Folder JSON responses
|
||||
* Example:
|
||||
"createdAt": "2016-10-03T09:48:52.385+0000",
|
||||
"sizeInBytes": 19,
|
||||
"versionLabel": "1.0",
|
||||
"createdBy": "admin",
|
||||
"modifiedAt": "2016-10-03T09:48:52.385+0000",
|
||||
"name": "file-OUQAyqdsNi.txt",
|
||||
"guid": "00f6b250-a841-4ff6-b660-5b45cee30497",
|
||||
"modifiedBy": "admin",
|
||||
"mimeType": "text/plain",
|
||||
"id": "00f6b250-a841-4ff6-b660-5b45cee30497"
|
||||
*/
|
||||
|
||||
public class RestFileModel extends TestModel implements IRestModel<RestFileModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestFileModel model;
|
||||
|
||||
@Override
|
||||
public RestFileModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
@JsonProperty(required = true)
|
||||
protected String createdAt;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
protected String sizeInBytes;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
protected String versionLabel;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
protected String createdBy;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
protected String modifiedAt;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
protected String name;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
protected String guid;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
protected String modifiedBy;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
protected String mimeType;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
protected String id;
|
||||
|
||||
@JsonProperty(required = false)
|
||||
RestPathModel path;
|
||||
|
||||
private boolean isFile;
|
||||
private boolean isFolder;
|
||||
private RestByUserModel createdByUser;
|
||||
private RestByUserModel modifiedByUser;
|
||||
private RestContentModel content;
|
||||
private String parentId;
|
||||
|
||||
public RestFileModel()
|
||||
{
|
||||
}
|
||||
|
||||
public String getCreatedAt()
|
||||
{
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(String createdAt)
|
||||
{
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public String getSizeInBytes()
|
||||
{
|
||||
return sizeInBytes;
|
||||
}
|
||||
|
||||
public void setSizeInBytes(String sizeInBytes)
|
||||
{
|
||||
this.sizeInBytes = sizeInBytes;
|
||||
}
|
||||
|
||||
public String getVersionLabel()
|
||||
{
|
||||
return versionLabel;
|
||||
}
|
||||
|
||||
public void setVersionLabel(String versionLabel)
|
||||
{
|
||||
this.versionLabel = versionLabel;
|
||||
}
|
||||
|
||||
public String getCreatedBy()
|
||||
{
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
public void setCreatedBy(String createdBy)
|
||||
{
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
public String getModifiedBy()
|
||||
{
|
||||
return modifiedBy;
|
||||
}
|
||||
|
||||
public void setModifiedBy(String modifiedBy)
|
||||
{
|
||||
this.modifiedBy = modifiedBy;
|
||||
}
|
||||
|
||||
public String getModifiedAt()
|
||||
{
|
||||
return modifiedAt;
|
||||
}
|
||||
|
||||
public void setModifiedAt(String modifiedAt)
|
||||
{
|
||||
this.modifiedAt = modifiedAt;
|
||||
}
|
||||
|
||||
public String getGuid()
|
||||
{
|
||||
return guid;
|
||||
}
|
||||
|
||||
public void setGuid(String guid)
|
||||
{
|
||||
this.guid = guid;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getMimeType()
|
||||
{
|
||||
return mimeType;
|
||||
}
|
||||
|
||||
public void setMimeType(String mimeType)
|
||||
{
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
public boolean getIsFile()
|
||||
{
|
||||
return isFile;
|
||||
}
|
||||
|
||||
public void setIsFile(boolean isFile)
|
||||
{
|
||||
this.isFile = isFile;
|
||||
}
|
||||
|
||||
public RestByUserModel getCreatedByUser()
|
||||
{
|
||||
return createdByUser;
|
||||
}
|
||||
|
||||
public void setCreatedByUser(RestByUserModel createdByUser)
|
||||
{
|
||||
this.createdByUser = createdByUser;
|
||||
}
|
||||
|
||||
public RestByUserModel getModifiedByUser()
|
||||
{
|
||||
return modifiedByUser;
|
||||
}
|
||||
|
||||
public void setModifiedByUser(RestByUserModel modifiedByUser)
|
||||
{
|
||||
this.modifiedByUser = modifiedByUser;
|
||||
}
|
||||
|
||||
public RestContentModel getContent()
|
||||
{
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(RestContentModel content)
|
||||
{
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getParentId()
|
||||
{
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public boolean getIsFolder()
|
||||
{
|
||||
return isFolder;
|
||||
}
|
||||
|
||||
public void setIsFolder(boolean isFolder)
|
||||
{
|
||||
this.isFolder = isFolder;
|
||||
}
|
||||
|
||||
public RestPathModel getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(RestPathModel path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestFileModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestFileModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestFileModel>(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,207 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Handles single Folder JSON responses
|
||||
* Example:
|
||||
"createdAt": "2016-10-03T08:15:08.722+0000",
|
||||
"createdBy": "admin",
|
||||
"modifiedAt": "2016-10-03T08:15:08.722+0000",
|
||||
"name": "Folder-EJJXzPAauf",
|
||||
"guid": "fd84a762-7fea-4ed8-b9cd-7622ab966ac4",
|
||||
"modifiedBy": "admin",
|
||||
"id": "fd84a762-7fea-4ed8-b9cd-7622ab966ac4"
|
||||
*/
|
||||
|
||||
public class RestFolderModel extends TestModel implements IRestModel<RestFolderModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestFolderModel model;
|
||||
|
||||
@Override
|
||||
public RestFolderModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
@JsonProperty(required = true)
|
||||
protected String createdAt;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
protected String createdBy;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
protected String modifiedAt;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
protected String name;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
protected String guid;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
protected String modifiedBy;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
protected String id;
|
||||
|
||||
@JsonProperty(required = false)
|
||||
RestPathModel path;
|
||||
|
||||
private boolean isFolder;
|
||||
private boolean isFile;
|
||||
private RestByUserModel createdByUser;
|
||||
private RestByUserModel modifiedByUser;
|
||||
private String parentId;
|
||||
|
||||
public RestFolderModel()
|
||||
{
|
||||
}
|
||||
|
||||
public String getCreatedAt()
|
||||
{
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(String createdAt)
|
||||
{
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public String getCreatedBy()
|
||||
{
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
public void setCreatedBy(String createdBy)
|
||||
{
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
public String getModifiedBy()
|
||||
{
|
||||
return modifiedBy;
|
||||
}
|
||||
|
||||
public void setModifiedBy(String modifiedBy)
|
||||
{
|
||||
this.modifiedBy = modifiedBy;
|
||||
}
|
||||
|
||||
public String getModifiedAt()
|
||||
{
|
||||
return modifiedAt;
|
||||
}
|
||||
|
||||
public void setModifiedAt(String modifiedAt)
|
||||
{
|
||||
this.modifiedAt = modifiedAt;
|
||||
}
|
||||
|
||||
public String getGuid()
|
||||
{
|
||||
return guid;
|
||||
}
|
||||
|
||||
public void setGuid(String guid)
|
||||
{
|
||||
this.guid = guid;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean getIsFolder()
|
||||
{
|
||||
return isFolder;
|
||||
}
|
||||
|
||||
public void setIsFolder(boolean isFolder)
|
||||
{
|
||||
this.isFolder = isFolder;
|
||||
}
|
||||
|
||||
public boolean getIsFile()
|
||||
{
|
||||
return isFile;
|
||||
}
|
||||
|
||||
public void setIsFile(boolean isFile)
|
||||
{
|
||||
this.isFile = isFile;
|
||||
}
|
||||
|
||||
public RestByUserModel getCreatedByUser()
|
||||
{
|
||||
return createdByUser;
|
||||
}
|
||||
|
||||
public void setCreatedByUser(RestByUserModel createdByUser)
|
||||
{
|
||||
this.createdByUser = createdByUser;
|
||||
}
|
||||
|
||||
public RestByUserModel getModifiedByUser()
|
||||
{
|
||||
return modifiedByUser;
|
||||
}
|
||||
|
||||
public void setModifiedByUser(RestByUserModel modifiedByUser)
|
||||
{
|
||||
this.modifiedByUser = modifiedByUser;
|
||||
}
|
||||
|
||||
public String getParentId()
|
||||
{
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public RestPathModel getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(RestPathModel path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestFolderModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestFolderModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestFolderModel>(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,127 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Handles single representation of a Start Form Model
|
||||
* * "entry": {
|
||||
* "allowedValues": [
|
||||
* "1",
|
||||
* "2",
|
||||
* "3"
|
||||
* ],
|
||||
* "qualifiedName": "{http://www.alfresco.org/model/bpm/1.0}workflowPriority",
|
||||
* "defaultValue": "2",
|
||||
* "dataType": "d:int",
|
||||
* "name": "bpm_workflowPriority",
|
||||
* "title": "Workflow Priority",
|
||||
* "required": false
|
||||
* }
|
||||
* Created by Claudia Agache on 10/18/2016.
|
||||
*/
|
||||
public class RestFormModel extends TestModel implements IRestModel<RestFormModel>
|
||||
{
|
||||
@JsonProperty(value = "entry") RestFormModel model;
|
||||
private String qualifiedName;
|
||||
private String defaultValue;
|
||||
private String dataType;
|
||||
private String name;
|
||||
private String title;
|
||||
private String required;
|
||||
private String[] allowedValues;
|
||||
|
||||
public RestFormModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public String[] getAllowedValues()
|
||||
{
|
||||
return allowedValues;
|
||||
}
|
||||
|
||||
public void setAllowedValues(String[] allowedValues)
|
||||
{
|
||||
this.allowedValues = allowedValues;
|
||||
}
|
||||
|
||||
public String getQualifiedName()
|
||||
{
|
||||
return qualifiedName;
|
||||
}
|
||||
|
||||
public void setQualifiedName(String qualifiedName)
|
||||
{
|
||||
this.qualifiedName = qualifiedName;
|
||||
}
|
||||
|
||||
public String getDefaultValue()
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setDefaultValue(String defaultValue)
|
||||
{
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public String getDataType()
|
||||
{
|
||||
return dataType;
|
||||
}
|
||||
|
||||
public void setDataType(String dataType)
|
||||
{
|
||||
this.dataType = dataType;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getRequired()
|
||||
{
|
||||
return required;
|
||||
}
|
||||
|
||||
public void setRequired(String required)
|
||||
{
|
||||
this.required = required;
|
||||
}
|
||||
|
||||
/**
|
||||
* DSL for assertion on this rest model
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ModelAssertion<RestFormModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestFormModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestFormModel>(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
/**
|
||||
* Handle collection of <RestFormModel>
|
||||
* "entries": [
|
||||
* "entry": {
|
||||
* "qualifiedName": "{http://www.alfresco.org/model/bpm/1.0}reassignable",
|
||||
* "defaultValue": "true",
|
||||
* "dataType": "d:boolean",
|
||||
* "name": "bpm_reassignable",
|
||||
* "required": false
|
||||
* }
|
||||
* },
|
||||
* {
|
||||
* "entry": {
|
||||
* "allowedValues": [
|
||||
* "1",
|
||||
* "2",
|
||||
* "3"
|
||||
* ],
|
||||
* "qualifiedName": "{http://www.alfresco.org/model/bpm/1.0}workflowPriority",
|
||||
* "defaultValue": "2",
|
||||
* "dataType": "d:int",
|
||||
* "name": "bpm_workflowPriority",
|
||||
* "title": "Workflow Priority",
|
||||
* "required": false
|
||||
* }
|
||||
* },
|
||||
* ]
|
||||
* Created by Claudia Agache on 10/18/2016.
|
||||
*/
|
||||
public class RestFormModelsCollection extends RestModels<RestFormModel, RestFormModelsCollection>
|
||||
{
|
||||
public RestFormModel getStartFormModelByQualifiedName(String qualifiedName)
|
||||
{
|
||||
STEP(String.format("REST API: Get start form model by qualified name '%s'", qualifiedName));
|
||||
List<RestFormModel> startFormModels = getEntries();
|
||||
|
||||
for (RestFormModel startFormModel: startFormModels)
|
||||
{
|
||||
if (startFormModel.onModel().getQualifiedName().equals(qualifiedName))
|
||||
{
|
||||
return startFormModel.onModel();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,131 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.rest.search.RestGenericMetricModel;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Generated by 'msuzuki' on '2017-05-15 13:08' from 'Alfresco Search REST API' swagger file
|
||||
* Generated from 'Alfresco Search REST API' swagger file
|
||||
* Base Path {@linkplain /alfresco/api/-default-/public/search/versions/1}
|
||||
*/
|
||||
public class RestGenericBucketModel extends TestModel implements IRestModel<RestGenericBucketModel>
|
||||
{
|
||||
@Override
|
||||
public ModelAssertion<RestGenericBucketModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestGenericBucketModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestGenericBucketModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestGenericBucketModel model;
|
||||
|
||||
@Override
|
||||
public RestGenericBucketModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
The bucket label
|
||||
*/
|
||||
|
||||
private String label;
|
||||
/**
|
||||
The filter query you can use to apply this facet
|
||||
*/
|
||||
|
||||
private String filterQuery;
|
||||
/**
|
||||
An optional field for additional display information
|
||||
*/
|
||||
|
||||
private Object display;
|
||||
/**
|
||||
An array of buckets and values
|
||||
*/
|
||||
|
||||
private List<RestGenericMetricModel> metrics;
|
||||
/**
|
||||
Additional list of nested facets
|
||||
*/
|
||||
|
||||
private List<Object> facets;
|
||||
/**
|
||||
Additional information of nested facet
|
||||
*/
|
||||
|
||||
private Object facetInfo;
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return this.label;
|
||||
}
|
||||
|
||||
public void setLabel(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getFilterQuery()
|
||||
{
|
||||
return this.filterQuery;
|
||||
}
|
||||
|
||||
public void setFilterQuery(String filterQuery)
|
||||
{
|
||||
this.filterQuery = filterQuery;
|
||||
}
|
||||
|
||||
public Object getDisplay()
|
||||
{
|
||||
return this.display;
|
||||
}
|
||||
|
||||
public void setDisplay(Object display)
|
||||
{
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public List<RestGenericMetricModel> getMetrics()
|
||||
{
|
||||
return this.metrics;
|
||||
}
|
||||
|
||||
public void setMetrics(List<RestGenericMetricModel> metrics)
|
||||
{
|
||||
this.metrics = metrics;
|
||||
}
|
||||
|
||||
public List<Object> getFacets()
|
||||
{
|
||||
return this.facets;
|
||||
}
|
||||
|
||||
public void setFacets(List<Object> facets)
|
||||
{
|
||||
this.facets = facets;
|
||||
}
|
||||
|
||||
public Object getFacetInfo()
|
||||
{
|
||||
return this.facetInfo;
|
||||
}
|
||||
|
||||
public void setFacetInfo(Object facetInfo)
|
||||
{
|
||||
this.facetInfo = facetInfo;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,69 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class RestGroupMember extends TestModel implements IRestModel<RestGroupMember>
|
||||
{
|
||||
@JsonProperty(required = true)
|
||||
private String id;
|
||||
@JsonProperty(required = true)
|
||||
private String displayName;
|
||||
@JsonProperty(required = true)
|
||||
private String memberType;
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestGroupMember model;
|
||||
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestGroupMember> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestGroupMember> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestGroupMember>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestGroupMember onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDisplayName()
|
||||
{
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName)
|
||||
{
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getMemberType()
|
||||
{
|
||||
return memberType;
|
||||
}
|
||||
|
||||
public void setMemberType(String memberType)
|
||||
{
|
||||
this.memberType = memberType;
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
public class RestGroupMemberModelsCollection extends RestModels<RestGroupMember, RestGroupMemberModelsCollection>
|
||||
{
|
||||
}
|
@@ -0,0 +1,96 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class RestGroupsModel extends TestModel implements IRestModel<RestGroupsModel>
|
||||
{
|
||||
@JsonProperty(required = true)
|
||||
private String id;
|
||||
@JsonProperty(required = true)
|
||||
private String displayName;
|
||||
@JsonProperty(required = true)
|
||||
private Boolean isRoot;
|
||||
|
||||
@JsonProperty("parentIds")
|
||||
private ArrayList<String> parentIds;
|
||||
@JsonProperty("zones")
|
||||
private ArrayList<String> zones;
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestGroupsModel model;
|
||||
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestGroupsModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestGroupsModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestGroupsModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestGroupsModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getDisplayName()
|
||||
{
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName)
|
||||
{
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public Boolean getIsRoot()
|
||||
{
|
||||
return isRoot;
|
||||
}
|
||||
|
||||
public void setIsRoot(Boolean isRoot)
|
||||
{
|
||||
this.isRoot = isRoot;
|
||||
}
|
||||
|
||||
public ArrayList<String> getParentIds()
|
||||
{
|
||||
return parentIds;
|
||||
}
|
||||
|
||||
public void setParentIds(ArrayList<String> parentIds)
|
||||
{
|
||||
this.parentIds = parentIds;
|
||||
}
|
||||
|
||||
public ArrayList<String> getZones()
|
||||
{
|
||||
return zones;
|
||||
}
|
||||
|
||||
public void setZones(ArrayList<String> zones)
|
||||
{
|
||||
this.zones = zones;
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
public class RestGroupsModelsCollection extends RestModels<RestGroupsModel, RestGroupsModelsCollection>
|
||||
{
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.testng.Assert;
|
||||
|
||||
import io.restassured.http.Headers;
|
||||
import io.restassured.response.ResponseBody;
|
||||
|
||||
/**
|
||||
* Created by Claudia Agache on 10/13/2016.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class RestHtmlResponse
|
||||
{
|
||||
private Headers headers;
|
||||
private ResponseBody body;
|
||||
|
||||
/**
|
||||
* @return the {@link ResponseBody}
|
||||
*/
|
||||
public ResponseBody getBody()
|
||||
{
|
||||
return body;
|
||||
}
|
||||
|
||||
public RestHtmlResponse(Headers headers, ResponseBody body)
|
||||
{
|
||||
this.headers = headers;
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public void assertResponseContainsImage() throws Exception
|
||||
{
|
||||
STEP("REST API: Assert that response has an image.");
|
||||
Utility.checkObjectIsInitialized(headers, "Headers");
|
||||
Utility.checkObjectIsInitialized(body, "Body");
|
||||
Assert.assertTrue(headers.getValue("content-type").contains("image/png"),
|
||||
String.format("Content type is not an image. Actual content type is %s", headers.getValue("content-type")));
|
||||
Assert.assertNotEquals(headers.getValue("content-length"), "0", "Content length should be greater than 0 bytes.");
|
||||
Assert.assertFalse(body.toString().isEmpty(), "Body should not be empty.");
|
||||
}
|
||||
|
||||
/**
|
||||
* DSL for assertion on this rest model
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ModelAssertion<RestHtmlResponse> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestHtmlResponse>(this);
|
||||
}
|
||||
|
||||
public ModelAssertion<RestHtmlResponse> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assetion that a html element with specific html path has the specified value
|
||||
*
|
||||
* @param elementHtmlPath the HTML path of the HTML element
|
||||
* @param value value of the field
|
||||
*/
|
||||
public void assertPathInHtmlBodyEquals(String elementHtmlPath, String value)
|
||||
{
|
||||
Assert.assertEquals(body.htmlPath().get(elementHtmlPath), value);
|
||||
}
|
||||
}
|
@@ -0,0 +1,120 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
"entry": {
|
||||
"createdAt": "2016-10-13T11:21:34.621+0000",
|
||||
"size": 19,
|
||||
"createdBy": "admin",
|
||||
"modifiedAt": "2016-10-13T11:21:38.338+0000",
|
||||
"name": "file-yCQFYpLniWAzkcR.txt",
|
||||
"modifiedBy": "User-cchKFZoNIAfZXXn",
|
||||
"id": "ffb7178f-fc11-41c9-8c40-df6523ad917f",
|
||||
"mimeType": "text/plain"
|
||||
}
|
||||
*
|
||||
*/
|
||||
public class RestItemModel extends TestModel implements IRestModel<RestItemModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestItemModel model;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String createdAt;
|
||||
private int size;
|
||||
private String createdBy;
|
||||
private String modifiedAt;
|
||||
private String name;
|
||||
private String modifiedBy;
|
||||
private String id;
|
||||
private String mimeType;
|
||||
|
||||
@Override
|
||||
public RestItemModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getCreatedAt()
|
||||
{
|
||||
return createdAt;
|
||||
}
|
||||
public void setCreatedAt(String createdAt)
|
||||
{
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
public int getSize()
|
||||
{
|
||||
return size;
|
||||
}
|
||||
public void setSize(int size)
|
||||
{
|
||||
this.size = size;
|
||||
}
|
||||
public String getCreatedBy()
|
||||
{
|
||||
return createdBy;
|
||||
}
|
||||
public void setCreatedBy(String createdBy)
|
||||
{
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
public String getModifiedBy()
|
||||
{
|
||||
return modifiedBy;
|
||||
}
|
||||
public void setModifiedBy(String modifiedBy)
|
||||
{
|
||||
this.modifiedBy = modifiedBy;
|
||||
}
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
public String getMimeType()
|
||||
{
|
||||
return mimeType;
|
||||
}
|
||||
public void setMimeType(String mimeType)
|
||||
{
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
public String getModifiedAt()
|
||||
{
|
||||
return modifiedAt;
|
||||
}
|
||||
public void setModifiedAt(String modifiedAt)
|
||||
{
|
||||
this.modifiedAt = modifiedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestItemModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestItemModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestItemModel>(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
/**
|
||||
* Handles collection of Processes
|
||||
*
|
||||
* Example:
|
||||
* "entries": [
|
||||
{
|
||||
"entry": {
|
||||
"createdAt": "2016-10-13T11:21:34.621+0000",
|
||||
"size": 19,
|
||||
"createdBy": "admin",
|
||||
"modifiedAt": "2016-10-13T11:21:38.338+0000",
|
||||
"name": "file-yCQFYpLniWAzkcR.txt",
|
||||
"modifiedBy": "User-cchKFZoNIAfZXXn",
|
||||
"id": "ffb7178f-fc11-41c9-8c40-df6523ad917f",
|
||||
"mimeType": "text/plain"
|
||||
}
|
||||
}
|
||||
]
|
||||
*/
|
||||
public class RestItemModelsCollection extends RestModels<RestItemModel, RestItemModelsCollection>
|
||||
{
|
||||
public RestItemModel getProcessItemByName(String name)
|
||||
{
|
||||
STEP(String.format("REST API: Get process item entry with name '%s'", name));
|
||||
List<RestItemModel> processItemsList = getEntries();
|
||||
|
||||
for (RestItemModel item: processItemsList)
|
||||
{
|
||||
if (item.onModel().getName().equals(name))
|
||||
{
|
||||
return item.onModel();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,115 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Generated by 'aforascu' on '2018-01-10 16:02' from 'Alfresco Content Services REST API' swagger file
|
||||
* Generated from 'Alfresco Content Services REST API' swagger file
|
||||
* Base Path {@linkplain /alfresco/api}
|
||||
*/
|
||||
public class RestLicenseInfoModel extends TestModel implements IRestModel<RestLicenseInfoModel>
|
||||
{
|
||||
@Override
|
||||
public ModelAssertion<RestLicenseInfoModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestLicenseInfoModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestLicenseInfoModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestLicenseInfoModel model;
|
||||
|
||||
@Override
|
||||
public RestLicenseInfoModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String issuedAt;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String expiresAt;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private int remainingDays;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String holder;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String mode;
|
||||
|
||||
private RestEntitlementsInfoModel entitlements;
|
||||
|
||||
public String getIssuedAt()
|
||||
{
|
||||
return this.issuedAt;
|
||||
}
|
||||
|
||||
public void setIssuedAt(String issuedAt)
|
||||
{
|
||||
this.issuedAt = issuedAt;
|
||||
}
|
||||
|
||||
public String getExpiresAt()
|
||||
{
|
||||
return this.expiresAt;
|
||||
}
|
||||
|
||||
public void setExpiresAt(String expiresAt)
|
||||
{
|
||||
this.expiresAt = expiresAt;
|
||||
}
|
||||
|
||||
public int getRemainingDays()
|
||||
{
|
||||
return this.remainingDays;
|
||||
}
|
||||
|
||||
public void setRemainingDays(int remainingDays)
|
||||
{
|
||||
this.remainingDays = remainingDays;
|
||||
}
|
||||
|
||||
public String getHolder()
|
||||
{
|
||||
return this.holder;
|
||||
}
|
||||
|
||||
public void setHolder(String holder)
|
||||
{
|
||||
this.holder = holder;
|
||||
}
|
||||
|
||||
public String getMode()
|
||||
{
|
||||
return this.mode;
|
||||
}
|
||||
|
||||
public void setMode(String mode)
|
||||
{
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public RestEntitlementsInfoModel getEntitlements()
|
||||
{
|
||||
return this.entitlements;
|
||||
}
|
||||
|
||||
public void setEntitlements(RestEntitlementsInfoModel entitlements)
|
||||
{
|
||||
this.entitlements = entitlements;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,134 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Generated by 'aforascu' on '2018-01-10 16:02' from 'Alfresco Content Services REST API' swagger file
|
||||
* Generated from 'Alfresco Content Services REST API' swagger file
|
||||
* Base Path {@linkplain /alfresco/api}
|
||||
*/
|
||||
public class RestModuleInfoModel extends TestModel implements IRestModel<RestModuleInfoModel>
|
||||
{
|
||||
@Override
|
||||
public ModelAssertion<RestModuleInfoModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestModuleInfoModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestModuleInfoModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestModuleInfoModel model;
|
||||
|
||||
@Override
|
||||
public RestModuleInfoModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
private String id;
|
||||
|
||||
private String title;
|
||||
|
||||
private String description;
|
||||
|
||||
private String version;
|
||||
|
||||
private String installDate;
|
||||
|
||||
private String installState;
|
||||
|
||||
private String versionMin;
|
||||
|
||||
private String versionMax;
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public void setVersion(String version)
|
||||
{
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getInstallDate()
|
||||
{
|
||||
return this.installDate;
|
||||
}
|
||||
|
||||
public void setInstallDate(String installDate)
|
||||
{
|
||||
this.installDate = installDate;
|
||||
}
|
||||
|
||||
public String getInstallState()
|
||||
{
|
||||
return this.installState;
|
||||
}
|
||||
|
||||
public void setInstallState(String installState)
|
||||
{
|
||||
this.installState = installState;
|
||||
}
|
||||
|
||||
public String getVersionMin()
|
||||
{
|
||||
return this.versionMin;
|
||||
}
|
||||
|
||||
public void setVersionMin(String versionMin)
|
||||
{
|
||||
this.versionMin = versionMin;
|
||||
}
|
||||
|
||||
public String getVersionMax()
|
||||
{
|
||||
return this.versionMax;
|
||||
}
|
||||
|
||||
public void setVersionMax(String versionMax)
|
||||
{
|
||||
this.versionMax = versionMax;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,83 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import static org.alfresco.utility.report.log.Step.STEP;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.testng.Assert;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Created by Cristina Axinte on 9/26/2016.
|
||||
*
|
||||
* {
|
||||
"entry": {
|
||||
"id": "string",
|
||||
"homeNetwork": true,
|
||||
"isEnabled": true,
|
||||
"createdAt": "2016-09-26T11:33:36.343Z",
|
||||
"paidNetwork": true,
|
||||
"subscriptionLevel": "Free",
|
||||
"quotas": [
|
||||
{
|
||||
"id": "string",
|
||||
"limit": 0,
|
||||
"usage": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
*
|
||||
*/
|
||||
public class RestNetworkModel extends RestPersonNetworkModel implements IRestModel<RestNetworkModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestNetworkModel model;
|
||||
|
||||
@Override
|
||||
public RestNetworkModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public RestNetworkModel assertNetworkHasName(UserModel user)
|
||||
{
|
||||
STEP(String.format("REST API: Assert that network has name '%s'", user.getDomain()));
|
||||
Assert.assertTrue(getId().equalsIgnoreCase(user.getDomain()), "Network doesn't have the expected name.");
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public RestNetworkModel assertNetworkIsEnabled()
|
||||
{
|
||||
STEP(String.format("REST API: Assert network is enabled"));
|
||||
Assert.assertEquals(isEnabled(), true, "Network should be enabled.");
|
||||
|
||||
return this;
|
||||
}
|
||||
public RestNetworkModel assertNetworkIsNotEnabled()
|
||||
{
|
||||
STEP(String.format("REST API: Assert that network is disable"));
|
||||
Assert.assertEquals(isEnabled(), false, "Network should be disabled.");
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* DSL for assertion on this rest model
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ModelAssertion<RestNetworkModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestNetworkModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestNetworkModel>(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
public class RestNetworkModelsCollection extends RestModels<RestNetworkModel, RestNetworkModelsCollection>
|
||||
{
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Generated by 'pbrodner' on '2016-12-19 14:12' from 'Alfresco Core REST API' swagger file
|
||||
* Base Path {@linkplain /alfresco/api/-default-/public/alfresco/versions/1}
|
||||
*/
|
||||
public class RestNetworkQuotaModel extends TestModel implements IRestModel<RestNetworkQuotaModel>
|
||||
{
|
||||
@Override
|
||||
public ModelAssertion<RestNetworkQuotaModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestNetworkQuotaModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestNetworkQuotaModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestNetworkQuotaModel model;
|
||||
|
||||
@Override
|
||||
public RestNetworkQuotaModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String id;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private int limit;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private int usage;
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getLimit()
|
||||
{
|
||||
return this.limit;
|
||||
}
|
||||
|
||||
public void setLimit(int limit)
|
||||
{
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
public int getUsage()
|
||||
{
|
||||
return this.usage;
|
||||
}
|
||||
|
||||
public void setUsage(int usage)
|
||||
{
|
||||
this.usage = usage;
|
||||
}
|
||||
}
|
@@ -0,0 +1,68 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class RestNodeAssocTargetModel extends TestModel implements IRestModel<RestNodeAssocTargetModel>
|
||||
{
|
||||
@JsonProperty(value = "aggregate")
|
||||
RestNodeAssocTargetModel model;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String targetId;
|
||||
@JsonProperty(required = true)
|
||||
private String assocType;
|
||||
|
||||
public RestNodeAssocTargetModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public RestNodeAssocTargetModel(String targetId, String assocType)
|
||||
{
|
||||
this.targetId = targetId;
|
||||
this.assocType = assocType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestNodeAssocTargetModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getTargetId()
|
||||
{
|
||||
return targetId;
|
||||
}
|
||||
|
||||
public void setTargetId(String targetId)
|
||||
{
|
||||
this.targetId = targetId;
|
||||
}
|
||||
|
||||
public String getAssocType()
|
||||
{
|
||||
return assocType;
|
||||
}
|
||||
|
||||
public void setAssocType(String assocType)
|
||||
{
|
||||
this.assocType = assocType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestNodeAssocTargetModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestNodeAssocTargetModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestNodeAssocTargetModel>(this);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,314 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Created by Andrei Forascu on 30/08/2017.
|
||||
*/
|
||||
public class RestNodeAssociationModel extends TestModel implements IRestModel<RestNodeAssociationModel>
|
||||
{
|
||||
@Override
|
||||
public ModelAssertion<RestNodeAssociationModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestNodeAssociationModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestNodeAssociationModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestNodeAssociationModel model;
|
||||
|
||||
@Override
|
||||
public RestNodeAssociationModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* The name must not contain spaces or the following special characters: * " < > \ / ? : and |.
|
||||
* The character . must not be used at the end of the name.
|
||||
*/
|
||||
@JsonProperty(required = true)
|
||||
private String name;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String nodeType;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private boolean isFolder;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private boolean isFile;
|
||||
|
||||
private boolean isLocked;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String modifiedAt;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private RestByUserModel modifiedByUser;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String createdAt;
|
||||
|
||||
@JsonProperty
|
||||
private String archivedAt;
|
||||
|
||||
@JsonProperty
|
||||
private RestByUserModel archivedByUser;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private RestByUserModel createdByUser;
|
||||
|
||||
private String parentId;
|
||||
|
||||
private boolean isLink;
|
||||
|
||||
private RestContentModel content;
|
||||
|
||||
private List<String> aspectNames;
|
||||
|
||||
private Object properties;
|
||||
|
||||
private List<String> allowableOperations;
|
||||
|
||||
private Object path;
|
||||
|
||||
private Object permissions;
|
||||
|
||||
private RestNodeAssociationTypeModel association;
|
||||
|
||||
public RestNodeAssociationTypeModel getAssociation()
|
||||
{
|
||||
return association;
|
||||
}
|
||||
|
||||
public void setAssociation(RestNodeAssociationTypeModel association)
|
||||
{
|
||||
this.association = association;
|
||||
}
|
||||
|
||||
public RestNodeAssociationModel getModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(RestNodeAssociationModel model)
|
||||
{
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getNodeType()
|
||||
{
|
||||
return nodeType;
|
||||
}
|
||||
|
||||
public void setNodeType(String nodeType)
|
||||
{
|
||||
this.nodeType = nodeType;
|
||||
}
|
||||
|
||||
public boolean isFolder()
|
||||
{
|
||||
return isFolder;
|
||||
}
|
||||
|
||||
public void setFolder(boolean isFolder)
|
||||
{
|
||||
this.isFolder = isFolder;
|
||||
}
|
||||
|
||||
public boolean isFile()
|
||||
{
|
||||
return isFile;
|
||||
}
|
||||
|
||||
public void setFile(boolean isFile)
|
||||
{
|
||||
this.isFile = isFile;
|
||||
}
|
||||
|
||||
public boolean isLocked()
|
||||
{
|
||||
return isLocked;
|
||||
}
|
||||
|
||||
public void setLocked(boolean isLocked)
|
||||
{
|
||||
this.isLocked = isLocked;
|
||||
}
|
||||
|
||||
public String getModifiedAt()
|
||||
{
|
||||
return modifiedAt;
|
||||
}
|
||||
|
||||
public void setModifiedAt(String modifiedAt)
|
||||
{
|
||||
this.modifiedAt = modifiedAt;
|
||||
}
|
||||
|
||||
public RestByUserModel getModifiedByUser()
|
||||
{
|
||||
return modifiedByUser;
|
||||
}
|
||||
|
||||
public void setModifiedByUser(RestByUserModel modifiedByUser)
|
||||
{
|
||||
this.modifiedByUser = modifiedByUser;
|
||||
}
|
||||
|
||||
public String getCreatedAt()
|
||||
{
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(String createdAt)
|
||||
{
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public String getArchivedAt()
|
||||
{
|
||||
return archivedAt;
|
||||
}
|
||||
|
||||
public void setArchivedAt(String archivedAt)
|
||||
{
|
||||
this.archivedAt = archivedAt;
|
||||
}
|
||||
|
||||
public RestByUserModel getArchivedByUser()
|
||||
{
|
||||
return archivedByUser;
|
||||
}
|
||||
|
||||
public void setArchivedByUser(RestByUserModel archivedByUser)
|
||||
{
|
||||
this.archivedByUser = archivedByUser;
|
||||
}
|
||||
|
||||
public RestByUserModel getCreatedByUser()
|
||||
{
|
||||
return createdByUser;
|
||||
}
|
||||
|
||||
public void setCreatedByUser(RestByUserModel createdByUser)
|
||||
{
|
||||
this.createdByUser = createdByUser;
|
||||
}
|
||||
|
||||
public String getParentId()
|
||||
{
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public boolean isLink()
|
||||
{
|
||||
return isLink;
|
||||
}
|
||||
|
||||
public void setLink(boolean isLink)
|
||||
{
|
||||
this.isLink = isLink;
|
||||
}
|
||||
|
||||
public RestContentModel getContent()
|
||||
{
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(RestContentModel content)
|
||||
{
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public List<String> getAspectNames()
|
||||
{
|
||||
return aspectNames;
|
||||
}
|
||||
|
||||
public void setAspectNames(List<String> aspectNames)
|
||||
{
|
||||
this.aspectNames = aspectNames;
|
||||
}
|
||||
|
||||
public Object getProperties()
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(Object properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public List<String> getAllowableOperations()
|
||||
{
|
||||
return allowableOperations;
|
||||
}
|
||||
|
||||
public void setAllowableOperations(List<String> allowableOperations)
|
||||
{
|
||||
this.allowableOperations = allowableOperations;
|
||||
}
|
||||
|
||||
public Object getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(Object path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public Object getPermissions()
|
||||
{
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public void setPermissions(Object permissions)
|
||||
{
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
public class RestNodeAssociationModelCollection extends RestModels<RestNodeAssociationModel, RestNodeAssociationModelCollection>
|
||||
{
|
||||
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Represents an association between two nodes
|
||||
*/
|
||||
public class RestNodeAssociationTypeModel extends TestModel implements IRestModel<RestNodeAssociationTypeModel>
|
||||
{
|
||||
@Override
|
||||
public ModelAssertion<RestNodeAssociationTypeModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestNodeAssociationTypeModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestNodeAssociationTypeModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestNodeAssociationTypeModel model;
|
||||
|
||||
@Override
|
||||
public RestNodeAssociationTypeModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
@JsonProperty
|
||||
private String assocType;
|
||||
|
||||
@JsonProperty
|
||||
private boolean isPrimary;
|
||||
|
||||
public String getAssocType()
|
||||
{
|
||||
return assocType;
|
||||
}
|
||||
|
||||
public void setAssocType(String assocType)
|
||||
{
|
||||
this.assocType = assocType;
|
||||
}
|
||||
|
||||
public boolean isPrimary()
|
||||
{
|
||||
return isPrimary;
|
||||
}
|
||||
|
||||
public void setPrimary(boolean isPrimary)
|
||||
{
|
||||
this.isPrimary = isPrimary;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,142 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Generated from 'Alfresco Core REST API' swagger file
|
||||
* Base Path {@linkplain /alfresco/api/-default-/public/alfresco/versions/1}
|
||||
*/
|
||||
public class RestNodeBodyModel extends TestModel implements IRestModel<RestNodeBodyModel>
|
||||
{
|
||||
@Override
|
||||
public ModelAssertion<RestNodeBodyModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestNodeBodyModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestNodeBodyModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestNodeBodyModel model;
|
||||
|
||||
@Override
|
||||
public RestNodeBodyModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name must not contain spaces or the following special characters: * " < > \ / ? : and |.
|
||||
* The character . must not be used at the end of the name.
|
||||
*/
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String name;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String nodeType;
|
||||
|
||||
private List<String> aspectNames;
|
||||
|
||||
private Object properties;
|
||||
|
||||
private String relativePath;
|
||||
|
||||
private Object association;
|
||||
|
||||
private List<String> secondaryChildren;
|
||||
|
||||
private List<String> targets;
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getNodeType()
|
||||
{
|
||||
return this.nodeType;
|
||||
}
|
||||
|
||||
public void setNodeType(String nodeType)
|
||||
{
|
||||
this.nodeType = nodeType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Object getProperties()
|
||||
{
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
public void setProperties(Object properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public String getRelativePath()
|
||||
{
|
||||
return this.relativePath;
|
||||
}
|
||||
|
||||
public void setRelativePath(String relativePath)
|
||||
{
|
||||
this.relativePath = relativePath;
|
||||
}
|
||||
|
||||
public Object getAssociation()
|
||||
{
|
||||
return this.association;
|
||||
}
|
||||
|
||||
public void setAssociation(Object association)
|
||||
{
|
||||
this.association = association;
|
||||
}
|
||||
|
||||
public List<String> getAspectNames()
|
||||
{
|
||||
return aspectNames;
|
||||
}
|
||||
|
||||
public void setAspectNames(List<String> aspectNames)
|
||||
{
|
||||
this.aspectNames = aspectNames;
|
||||
}
|
||||
|
||||
public List<String> getSecondaryChildren()
|
||||
{
|
||||
return secondaryChildren;
|
||||
}
|
||||
|
||||
public void setSecondaryChildren(List<String> secondaryChildren)
|
||||
{
|
||||
this.secondaryChildren = secondaryChildren;
|
||||
}
|
||||
|
||||
public List<String> getTargets()
|
||||
{
|
||||
return targets;
|
||||
}
|
||||
|
||||
public void setTargets(List<String> targets)
|
||||
{
|
||||
this.targets = targets;
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
/**
|
||||
* Destination Model used for passing the body parameters in the move node request
|
||||
*
|
||||
* @author Ana Bozianu
|
||||
*/
|
||||
public class RestNodeBodyMoveCopyModel extends TestModel
|
||||
{
|
||||
@JsonProperty(required = true)
|
||||
private String targetParentId;
|
||||
|
||||
@JsonProperty
|
||||
private String name;
|
||||
|
||||
public String getTargetParentId()
|
||||
{
|
||||
return targetParentId;
|
||||
}
|
||||
|
||||
public void setTargetParentId(String targetParentId)
|
||||
{
|
||||
this.targetParentId = targetParentId;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
public class RestNodeChildAssocModelCollection extends RestModels<RestNodeChildAssociationModel, RestNodeChildAssocModelCollection>
|
||||
{
|
||||
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class RestNodeChildAssociationModel extends TestModel implements IRestModel<RestNodeChildAssociationModel>
|
||||
{
|
||||
@Override
|
||||
public ModelAssertion<RestNodeChildAssociationModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestNodeChildAssociationModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestNodeChildAssociationModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestNodeChildAssociationModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestNodeChildAssociationModel model;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String childId;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String assocType;
|
||||
|
||||
public RestNodeChildAssociationModel(String childId, String assocType)
|
||||
{
|
||||
this.childId = childId;
|
||||
this.assocType = assocType;
|
||||
}
|
||||
|
||||
public RestNodeChildAssociationModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public String getChildId()
|
||||
{
|
||||
return childId;
|
||||
}
|
||||
|
||||
public void setChildId(String childId)
|
||||
{
|
||||
this.childId = childId;
|
||||
}
|
||||
|
||||
public String getAssocType()
|
||||
{
|
||||
return assocType;
|
||||
}
|
||||
|
||||
public void setAssocType(String assocType)
|
||||
{
|
||||
this.assocType = assocType;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,313 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Generated from 'Alfresco Core REST API' swagger file
|
||||
* Base Path {@linkplain /alfresco/api/-default-/public/alfresco/versions/1}
|
||||
*/
|
||||
public class RestNodeModel extends TestModel implements IRestModel<RestNodeModel>
|
||||
{
|
||||
@Override
|
||||
public ModelAssertion<RestNodeModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestNodeModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestNodeModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestNodeModel model;
|
||||
|
||||
@Override
|
||||
public RestNodeModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* The name must not contain spaces or the following special characters: * " < > \ / ? : and |.
|
||||
* The character . must not be used at the end of the name.
|
||||
*/
|
||||
@JsonProperty(required = true)
|
||||
private String name;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String nodeType;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private boolean isFolder;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private boolean isFile;
|
||||
|
||||
private boolean isLocked;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String modifiedAt;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private RestByUserModel modifiedByUser;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private String createdAt;
|
||||
|
||||
@JsonProperty
|
||||
private String archivedAt;
|
||||
|
||||
@JsonProperty
|
||||
private RestByUserModel archivedByUser;
|
||||
|
||||
@JsonProperty(required = true)
|
||||
private RestByUserModel createdByUser;
|
||||
|
||||
private String parentId;
|
||||
|
||||
private boolean isLink;
|
||||
|
||||
private RestContentModel content;
|
||||
|
||||
private List<String> aspectNames;
|
||||
|
||||
private Object properties;
|
||||
|
||||
private List<String> allowableOperations;
|
||||
|
||||
private Object path;
|
||||
|
||||
private Object permissions;
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getNodeType()
|
||||
{
|
||||
return this.nodeType;
|
||||
}
|
||||
|
||||
public void setNodeType(String nodeType)
|
||||
{
|
||||
this.nodeType = nodeType;
|
||||
}
|
||||
|
||||
public boolean getIsFolder()
|
||||
{
|
||||
return this.isFolder;
|
||||
}
|
||||
|
||||
public void setIsFolder(boolean isFolder)
|
||||
{
|
||||
this.isFolder = isFolder;
|
||||
}
|
||||
|
||||
public boolean getIsFile()
|
||||
{
|
||||
return this.isFile;
|
||||
}
|
||||
|
||||
public void setIsFile(boolean isFile)
|
||||
{
|
||||
this.isFile = isFile;
|
||||
}
|
||||
|
||||
public boolean getIsLocked()
|
||||
{
|
||||
return this.isLocked;
|
||||
}
|
||||
|
||||
public void setIsLocked(boolean isLocked)
|
||||
{
|
||||
this.isLocked = isLocked;
|
||||
}
|
||||
|
||||
public String getModifiedAt()
|
||||
{
|
||||
return this.modifiedAt;
|
||||
}
|
||||
|
||||
public void setModifiedAt(String modifiedAt)
|
||||
{
|
||||
this.modifiedAt = modifiedAt;
|
||||
}
|
||||
|
||||
public String getCreatedAt()
|
||||
{
|
||||
return this.createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(String createdAt)
|
||||
{
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public String getArchivedAt()
|
||||
{
|
||||
return this.archivedAt;
|
||||
}
|
||||
|
||||
public void setArchivedAt(String archivedAt)
|
||||
{
|
||||
this.archivedAt = archivedAt;
|
||||
}
|
||||
|
||||
public RestByUserModel getArchivedByUser()
|
||||
{
|
||||
return this.archivedByUser;
|
||||
}
|
||||
|
||||
public void setArchivedByUser(RestByUserModel archivedByUser)
|
||||
{
|
||||
this.archivedByUser = archivedByUser;
|
||||
}
|
||||
|
||||
public String getParentId()
|
||||
{
|
||||
return this.parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public boolean getIsLink()
|
||||
{
|
||||
return this.isLink;
|
||||
}
|
||||
|
||||
public void setIsLink(boolean isLink)
|
||||
{
|
||||
this.isLink = isLink;
|
||||
}
|
||||
|
||||
public Object getProperties()
|
||||
{
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
public void setProperties(Object properties)
|
||||
{
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public RestByUserModel getModifiedByUser()
|
||||
{
|
||||
return modifiedByUser;
|
||||
}
|
||||
|
||||
public void setModifiedByUser(RestByUserModel modifiedByUser)
|
||||
{
|
||||
this.modifiedByUser = modifiedByUser;
|
||||
}
|
||||
|
||||
public RestByUserModel getCreatedByUser()
|
||||
{
|
||||
return createdByUser;
|
||||
}
|
||||
|
||||
public void setCreatedByUser(RestByUserModel createdByUser)
|
||||
{
|
||||
this.createdByUser = createdByUser;
|
||||
}
|
||||
|
||||
public RestContentModel getContent()
|
||||
{
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(RestContentModel content)
|
||||
{
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public List<String> getAspectNames()
|
||||
{
|
||||
return aspectNames;
|
||||
}
|
||||
|
||||
public void setAspectNames(List<String> aspectNames)
|
||||
{
|
||||
this.aspectNames = aspectNames;
|
||||
}
|
||||
|
||||
public List<String> getAllowableOperations()
|
||||
{
|
||||
return allowableOperations;
|
||||
}
|
||||
|
||||
public void setAllowableOperations(List<String> allowableOperations)
|
||||
{
|
||||
this.allowableOperations = allowableOperations;
|
||||
}
|
||||
|
||||
public Object getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(Object path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public Object getPermissions()
|
||||
{
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public void setPermissions(Object permissions)
|
||||
{
|
||||
this.permissions = permissions;
|
||||
}
|
||||
|
||||
public void setFolder(boolean isFolder)
|
||||
{
|
||||
this.isFolder = isFolder;
|
||||
}
|
||||
|
||||
public void setFile(boolean isFile)
|
||||
{
|
||||
this.isFile = isFile;
|
||||
}
|
||||
|
||||
public void setLocked(boolean isLocked)
|
||||
{
|
||||
this.isLocked = isLocked;
|
||||
}
|
||||
|
||||
public void setLink(boolean isLink)
|
||||
{
|
||||
this.isLink = isLink;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
/**
|
||||
* Handles collection of nodes.
|
||||
* Example:
|
||||
* {
|
||||
"list": {
|
||||
"pagination": {
|
||||
"count": 2,
|
||||
"hasMoreItems": false,
|
||||
"totalItems": 2,
|
||||
"skipCount": 0,
|
||||
"maxItems": 100
|
||||
},
|
||||
"entries": [
|
||||
{
|
||||
"entry": {
|
||||
"createdAt": "2017-01-26T14:34:13.781+0000",
|
||||
"isFolder": true,
|
||||
"isFile": false,
|
||||
"createdByUser": {
|
||||
"id": "admin",
|
||||
"displayName": "Administrator"
|
||||
},
|
||||
"modifiedAt": "2017-01-26T14:34:13.781+0000",
|
||||
"modifiedByUser": {
|
||||
"id": "admin",
|
||||
"displayName": "Administrator"
|
||||
},
|
||||
"name": "my folder",
|
||||
"id": "ad79ba3f-daf2-4446-be9b-9686a020a94a",
|
||||
"nodeType": "cm:folder",
|
||||
"parentId": "ab7eb66a-cfc4-4325-b0a5-a43a0a6ffecd"
|
||||
}
|
||||
},
|
||||
{
|
||||
"entry": {
|
||||
"createdAt": "2017-01-26T14:31:59.821+0000",
|
||||
"isFolder": false,
|
||||
"isFile": true,
|
||||
"createdByUser": {
|
||||
"id": "admin",
|
||||
"displayName": "Administrator"
|
||||
},
|
||||
"modifiedAt": "2017-01-26T14:31:59.821+0000",
|
||||
"modifiedByUser": {
|
||||
"id": "admin",
|
||||
"displayName": "Administrator"
|
||||
},
|
||||
"name": "my file",
|
||||
"id": "6c93bff3-2174-4737-9c02-162df70a8549",
|
||||
"nodeType": "cm:content",
|
||||
"content": {
|
||||
"mimeType": "text/plain",
|
||||
"mimeTypeName": "Plain Text",
|
||||
"sizeInBytes": 17,
|
||||
"encoding": "UTF-8"
|
||||
},
|
||||
"parentId": "ab7eb66a-cfc4-4325-b0a5-a43a0a6ffecd"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
*/
|
||||
public class RestNodeModelsCollection extends RestModels<RestNodeModel, RestNodeModelsCollection>
|
||||
{
|
||||
|
||||
}
|
@@ -0,0 +1,88 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.assertion.IModelAssertion;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
/**
|
||||
* Handles Pagination JSON
|
||||
*
|
||||
* Example:
|
||||
* "pagination": {
|
||||
"count": 100,
|
||||
"hasMoreItems": true,
|
||||
"totalItems": 269,
|
||||
"skipCount": 0,
|
||||
"maxItems": 100
|
||||
},
|
||||
*/
|
||||
public class RestPaginationModel extends TestModel implements IModelAssertion<RestPaginationModel>
|
||||
{
|
||||
private int count;
|
||||
private boolean hasMoreItems;
|
||||
private Integer totalItems;
|
||||
private int skipCount;
|
||||
private int maxItems;
|
||||
|
||||
public int getCount()
|
||||
{
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count)
|
||||
{
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public boolean isHasMoreItems()
|
||||
{
|
||||
return hasMoreItems;
|
||||
}
|
||||
|
||||
public void setHasMoreItems(boolean hasMoreItems)
|
||||
{
|
||||
this.hasMoreItems = hasMoreItems;
|
||||
}
|
||||
|
||||
public Integer getTotalItems()
|
||||
{
|
||||
return totalItems;
|
||||
}
|
||||
|
||||
public void setTotalItems(Integer totalItems)
|
||||
{
|
||||
this.totalItems = totalItems;
|
||||
}
|
||||
|
||||
public int getSkipCount()
|
||||
{
|
||||
return skipCount;
|
||||
}
|
||||
|
||||
public void setSkipCount(int skipCount)
|
||||
{
|
||||
this.skipCount = skipCount;
|
||||
}
|
||||
|
||||
public int getMaxItems()
|
||||
{
|
||||
return maxItems;
|
||||
}
|
||||
|
||||
public void setMaxItems(int maxItems)
|
||||
{
|
||||
this.maxItems = maxItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestPaginationModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestPaginationModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestPaginationModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
}
|
@@ -0,0 +1,109 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class RestParameterDefinitionModel extends TestModel implements IRestModel<RestParameterDefinitionModel>
|
||||
{
|
||||
private String name;
|
||||
private String type;
|
||||
private boolean multiValued;
|
||||
private boolean mandatory;
|
||||
private String displayLabel;
|
||||
private String parameterConstraintName;
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean isMultiValued()
|
||||
{
|
||||
return multiValued;
|
||||
}
|
||||
|
||||
public void setMultiValued(boolean multiValued)
|
||||
{
|
||||
this.multiValued = multiValued;
|
||||
}
|
||||
|
||||
public boolean isMandatory()
|
||||
{
|
||||
return mandatory;
|
||||
}
|
||||
|
||||
public void setMandatory(boolean mandatory)
|
||||
{
|
||||
this.mandatory = mandatory;
|
||||
}
|
||||
|
||||
public String getDisplayLabel()
|
||||
{
|
||||
return displayLabel;
|
||||
}
|
||||
|
||||
public void setDisplayLabel(String displayLabel)
|
||||
{
|
||||
this.displayLabel = displayLabel;
|
||||
}
|
||||
|
||||
public String getParameterConstraintName()
|
||||
{
|
||||
return parameterConstraintName;
|
||||
}
|
||||
|
||||
public void setParameterConstraintName(String parameterConstraintName)
|
||||
{
|
||||
this.parameterConstraintName = parameterConstraintName;
|
||||
}
|
||||
|
||||
public RestParameterDefinitionModel getParameterDefinitionModel()
|
||||
{
|
||||
return parameterDefinitionModel;
|
||||
}
|
||||
|
||||
public void setParameterDefinitionModel(RestParameterDefinitionModel parameterDefinitionModel)
|
||||
{
|
||||
this.parameterDefinitionModel = parameterDefinitionModel;
|
||||
}
|
||||
|
||||
@JsonProperty(value = "entry")
|
||||
RestParameterDefinitionModel parameterDefinitionModel;
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestParameterDefinitionModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestParameterDefinitionModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<RestParameterDefinitionModel>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestParameterDefinitionModel onModel()
|
||||
{
|
||||
return parameterDefinitionModel;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* Created by Meenal Bhave
|
||||
* "path": {
|
||||
* "name": "/Folder-oawzdncUXFLgnFe",
|
||||
* "isComplete": false,
|
||||
* "elements": [
|
||||
* {
|
||||
* "aspectNames": ["cm:titled", "cm:auditable", "app:uifacets"],
|
||||
* "id": "7f0c47ae-d334-4b66-a86b-1a60d2518ad1",
|
||||
* "name": "Folder-oawzdncUXFLgnFe",
|
||||
* "nodeType": "cm:folder"
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
public class RestPathModel extends TestModel
|
||||
{
|
||||
private String name;
|
||||
@JsonProperty(value = "isComplete")
|
||||
private boolean isComplete;
|
||||
private List<RestElementModel> elements;
|
||||
|
||||
public List<RestElementModel> getElements()
|
||||
{
|
||||
return elements;
|
||||
}
|
||||
|
||||
public void setElements(List<RestElementModel> elements)
|
||||
{
|
||||
this.elements = elements;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
return isComplete;
|
||||
}
|
||||
|
||||
public void setComplete(boolean isComplete)
|
||||
{
|
||||
this.isComplete = isComplete;
|
||||
}
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.IRestModel;
|
||||
import org.alfresco.rest.core.assertion.ModelAssertion;
|
||||
import org.alfresco.utility.model.TestModel;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class RestPersonFavoritesModel extends TestModel implements IRestModel<RestPersonFavoritesModel>
|
||||
{
|
||||
@JsonProperty(value = "entry")
|
||||
RestPersonFavoritesModel model;
|
||||
|
||||
@Override
|
||||
public RestPersonFavoritesModel onModel()
|
||||
{
|
||||
return model;
|
||||
}
|
||||
|
||||
private String targetGuid;
|
||||
private String createdAt;
|
||||
|
||||
private RestTargetModel target;
|
||||
|
||||
public RestPersonFavoritesModel()
|
||||
{
|
||||
}
|
||||
|
||||
public RestPersonFavoritesModel(String targetGuid, String createdAt)
|
||||
{
|
||||
super();
|
||||
this.targetGuid = targetGuid;
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public String getTargetGuid()
|
||||
{
|
||||
return targetGuid;
|
||||
}
|
||||
|
||||
public void setTargetGuid(String targetGuid)
|
||||
{
|
||||
this.targetGuid = targetGuid;
|
||||
}
|
||||
|
||||
public RestTargetModel getTarget()
|
||||
{
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(RestTargetModel target)
|
||||
{
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public String getCreatedAt()
|
||||
{
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(String createdAt)
|
||||
{
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestPersonFavoritesModel> assertThat()
|
||||
{
|
||||
return new ModelAssertion<>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelAssertion<RestPersonFavoritesModel> and()
|
||||
{
|
||||
return assertThat();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package org.alfresco.rest.model;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
/**
|
||||
* Handle collection of <RestFavoriteModel>
|
||||
* Example:
|
||||
{
|
||||
"list": {
|
||||
"pagination": {
|
||||
"count": 1,
|
||||
"hasMoreItems": false,
|
||||
"totalItems": 1,
|
||||
"skipCount": 0,
|
||||
"maxItems": 100
|
||||
},
|
||||
"entries": [
|
||||
{
|
||||
"entry": {
|
||||
"targetGuid": "096babce-9f28-40d2-a38b-84b2ae41d71f",
|
||||
"createdAt": "2016-09-26T13:04:42.066+0000",
|
||||
"target": {
|
||||
"site": {
|
||||
"id": "site",
|
||||
"guid": "096babce-9f28-40d2-a38b-84b2ae41d71f",
|
||||
"title": "site",
|
||||
"visibility": "PUBLIC",
|
||||
"role": "SiteManager"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public class RestPersonFavoritesModelsCollection extends RestModels<RestPersonFavoritesModel, RestPersonFavoritesModelsCollection>
|
||||
{
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user