diff --git a/.travis.yml b/.travis.yml index ac9c1ae7cd..df0572754f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -396,7 +396,7 @@ jobs: script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql -PagsAllTestSuitePt4 -f amps/ags/pom.xml ${LOG_WARN} - name: "AGS Community Rest API Tests" - if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ + if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/ AND commit_message !~ /\[skip tas\]/) OR (commit_message =~ /\[ags\]/ AND commit_message =~ /\[tas\]/) install: travis_retry travis_wait 40 env REQUIRES_LOCAL_IMAGES=true bash scripts/travis/build.sh addons: artifacts: @@ -408,7 +408,8 @@ jobs: before_script: - ${TAS_SCRIPTS}/start-compose.sh ./amps/ags/rm-community/rm-community-repo/docker-compose.yml - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8080/alfresco" - script: travis_wait 40 mvn -B test -pl :alfresco-governance-services-automation-community-rest-api -am -DfailIfNoTests=false -Dskip.automationtests=false -Pags + - travis_wait 40 mvn -B install -pl :alfresco-governance-services-automation-community-rest-api -am -Pags -Pall-tas-tests -DskipTests + script: travis_wait 40 mvn -B test -pl :alfresco-governance-services-automation-community-rest-api -Dskip.automationtests=false -Pags -Pall-tas-tests after_script: bash amps/ags/travis/scripts/getLogs.sh - name: "Push to Nexus" diff --git a/amps/ags/pom.xml b/amps/ags/pom.xml index 3667a35dcd..1bd7f461f8 100644 --- a/amps/ags/pom.xml +++ b/amps/ags/pom.xml @@ -12,9 +12,17 @@ rm-community - rm-automation + + + all-tas-tests + + rm-automation + + + + UTF-8 UTF-8 diff --git a/amps/ags/rm-automation/rm-automation-community-rest-api/pom.xml b/amps/ags/rm-automation/rm-automation-community-rest-api/pom.xml index 81253fd43f..27da47216f 100644 --- a/amps/ags/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/amps/ags/rm-automation/rm-automation-community-rest-api/pom.xml @@ -57,6 +57,7 @@ org.alfresco.tas restapi + ${project.version} org.alfresco.tas diff --git a/packaging/tests/tas-integration/pom.xml b/packaging/tests/tas-integration/pom.xml index cd13c824de..be1ec90716 100644 --- a/packaging/tests/tas-integration/pom.xml +++ b/packaging/tests/tas-integration/pom.xml @@ -66,6 +66,7 @@ org.alfresco.tas restapi + ${project.version} test diff --git a/packaging/tests/tas-restapi/README.md b/packaging/tests/tas-restapi/README.md new file mode 100644 index 0000000000..ac083eba0d --- /dev/null +++ b/packaging/tests/tas-restapi/README.md @@ -0,0 +1,564 @@ +![in progress](https://img.shields.io/badge/Document_Level-In_Progress-yellow.svg?style=flat-square) + +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) 🌟 +* [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= +alfresco.port= +``` + +* 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``````.txt" file for further analysis +All current implementation are saved under "implemented-requests``````.txt" +![](docs/pics/coverage.png) + +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.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. + +![](docs/pics/models-all.png) + +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: src/main/resources/shared-resources/restapi-acs-community-suite.xml + + 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 + + + + + (...) + + ``` + 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: + +![](docs/pics/xml-steps-report.JPG) + +**[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 + + ``` + 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. + + ![](docs/pics/html-report-sample.JPG) + + 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= +# testManagement.endPoint=https://alfresco.testrail.com/ +# testManagement.username= +# testManagement.apiKey= +# testManagement.project= +# testManagement.rateLimitInSeconds= 1 +# testManagement.testRun= +# testManagement.suiteId= +``` +!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= **_" 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 + + + (...) + + ``` + + 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) diff --git a/packaging/tests/tas-restapi/docs/pics/coverage.png b/packaging/tests/tas-restapi/docs/pics/coverage.png new file mode 100644 index 0000000000..d611959317 Binary files /dev/null and b/packaging/tests/tas-restapi/docs/pics/coverage.png differ diff --git a/packaging/tests/tas-restapi/docs/pics/html-report-sample.png b/packaging/tests/tas-restapi/docs/pics/html-report-sample.png new file mode 100644 index 0000000000..576422e34f Binary files /dev/null and b/packaging/tests/tas-restapi/docs/pics/html-report-sample.png differ diff --git a/packaging/tests/tas-restapi/docs/pics/models-all.png b/packaging/tests/tas-restapi/docs/pics/models-all.png new file mode 100644 index 0000000000..05e2031d52 Binary files /dev/null and b/packaging/tests/tas-restapi/docs/pics/models-all.png differ diff --git a/packaging/tests/tas-restapi/pom.xml b/packaging/tests/tas-restapi/pom.xml index ea71b5dda9..a7d65569fd 100644 --- a/packaging/tests/tas-restapi/pom.xml +++ b/packaging/tests/tas-restapi/pom.xml @@ -2,9 +2,8 @@ 4.0.0 org.alfresco.tas - alfresco-community-repo-restapi-test - restapi test - jar + restapi + alfresco-tas-restapi org.alfresco @@ -12,17 +11,17 @@ 20.32-SNAPSHOT - - - Paul Brodner - - Test Automation Architect - - - - ${project.basedir}/src/test/resources/restapi-suite.xml + 11 + UTF-8 + master + 4.5.6 + 1.1.4 + 3.12.0 + 8.3.1 + 2.0.1.alfresco-2 + 11 @@ -47,26 +46,146 @@ + + + javax.servlet + servlet-api + 2.5 + provided + + + org.alfresco.tas - restapi - test + utility + + + slf4j-api + org.slf4j + + + commons-lang3 + org.apache.commons + + + commons-lang + commons-lang + + + mysql + mysql-connector-java + + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + + org.apache.httpcomponents + httpclient-osgi + ${httpclient-osgi-version} + + io.rest-assured rest-assured - test + + + io.rest-assured + json-path + + + commons-lang3 + org.apache.commons + + + + + + io.rest-assured + xml-path + + + commons-lang3 + org.apache.commons + + + + + + io.rest-assured + json-schema-validator + + + + com.github.scribejava + scribejava-apis + ${scribejava-apis.version} + + + + + com.fasterxml.jackson.core + jackson-databind + + + + + org.glassfish + javax.json + ${org.glassfish.version} + + + + + io.swagger + swagger-parser + + + commons-lang3 + org.apache.commons + + + + + + xerces + xercesImpl + + + + + + org.codehaus.groovy + groovy + 3.0.12 + + + + + org.codehaus.groovy + groovy-json + 3.0.12 + + + + org.mockito + mockito-core + test + + org.glassfish jakarta.json test - - org.springframework - spring-test - test - @@ -96,6 +215,32 @@ + + + **/*UnitTest* + + + + + org.codehaus.mojo + exec-maven-plugin + + + + java + + + + + + https://raw.githubusercontent.com/Alfresco/rest-api-explorer/${rest.api.explorer.branch}/src/main/webapp/definitions/alfresco-auth.yaml + https://raw.githubusercontent.com/Alfresco/rest-api-explorer/${rest.api.explorer.branch}/src/main/webapp/definitions/alfresco-core.yaml + https://raw.githubusercontent.com/Alfresco/rest-api-explorer/${rest.api.explorer.branch}/src/main/webapp/definitions/alfresco-discovery.yaml + https://raw.githubusercontent.com/Alfresco/rest-api-explorer/${rest.api.explorer.branch}/src/main/webapp/definitions/alfresco-search.yaml + https://raw.githubusercontent.com/Alfresco/rest-api-explorer/${rest.api.explorer.branch}/src/main/webapp/definitions/alfresco-workflow.yaml + + org.alfresco.rest.core.swagger.Generator + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/NetworkDataPrep.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/NetworkDataPrep.java new file mode 100644 index 0000000000..f2a968f338 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/NetworkDataPrep.java @@ -0,0 +1,70 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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() + { + if(!isInitialized) + { + isInitialized = true; + initialization(); + } + } + + public void initialization() + { + 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(); + } +} diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/RestTest.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/RestTest.java similarity index 64% rename from packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/RestTest.java rename to packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/RestTest.java index 92fff70016..ba3bd8534c 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/RestTest.java +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/RestTest.java @@ -1,3 +1,28 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ package org.alfresco.rest; import java.lang.reflect.Method; @@ -5,7 +30,6 @@ 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.rest.rules.RulesTestsUtils; import org.alfresco.utility.LogFactory; import org.alfresco.utility.TasProperties; import org.alfresco.utility.data.DataContent; @@ -62,15 +86,19 @@ public abstract class RestTest extends AbstractTestNGSpringContextTests @Autowired protected WorkflowService workflow; - @Autowired - protected RulesTestsUtils rulesUtils; - protected SiteModel testSite; @BeforeSuite(alwaysRun = true) - public void checkServerHealth() throws Exception + public void checkServerHealth() { - super.springTestContextPrepareTestInstance(); + try + { + super.springTestContextPrepareTestInstance(); + } + catch (Exception e) + { + throw new IllegalStateException("Error while preparing for test execution", e); + } serverHealth.assertServerIsOnline(); testSite = dataSite.createPublicRandomSite(); } diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/IRestModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/IRestModel.java new file mode 100644 index 0000000000..75dacad04e --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/IRestModel.java @@ -0,0 +1,32 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.core; + +import org.alfresco.rest.core.assertion.IModelAssertion; + +public interface IRestModel extends IModelAssertion { + Model onModel(); +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/IRestModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/IRestModelsCollection.java new file mode 100644 index 0000000000..415b16cedb --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/IRestModelsCollection.java @@ -0,0 +1,46 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.core; + +import java.util.List; + +import org.alfresco.rest.exception.EmptyRestModelCollectionException; +import org.alfresco.rest.model.RestPaginationModel; + +public interface IRestModelsCollection { + + public List getEntries(); + + public Model getOneRandomEntry() throws EmptyRestModelCollectionException; + + /** + * @return boolean value if entry is empty + */ + public boolean isEmpty(); + + public RestPaginationModel getPagination(); + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/JsonBodyGenerator.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/JsonBodyGenerator.java new file mode 100644 index 0000000000..1ed7cbc9f2 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/JsonBodyGenerator.java @@ -0,0 +1,370 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.core; + +import javax.json.Json; +import javax.json.JsonArrayBuilder; +import javax.json.JsonBuilderFactory; +import javax.json.JsonObject; +import javax.json.JsonObjectBuilder; +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.StringJoiner; + +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.constants.UserRole; +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.TestModel; +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) + { + 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 siteGroup(String authorityId, UserRole role) + { + Utility.checkObjectIsInitialized(authorityId, "authorityId"); + JsonObject value = defineJSON() + .add("role", role.name()) + .add("id", authorityId).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(); + } + /** + * Method to create a Json object for SiteBody with site title, description, visibility + * @param siteModel + * @return String + */ + public static String updateSiteRequest(SiteModel siteModel) + { + JsonObject value = defineJSON() + .add("title", siteModel.getTitle()) + .add("description", siteModel.getDescription()) + .add("visibility", siteModel.getVisibility().toString()).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 params) + { + JsonObjectBuilder objectBuilder = jsonBuilder().createObjectBuilder(); + for(Map.Entry param : params.entrySet()) + { + addJsonValue(objectBuilder, param.getKey(), param.getValue()); + + } + JsonObject value = defineJSON() + .add("actionDefinitionId", actionDefinitionId) + .add("targetId", targetNode.getNodeRefWithoutVersion()) + .add("params", objectBuilder).build(); + return value.toString(); + } + + /** Add a value to the JSON object. */ + private static void addJsonValue(JsonObjectBuilder objectBuilder, String key, Serializable value) + { + if (value == null) + { + objectBuilder.add(key, JsonObject.NULL); + } + else if (value instanceof Boolean) + { + objectBuilder.add(key, (boolean) value); + } + else if (value instanceof String) + { + objectBuilder.add(key, (String) value); + } + else if (value instanceof Integer) + { + objectBuilder.add(key, (int) value); + } + else if (value instanceof Long) + { + objectBuilder.add(key, (long) value); + } + else if (value instanceof Double) + { + objectBuilder.add(key, (double) value); + } + else + { + throw new UnsupportedOperationException("Unable to add entry to JsonObject: {" + key + ": " + value + "}"); + } + } + + /** + * { + * "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 mapJson) + { + JsonObjectBuilder builder= defineJSON(); + + for (Map.Entry entry : mapJson.entrySet()) + { + builder.add(entry.getKey().toString(), entry.getValue().toString()); + } + return builder.build().toString(); + } + + /** + * Convert a collection of {@link TestModel} objects to JSON for a multi-entity POST request. + * + * @param models The entities to convert. + * @return The JSON string. + */ + public static String arrayToJson(List models) + { + // Rather than convert backwards and forwards between Jackson and javax objects then we handle array creation ourselves. + StringJoiner stringJoiner = new StringJoiner(",\n"); + for (TestModel model : models) + { + stringJoiner.add(model.toJson()); + } + return "[\n" + stringJoiner.toString() + "\n]"; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestAisAuthentication.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestAisAuthentication.java new file mode 100644 index 0000000000..5fe12f930f --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestAisAuthentication.java @@ -0,0 +1,108 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestModels.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestModels.java new file mode 100644 index 0000000000..7d3287dd14 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestModels.java @@ -0,0 +1,162 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.core; + +import static org.alfresco.utility.report.log.Step.STEP; + +import java.util.List; +import java.util.Random; + +import com.fasterxml.jackson.annotation.JsonProperty; + +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; + +/** + * Map multiple entries of JSON response to a class + * + * 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 based on this example + * + * @author Paul Brodner + */ +public abstract class RestModels implements IRestModelsCollection, IModelsCollectionAssertion +{ + @JsonProperty(value = "entries") + private List modelEntries; + + private RestPaginationModel pagination; + + @Override + public List 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 models = getEntries(); + if(models.isEmpty()) + throw new EmptyRestModelCollectionException(models); + + int index = random.nextInt(models.size()); + return models.get(index); + } + + /** + * Example + * + * 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()); + * + * @param index + * @return + * @throws EmptyRestModelCollectionException + */ + @SuppressWarnings("unchecked") + public Model getEntryByIndex(int index) throws EmptyRestModelCollectionException{ + STEP("REST API: Get index entry from response"); + + List 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> assertThat() + { + return new ModelsCollectionAssertion<>(this); + } + + @Override + public ModelsCollectionAssertion> 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; + } + + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestProperties.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestProperties.java new file mode 100644 index 0000000000..7a6b345a81 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestProperties.java @@ -0,0 +1,45 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestRequest.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestRequest.java new file mode 100644 index 0000000000..33a00a60a6 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestRequest.java @@ -0,0 +1,216 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.core; + +import static org.alfresco.utility.report.log.Step.STEP; + +import java.util.MissingFormatArgumentException; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import io.restassured.RestAssured; +import org.springframework.http.HttpMethod; + +/** + * @author Paul Brodner + */ +public class RestRequest +{ + private static final String TOKEN_REGEX = "\\{.*?}"; + 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) + { + this(httpMethod, "", path, pathParams); + } + + private RestRequest(HttpMethod httpMethod, String body, String path, String... pathParams) + { + setHttpMethod(httpMethod); + setPath(path); + setPathParams(pathParams); + setBody(body); + // Validate that the supplied path and pathParams are compatible. + constructPath(); + } + + /** + * 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; + addQueryParamsIfNeeded(); + } + + public Object[] getPathParams() + { + return pathParams; + } + + public void setPathParams(Object[] pathParams) + { + this.pathParams = pathParams; + addQueryParamsIfNeeded(); + } + + /** + * Add query parameters to the path if needed. + *

+ * e.g. For a path of "api/{fruit}" and params ["apple", "size=10", "colour=red"] then this will + * update the path to be "api/{fruit}?{param0}&{param1}" so that the tokens will be populated by + * RestAssured to make "api/apple?size=10&colour=red". + */ + private void addQueryParamsIfNeeded() + { + // Don't do anything if the path or path params haven't been set yet. + if (path == null || path.length() == 0 || pathParams == null) + { + return; + } + int groupCount = (int) Pattern.compile(TOKEN_REGEX).matcher(path).results().count(); + if (pathParams.length > groupCount) + { + // Add the remaining parameters to the URL query. + String queryParams = IntStream.range(0, pathParams.length - groupCount) + .mapToObj(index -> "{parameter" + index + "}") + .collect(Collectors.joining("&")); + path += (path.contains("?") ? "&" : "?") + queryParams; + } + } + + public String getContentType() + { + return contentType; + } + + public void setContentType(String contentType) + { + this.contentType = contentType; + } + + /** + * {@inheritDoc} + * @throws MissingFormatArgumentException If there are not enough pathParams for the path. + */ + @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("/"); + + sb.append(constructPath()); + + if(!getBody().isEmpty()) + { + sb.append("\nbody:") + .append(getBody()); + } + sb.append("\n"); + + + return sb.toString(); + } + + /** + * Populate the path with the pathParams. + * + * @return The path with tokens replaced with values. + * @throws MissingFormatArgumentException If there are not enough pathParams for the path. + */ + private String constructPath() + { + String getPathFormatted = getPath(); + if(getPath().contains("{")) + { + getPathFormatted = getPath().replaceAll(TOKEN_REGEX, "%s"); + getPathFormatted = String.format(getPathFormatted, getPathParams()); + } + return getPathFormatted; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestResponse.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestResponse.java new file mode 100644 index 0000000000..cdb1768519 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestResponse.java @@ -0,0 +1,71 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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 toModel(Class classz) + { + return response.as(classz); + + } + + public ValidatableResponse assertThat() + { + return response.then(); + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestWrapper.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestWrapper.java new file mode 100644 index 0000000000..9d4e41442b --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/RestWrapper.java @@ -0,0 +1,1197 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.core; + +import static io.restassured.RestAssured.basic; +import static io.restassured.RestAssured.given; +import static io.restassured.RestAssured.oauth2; +import static org.alfresco.utility.report.log.Step.STEP; + +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +import javax.annotation.PostConstruct; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.alfresco.rest.exception.EmptyJsonResponseException; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestHtmlResponse; +import org.alfresco.rest.model.RestSiteContainerModelsCollection; +import org.alfresco.rest.model.RestSiteMemberModelsCollection; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.rest.model.RestSyncSetRequestModel; +import org.alfresco.rest.model.RestTextResponse; +import org.alfresco.rest.requests.AdminConsole; +import org.alfresco.rest.requests.Tenant; +import org.alfresco.rest.requests.aosAPI.RestAosAPI; +import org.alfresco.rest.requests.authAPI.RestAuthAPI; +import org.alfresco.rest.requests.cmisAPI.RestCmisAPI; +import org.alfresco.rest.requests.coreAPI.RestCoreAPI; +import org.alfresco.rest.requests.discoveryAPI.RestDiscoveryAPI; +import org.alfresco.rest.requests.modelAPI.RestModelAPI; +import org.alfresco.rest.requests.privateAPI.RestPrivateAPI; +import org.alfresco.rest.requests.search.SearchAPI; +import org.alfresco.rest.requests.search.SearchSQLAPI; +import org.alfresco.rest.requests.search.SearchSQLJDBC; +import org.alfresco.rest.requests.search.ShardInfoAPI; +import org.alfresco.rest.requests.search.SolrAPI; +import org.alfresco.rest.requests.search.SolrAdminAPI; +import org.alfresco.rest.requests.workflowAPI.RestWorkflowAPI; +import org.alfresco.utility.LogFactory; +import org.alfresco.utility.Utility; +import org.alfresco.utility.dsl.DSLWrapper; +import org.alfresco.utility.model.StatusModel; +import org.alfresco.utility.model.TestModel; +import org.alfresco.utility.model.UserModel; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import org.apache.xml.serialize.OutputFormat; +import org.apache.xml.serialize.XMLSerializer; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Service; +import org.testng.Assert; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.restassured.RestAssured; +import io.restassured.builder.RequestSpecBuilder; +import io.restassured.http.ContentType; +import io.restassured.parsing.Parser; +import io.restassured.http.Headers; +import io.restassured.response.Response; +import io.restassured.specification.RequestSpecification; + +@SuppressWarnings("deprecation") +@Service +@Scope(value = "prototype") +public class RestWrapper extends DSLWrapper +{ + private static final Integer IGNORE_CONTENT_LIMIT_BYTES = 4 * 1024 * 1024; + + @Autowired + protected RestProperties restProperties; + + private Logger LOG = LogFactory.getLogger(); + + private RequestSpecification request; + private RestErrorModel lastError; + private StatusModel lastStatusModel; + private Object lastException = ""; // handle values of last exception thrown + private UserModel currentUser; + private String statusCode; + private String parameters = ""; + private ContentType defaultContentType = ContentType.JSON; + private RequestSpecBuilder requestSpecBuilder = new RequestSpecBuilder(); + private Headers responseHeaders; + private RestResponse response; + private String serverURI; + private int serverPort; + + /** + * After configuring {@link #setServerURI(String)} and {@link #setServerPort(int)} call {@link #configureServerEndpoint()} + * + * @param serverURI in format of "http://localhost", without port. Set port via {@link #setServerPort(int)} + */ + public void setServerURI(String serverURI) + { + this.serverURI = serverURI; + } + + public void setServerPort(int serverPort) + { + this.serverPort = serverPort; + } + + @Autowired + private RestAisAuthentication aisAuthentication; + + public void setResponseHeaders(Headers responseHeaders) + { + this.responseHeaders = responseHeaders; + } + + public Headers getResponseHeaders() + { + return responseHeaders; + } + + /** + * Verify response header contains a specific value + * Example: + * assertHeaderValueContains("Content-Disposition", "filename=\"myfile.txt\""); + * + * @param headerName the header name from response + * @param expectedHeaderValue the header property value to be checked + * @return + */ + public RestWrapper assertHeaderValueContains(String headerName, String expectedHeaderValue) + { + STEP(String.format("REST API: Assert that header value contains %s", expectedHeaderValue)); + String actualHeaderValue = getResponseHeaders().getValue(headerName); + Assert.assertTrue(getResponseHeaders().getValue(headerName).contains(expectedHeaderValue), + String.format("Header %s is %s", headerName, actualHeaderValue)); + return this; + } + + @PostConstruct + public void initializeRequestSpecBuilder() + { + this.serverURI = restProperties.envProperty().getTestServerUrl(); + this.serverPort = restProperties.envProperty().getPort(); + configureServerEndpoint(); + } + + /** + * Authenticate specific user to Alfresco REST API + * + * @param userModel + * @return + */ + public RestWrapper authenticateUser(UserModel userModel) + { + STEP(String.format("REST API: Basic Authentication using user {%s}", userModel.toString())); + currentUser = userModel; + setTestUser(userModel); + return this; + } + + public RestWrapper noAuthentication() + { + STEP("REST API: No Authentication"); + currentUser = null; + setTestUser(null); + return this; + } + + /** + * Request sent to server + */ + protected RequestSpecification onRequest() + { + if (currentUser != null) + { + if(aisAuthentication.isAisAuthenticationEnabled()) + { + configureRequestSpec().setAuth(oauth2(aisAuthentication.getAisAuthenticationToken(currentUser))); + } + else + { + configureRequestSpec().setAuth(basic(currentUser.getUsername(), currentUser.getPassword())); + } + } + + request = given().spec(configureRequestSpec().build()); + + // reset to default as JSON + usingContentType(ContentType.JSON); + return request; + } + + /** + * @return the last error model thrown if any + */ + private RestErrorModel getLastError() + { + if (lastError == null) + return new RestErrorModel(); + else + return lastError; + } + + public void setLastError(RestErrorModel errorModel) + { + lastError = errorModel; + } + + public RestErrorModel assertLastError() + { + + return getLastError(); + } + + public StatusModel assertLastStatus() + { + return getLastStatus(); + } + + public RestWrapper assertLastExceptionContains(String exception) + { + if (!lastException.toString().contains(exception)) + Assert.fail(String.format("Expected exception {%s} but found {%s}", exception, lastException)); + + return this; + } + + /** + * Process responses for a collection of models as {@link RestSiteModelsCollection} + * + * @throws JsonToModelConversionException If the response cannot be converted to the given model. + * @throws EmptyJsonResponseException If there is no response from the server. + */ + + public T processModels(Class classz, RestRequest restRequest) + throws EmptyJsonResponseException, JsonToModelConversionException + { + T models = callAPIAndCreateModel(classz, restRequest, "list"); + + if (models == null) + { + try + { + return classz.getDeclaredConstructor().newInstance(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + return models; + } + + /** + * Process responses for a single model as {@link RestSiteModel} + * + * @throws JsonToModelConversionException If the response cannot be converted to the given model. + * @throws EmptyJsonResponseException If there is no response from the server. + */ + public T processModel(Class classz, RestRequest restRequest) + throws EmptyJsonResponseException, JsonToModelConversionException + { + T model = callAPIAndCreateModel(classz, restRequest, "entry"); + + if (model == null) + { + try + { + return classz.newInstance(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + return model; + } + + /** + * Send the request and convert the response to the appropriate model. + * + * @param classz The class of the model to create. + * @param restRequest The request to send. + * @param path The path to the part of the response from which the model should be populated. + * @return The populated model object. + */ + private T callAPIAndCreateModel(Class classz, RestRequest restRequest, String path) + { + Response returnedResponse = sendRequest(restRequest); + + setStatusCode(String.valueOf(returnedResponse.getStatusCode())); + + boolean responseHasErrors = checkForJsonError(returnedResponse); + boolean responseHasExceptions = checkForJsonStatusException(returnedResponse); + + T models = null; + + if (!responseHasExceptions && !responseHasErrors) + { + try + { + models = returnedResponse.jsonPath().getObject(path, classz); + validateJsonModelSchema(classz, models); + } + catch (Exception processError) + { + processError.printStackTrace(); + throw new JsonToModelConversionException(classz, processError); + } + } + return models; + } + + /** + * Process responses for a single model as {@link RestSiteModel} + * + * @throws JsonToModelConversionException If the response cannot be converted to the given model. + * @throws EmptyJsonResponseException If there is no response from the server. + */ + public JSONObject processJson(RestRequest restRequest) + throws EmptyJsonResponseException, JsonToModelConversionException + { + Response returnedResponse = sendRequest(restRequest); + + setStatusCode(String.valueOf(returnedResponse.getStatusCode())); + + boolean responseHasErrors = checkForJsonError(returnedResponse); + boolean responseHasExceptions = checkForJsonStatusException(returnedResponse); + + JSONObject response = null; + + try + { + if (!responseHasExceptions && !responseHasErrors) + { + JSONObject jsonObject = new JSONObject(returnedResponse.getBody().asString()); + response = jsonObject.getJSONObject("entry"); + } + } + catch (Exception processError) + { + throw new EmptyJsonResponseException(processError.getMessage()); + } + + return response; + } + + /** + * Process responses for site relations models, such as {@link RestSiteModel, RestSiteContainerModelsCollection, RestSiteMemberModelsCollection} + */ + public List processRelationsJson(RestRequest restRequest) + { + List jsonObjects = new ArrayList(); + Response returnedResponse = sendRequest(restRequest); + + setStatusCode(String.valueOf(returnedResponse.getStatusCode())); + + boolean responseHasErrors = checkForJsonError(returnedResponse); + boolean responseHasExceptions = checkForJsonStatusException(returnedResponse); + + ObjectMapper mapper = new ObjectMapper(); + JSONObject response = null; + + try + { + if (!responseHasExceptions && !responseHasErrors) + { + JSONObject jsonObject = new JSONObject(returnedResponse.getBody().asString()); + + response = jsonObject.getJSONObject("entry"); + RestSiteModel site = mapper.readValue(response.toString(), RestSiteModel.class); + jsonObjects.add(site); + + if (!jsonObject.getJSONObject("relations").isNull("containers")) + { + response = jsonObject.getJSONObject("relations").getJSONObject("containers").getJSONObject("list"); + RestSiteContainerModelsCollection containers = mapper.readValue(response.toString(), + RestSiteContainerModelsCollection.class); + jsonObjects.add(containers); + } + + if (!jsonObject.getJSONObject("relations").isNull("members")) + { + response = jsonObject.getJSONObject("relations").getJSONObject("members").getJSONObject("list"); + RestSiteMemberModelsCollection members = mapper.readValue(response.toString(), + RestSiteMemberModelsCollection.class); + jsonObjects.add(members); + } + } + } + catch (Exception processError) + { + throw new EmptyJsonResponseException(processError.getMessage()); + } + + return jsonObjects; + } + + /** + * Process responses for site relations models, such as {@link RestSiteModel, RestSiteContainerModelsCollection, RestSiteMemberModelsCollection} + */ + public List> processSitesRelationsJson(RestRequest restRequest) + { + List> allObjects = new ArrayList>(); + List sitesList = new ArrayList(); + List containersList = new ArrayList(); + List membersList = new ArrayList(); + + Response returnedResponse = sendRequest(restRequest); + + setStatusCode(String.valueOf(returnedResponse.getStatusCode())); + + boolean responseHasErrors = checkForJsonError(returnedResponse); + boolean responseHasExceptions = checkForJsonStatusException(returnedResponse); + + ObjectMapper mapper = new ObjectMapper(); + JSONObject response = null; + + try + { + if (!responseHasExceptions && !responseHasErrors) + { + JSONObject jsonObject = new JSONObject(returnedResponse.getBody().asString()); + + if (jsonObject.getJSONObject("list").getJSONArray("entries").length() != 0) + { + { + for (int i = 0; i < jsonObject.getJSONObject("list").getJSONArray("entries").length(); i++) + { + response = jsonObject.getJSONObject("list").getJSONArray("entries").getJSONObject(i) + .getJSONObject("entry"); + RestSiteModel site = mapper.readValue(response.toString(), RestSiteModel.class); + sitesList.add(site); + } + + allObjects.add(sitesList); + } + + if (jsonObject.toString().contains("containers")) + { + for (int i = 0; i < jsonObject.getJSONObject("list").getJSONArray("entries").length(); i++) + { + response = jsonObject.getJSONObject("list").getJSONArray("entries").getJSONObject(i) + .getJSONObject("relations").getJSONObject("containers").getJSONObject("list"); + RestSiteContainerModelsCollection containers = mapper.readValue(response.toString(), + RestSiteContainerModelsCollection.class); + containersList.add(containers); + } + + allObjects.add(containersList); + } + + if (jsonObject.toString().contains("members")) + { + for (int i = 0; i < jsonObject.getJSONObject("list").getJSONArray("entries").length(); i++) + { + response = jsonObject.getJSONObject("list").getJSONArray("entries").getJSONObject(i) + .getJSONObject("relations").getJSONObject("members").getJSONObject("list"); + RestSiteMemberModelsCollection members = mapper.readValue(response.toString(), + RestSiteMemberModelsCollection.class); + membersList.add(members); + } + + allObjects.add(membersList); + } + } + } + } + catch (Exception processError) + { + throw new EmptyJsonResponseException(processError.getMessage()); + } + + return allObjects; + } + + /** + * Process a response that returns a html + * + * @param restRequest + * @return + * @throws EmptyJsonResponseException If there is no response from the server. + */ + public RestHtmlResponse processHtmlResponse(RestRequest restRequest) throws EmptyJsonResponseException + { + Response returnedResponse = sendRequest(restRequest); + + setStatusCode(String.valueOf(returnedResponse.getStatusCode())); + + if (returnedResponse.contentType().contains("json")) + { + checkForJsonError(returnedResponse); + checkForJsonStatusException(returnedResponse); + } + + return new RestHtmlResponse(returnedResponse.getHeaders(), returnedResponse.getBody()); + } + + /** + * Generic REST API call on a {@link RestRequest} + * + * @param restRequest + * @return + */ + public RestResponse process(RestRequest restRequest) + { + Response returnedResponse = sendRequest(restRequest); + setStatusCode(String.valueOf(returnedResponse.getStatusCode())); + RestResponse response = new RestResponse(returnedResponse); + setResponseHeaders(response.getResponse().getHeaders()); + return response; + } + + public RestTextResponse processTextResponse(RestRequest restRequest) + { + Response returnedResponse = sendRequest(restRequest); + setStatusCode(String.valueOf(returnedResponse.getStatusCode())); + if (returnedResponse.contentType().contains("text/plain")) + { + RestAssured.registerParser("text/plain", Parser.TEXT); + + RestTextResponse testResponse = new RestTextResponse(returnedResponse); + return testResponse; + } + + RestResponse response = new RestResponse(returnedResponse); + setResponseHeaders(response.getResponse().getHeaders()); + RestTextResponse testResponse = new RestTextResponse(returnedResponse); + return testResponse; + } + + /** + * Process a response that has no body - basically will need only the status code from it + * + * @param restRequest + * @throws EmptyJsonResponseException + */ + public void processEmptyModel(RestRequest restRequest) throws EmptyJsonResponseException + { + Response returnedResponse = sendRequest(restRequest); + setStatusCode(String.valueOf(returnedResponse.getStatusCode())); + + if (!returnedResponse.asString().isEmpty()) + { + checkForJsonError(returnedResponse); + checkForJsonStatusException(returnedResponse); + } + + } + + public StatusModel getLastStatus() + { + return lastStatusModel; + } + + /** + * Set the status code for the latest REST call + * + * @param lastStatusModel + */ + public void setLastStatus(StatusModel lastStatusModel) + { + this.lastStatusModel = lastStatusModel; + } + + public String getStatusCode() + { + return statusCode; + } + + public void setStatusCode(String statusCode) + { + this.statusCode = statusCode; + } + + /** + * Send REST request based on HTTP method + * + * @param restRequest + * @return + */ + protected Response sendRequest(RestRequest restRequest) + { + // If there are unused parameters then include them in the request. + String parameters = getParameters(); + if (parameters != null && !parameters.isEmpty()) + { + restRequest.setPathParams(ArrayUtils.addAll(restRequest.getPathParams(), parameters)); + } + + STEP(restRequest.toString()); + + Response returnedResponse; + switch (restRequest.getHttpMethod()) + { + case GET: + returnedResponse = onRequest().get(restRequest.getPath(), restRequest.getPathParams()).andReturn(); + break; + case DELETE: + returnedResponse = onRequest().delete(restRequest.getPath(), restRequest.getPathParams()).andReturn(); + break; + case HEAD: + returnedResponse = onRequest().head(restRequest.getPath(), restRequest.getPathParams()).andReturn(); + break; + case OPTIONS: + returnedResponse = onRequest().options(restRequest.getPath(), restRequest.getPathParams()).andReturn(); + break; + case POST: + returnedResponse = onRequest().body(restRequest.getBody()) + .post(restRequest.getPath(), restRequest.getPathParams()).andReturn(); + break; + case PUT: + returnedResponse = onRequest().body(restRequest.getBody()) + .contentType(ContentType.JSON.withCharset(restRequest.getContentType())) + .put(restRequest.getPath(), restRequest.getPathParams()).andReturn(); + break; + case TRACE: + returnedResponse = onRequest().get(restRequest.getPath(), restRequest.getPathParams()).andReturn(); + break; + default: + returnedResponse = onRequest().get(restRequest.getPath(), restRequest.getPathParams()).andReturn(); + break; + } + + logResponseInformation(restRequest, returnedResponse); + + configureServerEndpoint(); + response = new RestResponse(returnedResponse); + return returnedResponse; + } + + private void logResponseInformation(RestRequest restRequest, Response returnedResponse) + { + String responseSizeString = returnedResponse.getHeader("Content-Length"); + if (responseSizeString != null && Integer.valueOf(responseSizeString) > IGNORE_CONTENT_LIMIT_BYTES) + { + LOG.info("On {} {}, received a response size that was {} bytes.\n" + + "This is bigger than the limit of {} bytes so its content will not be displayed: \n", restRequest.getHttpMethod(), + restRequest.getPath(), Integer.valueOf(responseSizeString), IGNORE_CONTENT_LIMIT_BYTES); + } + else + { + if (returnedResponse.getContentType().contains("image/png")) + { + LOG.info("On {} {}, received the response with an image and headers: \n{}", restRequest.getHttpMethod(), restRequest.getPath(), + returnedResponse.getHeaders().toString()); + } + else if (returnedResponse.getContentType().contains("application/json") && !returnedResponse.asString().isEmpty()) + { + LOG.info("On {} {}, received the following response \n{}", restRequest.getHttpMethod(), restRequest.getPath(), + Utility.prettyPrintJsonString(returnedResponse.asString())); + } + else if (returnedResponse.getContentType().contains("application/xml") && !returnedResponse.asString().isEmpty()) + { + String response = parseXML(returnedResponse); + LOG.info("On {} {}, received the following response \n{}", restRequest.getHttpMethod(), restRequest.getPath(), response); + } + else + { + LOG.info("On {} {}, received the following response \n{}", restRequest.getHttpMethod(), restRequest.getPath(), + ToStringBuilder.reflectionToString(returnedResponse.asString(), ToStringStyle.MULTI_LINE_STYLE)); + } + } + } + + private String parseXML(Response returnedResponse) + { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + String result = ""; + try + { + DocumentBuilder db = dbf.newDocumentBuilder(); + InputSource is = new InputSource(new StringReader(returnedResponse.asString())); + Document document = db.parse(is); + + OutputFormat format = new OutputFormat(document); + format.setLineWidth(65); + format.setIndenting(true); + format.setIndent(2); + Writer out = new StringWriter(); + XMLSerializer serializer = new XMLSerializer(out, format); + serializer.serialize(document); + + result = out.toString(); + } + catch (Exception e) + { + result = "Error Parsing XML file returned: "+ e.getMessage(); + setStatusCode(String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value())); + } + + return result; + } + + /** + * Check if returned response contains an error (error node) + * + * @param returnedResponse + * @throws EmptyJsonResponseException + */ + private boolean checkForJsonError(Response returnedResponse) throws EmptyJsonResponseException + { + setLastError(null); + + try + { + // check for empty json response + returnedResponse.jsonPath().get(); + } + catch (Exception e) + { + throw new EmptyJsonResponseException(e.getMessage()); + } + Object error = returnedResponse.jsonPath().get("error"); + if (error != null) + { + setLastError(returnedResponse.jsonPath().getObject("error", RestErrorModel.class)); + return true; + } + + return false; + } + + /** + * Check if returned response contains an exception (status node) + * + * @param returnedResponse + * @throws EmptyJsonResponseException + */ + private boolean checkForJsonStatusException(Response returnedResponse) throws EmptyJsonResponseException + { + try + { + // check for empty json response + lastException = returnedResponse.jsonPath().get("exception"); + } + catch (Exception e) + { + throw new EmptyJsonResponseException(e.getMessage()); + } + if (lastException == null) + lastException = ""; + + Object error = returnedResponse.jsonPath().get("status"); + if (error != null) + { + setLastStatus(returnedResponse.jsonPath().getObject("status", StatusModel.class)); + LOG.error("Exception thrown on response: {}", getLastStatus().toInfo()); + return true; + } + + return false; + } + + /** + * Assert that a specific status code is returned + * + * @param statusCode + * @return; + */ + public RestWrapper assertStatusCodeIs(HttpStatus statusCode) + { + STEP(String.format("REST API: Assert that status code is %s", statusCode.toString())); + Assert.assertEquals(getStatusCode(), String.valueOf(statusCode.value()), "Status code is not as expected."); + + return this; + } + + /** + * Backtrack algorithm to gather all declared fields within SuperClasses + * but stopping on TestModel.class + * + * @param fields + * @param classz + * @return + */ + private List getAllDeclaredFields(List 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; + } + + /** + * Check that REST response has returned all required fields + * + * @param classz + * @param classzInstance + * @throws IllegalAccessException + * @throws IllegalArgumentException + * @throws InvocationTargetException + * @throws InstantiationException + */ + public void validateJsonModelSchema(Class classz, Object classzInstance) + throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, InstantiationException + { + List allFields = getAllDeclaredFields(new LinkedList(), classz); + + for (Field field : allFields) + { + /* + * check for required fields + */ + if (field.isAnnotationPresent(JsonProperty.class)) + { + if (field.getAnnotation(JsonProperty.class).required()) + { + // we make it accessible to get the value + field.setAccessible(true); + + // now obtaining the field value from instance + Object fieldValue = field.get(classzInstance); + String info = String.format("Checking required field [%s] from class %s - value: %s", + field.getName(), classzInstance.getClass().getName(), fieldValue); + LOG.info(info); + Assert.assertNotNull(fieldValue, info); + + // continue for non-primitive objects + if (!field.getType().isPrimitive()) + { + validateJsonModelSchema(fieldValue.getClass(), fieldValue); + } + } + } + } + } + + /** + * Get and clear the stored parameters. + * + * @return parameters that you could pass on the request ?param=value + */ + public String getParameters() + { + String localParam = parameters; + clearParameters(); + return localParam; + } + + /** + * Define the entire string of parameters that will be send to request + * Don't forget to call {@link #getParameters()} in the request to enable this. + * + * @param parameters + */ + public void setParameters(String parameters) + { + this.parameters = parameters; + } + + /** + * Just clear the parameters sent + */ + public void clearParameters() + { + setParameters(""); + } + + /** + * just clear the base path + * + * @return + */ + public RestWrapper clearBasePath() + { + this.configureRequestSpec().setBasePath(""); + return this; + } + + /** + * Send key=value parameters. + *

+ * Note that this will replace any existing parameters. + * + * @param parameters A list of URL query parameters - e.g. "maxItems=10000" + * @return The RestWrapper + */ + public RestWrapper withParams(String... parameters) + { + String paramsStr = Arrays.stream(parameters).collect(Collectors.joining("&")); + setParameters(paramsStr); + return this; + } + + /** + * @return {@link RestCoreAPI} using the rest Core API as prefix: {@link /alfresco/api/-default-/public/alfresco/versions/1} + */ + public RestCoreAPI withCoreAPI() + { + return new RestCoreAPI(this); + } + + /** + * @return {@link RestWorkflowAPI} using the rest Workflow API with prefix: {@link /alfresco/api/-default-/public/workflow/versions/1 } + */ + public RestWorkflowAPI withWorkflowAPI() + { + return new RestWorkflowAPI(this); + } + + /** + * @return {@link RestAuthAPI} using the rest Auth API with prefix: {@link /alfresco/api/-default-/public/authentication/versions/1 } + */ + public RestAuthAPI withAuthAPI() + { + return new RestAuthAPI(this); + } + + public RestModelAPI withModelAPI() + { + return new RestModelAPI(this); + } + + public SearchAPI withSearchAPI() + { + return new SearchAPI(this); + } + + public SearchSQLAPI withSearchSqlAPI() + { + return new SearchSQLAPI(this); + } + + public SearchSQLJDBC withSearchSqlViaJDBC() + { + return new SearchSQLJDBC(this); + } + + public ShardInfoAPI withShardInfoAPI() + { + return new ShardInfoAPI(this); + } + + public SolrAPI withSolrAPI() + { + return new SolrAPI(this); + } + + public SolrAdminAPI withSolrAdminAPI() + { + return new SolrAdminAPI(this); + } + + /** + * @return {@link RestDiscoveryAPI} using the rest Discovery API as prefix: {@link /alfresco/api/discovery} + */ + public RestDiscoveryAPI withDiscoveryAPI() + { + return new RestDiscoveryAPI(this); + } + + /** + * @return {@link AdminConsole} using the Admin Console API as prefix: {@link /alfresco/service/api/server} + */ + public AdminConsole withAdminConsole() + { + return new AdminConsole(this); + } + + /** + * Provides DSL on creating Tenant users + * + * @return {@link Tenant} + */ + public Tenant usingTenant() + { + return new Tenant(this, restProperties); + } + + /** + * Construct the Where clause of any REST API call + * You can use the where parameter to restrict the list in the response to entries of a specific kind. + * The where parameter takes a value. + */ + public RestWrapper where(String whereExpression) + { + String whereClause = "where=(%s)"; + + return withParams(String.format(whereClause, whereExpression)); + } + + public ContentType getDefaultContentType() + { + return defaultContentType; + } + + public RestWrapper usingContentType(ContentType defaultContentType) + { + this.defaultContentType = defaultContentType; + return this; + } + + /** + * You can handle the request sent to server by calling this method. + * If for example you want to sent multipart form data you can use: + * restClient.configureRequestSpec() + .addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource")) + .addFormParam("renditions", "doclib") + .addFormParam("autoRename", true); + + restClient.withCoreAPI().usingNode(ContentModel.my()).createNode(); + * This will create the node using the multipart data defined. + * + * @return + */ + public RequestSpecBuilder configureRequestSpec() + { + return this.requestSpecBuilder; + } + + /** + * Perform CMIS browser binding calls ("alfresco/api/-default-/public/cmis/versions/1.1/browser") with Rest API + * + * @return {@link RestCmisAPI} + */ + public RestCmisAPI withCMISApi() + { + return new RestCmisAPI(this); + } + + /** + * Perform AOS browser binding calls ("alfresco/aos") with Rest API + * + * @return {@link RestAosAPI} + */ + public RestAosAPI withAosAPI() + { + return new RestAosAPI(this); + } + + /** + * @return {@link RestPrivateAPI} using the rest Private API as prefix: {@link /alfresco/api/-default-/private/alfresco/versions/1} + */ + public RestPrivateAPI withPrivateAPI() + { + return new RestPrivateAPI(this); + } + + public RestResponse onResponse() + { + if (response == null) + throw new UnsupportedOperationException("Cannot perform on a Response that wasn't yet received!"); + return response; + } + + /** + * Process responses for a single model as {@link RestSyncSetRequestModel} + * Notice that {@link RestSyncSetRequestModel} doesn't have one "entry" field as any other rest request model + * + * @throws JsonToModelConversionException If the response cannot be converted to the given model. + * @throws EmptyJsonResponseException If there is no response from the server. + */ + public T processModelWithoutEntryObject(Class classz, RestRequest restRequest) + throws EmptyJsonResponseException, JsonToModelConversionException + { + Response returnedResponse = sendRequest(restRequest); + + setStatusCode(String.valueOf(returnedResponse.getStatusCode())); + + boolean responseHasErrors = checkForJsonError(returnedResponse); + // Do not check checkForJsonStatusException as status object in the API response is not a standard statusModel + // boolean responseHasExceptions = checkForJsonStatusException(returnedResponse); + + T model = null; + + try + { + if (!responseHasErrors) + { + model = returnedResponse.jsonPath().getObject("$", classz); + validateJsonModelSchema(classz, model); + } + } + catch (Exception processError) + { + throw new JsonToModelConversionException(classz, processError); + } + if (model == null) + { + try + { + return classz.newInstance(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + return model; + } + + public void configureSyncServiceEndPoint() + { + this.serverURI = restProperties.envProperty().getSyncServerUrl(); + this.serverPort = restProperties.envProperty().getSyncPort(); + configureServerEndpoint(); + } + + public void configureSolrEndPoint() + { + this.serverURI = restProperties.envProperty().getSolrServerUrl(); + this.serverPort = restProperties.envProperty().getSolrPort(); + configureServerEndpoint(); + configureSecretHeader(); + } + + /** + * Adds the secret Solr header if it has been set + */ + private void configureSecretHeader() + { + String solrSecret = restProperties.envProperty().getSolrSecret(); + if(!solrSecret.isEmpty()) + { + String solrSecretName = restProperties.envProperty().getSolrSecretName(); + configureRequestSpec().addHeader(solrSecretName, solrSecret); + } + } + + /** + * Use {@link #setServerURI(String)} and {@link #setServerPort(int)} + */ + public void configureServerEndpoint() + { + requestSpecBuilder = new RequestSpecBuilder(); + + // use static variables for logs, etc + // the request spec is built from data set via setters, see RestWrapper#onRequest + RestAssured.baseURI = this.serverURI; + RestAssured.port = this.serverPort; + + configureRequestSpec().setBaseUri(this.serverURI); + configureRequestSpec().setPort(this.serverPort); + } + + /** + * Adding new method to configure Alfresco Endpoint. + * Reconfiguration is required when restClient is used to executed apis on different : e.g. solr api followed by search api + */ + public void configureAlfrescoEndpoint() + { + this.serverURI = restProperties.envProperty().getTestServerUrl(); + this.serverPort = restProperties.envProperty().getPort(); + configureServerEndpoint(); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/assertion/IModelAssertion.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/assertion/IModelAssertion.java new file mode 100644 index 0000000000..a5fcdaa647 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/assertion/IModelAssertion.java @@ -0,0 +1,39 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.core.assertion; + +public interface IModelAssertion +{ + default ModelAssertion assertThat() + { + return new ModelAssertion<>(this); + } + + default ModelAssertion and() + { + return assertThat(); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/assertion/IModelsCollectionAssertion.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/assertion/IModelsCollectionAssertion.java new file mode 100644 index 0000000000..256d393531 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/assertion/IModelsCollectionAssertion.java @@ -0,0 +1,39 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.core.assertion; + +@SuppressWarnings("rawtypes") +public interface IModelsCollectionAssertion { + public ModelsCollectionAssertion and(); + + public ModelsCollectionAssertion assertThat(); + + @SuppressWarnings("unchecked") + default ModelCollection when() + { + return (ModelCollection) this; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/assertion/ModelAssertion.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/assertion/ModelAssertion.java new file mode 100644 index 0000000000..d6c1407383 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/assertion/ModelAssertion.java @@ -0,0 +1,435 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.core.assertion; + +import java.io.Serializable; +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 com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; + +import io.restassured.path.json.JsonPath; +import org.alfresco.utility.exception.TestConfigurationException; +import org.alfresco.utility.model.TestModel; +import org.testng.Assert; + +/** + * Assertion on Rest Model + * Just pass your rest model as constructor + * + * @author Paul Brodner + */ + +public class ModelAssertion +{ + 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 final 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 + * { private String id = "1234"; } + * you can use assert the id of this person as: + * Person p = new Person(); p.assertThat().field("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() + { + + int actualSize = 0; + List allFields = getAllDeclaredFields(new LinkedList(), model.getClass()); + + for (Field field : allFields) + { + + field.setAccessible(true); + Object fieldValue = null; + try + { + fieldValue = field.get(model); + } + catch (IllegalAccessException e) + { + throw new IllegalStateException("Unable to load model using reflection.", e); + } + if (fieldValue != null) + actualSize++; + } + return new AssertionItemVerbs(model, actualSize); + } + + /** + * Use this method for asserting whole model with different model object. Method allows to ignore particular fields during the comparison. + * + * WARNING: For proper work model should implement {@code toString()} and {@code equals()} methods. + * + * @param expected - expected model. + * @param ignoreFields - fields which should be ignored during assertion. + * @return model. + */ + @SuppressWarnings("unchecked") + public T isEqualTo(T expected, String... ignoreFields) + { + T modelCopy = createCopyIgnoringFields((T) model, ignoreFields); + T expectedCopy = createCopyIgnoringFields(expected, ignoreFields); + Assert.assertEquals(modelCopy, expectedCopy, String.format("Compared objects of type: %s are not equal!", model.getClass())); + return (T) model; + } + + /** + * Get all fields declared from all classes hierarchy + * + * @param fields + * @param classz + * @return + */ + private List getAllDeclaredFields(List 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; + } + + @SuppressWarnings("unchecked") + private T createCopyIgnoringFields(T model, String... ignoreFields) + { + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.registerTypeAdapterFactory(new SerializableTypeAdapterFactory()); + Gson gson = gsonBuilder.create(); + JsonObject jsonObject = gson.fromJson(gson.toJson(model), JsonObject.class); + for (String ignoreField : ignoreFields) + { + jsonObject.remove(ignoreField); + } + return gson.fromJson(gson.toJson(jsonObject), (Class) model.getClass()); + } + + /** Workaround from https://github.com/google/gson/issues/544 */ + private class SerializableTypeAdapterFactory implements TypeAdapterFactory + { + @Override + public TypeAdapter create(Gson gson, TypeToken type) + { + if (Serializable.class.equals(type.getRawType())) + { + return (TypeAdapter) gson.getAdapter(Object.class); + } + return null; + } + } + + /** + * 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; + } + + public T notContains(String value) + { + if (fieldValue.toString().contains(value)) + { + Assert.fail(errorMessage("does contain unexpected 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) + { + 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 + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/assertion/ModelsCollectionAssertion.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/assertion/ModelsCollectionAssertion.java new file mode 100644 index 0000000000..99ca55e875 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/assertion/ModelsCollectionAssertion.java @@ -0,0 +1,279 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.core.assertion; + +import static org.alfresco.utility.report.log.Step.STEP; + +import java.lang.reflect.InvocationTargetException; +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.core.JsonProcessingException; +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 +{ + @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) + { + List modelEntries = modelCollection.getEntries(); + String fieldValue = ""; + for (Model m : modelEntries) { + Object model = loadModel(m); + 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) + { + boolean exist = false; + List modelEntries = modelCollection.getEntries(); + for (Model m : modelEntries) { + Object model = loadModel(m); + 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) + { + boolean exist = modelInList(key); + Assert.assertFalse(exist, + String.format("Entry list contains key: %s", key)); + + return (C) modelCollection; + } + + @SuppressWarnings("unchecked") + public C entriesListContains(String key) + { + boolean exist = modelInList(key); + Assert.assertTrue(exist, + String.format("Entry list doesn't contain key: %s", key)); + + return (C) modelCollection; + } + + private boolean modelInList(String key) + { + List modelEntries = modelCollection.getEntries(); + for (Model m : modelEntries) + { + Object model = loadModel(m); + ObjectMapper mapper = new ObjectMapper(); + String jsonInString; + try + { + jsonInString = mapper.writeValueAsString(model); + } + catch (JsonProcessingException e) + { + throw new IllegalStateException("Failed to convert model to string.", e); + } + Object fieldValue = JsonPath.with(jsonInString).get(key); + if (fieldValue != null) + { + return true; + } + } + return false; + } + + @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(modelCollection, field, modelCollection.getPagination()); + } + + /** + * check is the entries are ordered ASC by a specific field + * + * @param field from json response + * @return + */ + @SuppressWarnings("unchecked") + public C entriesListIsSortedAscBy(String field) + { + List modelEntries = modelCollection.getEntries(); + List fieldValues = new ArrayList(); + for(Model m: modelEntries) + { + Object model = loadModel(m); + 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 + */ + @SuppressWarnings("unchecked") + public C entriesListIsSortedDescBy(String field) + { + List modelEntries = modelCollection.getEntries(); + List fieldValues = new ArrayList(); + for(Model m: modelEntries) + { + Object model = loadModel(m); + 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; + } + + private Object loadModel(Model m) + { + try + { + Method method = m.getClass().getMethod("onModel", new Class[] {}); + return method.invoke(m, new Object[] {}); + } + catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) + { + throw new IllegalStateException("Failed to load model using reflection.", e); + } + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/assertion/PaginationAssertionVerbs.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/assertion/PaginationAssertionVerbs.java new file mode 100644 index 0000000000..f3e8072db1 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/assertion/PaginationAssertionVerbs.java @@ -0,0 +1,104 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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 { + 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 + */ + private String getFieldValue() { + 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) { + + Assert.assertEquals(getFieldValue(), expected, errorMessage("is NOT correct,")); + return modelCollection; + } + + public C isNot(Object expected) { + + Assert.assertNotEquals(getFieldValue(), expected, errorMessage("is correct,")); + return modelCollection; + } + + public C isNotEmpty() { + Assert.assertNotEquals(getFieldValue(), "", errorMessage("is empty,")); + return modelCollection; + } + + public C isNotNull() { + Assert.assertNotNull(getFieldValue(), errorMessage("is null,")); + return modelCollection; + } + + public C isNotPresent() { + Assert.assertNull(getFieldValue(), errorMessage("is present,")); + return modelCollection; + } + + public C isEmpty() { + Assert.assertEquals(getFieldValue(), "", errorMessage("is NOT empty,")); + return modelCollection; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/Generator.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/Generator.java new file mode 100644 index 0000000000..96bebd68db --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/Generator.java @@ -0,0 +1,76 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.core.swagger; + +/** + * Executed via command line/terminal from root of this project + * Just execute mvn exec:java 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) + { + + 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) + { + /* + * mvn exec:java -Dcoverage + */ + new SwaggerYamlParser(url).computeCoverage(); + } + else if (System.getProperty("models") != null) + { + /* + * mvn exec:java -Dmodels + * mvn exec:java -Dmodels=a,c,e + */ + new SwaggerYamlParser(url).generateMissingModules(); + } + } + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/RestModelProperty.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/RestModelProperty.java new file mode 100644 index 0000000000..8b3d5b8a68 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/RestModelProperty.java @@ -0,0 +1,150 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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 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 itemsEntry = new AbstractMap.SimpleEntry( + 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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/SwaggerDefinitions.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/SwaggerDefinitions.java new file mode 100644 index 0000000000..76b709f709 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/SwaggerDefinitions.java @@ -0,0 +1,222 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.core.swagger; + +import java.io.BufferedReader; +import java.io.Console; +import java.io.FileNotFoundException; +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 + * Entry model : swagger.getDefinitions().entrySet() + * + * @author Paul Brodner + */ +public class SwaggerDefinitions +{ + private Swagger swagger; + List missingSwaggerModels = new ArrayList(); + 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() + { + /* + * read the content of ignore-moldels file + */ + List ignoreModel = new ArrayList(); + try + { + 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); + } + } + } + catch (IOException e) + { + throw new IllegalStateException("Exception while generating missing definitions.", e); + } + + /* + * filter all models, ignoring the ones from ignore-model or the ones that are already created locally + */ + for (Entry 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 <>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) + { + generateModel(swaggerModel); + } + } + 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 + */ + private void generateSelectedSwaggerModel(String id) + { + int choice = Integer.parseInt(id); + if ((choice - 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!"); + } + generateModel(missingSwaggerModels.get(choice - 1)); + } + + public boolean generateDefinition(String modelParamValue) + { + for (Entry model : swagger.getDefinitions().entrySet()) + { + SwaggerModel swaggerModel = new SwaggerModel(model, swagger); + if (swaggerModel.getName().equals(modelParamValue)) + { + generateModel(swaggerModel); + 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; + } + + private void generateModel(SwaggerModel swaggerModel) + { + try + { + swaggerModel.generate(); + } + catch (IOException | TemplateException e) + { + throw new IllegalStateException("Exception while generating model definition.", e); + } + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/SwaggerModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/SwaggerModel.java new file mode 100644 index 0000000000..a2ab91ea66 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/SwaggerModel.java @@ -0,0 +1,186 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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 Entry model : swagger.getDefinitions().entrySet() + * + * @author Paul Brodner + */ +public class SwaggerModel +{ + private Swagger swagger; + private Entry model; + private Path modelsPath = Paths.get(Paths.get(".").toAbsolutePath().normalize().toFile().getPath(), "src/main/java/org/alfresco/rest/model"); + private List properties = new ArrayList(); + 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 model, Swagger swagger) + { + this.model = model; + this.swagger = swagger; + + + if(model.getValue().getProperties()!=null) + { + /* + * compute the properties of this model + */ + for (Entry 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 getProperties() + { + return properties; + } + + public void setProperties(List 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 data = new HashMap(); + 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(); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/SwaggerPaths.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/SwaggerPaths.java new file mode 100644 index 0000000000..953d48ca19 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/SwaggerPaths.java @@ -0,0 +1,219 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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 + * Entry path : swagger.getPaths().entrySet() + * + * @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 TestConfigurationException + */ + public void computeCoverage() + { + try + { + 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 path : swagger.getPaths().entrySet()) + { + for (Map.Entry 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 file(s), it seems some request were NOT implemented!"); + } + else + missingReq.delete(); + + System.out.println("ALSO ANALYZE for current implementation, take a look at duplicated requests if any!"); + } + catch (IOException e) + { + throw new RuntimeException("Exception while trying to create coverage report.", e); + } + } + + /** + * 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 + */ + private void searchPattern(String pathUrl, Entry operation) + { + 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: "(HttpMethod.GET, "process-definitions?{parameters}" + * 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 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(); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/SwaggerRequest.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/SwaggerRequest.java new file mode 100644 index 0000000000..7b2b778b63 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/SwaggerRequest.java @@ -0,0 +1,92 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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 freemarker.template.TemplateException; +import io.swagger.models.Operation; + +public class SwaggerRequest +{ + private Configuration cfg; + private Operation swaggerRequest; + private String httpMethod; + private String pathUrl; + + private Configuration getConfig() + { + if (cfg == null) + { + cfg = new Configuration(Configuration.VERSION_2_3_23); + try + { + cfg.setDirectoryForTemplateLoading(new File("src/main/resources")); + } + catch (IOException e) + { + throw new IllegalStateException("Exception while configuring Freemarker template directory.", e); + } + } + return cfg; + } + + public SwaggerRequest(String httpMethod, String pathUrl, Operation swaggerRequest) + { + this.swaggerRequest = swaggerRequest; + this.httpMethod = httpMethod; + this.pathUrl = pathUrl; + } + + public String getRequestSample() + { + try + { + Template template = getConfig().getTemplate("rest-request.ftl"); + Map data = new HashMap(); + 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(); + } + catch (IOException | TemplateException e) + { + throw new IllegalStateException("Exception while loading sample request.", e); + } + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/SwaggerYamlParser.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/SwaggerYamlParser.java new file mode 100644 index 0000000000..35aa0564aa --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/core/swagger/SwaggerYamlParser.java @@ -0,0 +1,104 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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 ''"); + + this.swaggerFilePath = swaggerFilePath; + this.swagger = new SwaggerParser().read(this.swaggerFilePath); + + } + + public void computeCoverage() + { + new SwaggerPaths(swagger, this.swaggerFilePath).computeCoverage(); + } + + public void generateMissingModules() + { + 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); + } + } + + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/exception/EmptyJsonResponseException.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/exception/EmptyJsonResponseException.java new file mode 100644 index 0000000000..b539494ccf --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/exception/EmptyJsonResponseException.java @@ -0,0 +1,36 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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)); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/exception/EmptyRestModelCollectionException.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/exception/EmptyRestModelCollectionException.java new file mode 100644 index 0000000000..f855a13126 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/exception/EmptyRestModelCollectionException.java @@ -0,0 +1,38 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.exception; + +import java.util.Collection; + +public class EmptyRestModelCollectionException extends Exception +{ + private static final long serialVersionUID = 1L; + + public EmptyRestModelCollectionException(Collection models) + { + super(String.format("Empty Rest Model Collection of type: %s -> %s", models.getClass(), models.toString())); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/exception/JsonToModelConversionException.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/exception/JsonToModelConversionException.java new file mode 100644 index 0000000000..00287f08ae --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/exception/JsonToModelConversionException.java @@ -0,0 +1,38 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.exception; + +public class JsonToModelConversionException extends RuntimeException +{ + + private static final long serialVersionUID = 1L; + + public JsonToModelConversionException(Class classz, Exception e) + { + super(String.format("Could not parse Json Response to model [%s] error: %s", classz.getName(), e.getMessage())); + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/exception/ModelToJsonConversionException.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/exception/ModelToJsonConversionException.java new file mode 100644 index 0000000000..a23363c38e --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/exception/ModelToJsonConversionException.java @@ -0,0 +1,36 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.exception; + +public class ModelToJsonConversionException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + public ModelToJsonConversionException(Class classz, Exception e) + { + super(String.format("Could not convert model for [%s] to JSON", classz.getName()), e); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAbstractClassModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAbstractClassModel.java new file mode 100644 index 0000000000..5804d87d17 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAbstractClassModel.java @@ -0,0 +1,167 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestAbstractClassModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestAbstractClassModel model; + + @Override + public RestAbstractClassModel onModel() + { + return model; + } + + public String id; + public String title; + public String description; + public String parentId; + public Boolean isContainer = null; + public Boolean isArchive = null; + public Boolean includedInSupertypeQuery = null; + public List mandatoryAspects = null; + public List associations = null; + public List properties = null; + + @JsonProperty(value = "model") + public RestClassModel modelInfo; + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + 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 String getParentId() + { + return parentId; + } + + public void setParentId(String parentId) + { + this.parentId = parentId; + } + + public Boolean getContainer() + { + return isContainer; + } + + public void setContainer(Boolean container) + { + isContainer = container; + } + + public Boolean getArchive() + { + return isArchive; + } + + public void setArchive(Boolean archive) + { + isArchive = archive; + } + + public Boolean getIncludedInSupertypeQuery() + { + return includedInSupertypeQuery; + } + + public void setIncludedInSupertypeQuery(Boolean includedInSupertypeQuery) + { + this.includedInSupertypeQuery = includedInSupertypeQuery; + } + + public List getMandatoryAspects() + { + return mandatoryAspects; + } + + public void setMandatoryAspects(List mandatoryAspects) + { + this.mandatoryAspects = mandatoryAspects; + } + + public List getAssociations() + { + return associations; + } + + public void setAssociations(List associations) + { + this.associations = associations; + } + + public List getProperties() { + return properties; + } + + public void setProperties(List properties) + { + this.properties = properties; + } + + public RestClassModel getModelInfo() + { + return modelInfo; + } + + public void setModelInfo(RestClassModel modelInfo) + { + this.modelInfo = modelInfo; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActionBodyExecTemplateModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActionBodyExecTemplateModel.java new file mode 100644 index 0000000000..c4957dc03f --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActionBodyExecTemplateModel.java @@ -0,0 +1,102 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.io.Serializable; +import java.util.Map; +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'Kristian.Dimitrov@hyland.com' on '2022-07-14 13:22' 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 RestActionBodyExecTemplateModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestActionBodyExecTemplateModel model; + + @Override + public RestActionBodyExecTemplateModel onModel() + { + return model; + } + + + @JsonProperty(required = true) + private String actionDefinitionId; + + private Map params; + + public String getActionDefinitionId() + { + return this.actionDefinitionId; + } + + public void setActionDefinitionId(String actionDefinitionId) + { + this.actionDefinitionId = actionDefinitionId; + } + + public Map getParams() + { + return this.params; + } + + public void setParams(Map params) + { + this.params = params; + } + + @Override + public String toString() + { + return "RestActionBodyExecTemplateModel{" + "actionDefinitionId='" + actionDefinitionId + '\'' + ", params=" + params + '}'; + } + + @Override + public boolean equals(Object o) + { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + RestActionBodyExecTemplateModel that = (RestActionBodyExecTemplateModel) o; + return Objects.equals(actionDefinitionId, that.actionDefinitionId) && Objects.equals(params, that.params); + } + + @Override + public int hashCode() + { + return Objects.hash(actionDefinitionId, params); + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActionConstraintDataModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActionConstraintDataModel.java new file mode 100644 index 0000000000..1304aea7ef --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActionConstraintDataModel.java @@ -0,0 +1,100 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ + +package org.alfresco.rest.model; + +import java.util.List; +import java.util.Objects; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Generated by 'mpichura' on '2022-10-05 09:58' 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 RestActionConstraintDataModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestActionConstraintDataModel model; + + @Override + public RestActionConstraintDataModel onModel() + { + return model; + } + + /** + Constraint value (this can also be a node id) + */ + + @JsonProperty(required = true) + private String value; + /** + Constraint display label + */ + + private String label; + + public String getValue() + { + return this.value; + } + + public void setValue(String value) + { + this.value = value; + } + + public String getLabel() + { + return this.label; + } + + public void setLabel(String label) + { + this.label = label; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RestActionConstraintDataModel that = (RestActionConstraintDataModel) o; + return value.equals(that.value) && Objects.equals(label, that.label); + } + + @Override + public int hashCode() + { + return Objects.hash(value, label); + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActionConstraintModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActionConstraintModel.java new file mode 100644 index 0000000000..29a50cb839 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActionConstraintModel.java @@ -0,0 +1,136 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ + +package org.alfresco.rest.model; + +import java.util.List; +import java.util.Objects; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Generated by 'mpichura' on '2022-10-05 09:58' 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 RestActionConstraintModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestActionConstraintModel model; + + @Override + public RestActionConstraintModel onModel() + { + return model; + } + + /** + Name of the constraint. + + */ + + private String constraintName; + /** + A list of constraint possbile values along with additional data (label, isNode flag). +Sample object could be: +```JSON +"constraintValues": [ + { + "value": "EQUALS", + "label": "Equals" + }, + { + "value": "CONTAINS", + "label": "Contains" + }, + { + "value": "BEGINS", + "label": "Begins With" + }, + { + "value": "ENDS", + "label": "Ends With" + }, + { + "value": "GREATER_THAN", + "label": "Greater Than" + }, + { + "value": "GREATER_THAN_EQUAL", + "label": "Greater Than Or Equal To" + }, + { + "value": "LESS_THAN", + "label": "Less Than" + }, + { + "value": "LESS_THAN_EQUAL", + "label": "Less Than Or Equal To" + } + ] + */ + + private List constraintValues; + + public String getConstraintName() + { + return this.constraintName; + } + + public void setConstraintName(String constraintName) + { + this.constraintName = constraintName; + } + + public List getConstraintValues() + { + return this.constraintValues; + } + + public void setConstraintValues(List constraintValues) + { + this.constraintValues = constraintValues; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RestActionConstraintModel that = (RestActionConstraintModel) o; + return constraintName.equals(that.constraintName) && Objects.equals(constraintValues, that.constraintValues); + } + + @Override + public int hashCode() + { + return Objects.hash(constraintName, constraintValues); + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActionDefinitionModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActionDefinitionModel.java new file mode 100644 index 0000000000..c3aaf41f52 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActionDefinitionModel.java @@ -0,0 +1,135 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestActionDefinitionModel extends TestModel implements IRestModel +{ + + @JsonProperty(value = "entry") + RestActionDefinitionModel actionDefinitionModel; + private String id; + private String name; + private String title; + private String description; + private List applicableTypes; + private boolean adhocPropertiesAllowed; + private boolean trackStatus; + private List 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 getApplicableTypes() + { + return applicableTypes; + } + + public void setApplicableTypes(List 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 getParameterDefinitions() + { + return parameterDefinitions; + } + + public void setParameterDefinitions(List parameterDefinitions) + { + this.parameterDefinitions = parameterDefinitions; + } + + @Override + public RestActionDefinitionModel onModel() + { + return actionDefinitionModel; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActionDefinitionModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActionDefinitionModelsCollection.java new file mode 100644 index 0000000000..bd3c04e6d5 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActionDefinitionModelsCollection.java @@ -0,0 +1,33 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +public class RestActionDefinitionModelsCollection extends RestModels +{ + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActivityModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActivityModel.java new file mode 100644 index 0000000000..1c1b1df75f --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActivityModel.java @@ -0,0 +1,161 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * + * @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 +{ + @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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActivityModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActivityModelsCollection.java new file mode 100644 index 0000000000..6a6fa694c1 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActivityModelsCollection.java @@ -0,0 +1,69 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; +/** + * + * @author Cristina Axinte + * + * /** + * Handle collection of + * 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 +{ +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActivitySummaryModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActivitySummaryModel.java new file mode 100644 index 0000000000..1251ada001 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestActivitySummaryModel.java @@ -0,0 +1,144 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.TestModel; + +/** + * + * "activitySummary": { + "firstName": "string", + "lastName": "string", + "parentObjectId": "string", + "title": "string", + "objectId": "string" + } + * + * @author Cristina Axinte + * + */ +public class RestActivitySummaryModel extends TestModel implements IRestModel +{ + @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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAggregateModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAggregateModel.java new file mode 100644 index 0000000000..faf67c77b8 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAggregateModel.java @@ -0,0 +1,67 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestAggregateModel extends TestModel implements IRestModel +{ + @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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestArchiveContentRequestModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestArchiveContentRequestModel.java new file mode 100644 index 0000000000..cc32ae3dad --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestArchiveContentRequestModel.java @@ -0,0 +1,72 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2021 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'dedwards' on '2021-12-16 08:32' 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 RestArchiveContentRequestModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestArchiveContentRequestModel model; + + @Override + public RestArchiveContentRequestModel onModel() + { + return model; + } + + /** + A map (String-String) of archive request properties for given content. + + */ + + private Object archiveProperties; + + public Object getArchiveProperties() + { + return this.archiveProperties; + } + + public void setArchiveProperties(Object archiveProperties) + { + this.archiveProperties = archiveProperties; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAspectModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAspectModel.java new file mode 100644 index 0000000000..0c931a02ca --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAspectModel.java @@ -0,0 +1,30 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +public class RestAspectModel extends RestAbstractClassModel +{ +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAspectsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAspectsCollection.java new file mode 100644 index 0000000000..7bcf85324a --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAspectsCollection.java @@ -0,0 +1,32 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +public class RestAspectsCollection extends RestModels +{ +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAuditAppModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAuditAppModel.java new file mode 100644 index 0000000000..345a68f169 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAuditAppModel.java @@ -0,0 +1,86 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * 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 +{ + @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; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAuditAppModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAuditAppModelsCollection.java new file mode 100644 index 0000000000..a965f08702 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAuditAppModelsCollection.java @@ -0,0 +1,33 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +public class RestAuditAppModelsCollection extends RestModels +{ + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAuditEntryModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAuditEntryModel.java new file mode 100644 index 0000000000..25bca6544a --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAuditEntryModel.java @@ -0,0 +1,106 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestAuditEntryModel extends TestModel implements IRestModel +{ + @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 values; + +public Map getValues() + { + return values; + } + + public void setValues(Map 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; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAuditEntryModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAuditEntryModelsCollection.java new file mode 100644 index 0000000000..1d33b23f2d --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAuditEntryModelsCollection.java @@ -0,0 +1,33 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +public class RestAuditEntryModelsCollection extends RestModels +{ + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAuditValuesModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAuditValuesModel.java new file mode 100644 index 0000000000..60a3a3625f --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestAuditValuesModel.java @@ -0,0 +1,52 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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; + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestByUserModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestByUserModel.java new file mode 100644 index 0000000000..7a172f185d --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestByUserModel.java @@ -0,0 +1,57 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCandidateModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCandidateModel.java new file mode 100644 index 0000000000..f9636486f0 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCandidateModel.java @@ -0,0 +1,71 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestCandidateModel extends TestModel implements IRestModel +{ + @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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCandidateModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCandidateModelsCollection.java new file mode 100644 index 0000000000..d6a4afe0a2 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCandidateModelsCollection.java @@ -0,0 +1,33 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +public class RestCandidateModelsCollection extends RestModels +{ + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestClassAssociationDefinitionModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestClassAssociationDefinitionModel.java new file mode 100644 index 0000000000..01f9579c9e --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestClassAssociationDefinitionModel.java @@ -0,0 +1,87 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.utility.model.TestModel; + +public class RestClassAssociationDefinitionModel extends TestModel +{ + public String role = null; + public String cls = null; + public Boolean isMany = null; + public Boolean isMandatory = null; + public Boolean isMandatoryEnforced = null; + + public String getRole() + { + return role; + } + + public void setRole(String role) + { + this.role = role; + } + + public String getCls() + { + return cls; + } + + public void setCls(String cls) + { + this.cls = cls; + } + + public Boolean getMany() + { + return isMany; + } + + public void setMany(Boolean many) + { + isMany = many; + } + + public Boolean getMandatory() + { + return isMandatory; + } + + public void setMandatory(Boolean mandatory) + { + isMandatory = mandatory; + } + + public Boolean getMandatoryEnforced() + { + return isMandatoryEnforced; + } + + public void setMandatoryEnforced(Boolean mandatoryEnforced) + { + isMandatoryEnforced = mandatoryEnforced; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestClassAssociationModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestClassAssociationModel.java new file mode 100644 index 0000000000..7956bb6fb6 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestClassAssociationModel.java @@ -0,0 +1,111 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.utility.model.TestModel; + +public class RestClassAssociationModel extends TestModel +{ + public String id; + public String title; + public String description; + public Boolean isChild; + public Boolean isProtected; + public RestClassAssociationDefinitionModel source = null; + public RestClassAssociationDefinitionModel target = null; + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + 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 Boolean getChild() + { + return isChild; + } + + public void setIsChild(Boolean isChild) + { + this.isChild = isChild; + } + + public Boolean getIsProtected() + { + return isProtected; + } + + public void setIsProtected(Boolean isProtected) + { + this.isProtected = isProtected; + } + + public RestClassAssociationDefinitionModel getSource() + { + return source; + } + + public void setSource(RestClassAssociationDefinitionModel source) + { + this.source = source; + } + + public RestClassAssociationDefinitionModel getTarget() + { + return target; + } + + public void setTarget(RestClassAssociationDefinitionModel target) + { + this.target = target; + } +} + + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestClassModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestClassModel.java new file mode 100644 index 0000000000..0d27ae2488 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestClassModel.java @@ -0,0 +1,87 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.utility.model.TestModel; + +public class RestClassModel extends TestModel +{ + public String id; + public String author; + public String description; + public String namespaceUri; + public String namespacePrefix; + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + public String getAuthor() + { + return author; + } + + public void setAuthor(String author) + { + this.author = author; + } + + public String getDescription() + { + return description; + } + + public void setDescription(String description) + { + this.description = description; + } + + public String getNamespaceUri() + { + return namespaceUri; + } + + public void setNamespaceUri(String namespaceUri) + { + this.namespaceUri = namespaceUri; + } + + public String getNamespacePrefix() + { + return namespacePrefix; + } + + public void setNamespacePrefix(String namespacePrefix) + { + this.namespacePrefix = namespacePrefix; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCommentModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCommentModel.java new file mode 100644 index 0000000000..ef4ca501f8 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCommentModel.java @@ -0,0 +1,143 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestCommentModel extends TestModel implements IRestModel +{ + @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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCommentModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCommentModelsCollection.java new file mode 100644 index 0000000000..4150732708 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCommentModelsCollection.java @@ -0,0 +1,32 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +public class RestCommentModelsCollection extends RestModels +{ +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCompanyModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCompanyModel.java new file mode 100644 index 0000000000..2ebcbf3526 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCompanyModel.java @@ -0,0 +1,143 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +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 implements IRestModel +{ + @JsonProperty (value = "entry") + RestCompanyModel model; + private String organization; + private String address1; + private String address2; + private String address3; + private String postcode; + private String telephone; + private String fax; + private String email; + + @Override + public RestCompanyModel onModel() + { + return model; + } + + 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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCompositeConditionDefinitionModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCompositeConditionDefinitionModel.java new file mode 100644 index 0000000000..ad7d5a5546 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCompositeConditionDefinitionModel.java @@ -0,0 +1,138 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'Kristian.Dimitrov@hyland.com' on '2022-07-13 15:53' 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 RestCompositeConditionDefinitionModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestCompositeConditionDefinitionModel model; + + @Override + public RestCompositeConditionDefinitionModel onModel() + { + return model; + } + + /** + Whether to invert the logic for this condition (if true then "not" is applied to the whole condition) + */ + + private boolean inverted; + /** + How to combine the clauses of this condition ("and" or "or") + */ + + private String booleanMode; + /** + Nested list of composite clauses in this condition + */ + + private List compositeConditions; + /** + Nested list of simple (per field) conditions. + */ + + private List simpleConditions; + + public boolean getInverted() + { + return this.inverted; + } + + public void setInverted(boolean inverted) + { + this.inverted = inverted; + } + + public String getBooleanMode() + { + return this.booleanMode; + } + + public void setBooleanMode(String booleanMode) + { + this.booleanMode = booleanMode; + } + + public List getCompositeConditions() + { + return this.compositeConditions; + } + + public void setCompositeConditions(List compositeConditions) + { + this.compositeConditions = compositeConditions; + } + + public List getSimpleConditions() + { + return this.simpleConditions; + } + + public void setSimpleConditions(List simpleConditions) + { + this.simpleConditions = simpleConditions; + } + + @Override + public String toString() + { + return "RestCompositeConditionDefinitionModel{" + "inverted=" + inverted + ", booleanMode='" + booleanMode + '\'' + ", compositeConditions=" + compositeConditions + + ", simpleConditions=" + simpleConditions + '}'; + } + + @Override + public boolean equals(Object o) + { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + RestCompositeConditionDefinitionModel that = (RestCompositeConditionDefinitionModel) o; + return inverted == that.inverted && Objects.equals(booleanMode, that.booleanMode) && Objects.equals(compositeConditions, that.compositeConditions) && Objects.equals( + simpleConditions, that.simpleConditions); + } + + @Override + public int hashCode() + { + return Objects.hash(inverted, booleanMode, compositeConditions, simpleConditions); + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestConstraintDefinitionModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestConstraintDefinitionModel.java new file mode 100644 index 0000000000..0e17244421 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestConstraintDefinitionModel.java @@ -0,0 +1,87 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.Map; + +public class RestConstraintDefinitionModel +{ + private String id; + private String type; + private String title; + private String description; + private Map parameters; + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + public String getType() + { + return type; + } + + public void setType(String type) + { + this.type = type; + } + + 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 Map getParameters() + { + return parameters; + } + + public void setParameters(Map parameters) + { + this.parameters = parameters; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestContentModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestContentModel.java new file mode 100644 index 0000000000..f8c14203d3 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestContentModel.java @@ -0,0 +1,92 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.utility.model.TestModel; + +import java.util.Set; + +/** + * 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; + private Set storageClasses; + + 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; + } + + public Set getStorageClasses() + { + return storageClasses; + } + + public void setStorageClasses(Set storageClasses) + { + this.storageClasses = storageClasses; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestContentStorageInfoModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestContentStorageInfoModel.java new file mode 100644 index 0000000000..4032c45dae --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestContentStorageInfoModel.java @@ -0,0 +1,91 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2021 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ +package org.alfresco.rest.model; + +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'dedwards' on '2021-12-16 08:32' 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 RestContentStorageInfoModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestContentStorageInfoModel model; + + @Override + public RestContentStorageInfoModel onModel() + { + return model; + } + + /** + Content type property identifier (e.g. cm:content). Inside this object only colon (':') delimiter for namespace-prefix will be used. + + */ + + @JsonProperty(required = true) + private String id; + /** + A map (String-String) of storage properties for given content. + + */ + + private Map storageProperties; + + public String getId() + { + return this.id; + } + + public void setId(String id) + { + this.id = id; + } + + public Map getStorageProperties() + { + return this.storageProperties; + } + + public void setStorageProperties(Map storageProperties) + { + this.storageProperties = storageProperties; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCustomAspectModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCustomAspectModel.java new file mode 100644 index 0000000000..289a7aa4f3 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCustomAspectModel.java @@ -0,0 +1,66 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.CustomAspectModel; +import org.alfresco.utility.model.CustomAspectPropertiesModel; +import org.testng.Assert; + +/** + * @author Bogdan Bocancea + */ +public class RestCustomAspectModel extends CustomAspectModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestCustomAspectModel model; + + @Override + public RestCustomAspectModel onModel() + { + return model; + } + + public RestCustomAspectModel assertHasProperties(CustomAspectPropertiesModel... propertiesName) + { + List propertiesModelName = new ArrayList(); + List 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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCustomModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCustomModel.java new file mode 100644 index 0000000000..9edae5049a --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCustomModel.java @@ -0,0 +1,46 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.CustomContentModel; + +/** + * @author Bogdan Bocancea + */ +public class RestCustomModel extends CustomContentModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestCustomModel model; + + @Override + public RestCustomModel onModel() + { + return model; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCustomTypeModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCustomTypeModel.java new file mode 100644 index 0000000000..003ba568a4 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestCustomTypeModel.java @@ -0,0 +1,133 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.CustomAspectPropertiesModel; +import org.alfresco.utility.model.TestModel; + +/** + * @author Bogdan Bocancea + */ +public class RestCustomTypeModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestCustomTypeModel model; + + @JsonProperty(required = true) + private String name; + + @JsonProperty(required = true) + private String parentName; + + @JsonProperty + private String title; + + @JsonProperty + private String description; + + @JsonProperty + private List properties; + + public RestCustomTypeModel() + { + + } + + public RestCustomTypeModel(String name, String parentName) + { + this.name = name; + this.parentName = parentName; + } + + public RestCustomTypeModel(String name, String parentName, String title) + { + this.name = name; + this.parentName = parentName; + this.title = title; + } + + @Override + public RestCustomTypeModel onModel() + { + return model; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getParentName() + { + return parentName; + } + + public void setParentName(String parentName) + { + this.parentName = parentName; + } + + 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 getProperties() + { + return properties; + } + + public void setProperties(List properties) + { + this.properties = properties; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestDeploymentModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestDeploymentModel.java new file mode 100644 index 0000000000..53e1ef503e --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestDeploymentModel.java @@ -0,0 +1,110 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * 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 +{ + @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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestDeploymentModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestDeploymentModelsCollection.java new file mode 100644 index 0000000000..3a4d0a2d2e --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestDeploymentModelsCollection.java @@ -0,0 +1,71 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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 +{ + + public RestDeploymentModel getDeploymentByName(String deploymentName) + { + STEP(String.format("REST API: Get deployment with name '%s'", deploymentName)); + List deploymentsList = getEntries(); + + for (RestDeploymentModel deploymentEntry: deploymentsList) + { + if (deploymentEntry.onModel().getName().equals(deploymentName)) + { + return deploymentEntry.onModel(); + } + } + + return null; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestDiscoveryModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestDiscoveryModel.java new file mode 100644 index 0000000000..0bd670f33e --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestDiscoveryModel.java @@ -0,0 +1,56 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestDiscoveryModel extends TestModel implements IRestModel +{ + @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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestDownloadsModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestDownloadsModel.java new file mode 100644 index 0000000000..36c712365e --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestDownloadsModel.java @@ -0,0 +1,147 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/* + * 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 +{ + @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; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestElementModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestElementModel.java new file mode 100644 index 0000000000..bcfeda92b1 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestElementModel.java @@ -0,0 +1,91 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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 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 getAspectNames() + { + return aspectNames; + } + + public void setAspectNames(List aspectNames) + { + this.aspectNames = aspectNames; + } + + public String getNodeType() + { + return nodeType; + } + + public void setNodeType(String nodeType) + { + this.nodeType = nodeType; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestEntitlementsInfoModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestEntitlementsInfoModel.java new file mode 100644 index 0000000000..c43584543f --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestEntitlementsInfoModel.java @@ -0,0 +1,110 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Generated by 'saspery' on '2022-09-28 06:54' 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 +{ + @JsonProperty(value = "entry") + RestEntitlementsInfoModel model; + + @Override + public RestEntitlementsInfoModel onModel() + { + return model; + } + + + private int maxUsers; + + private int maxDocs; + + private boolean isClusterEnabled; + + private boolean isCryptodocEnabled; + + private boolean isCustomEmbeddedWorkflowEnabled; + + 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; + } + + public boolean getIsCustomEmbeddedWorkflowEnabled() + { + return this.isCustomEmbeddedWorkflowEnabled; + } + + public void setIsCustomEmbeddedWorkflowEnabled(boolean isCustomEmbeddedWorkflowEnabled) + { + this.isCustomEmbeddedWorkflowEnabled = isCustomEmbeddedWorkflowEnabled; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestErrorModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestErrorModel.java new file mode 100644 index 0000000000..35993797a5 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestErrorModel.java @@ -0,0 +1,212 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestFavoriteSiteModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestFavoriteSiteModel.java new file mode 100644 index 0000000000..89b52b517d --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestFavoriteSiteModel.java @@ -0,0 +1,54 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestFavoriteSiteModel extends TestModel implements IRestModel +{ + @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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestFileModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestFileModel.java new file mode 100644 index 0000000000..be4617b908 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestFileModel.java @@ -0,0 +1,272 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * 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 +{ + @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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestFolderModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestFolderModel.java new file mode 100644 index 0000000000..b54c84f1aa --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestFolderModel.java @@ -0,0 +1,219 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * 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 +{ + @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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestFormModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestFormModel.java new file mode 100644 index 0000000000..d0f22e7698 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestFormModel.java @@ -0,0 +1,135 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * 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 +{ + @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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestFormModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestFormModelsCollection.java new file mode 100644 index 0000000000..8da30fda72 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestFormModelsCollection.java @@ -0,0 +1,79 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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 + * "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 +{ + public RestFormModel getStartFormModelByQualifiedName(String qualifiedName) + { + STEP(String.format("REST API: Get start form model by qualified name '%s'", qualifiedName)); + List startFormModels = getEntries(); + + for (RestFormModel startFormModel: startFormModels) + { + if (startFormModel.onModel().getQualifiedName().equals(qualifiedName)) + { + return startFormModel.onModel(); + } + } + return null; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestGenericBucketModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestGenericBucketModel.java new file mode 100644 index 0000000000..8eca867e8c --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestGenericBucketModel.java @@ -0,0 +1,143 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.rest.search.RestGenericMetricModel; +import org.alfresco.utility.model.TestModel; + +/** + * 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 +{ + @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 metrics; + /** + Additional list of nested facets + */ + + private List 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 getMetrics() + { + return this.metrics; + } + + public void setMetrics(List metrics) + { + this.metrics = metrics; + } + + public List getFacets() + { + return this.facets; + } + + public void setFacets(List facets) + { + this.facets = facets; + } + + public Object getFacetInfo() + { + return this.facetInfo; + } + + public void setFacetInfo(Object facetInfo) + { + this.facetInfo = facetInfo; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestGroupMember.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestGroupMember.java new file mode 100644 index 0000000000..2ffd06eee5 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestGroupMember.java @@ -0,0 +1,80 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestGroupMember extends TestModel implements IRestModel +{ + @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 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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestGroupMemberModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestGroupMemberModelsCollection.java new file mode 100644 index 0000000000..b619bc236d --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestGroupMemberModelsCollection.java @@ -0,0 +1,32 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +public class RestGroupMemberModelsCollection extends RestModels +{ +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestGroupsModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestGroupsModel.java new file mode 100644 index 0000000000..ec8c28b105 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestGroupsModel.java @@ -0,0 +1,107 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.ArrayList; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestGroupsModel extends TestModel implements IRestModel +{ + @JsonProperty(required = true) + private String id; + @JsonProperty(required = true) + private String displayName; + @JsonProperty(required = true) + private Boolean isRoot; + + @JsonProperty("parentIds") + private ArrayList parentIds; + @JsonProperty("zones") + private ArrayList zones; + + @JsonProperty(value = "entry") + RestGroupsModel model; + + @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 getParentIds() + { + return parentIds; + } + + public void setParentIds(ArrayList parentIds) + { + this.parentIds = parentIds; + } + + public ArrayList getZones() + { + return zones; + } + + public void setZones(ArrayList zones) + { + this.zones = zones; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestGroupsModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestGroupsModelsCollection.java new file mode 100644 index 0000000000..7fa20d4948 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestGroupsModelsCollection.java @@ -0,0 +1,32 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +public class RestGroupsModelsCollection extends RestModels +{ +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestHtmlResponse.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestHtmlResponse.java new file mode 100644 index 0000000000..786997c445 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestHtmlResponse.java @@ -0,0 +1,79 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import static org.alfresco.utility.report.log.Step.STEP; + +import io.restassured.http.Headers; +import io.restassured.response.ResponseBody; +import org.alfresco.utility.Utility; +import org.testng.Assert; + +/** + * 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() + { + 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."); + } + + /** + * 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); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestIdentityServiceConfigurationModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestIdentityServiceConfigurationModel.java new file mode 100644 index 0000000000..134f6994a7 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestIdentityServiceConfigurationModel.java @@ -0,0 +1,152 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2020 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +package org.alfresco.rest.model; + +import org.alfresco.utility.model.TestModel; + +public class RestIdentityServiceConfigurationModel extends TestModel{ + + public RestIdentityServiceConfigurationModel() { + + } + + private String authenticationChain; + + private String authenticationEnabled; + + private String enableBasicAuth; + + private String authServerUrl; + + private String realm; + + private String resource; + + private String publicClient; + + private String sslRequired; + + private String enablePkce; + + private String credentialsSecret; + + private String credentialsProvider; + + public String getAuthenticationChain() { + return authenticationChain; + } + + public void setAuthenticationChain(String authenticationChain) { + this.authenticationChain = authenticationChain; + } + + public String getAuthenticationEnabled() { + return authenticationEnabled; + } + + public void setAuthenticationEnabled(String authenticationEnabled) { + this.authenticationEnabled = authenticationEnabled; + } + + public String getEnableBasicAuth() { + return enableBasicAuth; + } + + public void setEnableBasicAuth(String enableBasicAuth) { + this.enableBasicAuth = enableBasicAuth; + } + + public String getAuthServerUrl() { + return authServerUrl; + } + + public void setAuthServerUrl(String authServerUrl) { + this.authServerUrl = authServerUrl; + } + + public String getRealm() { + return realm; + } + + public void setRealm(String realm) { + this.realm = realm; + } + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + + public String getPublicClient() { + return publicClient; + } + + public void setPublicClient(String publicClient) { + this.publicClient = publicClient; + } + + public String getSslRequired() { + return sslRequired; + } + + public void setSslRequired(String sslRequired) { + this.sslRequired = sslRequired; + } + + public String getEnablePkce() { + return enablePkce; + } + + public void setEnablePkce(String enablePkce) { + this.enablePkce = enablePkce; + } + + public String getCredentialsSecret() { + return credentialsSecret; + } + + public void setCredentialsSecret(String credentialsSecret) { + this.credentialsSecret = credentialsSecret; + } + + public String getCredentialsProvider() { + return credentialsProvider; + } + + public void setCredentialsProvider(String credentialsProvider) { + this.credentialsProvider = credentialsProvider; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestItemModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestItemModel.java new file mode 100644 index 0000000000..11a3a32b0d --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestItemModel.java @@ -0,0 +1,132 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * + "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 +{ + @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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestItemModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestItemModelsCollection.java new file mode 100644 index 0000000000..3e1f6542dc --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestItemModelsCollection.java @@ -0,0 +1,69 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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 +{ + public RestItemModel getProcessItemByName(String name) + { + STEP(String.format("REST API: Get process item entry with name '%s'", name)); + List processItemsList = getEntries(); + + for (RestItemModel item: processItemsList) + { + if (item.onModel().getName().equals(name)) + { + return item.onModel(); + } + } + return null; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestLicenseInfoModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestLicenseInfoModel.java new file mode 100644 index 0000000000..442c04277d --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestLicenseInfoModel.java @@ -0,0 +1,127 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * 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 +{ + @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; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestLinkedRuleSetBodyCreateModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestLinkedRuleSetBodyCreateModel.java new file mode 100644 index 0000000000..73cfce7d28 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestLinkedRuleSetBodyCreateModel.java @@ -0,0 +1,66 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'Kristian.Dimitrov@hyland.com' on '2022-07-13 15:53' 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 RestLinkedRuleSetBodyCreateModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestLinkedRuleSetBodyCreateModel model; + + @Override + public RestLinkedRuleSetBodyCreateModel onModel() + { + return model; + } + + /** + Identifier for either the folder or the rule set + */ + + @JsonProperty(required = true) + private String id; + + public String getId() + { + return this.id; + } + + public void setId(String id) + { + this.id = id; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestModuleInfoModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestModuleInfoModel.java new file mode 100644 index 0000000000..0ed7232e6d --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestModuleInfoModel.java @@ -0,0 +1,146 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * 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 +{ + @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; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNetworkModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNetworkModel.java new file mode 100644 index 0000000000..0275a0eb31 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNetworkModel.java @@ -0,0 +1,91 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import static org.alfresco.utility.report.log.Step.STEP; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.UserModel; +import org.testng.Assert; + +/** + * 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 +{ + @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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNetworkModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNetworkModelsCollection.java new file mode 100644 index 0000000000..798f0026f8 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNetworkModelsCollection.java @@ -0,0 +1,32 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +public class RestNetworkModelsCollection extends RestModels +{ +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNetworkQuotaModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNetworkQuotaModel.java new file mode 100644 index 0000000000..418a864b38 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNetworkQuotaModel.java @@ -0,0 +1,86 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * 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 +{ + @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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeAssocTargetModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeAssocTargetModel.java new file mode 100644 index 0000000000..6a962b3a38 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeAssocTargetModel.java @@ -0,0 +1,79 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestNodeAssocTargetModel extends TestModel implements IRestModel +{ + @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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeAssociationModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeAssociationModel.java new file mode 100644 index 0000000000..371980a789 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeAssociationModel.java @@ -0,0 +1,326 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Created by Andrei Forascu on 30/08/2017. + */ +public class RestNodeAssociationModel extends TestModel implements IRestModel +{ + @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 aspectNames; + + private Object properties; + + private List 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 getAspectNames() + { + return aspectNames; + } + + public void setAspectNames(List aspectNames) + { + this.aspectNames = aspectNames; + } + + public Object getProperties() + { + return properties; + } + + public void setProperties(Object properties) + { + this.properties = properties; + } + + public List getAllowableOperations() + { + return allowableOperations; + } + + public void setAllowableOperations(List 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; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeAssociationModelCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeAssociationModelCollection.java new file mode 100644 index 0000000000..00aa294f0b --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeAssociationModelCollection.java @@ -0,0 +1,33 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +public class RestNodeAssociationModelCollection extends RestModels +{ + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeAssociationTypeModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeAssociationTypeModel.java new file mode 100644 index 0000000000..2892e41b83 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeAssociationTypeModel.java @@ -0,0 +1,73 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Represents an association between two nodes + */ +public class RestNodeAssociationTypeModel extends TestModel implements IRestModel +{ + @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; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeBodyModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeBodyModel.java new file mode 100644 index 0000000000..42a68a506a --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeBodyModel.java @@ -0,0 +1,154 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * 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 +{ + @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 aspectNames; + + private Object properties; + + private String relativePath; + + private Object association; + + private List secondaryChildren; + + private List 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 getAspectNames() + { + return aspectNames; + } + + public void setAspectNames(List aspectNames) + { + this.aspectNames = aspectNames; + } + + public List getSecondaryChildren() + { + return secondaryChildren; + } + + public void setSecondaryChildren(List secondaryChildren) + { + this.secondaryChildren = secondaryChildren; + } + + public List getTargets() + { + return targets; + } + + public void setTargets(List targets) + { + this.targets = targets; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeBodyMoveCopyModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeBodyMoveCopyModel.java new file mode 100644 index 0000000000..702751271f --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeBodyMoveCopyModel.java @@ -0,0 +1,64 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeChildAssocModelCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeChildAssocModelCollection.java new file mode 100644 index 0000000000..2dea5c1ca6 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeChildAssocModelCollection.java @@ -0,0 +1,33 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +public class RestNodeChildAssocModelCollection extends RestModels +{ + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeChildAssociationModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeChildAssociationModel.java new file mode 100644 index 0000000000..fcc5067334 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeChildAssociationModel.java @@ -0,0 +1,81 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestNodeChildAssociationModel extends TestModel implements IRestModel +{ + @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; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeModel.java new file mode 100644 index 0000000000..69ee1588f7 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeModel.java @@ -0,0 +1,325 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * 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 +{ + @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 aspectNames; + + private Object properties; + + private List 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 getAspectNames() + { + return aspectNames; + } + + public void setAspectNames(List aspectNames) + { + this.aspectNames = aspectNames; + } + + public List getAllowableOperations() + { + return allowableOperations; + } + + public void setAllowableOperations(List 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; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeModelsCollection.java new file mode 100644 index 0000000000..0eaf6c9833 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestNodeModelsCollection.java @@ -0,0 +1,96 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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 +{ + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPaginationModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPaginationModel.java new file mode 100644 index 0000000000..6daaee277b --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPaginationModel.java @@ -0,0 +1,109 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.assertion.IModelAssertion; +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 +{ + private int count; + private boolean hasMoreItems; + /** + * {code}totalItems{code} is optional and some endpoints don't include it e.g. GET sites/{siteId}/members + * See the section entitled "The list object" in https://ts.alfresco.com/share/page/site/prodman/document-details?nodeRef=workspace://SpacesStore/17eacc65-28e5-40bb-8113-edb8c21d57a5 + */ + 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; + } + + /** + * Get the totalItems. + * + * @return The total number of items, or null if it was not included in the response. + */ + 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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestParameterDefinitionModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestParameterDefinitionModel.java new file mode 100644 index 0000000000..efff831b31 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestParameterDefinitionModel.java @@ -0,0 +1,121 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestParameterDefinitionModel extends TestModel implements IRestModel +{ + 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 RestParameterDefinitionModel onModel() + { + return parameterDefinitionModel; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPathModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPathModel.java new file mode 100644 index 0000000000..4f5f3727f3 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPathModel.java @@ -0,0 +1,85 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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 elements; + + public List getElements() + { + return elements; + } + + public void setElements(List 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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPersonFavoritesModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPersonFavoritesModel.java new file mode 100644 index 0000000000..f3ef35ed78 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPersonFavoritesModel.java @@ -0,0 +1,89 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestPersonFavoritesModel extends TestModel implements IRestModel +{ + @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; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPersonFavoritesModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPersonFavoritesModelsCollection.java new file mode 100644 index 0000000000..fea51012f2 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPersonFavoritesModelsCollection.java @@ -0,0 +1,63 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +/** + * Handle collection of + * 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 +{ +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPersonModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPersonModel.java new file mode 100644 index 0000000000..6bea884980 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPersonModel.java @@ -0,0 +1,360 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.rest.core.assertion.IModelAssertion; +import org.alfresco.utility.model.TestModel; + +/** + * Person Model implementation + */ +public class RestPersonModel extends TestModel implements IModelAssertion, IRestModel +{ + @JsonProperty(value = "entry") + RestPersonModel personModel; + + @Override + public RestPersonModel onModel() + { + return personModel; + } + + private List aspectNames; + + @JsonProperty(required = true) + private String firstName; + @JsonProperty(required = true) + private String id; + @JsonProperty(required = true) + private boolean enabled; + @JsonProperty(required = true) + private String email; + private String lastName; + private String displayName; + private boolean emailNotificationsEnabled; + + private RestCompanyModel company; + + private String avatarId; + private String location; + private String instantMessageId; + private String googleId; + private String skypeId; + private String description; + private String telephone; + private String jobTitle; + private String mobile; + private String statusUpdatedAt; + private String userStatus; + private String password; + private Object properties; + private String quotaUsed; + private String quota; + private Map capabilities; + + public RestPersonModel() + { + } + + public RestPersonModel(String firstName, boolean emailNotificationsEnabled, RestCompanyModel company, String id, boolean enabled, String email) + { + super(); + this.firstName = firstName; + this.emailNotificationsEnabled = emailNotificationsEnabled; + this.company = company; + this.id = id; + this.enabled = enabled; + this.email = email; + } + + 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 boolean getEmailNotificationsEnabled() + { + return emailNotificationsEnabled; + } + + public void setEmailNotificationsEnabled(boolean emailNotificationsEnabled) + { + this.emailNotificationsEnabled = emailNotificationsEnabled; + } + + public RestCompanyModel getCompany() + { + return company; + } + + public void setCompany(RestCompanyModel company) + { + this.company = company; + } + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + public boolean getEnabled() + { + return enabled; + } + + public void setEnabled(boolean enabled) + { + this.enabled = enabled; + } + + public String getEmail() + { + return email; + } + + public void setEmail(String email) + { + this.email = email; + } + + public String getAvatarId() + { + return avatarId; + } + + public void setAvatarId(String avatarId) + { + this.avatarId = avatarId; + } + + public String getLocation() + { + return location; + } + + public void setLocation(String location) + { + this.location = location; + } + + public String getInstantMessageId() + { + return instantMessageId; + } + + public void setInstantMessageId(String instantMessageId) + { + this.instantMessageId = instantMessageId; + } + + public String getGoogleId() + { + return googleId; + } + + public void setGoogleId(String googleId) + { + this.googleId = googleId; + } + + public String getSkypeId() + { + return skypeId; + } + + public void setSkypeId(String skypeId) + { + this.skypeId = skypeId; + } + + public String getDescription() + { + return description; + } + + public void setDescription(String description) + { + this.description = description; + } + + public String getTelephone() + { + return telephone; + } + + public void setTelephone(String telephone) + { + this.telephone = telephone; + } + + public String getJobTitle() + { + return jobTitle; + } + + public void setJobTitle(String jobTitle) + { + this.jobTitle = jobTitle; + } + + public String getMobile() + { + return mobile; + } + + public void setMobile(String mobile) + { + this.mobile = mobile; + } + + public String getStatusUpdatedAt() + { + return statusUpdatedAt; + } + + public void setStatusUpdatedAt(String statusUpdatedAt) + { + this.statusUpdatedAt = statusUpdatedAt; + } + + public String getUserStatus() + { + return userStatus; + } + + public void setUserStatus(String userStatus) + { + this.userStatus = userStatus; + } + + public List getAspectNames() + { + return aspectNames; + } + + public void setAspectNames(List aspectNames) + { + this.aspectNames = aspectNames; + } + + public Object getProperties() + { + return properties; + } + + public void setProperties(Object properties) + { + this.properties = properties; + } + + public Map getCapabilities() + { + return capabilities; + } + + public void setCapabilities(Map capabilities) + { + this.capabilities = capabilities; + } + + public String getPassword() + { + return password; + } + + + public void setPassword(String password) + { + this.password = password; + } + + public String getDisplayName() + { + return displayName; + } + + public void setDisplayName(String displayName) + { + this.displayName = displayName; + } + + public String getQuotaUsed() { + return quotaUsed; + } + + + public void setQuotaUsed(String quotaUsed) { + this.quotaUsed = quotaUsed; + } + + public String getQuota() { + return quota; + } + + public void setQuota(String quota) { + this.quota = quota; + } + + + /** + * Generate a PersonModel with random values for all existing fields excluding fields specified as ingnoredFields + * + * @param ignoredFields field to be excluded when generating a random model + * @return + */ + public static RestPersonModel getRandomPersonModel(String... ignoredFields) + { + RestPersonModel personModel = new RestPersonModel(); + setRandomValuesForAllFields(personModel, ignoredFields); + return personModel; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPersonModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPersonModelsCollection.java new file mode 100644 index 0000000000..1d9a8d10de --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPersonModelsCollection.java @@ -0,0 +1,38 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; +/** + * Handle collection of + * + * @author Cristina Axinte + * + */ +public class RestPersonModelsCollection extends RestModels +{ + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPersonNetworkModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPersonNetworkModel.java new file mode 100644 index 0000000000..adc96e02e7 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPersonNetworkModel.java @@ -0,0 +1,134 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; + +import org.alfresco.utility.constants.NetworkSubscriptionLevel; +import org.alfresco.utility.model.TestModel; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Created by Cristina Axinte on 9/26/2016. + */ +public class RestPersonNetworkModel extends TestModel +{ + @JsonProperty(required = true) + private String id; + + private boolean homeNetwork; + + @JsonProperty(required = true) + private boolean isEnabled; + + private String createdAt; + private boolean paidNetwork; + private NetworkSubscriptionLevel subscriptionLevel; + + private List quotas; + + public RestPersonNetworkModel() + { + } + + public RestPersonNetworkModel(String id, boolean isEnabled) + { + this.id = id; + this.isEnabled = isEnabled; + } + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + public boolean isHomeNetwork() + { + return homeNetwork; + } + + public void setHomeNetwork(boolean homeNetwork) + { + this.homeNetwork = homeNetwork; + } + + public String getCreatedAt() + { + return createdAt; + } + + public void setCreatedAt(String createdAt) + { + this.createdAt = createdAt; + } + + public boolean isPaidNetwork() + { + return paidNetwork; + } + + public void setPaidNetwork(boolean paidNetwork) + { + this.paidNetwork = paidNetwork; + } + + public NetworkSubscriptionLevel getSubscriptionLevel() + { + return subscriptionLevel; + } + + public void setSubscriptionLevel(NetworkSubscriptionLevel subscriptionLevel) + { + this.subscriptionLevel = subscriptionLevel; + } + + public List getQuotas() + { + return quotas; + } + + public void setQuotas(List quotas) + { + this.quotas = quotas; + } + + public boolean isEnabled() + { + return isEnabled; + } + + public void setEnabled(boolean isEnabled) + { + this.isEnabled = isEnabled; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPreferenceModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPreferenceModel.java new file mode 100644 index 0000000000..4dfc88eb7f --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPreferenceModel.java @@ -0,0 +1,76 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Handles Pagination JSON + * + * Example: + * { + "entry": { + "id": "org.alfresco.share.sites.favourites.site-lwdxYDQFIi", + "value": true + } + * + * @author Cristina Axinte + */ +public class RestPreferenceModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestPreferenceModel model; + + @Override + public RestPreferenceModel onModel() + { + return model; + } + + @JsonProperty(required = true) + String id; + String value; + + public String getValue() + { + return value; + } + public void setValue(String value) + { + this.value = value; + } + public String getId() + { + return id; + } + public void setId(String id) + { + this.id = id; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPreferenceModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPreferenceModelsCollection.java new file mode 100644 index 0000000000..33ea653c6a --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPreferenceModelsCollection.java @@ -0,0 +1,62 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +/** + * Handle collection of + * { + * "list": { + * "pagination": { + * "count": 2, + * "hasMoreItems": false, + * "totalItems": 2, + * "skipCount": 0, + * "maxItems": 100 + * }, + * "entries": [ + * { + * "entry": { + * "id": "org.alfresco.ext.sites.favourites.site-lwdxYDQFIi.createdAt", + * "value": "2016-09-30T16:31:05.085Z" + * } + * }, + * { + * "entry": { + * "id": "org.alfresco.share.sites.favourites.site-lwdxYDQFIi", + * "value": true + * } + * } + * ] + * } + * } + * + * @author Cristina Axinte + */ +public class RestPreferenceModelsCollection extends RestModels +{ +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessDefinitionModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessDefinitionModel.java new file mode 100644 index 0000000000..03de46652d --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessDefinitionModel.java @@ -0,0 +1,172 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Handles single Process Definition Entry JSON response + * "entry": { + * "deploymentId": "1", + * "name": "Adhoc Activiti Process", + * "description": "Assign a new task to yourself or a colleague", + * "id": "activitiAdhoc:1:4", + * "startFormResourceKey": "wf:submitAdhocTask", + * "category": "http://alfresco.org", + * "title": "New Task", + * "version": 1, + * "graphicNotationDefined": true, + * "key": "activitiAdhoc" + * } + * Created by Claudia Agache on 10/13/2016. + */ +public class RestProcessDefinitionModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestProcessDefinitionModel model; + + @JsonProperty(required = true) + private String id; + private String deploymentId; + private String name; + private String description; + private String startFormResourceKey; + private String category; + private String title; + private int version; + private boolean graphicNotationDefined; + private String key; + + @Override + public RestProcessDefinitionModel onModel() + { + return model; + } + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + public String getKey() + { + return key; + } + + public void setKey(String key) + { + this.key = key; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getCategory() + { + return category; + } + + public void setCategory(String category) + { + this.category = category; + } + + public String getDeploymentId() + { + return deploymentId; + } + + public void setDeploymentId(String deploymentId) + { + this.deploymentId = deploymentId; + } + + 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 String getStartFormResourceKey() + { + return startFormResourceKey; + } + + public void setStartFormResourceKey(String startFormResourceKey) + { + this.startFormResourceKey = startFormResourceKey; + } + + public boolean getGraphicNotationDefined() + { + return graphicNotationDefined; + } + + public void setGraphicNotationDefined(boolean graphicNotationDefined) + { + this.graphicNotationDefined = graphicNotationDefined; + } + + public int getVersion() + { + return version; + } + + public void setVersion(int version) + { + this.version = version; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessDefinitionModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessDefinitionModelsCollection.java new file mode 100644 index 0000000000..71785b1163 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessDefinitionModelsCollection.java @@ -0,0 +1,100 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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 + * "entries": [ + * { + * "entry": { + * "deploymentId": "1", + * "name": "Adhoc Activiti Process", + * "description": "Assign a new task to yourself or a colleague", + * "id": "activitiAdhoc:1:4", + * "startFormResourceKey": "wf:submitAdhocTask", + * "category": "http://alfresco.org", + * "title": "New Task", + * "version": 1, + * "graphicNotationDefined": true, + * "key": "activitiAdhoc" + * } + * }, + * ] + * Created by Claudia Agache on 10/13/2016. + */ +public class RestProcessDefinitionModelsCollection extends RestModels +{ + public RestProcessDefinitionModel getProcessDefinitionByDeploymentId(String deploymentId) + { + STEP(String.format("REST API: Get process definition with deploymentId '%s'", deploymentId)); + List processDefinitionsList = getEntries(); + + for (RestProcessDefinitionModel processDefinitionEntry: processDefinitionsList) + { + if (processDefinitionEntry.onModel().getDeploymentId().equals(deploymentId)) + { + return processDefinitionEntry.onModel(); + } + } + return null; + } + + public RestProcessDefinitionModel getProcessDefinitionById(String id) + { + STEP(String.format("REST API: Get process definition with id '%s'", id)); + List processDefinitionsList = getEntries(); + + for (RestProcessDefinitionModel processDefinitionEntry: processDefinitionsList) + { + if (processDefinitionEntry.onModel().getId().equals(id)) + { + return processDefinitionEntry.onModel(); + } + } + return null; + } + + public RestProcessDefinitionModel getProcessDefinitionByKey(String key) + { + STEP(String.format("REST API: Get process definition with key '%s'", key)); + List processDefinitionsList = getEntries(); + + for (RestProcessDefinitionModel processDefinitionEntry: processDefinitionsList) + { + if (processDefinitionEntry.onModel().getKey().equals(key)) + { + return processDefinitionEntry.onModel(); + } + } + return null; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessModel.java new file mode 100644 index 0000000000..77ebc197c7 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessModel.java @@ -0,0 +1,157 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.rest.core.assertion.IModelAssertion; +import org.alfresco.utility.model.ProcessModel; + +/** + * Handles single Process Entry JSON response + * "entry": { + * "processDefinitionId": "activitiAdhoc:1:4", + * "startUserId": "admin", + * "startActivityId": "start", + * "startedAt": "2016-05-24T09:43:17.000+0000", + * "id": "55069", + * "completed": false, + * "processDefinitionKey": "activitiAdhoc" + * } + * Created by Claudia Agache on 10/11/2016. + */ +public class RestProcessModel extends ProcessModel implements IRestModel,IModelAssertion +{ + @JsonProperty(value = "entry") + RestProcessModel model; + + @Override + public RestProcessModel onModel() + { + return model; + } + + private String processDefinitionId; + private String startedAt; + private String startUserId; + private String startActivityId; + private String completed; + private String processDefinitionKey; + private String durationInMs; + private String endedAt; + private String deleteReason; + + public String getProcessDefinitionId() + { + return processDefinitionId; + } + + public void setProcessDefinitionId(String processDefinitionId) + { + this.processDefinitionId = processDefinitionId; + } + + public String getStartUserId() + { + return startUserId; + } + + public void setStartUserId(String startUserId) + { + this.startUserId = startUserId; + } + + public String getStartActivityId() + { + return startActivityId; + } + + public void setStartActivityId(String startActivityId) + { + this.startActivityId = startActivityId; + } + + public String getCompleted() + { + return completed; + } + + public void setCompleted(String completed) + { + this.completed = completed; + } + + public String getProcessDefinitionKey() + { + return processDefinitionKey; + } + + public void setProcessDefinitionKey(String processDefinitionKey) + { + this.processDefinitionKey = processDefinitionKey; + } + + public String getStartedAt() + { + return startedAt; + } + + public void setStartedAt(String startedAt) + { + this.startedAt = startedAt; + } + + public String getDurationInMs() + { + return durationInMs; + } + + public void setDurationInMs(String durationInMs) + { + this.durationInMs = durationInMs; + } + + public String getEndedAt() + { + return endedAt; + } + + public void setEndedAt(String endedAt) + { + this.endedAt = endedAt; + } + + public String getDeleteReason() + { + return deleteReason; + } + + public void setDeleteReason(String deleteReason) + { + this.deleteReason = deleteReason; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessModelsCollection.java new file mode 100644 index 0000000000..c89848afc4 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessModelsCollection.java @@ -0,0 +1,76 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import static org.alfresco.utility.report.log.Step.STEP; + +import java.util.List; + +import org.alfresco.rest.core.RestModels; + +/** + * Handles collection of Processes + * Example + * { + * "list": { + * "pagination": { + * "count": 100, + * "hasMoreItems": true, + * "totalItems": 849, + * "skipCount": 0, + * "maxItems": 100 + * , + * "entries": [ + * { + * "entry": { + * "processDefinitionId": "activitiAdhoc:1:4", + * "startUserId": "admin", + * "startActivityId": "start", + * "startedAt": "2016-05-24T09:43:17.000+0000", + * "id": "55069", + * "completed": false, + * "processDefinitionKey": "activitiAdhoc" + * } + * }, + * ] + * Created by Claudia Agache on 10/11/2016. + */ +public class RestProcessModelsCollection extends RestModels +{ + public RestProcessModel getProcessModelByProcessDefId(String processDefinitionId) + { + List processesList = getEntries(); + for (RestProcessModel processModel : processesList) + { + if (processModel.onModel().getId().equals(processDefinitionId)) + { + STEP(String.format("REST API: Get process with process definition '%s'", processDefinitionId)); + return processModel.onModel(); + } + } + return null; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessVariableCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessVariableCollection.java new file mode 100644 index 0000000000..8f7c2727c3 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessVariableCollection.java @@ -0,0 +1,60 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +import java.util.List; + +import static org.alfresco.utility.report.log.Step.STEP; + +/** + * + "entries": [ + {"entry": { + "name": "bpm_package", + "type": "bpm:workflowPackage", + "value": "workspace://SpacesStore/ab728441-84f4-4d61-bb04-c51822b114fe" + }}, + * + */ +public class RestProcessVariableCollection extends RestModels +{ + public RestProcessVariableModel getProcessVariableByName(String name) + { + STEP(String.format("REST API: Get process variable entry with name '%s'", name)); + List processVariablesList = getEntries(); + + for (RestProcessVariableModel variable: processVariablesList) + { + if (variable.onModel().getName().equals(name)) + { + return variable.onModel(); + } + } + return null; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessVariableModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessVariableModel.java new file mode 100644 index 0000000000..53c17a795e --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestProcessVariableModel.java @@ -0,0 +1,95 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.TestModel; + +public class RestProcessVariableModel extends TestModel implements IRestModel +{ + private String name; + + private String value; + + private String type; + + @JsonProperty(value = "entry") + RestProcessVariableModel model; + + public RestProcessVariableModel() + { + } + + public RestProcessVariableModel(String name, String value, String type) + { + this.name = name; + this.value = value; + this.type = type; + } + + @Override + public RestProcessVariableModel onModel() + { + return model; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getValue() + { + return value; + } + + public void setValue(String value) + { + this.value = value; + } + + public String getType() + { + return type; + } + + public void setType(String type) + { + this.type = type; + } + + public static RestProcessVariableModel getRandomProcessVariableModel(String variableType){ + return new RestProcessVariableModel(RandomData.getRandomName("name"), RandomData.getRandomName("value"), variableType); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPropertyDefinitionModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPropertyDefinitionModel.java new file mode 100644 index 0000000000..791a117ac6 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestPropertyDefinitionModel.java @@ -0,0 +1,142 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; + +public class RestPropertyDefinitionModel +{ + private String id; + private String title; + private String description; + private String defaultValue; + private String dataType; + private Boolean isMultiValued; + private Boolean isMandatory; + private Boolean isMandatoryEnforced; + private Boolean isProtected; + private List constraints; + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + 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 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 boolean getIsProtected() + { + return isProtected; + } + + public void setIsProtected(boolean isProtected) + { + this.isProtected = isProtected; + } + + public List getConstraints() + { + return constraints; + } + + public void setConstraints(List constraints) + { + this.constraints = constraints; + } + + public boolean getIsMultiValued() + { + return isMultiValued; + } + + public void setIsMultiValued(boolean isMultiValued) + { + this.isMultiValued = isMultiValued; + } + + public boolean getIsMandatory() + { + return isMandatory; + } + + public void setIsMandatory(boolean isMandatory) + { + this.isMandatory = isMandatory; + } + + public boolean getIsMandatoryEnforced() + { + return isMandatoryEnforced; + } + + public void setIsMandatoryEnforced(boolean isMandatoryEnforced) + { + this.isMandatoryEnforced = isMandatoryEnforced; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRatingModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRatingModel.java new file mode 100644 index 0000000000..4044c25da7 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRatingModel.java @@ -0,0 +1,90 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestRatingModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRatingModel model; + + @JsonProperty(required = true) + private String id; + + private String ratedAt; + private String myRating; + private RestAggregateModel aggregate; + + @Override + public RestRatingModel onModel() + { + return model; + } + + public RestAggregateModel getAggregate() + { + return aggregate; + } + + public void setAggregate(RestAggregateModel aggregate) + { + this.aggregate = aggregate; + } + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + public String getRatedAt() + { + return ratedAt; + } + + public void setRatedAt(String ratedAt) + { + this.ratedAt = ratedAt; + } + + public String getMyRating() + { + return myRating; + } + + public void setMyRating(String myRating) + { + this.myRating = myRating; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRatingModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRatingModelsCollection.java new file mode 100644 index 0000000000..42ae45c0e3 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRatingModelsCollection.java @@ -0,0 +1,115 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import static org.alfresco.utility.report.log.Step.STEP; + +import java.util.List; + +import org.alfresco.rest.core.RestModels; +import org.testng.Assert; + +/** + * Handle collection of +{ + "list": { + "pagination": { + "count": 0, + "hasMoreItems": true, + "totalItems": 0, + "skipCount": 0, + "maxItems": 0 + }, + "entries": [ + { + "entry": { + "id": "string", + "aggregate": { + "numberOfRatings": 0, + "average": 0 + }, + "ratedAt": "2016-09-28T13:56:58.931Z", + "myRating": "string" + } + } + ] + } +} + */ +public class RestRatingModelsCollection extends RestModels +{ + public RestRatingModelsCollection assertNodeIsLiked() + { + STEP("REST API: Assert that document is liked"); + Assert.assertTrue(getNumberOfRatingsFor("likes") > 0, "Node should have like ratings"); + + return this; + } + + public RestRatingModelsCollection assertNodeIsNotLiked() + { + STEP("REST API: Assert that document is not liked"); + Assert.assertTrue(getNumberOfRatingsFor("likes") == 0, "Node should have no like ratings"); + + return this; + } + + public RestRatingModelsCollection assertNodeHasFiveStarRating() + { + STEP("REST API: Assert that document has five star rating"); + Assert.assertTrue(getNumberOfRatingsFor("fiveStar") > 0, "Node should have five star ratings"); + + return this; + } + + public RestRatingModelsCollection assertNodeHasNoFiveStarRating() + { + STEP("REST API: Assert that document has no five star rating"); + Assert.assertTrue(getNumberOfRatingsFor("fiveStar") == 0, "Node should have no five star ratings"); + + return this; + } + + /** + * Default, the rating value can be: "likes" or "fiveStar" + * @param ratingValue + * @return + */ + public int getNumberOfRatingsFor(String ratingValue) + { + List ratings = getEntries(); + int noOfRatings = 0; + for (int i = 0; i < ratings.size(); i++) + { + if (ratings.get(i).onModel().getId().equals(ratingValue)) + { + noOfRatings = ratings.get(i).onModel().getAggregate().getNumberOfRatings(); + } + } + + return noOfRatings; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRenditionInfoModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRenditionInfoModel.java new file mode 100644 index 0000000000..bd3898be96 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRenditionInfoModel.java @@ -0,0 +1,76 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * @author cmocanu + * Base Path + * {@linkplain /alfresco/api/-default-/public/alfresco/versions/1} + */ + +public class RestRenditionInfoModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRenditionInfoModel model; + + @Override + public RestRenditionInfoModel onModel() { + return model; + } + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public RestContentModel getContent() { + return content; + } + + public void setContent(RestContentModel content) { + this.content = content; + } + + private String id; + private RestContentModel content; + private String status; + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRenditionInfoModelCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRenditionInfoModelCollection.java new file mode 100644 index 0000000000..8a0a912265 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRenditionInfoModelCollection.java @@ -0,0 +1,81 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +/** + * Handle collection of + * + * @author meenal bhave + * Example: + * { + * "list": + * { + * "pagination": + * { + * "count": 2, + * "hasMoreItems": false, + * "totalItems": 2, + * "skipCount": 0, + * "maxItems": 100 + * }, + * "entries": [ + * { + * "entry": + * { + * "id": "doclib", + * "content": + * { + * "mimeType": "image/png", + * "mimeTypeName": "PNG Image", + * "sizeInBytes": 414, + * "encoding": "UTF-8" + * }, + * "status": "CREATED" + * } + * }, + * { + * "entry": + * { + * "id": "pdf", + * "content": + * { + * "mimeType": "application/pdf", + * "mimeTypeName": "Adobe PDF Document", + * "sizeInBytes": 10144, + * "encoding": "UTF-8" + * }, + * "status": "CREATED" + * } + * } + * ] + * } + * } + */ +public class RestRenditionInfoModelCollection extends RestModels +{ +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRepositoryInfoModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRepositoryInfoModel.java new file mode 100644 index 0000000000..5fbeb1f8ab --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRepositoryInfoModel.java @@ -0,0 +1,127 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * 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 RestRepositoryInfoModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRepositoryInfoModel model; + + @Override + public RestRepositoryInfoModel onModel() + { + return model; + } + + @JsonProperty(required = true) + private String id; + + @JsonProperty(required = true) + private String edition; + + @JsonProperty(required = true) + private RestVersionInfoModel version; + + @JsonProperty(required = true) + private RestStatusInfoModel status; + + private RestLicenseInfoModel license; + + private List modules; + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + public String getEdition() + { + return this.edition; + } + + public void setEdition(String edition) + { + this.edition = edition; + } + + public RestVersionInfoModel getVersion() + { + return this.version; + } + + public void setVersion(RestVersionInfoModel version) + { + this.version = version; + } + + public RestStatusInfoModel getStatus() + { + return this.status; + } + + public void setStatus(RestStatusInfoModel status) + { + this.status = status; + } + + public RestLicenseInfoModel getLicense() + { + return this.license; + } + + public void setLicense(RestLicenseInfoModel license) + { + this.license = license; + } + + public List getModules() + { + return this.modules; + } + + public void setModules(List modules) + { + this.modules = modules; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRequestRangesModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRequestRangesModel.java new file mode 100644 index 0000000000..3efede9e65 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRequestRangesModel.java @@ -0,0 +1,187 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'msuzuki' on '2017-05-15 10:58' 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 RestRequestRangesModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRequestRangesModel model; + + @Override + public RestRequestRangesModel onModel() + { + return model; + } + + /** + The name of the field to perform range + */ + + private String field; + /** + The start of the range + */ + + private String start; + /** + The end of the range + */ + + private String end; + /** + Bucket size + */ + + private String gap; + /** + If true means that the last bucket will end at “end” even if it is less than “gap” wide. + */ + + private boolean hardend; + /** + before, after, between, non, all + */ + + private List other; + /** + lower, upper, edge, outer, all + */ + + private List include; + /** + Tags used exclude the filters from facet evaluation for multi-select facet support + */ + + private String label; + /** + Filter queries to exclude when calculating statistics + */ + + private List excludeFilters; + + public String getField() + { + return this.field; + } + + public void setField(String field) + { + this.field = field; + } + + public String getStart() + { + return this.start; + } + + public void setStart(String start) + { + this.start = start; + } + + public String getEnd() + { + return this.end; + } + + public void setEnd(String end) + { + this.end = end; + } + + public String getGap() + { + return this.gap; + } + + public void setGap(String gap) + { + this.gap = gap; + } + + public boolean getHardend() + { + return this.hardend; + } + + public void setHardend(boolean hardend) + { + this.hardend = hardend; + } + + public List getOther() + { + return this.other; + } + + public void setOther(List other) + { + this.other = other; + } + + public List getInclude() + { + return this.include; + } + + public void setInclude(List include) + { + this.include = include; + } + + public String getLabel() + { + return label; + } + + public void setLabel(String label) + { + this.label = label; + } + + public List getExcludeFilters() + { + return this.excludeFilters; + } + + public void setExcludeFilters(List excludeFilters) + { + this.excludeFilters = excludeFilters; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRequestSpellcheckModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRequestSpellcheckModel.java new file mode 100644 index 0000000000..d25347c688 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRequestSpellcheckModel.java @@ -0,0 +1,62 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'msuzuki' on '2017-02-28 16:04' from 'Alfresco Content Services REST API' swagger file + * Generated from 'Alfresco Content Services REST API' swagger file + * Base Path {@linkplain /alfresco/api/-default-/public/search/versions/1} + */ +public class RestRequestSpellcheckModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRequestSpellcheckModel model; + + @Override + public RestRequestSpellcheckModel onModel() + { + return model; + } + + + private String query; + + public String getQuery() + { + return this.query; + } + + public void setQuery(String query) + { + this.query = query; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRestoreArchivedContentRequestModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRestoreArchivedContentRequestModel.java new file mode 100644 index 0000000000..27a7ca5bf9 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRestoreArchivedContentRequestModel.java @@ -0,0 +1,71 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2021 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'dedwards' on '2021-12-16 08:32' 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 RestRestoreArchivedContentRequestModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRestoreArchivedContentRequestModel model; + + @Override + public RestRestoreArchivedContentRequestModel onModel() + { + return model; + } + + /** + Restore from archive priority (Standard/High - to be mapped to Storage Provider specific values in Cloud Connectors) + */ + + private String restorePriority; + + public String getRestorePriority() + { + return this.restorePriority; + } + + public void setRestorePriority(String restorePriority) + { + this.restorePriority = restorePriority; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleBodyModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleBodyModel.java new file mode 100644 index 0000000000..12398dc73d --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleBodyModel.java @@ -0,0 +1,198 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'Kristian.Dimitrov@hyland.com' on '2022-07-13 15:53' 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 RestRuleBodyModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRuleBodyModel model; + + @Override + public RestRuleBodyModel onModel() + { + return model; + } + + /** + Name of the rule + */ + + @JsonProperty(required = true) + private String name; + /** + Description of the rule + */ + + private String description; + /** + Whether the rule is enabled + */ + + private boolean enabled; + /** + Whether the rule also applies to subfolders + */ + + private boolean cascade; + /** + Whether the rule should be run in the background + */ + + private boolean asynchronous; + /** + If the rule should be run in the background then an optional error script can be referenced + */ + + private String errorScript; + /** + The set of triggers that cause the rule to be activated. +* inbound - The rule should be activated when an item enters the folder +* update - The rule should be activated when an item within the folder is updated +* outbound - The rule should be activated when an item leaves the folder or is deleted + + */ + + private List triggers; + /** + The conditions that determine whether the actions will be executed for a rule. + +A condition should contain at least one entry in compositeConditions or simpleConditions. + +If the field is omitted then the rule will apply to all nodes. + + */ + + private RestCompositeConditionDefinitionModel conditions; + /** + The actions for the rule + */ + + @JsonProperty(required = true) + private List actions; + + public String getName() + { + return this.name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getDescription() + { + return this.description; + } + + public void setDescription(String description) + { + this.description = description; + } + + public boolean getEnabled() + { + return this.enabled; + } + + public void setEnabled(boolean enabled) + { + this.enabled = enabled; + } + + public boolean getCascade() + { + return this.cascade; + } + + public void setCascade(boolean cascade) + { + this.cascade = cascade; + } + + public boolean getAsynchronous() + { + return this.asynchronous; + } + + public void setAsynchronous(boolean asynchronous) + { + this.asynchronous = asynchronous; + } + + public String getErrorScript() + { + return this.errorScript; + } + + public void setErrorScript(String errorScript) + { + this.errorScript = errorScript; + } + + public List getTriggers() + { + return this.triggers; + } + + public void setTriggers(List triggers) + { + this.triggers = triggers; + } + + public RestCompositeConditionDefinitionModel getConditions() + { + return this.conditions; + } + + public void setConditions(RestCompositeConditionDefinitionModel conditions) + { + this.conditions = conditions; + } + + public List getActions() + { + return this.actions; + } + + public void setActions(List actions) + { + this.actions = actions; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleExecutionModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleExecutionModel.java new file mode 100644 index 0000000000..b1e8c8bde0 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleExecutionModel.java @@ -0,0 +1,91 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'krystian' on '2022-09-28 11:33' 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 RestRuleExecutionModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRuleExecutionModel model; + + @Override + public RestRuleExecutionModel onModel() + { + return model; + } + + /** + Whether to execute rules also against sub-folders + */ + + @JsonProperty(required = true) + private boolean isEachSubFolderIncluded; + + public boolean getIsEachSubFolderIncluded() + { + return this.isEachSubFolderIncluded; + } + + public void setIsEachSubFolderIncluded(boolean isEachSubFolderIncluded) + { + this.isEachSubFolderIncluded = isEachSubFolderIncluded; + } + + @Override + public String toString() + { + return "RestRuleExecutionModel{" + "isEachSubFolderIncluded=" + isEachSubFolderIncluded + '}'; + } + + @Override + public boolean equals(Object o) + { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + RestRuleExecutionModel that = (RestRuleExecutionModel) o; + return isEachSubFolderIncluded == that.isEachSubFolderIncluded; + } + + @Override + public int hashCode() + { + return Objects.hash(isEachSubFolderIncluded); + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleModel.java new file mode 100644 index 0000000000..12ca840fee --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleModel.java @@ -0,0 +1,257 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'Kristian.Dimitrov@hyland.com' on '2022-07-13 15:53' 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 RestRuleModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRuleModel model; + + @Override + public RestRuleModel onModel() + { + return model; + } + + /** + Identifier for the rule + */ + + @JsonProperty(required = true) + private String id; + /** + Name of the rule + */ + + @JsonProperty(required = true) + private String name; + /** + Description of the rule + */ + + private String description; + /** + Whether the rule is enabled + */ + + private boolean isEnabled; + /** + Whether the rule also applies to subfolders + */ + + private boolean isInheritable; + /** + Whether the rule should be run in the background + */ + + private boolean isAsynchronous; + /** + If the rule should be run in the background then an optional error script can be referenced + */ + + private String errorScript; + /** True if the rule set is linked to, or if the rule is inheritable and the rule set is inherited by a folder with inheriting enabled. */ + @JsonProperty + private Boolean isShared; + + /** + The set of triggers that cause the rule to be activated. +* inbound - The rule should be activated when an item enters the folder +* update - The rule should be activated when an item within the folder is updated +* outbound - The rule should be activated when an item leaves the folder or is deleted + + */ + + private List triggers; + /** + The conditions that determine whether the actions will be executed for a rule. + +A condition should contain at least one entry in compositeConditions or simpleConditions. + +If the field is omitted then the rule will apply to all nodes. + + */ + + private RestCompositeConditionDefinitionModel conditions; + /** + The actions for the rule + */ + + @JsonProperty(required = true) + private List actions; + + 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 getDescription() + { + return this.description; + } + + public void setDescription(String description) + { + this.description = description; + } + + public boolean getIsEnabled() + { + return this.isEnabled; + } + + public void setIsEnabled(boolean isEnabled) + { + this.isEnabled = isEnabled; + } + + public boolean getIsInheritable() + { + return this.isInheritable; + } + + public void setIsInheritable(boolean isInheritable) + { + this.isInheritable = isInheritable; + } + + public boolean getIsAsynchronous() + { + return this.isAsynchronous; + } + + public void setIsAsynchronous(boolean isAsynchronous) + { + this.isAsynchronous = isAsynchronous; + } + + public String getErrorScript() + { + return this.errorScript; + } + + public void setErrorScript(String errorScript) + { + this.errorScript = errorScript; + } + + public Boolean getIsShared() + { + return this.isShared; + } + + public void setIsShared(Boolean shared) + { + this.isShared = shared; + } + + public List getTriggers() + { + return this.triggers; + } + + public void setTriggers(List triggers) + { + this.triggers = triggers; + } + + public RestCompositeConditionDefinitionModel getConditions() + { + return this.conditions; + } + + public void setConditions(RestCompositeConditionDefinitionModel conditions) + { + this.conditions = conditions; + } + + public List getActions() + { + return this.actions; + } + + public void setActions(List actions) + { + this.actions = actions; + } + + @Override + public String toString() + { + return "RestRuleModel{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", description='" + description + '\'' + ", isEnabled=" + isEnabled + ", isInheritable=" + isInheritable + + ", isAsynchronous=" + isAsynchronous + ", errorScript='" + errorScript + '\'' + ", isShared=" + isShared + ", triggers=" + triggers + ", conditions=" + conditions + + ", actions=" + actions + '}'; + } + + @Override + public boolean equals(Object o) + { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + RestRuleModel ruleModel = (RestRuleModel) o; + return isEnabled == ruleModel.isEnabled && isInheritable == ruleModel.isInheritable && isAsynchronous == ruleModel.isAsynchronous && Objects.equals(id, ruleModel.id) && Objects.equals( + name, ruleModel.name) && Objects.equals(description, ruleModel.description) && Objects.equals(errorScript, ruleModel.errorScript) && Objects.equals( + isShared, ruleModel.isShared) && Objects.equals(triggers, ruleModel.triggers) && Objects.equals(conditions, ruleModel.conditions) && Objects.equals( + actions, ruleModel.actions); + } + + @Override + public int hashCode() + { + return Objects.hash(id, name, description, isEnabled, isInheritable, isAsynchronous, errorScript, isShared, triggers, conditions, actions); + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleModelsCollection.java new file mode 100644 index 0000000000..a1d466ecc6 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleModelsCollection.java @@ -0,0 +1,33 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +public class RestRuleModelsCollection extends RestModels +{ + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleSetBodyUpdateModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleSetBodyUpdateModel.java new file mode 100644 index 0000000000..ff3a1f00df --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleSetBodyUpdateModel.java @@ -0,0 +1,72 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'Kristian.Dimitrov@hyland.com' on '2022-07-13 15:53' 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 RestRuleSetBodyUpdateModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRuleSetBodyUpdateModel model; + + @Override + public RestRuleSetBodyUpdateModel onModel() + { + return model; + } + + /** + An ordered list of the rule ids within the rule set. + +Rules may not be added or removed from the rule set using this endpoint. + +If this field is omitted then there is no change to the rule ordering. + + */ + + private List ruleIds; + + public List getRuleIds() + { + return this.ruleIds; + } + + public void setRuleIds(List ruleIds) + { + this.ruleIds = ruleIds; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleSetLinkModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleSetLinkModel.java new file mode 100644 index 0000000000..35cb753f55 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleSetLinkModel.java @@ -0,0 +1,81 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ + +package org.alfresco.rest.model; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'mpichura' on '2022-08-29 12:27' 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 RestRuleSetLinkModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRuleSetLinkModel model; + + @Override + public RestRuleSetLinkModel onModel() + { + return model; + } + + /** + Identifier for the folder node containing the rule set or the rule set node itself. + */ + + private String id; + + public String getId() + { + return this.id; + } + + public void setId(String id) + { + this.id = id; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RestRuleSetLinkModel that = (RestRuleSetLinkModel) o; + return id.equals(that.id); + } + + @Override + public int hashCode() + { + return Objects.hash(id); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleSetModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleSetModel.java new file mode 100644 index 0000000000..91508cea73 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleSetModel.java @@ -0,0 +1,181 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'Kristian.Dimitrov@hyland.com' on '2022-07-13 15:53' 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 RestRuleSetModel extends TestModel implements IRestModel +{ + @JsonProperty (value = "entry") + RestRuleSetModel model; + + @Override + public RestRuleSetModel onModel() + { + return model; + } + + /** + * Identifier for the rule set + */ + @JsonProperty (required = true) + private String id; + /** The node id of the folder that owns this rule set */ + private String owningFolder; + /** The reason why the rule set is included for the folder. */ + private String inclusionType; + /** A list of node ids for folders that inherit this rule set. */ + private List inheritedBy; + /** A list of node ids for folders that link to this rule set. */ + private List linkedToBy; + /** Whether any folders inherit this rule set. */ + private Boolean isInherited; + /** Whether any folders link to this rule set. */ + private Boolean isLinkedTo; + /** Ordered list of ids for the rules in this rule set. */ + private List ruleIds; + + public String getId() + { + return this.id; + } + + public void setId(String id) + { + this.id = id; + } + + public String getOwningFolder() + { + return owningFolder; + } + + public void setOwningFolder(String owningFolder) + { + this.owningFolder = owningFolder; + } + + public String getInclusionType() + { + return inclusionType; + } + + public void setInclusionType(String inclusionType) + { + this.inclusionType = inclusionType; + } + + public List getInheritedBy() + { + return inheritedBy; + } + + public void setInheritedBy(List inheritedBy) + { + this.inheritedBy = inheritedBy; + } + + public List getLinkedToBy() + { + return linkedToBy; + } + + public void setLinkedToBy(List linkedToBy) + { + this.linkedToBy = linkedToBy; + } + + public Boolean getIsInherited() + { + return isInherited; + } + + public void setIsInherited(Boolean isInherited) + { + this.isInherited = isInherited; + } + + public Boolean getIsLinkedTo() + { + return isLinkedTo; + } + + public void setIsLinkedTo(Boolean isLinkedTo) + { + this.isLinkedTo = isLinkedTo; + } + + public List getRuleIds() + { + return ruleIds; + } + + public void setRuleIds(List ruleIds) + { + this.ruleIds = ruleIds; + } + + @Override + public String toString() + { + return "RestRuleSetModel{id='" + id + "', owningFolder='" + owningFolder + "', inclusionType='" + inclusionType + + "', inheritedBy=" + inheritedBy + ", linkedToBy=" + linkedToBy + ", isInherited=" + isInherited + + ", isLinkedTo=" + isLinkedTo + ", ruleIds=" + ruleIds + "}"; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RestRuleSetModel that = (RestRuleSetModel) o; + return Objects.equals(id, that.id) + && Objects.equals(owningFolder, that.owningFolder) + && Objects.equals(inclusionType, that.inclusionType) + && Objects.equals(inheritedBy, that.inheritedBy) + && Objects.equals(linkedToBy, that.linkedToBy) + && Objects.equals(isInherited, that.isInherited) + && Objects.equals(isLinkedTo, that.isLinkedTo) + && Objects.equals(ruleIds, that.ruleIds); + } + + @Override + public int hashCode() + { + return Objects.hash(id, owningFolder, inclusionType, inheritedBy, linkedToBy, isInherited, isLinkedTo, ruleIds); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleSetModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleSetModelsCollection.java new file mode 100644 index 0000000000..611420b667 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleSetModelsCollection.java @@ -0,0 +1,33 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +public class RestRuleSetModelsCollection extends RestModels +{ + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleSettingsModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleSettingsModel.java new file mode 100644 index 0000000000..dd6758cdbb --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestRuleSettingsModel.java @@ -0,0 +1,101 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.Objects; +import java.util.StringJoiner; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestRuleSettingsModel extends TestModel implements IRestModel +{ + @JsonProperty (value = "entry") + private RestRuleSettingsModel model; + private String key; + @JsonProperty (required = true) + private Object value; + + @Override + public RestRuleSettingsModel onModel() + { + return model; + } + + public String getKey() + { + return key; + } + + public void setKey(String key) + { + this.key = key; + } + + public Object getValue() + { + return value; + } + + public void setValue(Object value) + { + this.value = value; + } + + @Override + public String toString() + { + return "RuleSetting{" + + new StringJoiner(", ") + .add("key=" + key) + .add("value=" + value.toString()) + .toString() + + "}"; + } + + @Override + public boolean equals(Object o) + { + if (this == o) + { + return true; + } + if (!(o instanceof RestRuleSettingsModel)) + { + return false; + } + RestRuleSettingsModel that = (RestRuleSettingsModel) o; + return Objects.equals(key, that.key) && Objects.equals(value, that.value); + } + + @Override + public int hashCode() + { + return Objects.hash(key, value); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSharedLinksModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSharedLinksModel.java new file mode 100644 index 0000000000..0d43b98ec5 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSharedLinksModel.java @@ -0,0 +1,202 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated from 'Alfresco Core REST API' swagger file + * Base Path {@linkplain /alfresco/api/-default-/public/alfresco/versions/1} + * + * @author Meenal Bhave + */ +public class RestSharedLinksModel extends TestModel implements IRestModel +{ + + public RestSharedLinksModel() + { + } + + public RestSharedLinksModel(String fileGuid) + { + super(); + this.nodeId = fileGuid; + } + + @JsonProperty(value = "entry") + RestSharedLinksModel model; + + @Override + public RestSharedLinksModel onModel() + { + return model; + } + + @JsonProperty(required = true) + private String modifiedAt; + + @JsonProperty(required = true) + private RestByUserModel modifiedByUser; + + @JsonProperty(required = true) + private String name; + + @JsonProperty(required = true) + private String id; + + @JsonProperty(required = true) + private String nodeId; + + @JsonProperty(required = true) + private RestByUserModel sharedByUser; + + private RestContentModel content; + + @JsonProperty(required = false) + RestPathModel path; + + @JsonProperty(required = false) + private String expiresAt; + + @JsonProperty(required = false) + private List allowableOperations; + + public List getAllowableOperations() + { + return allowableOperations; + } + + public void setAllowableOperations(List allowableOperations) + { + this.allowableOperations = allowableOperations; + } + + 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.nodeId; + } + + public void setNodeType(String nodeType) + { + this.nodeId = nodeType; + } + + public String getModifiedAt() + { + return this.modifiedAt; + } + + public void setModifiedAt(String modifiedAt) + { + this.modifiedAt = modifiedAt; + } + + public String getNodeId() + { + return nodeId; + } + + public void setNodeId(String nodeId) + { + this.nodeId = nodeId; + } + + public RestByUserModel getModifiedByUser() + { + return modifiedByUser; + } + + public void setModifiedByUser(RestByUserModel modifiedByUser) + { + this.modifiedByUser = modifiedByUser; + } + + public RestByUserModel getSharedByUser() + { + return sharedByUser; + } + + public void setSharedByUser(RestByUserModel SharedByUser) + { + this.sharedByUser = SharedByUser; + } + + public RestContentModel getContent() + { + return content; + } + + public void setContent(RestContentModel content) + { + this.content = content; + } + + public RestPathModel getPath() + { + return path; + } + + public void setPath(RestPathModel path) + { + this.path = path; + } + + public String getExpiresAt() + { + return expiresAt; + } + + public void setExpiresAt(String expiresAt) + { + this.expiresAt = expiresAt; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSharedLinksModelCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSharedLinksModelCollection.java new file mode 100644 index 0000000000..a29a08a340 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSharedLinksModelCollection.java @@ -0,0 +1,103 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +/** + * Handle collection of + * + * @author meenal bhave + * Example: + * { + * "list": { + * "pagination": { + * "count": 1, + * "hasMoreItems": false, + * "totalItems": 1, + * "skipCount": 0, + * "maxItems": 100 + * }, + * "entries": [ + * { + * "entry": { + * "path": { + * "name": "/Company Home/Sites/sitePublic-LACmuuuWwbeBYeG/documentLibrary/Folder-uxxKzDflwxOuetG/Folder-oawzdncUXFLgnFe", + * "isComplete": true, + * "elements": [ + * { + * "id": "50e1fe3c-d60f-4088-8f79-c6c10031a379", + * "name": "Company Home" + * }, + * { + * "id": "ad7887fe-ac12-464e-ab26-486b0574959c", + * "name": "Sites" + * }, + * { + * "id": "98db769c-9fa1-47ed-b66c-37a59f2c7a3c", + * "name": "sitePublic-LACmuuuWwbeBYeG" + * }, + * { + * "id": "155ffb4f-0d81-4548-bde1-44c41f10b34d", + * "name": "documentLibrary" + * }, + * { + * "id": "bd1bb93b-bcc3-40d9-857b-5222880d1e4d", + * "name": "Folder-uxxKzDflwxOuetG" + * }, + * { + * "id": "7f0c47ae-d334-4b66-a86b-1a60d2518ad1", + * "name": "Folder-oawzdncUXFLgnFe" + * } + * ] + * }, + * "modifiedAt": "2017-08-01T09:53:20.784+0000", + * "modifiedByUser": { + * "id": "User-hleADFGrDvxsonw", + * "displayName": "User-hleADFGrDvxsonw FirstName LN-User-hleADFGrDvxsonw" + * }, + * "name": "file-CUNTdqhjLRaMPuQ.txt", + * "id": "UztDeg4hSju1DSVZHA3Zmg", + * "nodeId": "fe065c44-4be2-4231-affa-fee8617eb4e6", + * "sharedByUser": { + * "id": "user2", + * "displayName": "user2" + * }, + * "content": { + * "mimeType": "text/plain", + * "mimeTypeName": "Plain Text", + * "sizeInBytes": 19, + * "encoding": "ISO-8859-2" + * } + * } + * } + * ] + * } + * } + */ +public class RestSharedLinksModelCollection extends RestModels +{ +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSimpleConditionDefinitionModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSimpleConditionDefinitionModel.java new file mode 100644 index 0000000000..54d7109300 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSimpleConditionDefinitionModel.java @@ -0,0 +1,143 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'Kristian.Dimitrov@hyland.com' on '2022-07-13 15:53' 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 RestSimpleConditionDefinitionModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestSimpleConditionDefinitionModel model; + + @Override + public RestSimpleConditionDefinitionModel onModel() + { + return model; + } + + /** + The name of the property to compare. + +This should be either a property (e.g. "cm:name") or one of the keywords from this list: +* size (the size of the content for a node) +* mimetype (the mimetype of the content for a node) +* encoding (the encoding of the content for a node) +* category (a category for the node) +* tag (a tag that the node has) +* aspect (an aspect that the node has) + +For multi-valued properties the condition is satisfied if any of the values match the condition. + + */ + + @JsonProperty(required = true) + private String field; + /** + The method to compare the property against the parameter. + +Depending on the type of the property then different comparators are available: +* All types: equals +* text: contains, startsWith, endsWith +* int/long/float/double/date: greaterThan, lessThan, greaterThanOrEqual, lessThanOrEqual +* type: instanceOf + +Where a property is multivalued then the condition is true if it is satisfied by any of the values. + + */ + + @JsonProperty(required = true) + private String comparator; + /** + The value to compare the field against + */ + + @JsonProperty(required = true) + private String parameter; + + public String getField() + { + return this.field; + } + + public void setField(String field) + { + this.field = field; + } + + public String getComparator() + { + return this.comparator; + } + + public void setComparator(String comparator) + { + this.comparator = comparator; + } + + public String getParameter() + { + return this.parameter; + } + + public void setParameter(String parameter) + { + this.parameter = parameter; + } + + @Override + public String toString() + { + return "RestSimpleConditionDefinitionModel{" + "field='" + field + '\'' + ", comparator='" + comparator + '\'' + ", parameter='" + parameter + '\'' + '}'; + } + + @Override + public boolean equals(Object o) + { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + RestSimpleConditionDefinitionModel that = (RestSimpleConditionDefinitionModel) o; + return Objects.equals(field, that.field) && Objects.equals(comparator, that.comparator) && Objects.equals(parameter, that.parameter); + } + + @Override + public int hashCode() + { + return Objects.hash(field, comparator, parameter); + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteContainerModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteContainerModel.java new file mode 100644 index 0000000000..4bfb79b3db --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteContainerModel.java @@ -0,0 +1,66 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestSiteContainerModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestSiteContainerModel model; + + @Override + public RestSiteContainerModel onModel() + { + return model; + } + + private String id; + private String folderId; + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + public String getFolderId() + { + return folderId; + } + + public void setFolderId(String folderId) + { + this.folderId = folderId; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteContainerModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteContainerModelsCollection.java new file mode 100644 index 0000000000..24d0cac747 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteContainerModelsCollection.java @@ -0,0 +1,55 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +/** + * Handle collection of + * Example: + * { + * "list": { + * "pagination": { + * "count": 1, + * "hasMoreItems": false, + * "totalItems": 1, + * "skipCount": 0, + * "maxItems": 100 + * }, + * "entries": [ + * { + * "entry": { + * "id": "d79666e2-3d77-4cbd-aa15-a1e0dcc4da1e", + * "folderId": "documentLibrary" + * } + * } + * ] + * } + * } + */ +public class RestSiteContainerModelsCollection extends RestModels +{ +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteEntry.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteEntry.java new file mode 100644 index 0000000000..1d106390fc --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteEntry.java @@ -0,0 +1,101 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * + * Handles Site Entry in Site Membership Information response + * + * "entry": /{ + "site": { + "id": "string", + "guid": "string", + "title": "string", + "description": "string", + "visibility": "PRIVATE", + "role": "SiteConsumer" + }, + "id": "string", + "guid": "string", + "role": "SiteConsumer" + } + * + */ +public class RestSiteEntry extends TestModel implements IRestModel +{ + private String role; + private String guid; + private String id; + + @JsonProperty(value = "site", required = true) + RestSiteModel site; + + @JsonProperty(value= "entry") + RestSiteEntry model; + + public RestSiteModel onSite() + { + return site; + } + + public String getRole() + { + return role; + } + + public void setRole(String role) + { + this.role = role; + } + + 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; + } + + @Override + public RestSiteEntry onModel() + { + return model; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteGroupModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteGroupModel.java new file mode 100644 index 0000000000..412b63e035 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteGroupModel.java @@ -0,0 +1,87 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import static org.alfresco.utility.report.log.Step.STEP; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.TestModel; +import org.testng.Assert; + +public class RestSiteGroupModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestSiteGroupModel model; + + @Override + public RestSiteGroupModel onModel() + { + return model; + } + + private UserRole role; + private String id = "no-id"; + private RestGroupsModel group; + + public UserRole getRole() + { + return role; + } + + public void setRole(UserRole role) + { + this.role = role; + } + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + public RestGroupsModel getGroup() + { + return group; + } + + public void setGroup(RestGroupsModel group) + { + this.group = group; + } + + public RestSiteGroupModel assertSiteGroupHasRole(UserRole role) { + STEP(String.format("REST API: Assert that site group role is '%s'", role)); + Assert.assertEquals(getRole(), role, "Site group role is not as expected."); + return this; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteGroupModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteGroupModelsCollection.java new file mode 100644 index 0000000000..c0f2891e57 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteGroupModelsCollection.java @@ -0,0 +1,57 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +import java.util.List; + +import static org.alfresco.utility.report.log.Step.STEP; + +public class RestSiteGroupModelsCollection extends RestModels +{ + + /** + * Get groups from site groups list + */ + public RestSiteGroupModel getSiteGroups(String groupId) + { + STEP(String.format("REST API: Get site group with id '%s'", groupId)); + RestSiteGroupModel siteGroupEntry = null; + List siteGroups = getEntries(); + + for (int i = 1; i < siteGroups.size(); i++) + { + if (siteGroups.get(i).onModel().getId().equals(groupId)) + { + siteGroupEntry = siteGroups.get(i).onModel(); + } + } + + return siteGroupEntry; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteMemberModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteMemberModel.java new file mode 100644 index 0000000000..e8ffd38fcd --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteMemberModel.java @@ -0,0 +1,100 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import static org.alfresco.utility.report.log.Step.STEP; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.TestModel; +import org.testng.Assert; + +public class RestSiteMemberModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestSiteMemberModel model; + + @Override + public RestSiteMemberModel onModel() + { + return model; + } + + private UserRole role; + private String id = "no-id"; + private boolean isMemberOfGroup; + + private RestPersonModel person; + + public UserRole getRole() + { + return role; + } + + public void setRole(UserRole role) + { + this.role = role; + } + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + public RestPersonModel getPerson() + { + return person; + } + + public boolean getIsMemberOfGroup() + { + return isMemberOfGroup; + } + + public void setIsMemberOfGroup(boolean memberOfGroup) + { + isMemberOfGroup = memberOfGroup; + } + + public void setPerson(RestPersonModel person) + { + this.person = person; + } + + public RestSiteMemberModel assertSiteMemberHasRole(UserRole role) { + STEP(String.format("REST API: Assert that site member role is '%s'", role)); + Assert.assertEquals(getRole(), role, "Site member role is not as expected."); + + return this; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteMemberModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteMemberModelsCollection.java new file mode 100644 index 0000000000..e98e7151fc --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteMemberModelsCollection.java @@ -0,0 +1,108 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +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 + * Example: + * { + * { + * "list": { + * "pagination": { + * "count": 2, + * "hasMoreItems": false, + * "skipCount": 0, + * "maxItems": 100 + * }, + * "entries": [ + * { + * "entry": { + * "role": "SiteManager", + * "isMemberOfGroup": false, + * "person": { + * "firstName": "Administrator", + * "emailNotificationsEnabled": true, + * "company": {}, + * "id": "admin", + * "enabled": true, + * "email": "admin@alfresco.com" + * }, + * "id": "admin" + * } + * }, + * { + * "entry": { + * "role": "SiteConsumer", + * "isMemberOfGroup": false, + * "person": { + * "firstName": "CqeKxvPHBd FirstName", + * "lastName": "LN-CqeKxvPHBd", + * "emailNotificationsEnabled": true, + * "company": {}, + * "id": "CqeKxvPHBd", + * "enabled": true, + * "email": "CqeKxvPHBd" + * }, + * "id": "CqeKxvPHBd" + * } + * } + * ] + * } + * } + */ +public class RestSiteMemberModelsCollection extends RestModels +{ + + /** + * Get member from site members list + * + * @param memberId + * @return + */ + public RestSiteMemberModel getSiteMember(String memberId) + { + STEP(String.format("REST API: Get site member with id '%s'", memberId)); + RestSiteMemberModel siteMemberEntry = null; + List siteMembers = getEntries(); + + for (int i = 1; i < siteMembers.size(); i++) + { + if (siteMembers.get(i).onModel().getId().equals(memberId)) + { + siteMemberEntry = siteMembers.get(i).onModel(); + } + } + + return siteMemberEntry; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteMembershipModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteMembershipModelsCollection.java new file mode 100644 index 0000000000..d1eaf859fd --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteMembershipModelsCollection.java @@ -0,0 +1,66 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +/** + * + * Handle collection of + * + * { + "list": { + "pagination": { + "count": 0, + "hasMoreItems": true, + "totalItems": 0, + "skipCount": 0, + "maxItems": 0 + }, + "entries": [ + { + "entry": { + "site": { + "id": "string", + "guid": "string", + "title": "string", + "description": "string", + "visibility": "PRIVATE", + "role": "SiteConsumer" + }, + "id": "string", + "guid": "string", + "role": "SiteConsumer" + } + } + ] + } +} + * + */ +public class RestSiteMembershipModelsCollection extends RestModels +{ +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteMembershipRequestModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteMembershipRequestModel.java new file mode 100644 index 0000000000..39575edec1 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteMembershipRequestModel.java @@ -0,0 +1,106 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; +import org.testng.Assert; + +public class RestSiteMembershipRequestModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestSiteMembershipRequestModel model; + + @Override + public RestSiteMembershipRequestModel onModel() + { + return model; + } + + private String id; + private String createdAt; + private String modifiedAt; + private String message; + private RestSiteModel site; + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + public String getCreatedAt() + { + return createdAt; + } + + public void setCreatedAt(String createdAt) + { + this.createdAt = createdAt; + } + + public String getMessage() + { + return message; + } + + public void setMessage(String message) + { + this.message = message; + } + + public RestSiteModel getSite() + { + return site; + } + + public void setSite(RestSiteModel site) + { + this.site = site; + } + + public String getModifiedAt() + { + return modifiedAt; + } + + public void setModifiedAt(String modifiedAt) + { + this.modifiedAt = modifiedAt; + } + + public RestSiteMembershipRequestModel assertMembershipRequestMessageIs(String message) + { + Assert.assertEquals(getMessage(), message, "Site membership request message is not correct"); + return this; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteMembershipRequestModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteMembershipRequestModelsCollection.java new file mode 100644 index 0000000000..8de1461c86 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteMembershipRequestModelsCollection.java @@ -0,0 +1,67 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +/** + * Handle collection of + * + * { + "list": { + "pagination": { + "count": 0, + "hasMoreItems": true, + "totalItems": 0, + "skipCount": 0, + "maxItems": 0 + }, + "entries": [ + { + "entry": { + "id": "string", + "createdAt": "2016-10-06T08:24:04.910Z", + "site": { + "id": "string", + "guid": "string", + "title": "string", + "description": "string", + "visibility": "PRIVATE", + "role": "SiteConsumer" + }, + "message": "string" + } + } + ] + } +} + * + * @author Cristina Axinte + * + */ +public class RestSiteMembershipRequestModelsCollection extends RestModels +{ +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteModel.java new file mode 100644 index 0000000000..1cf00c8967 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteModel.java @@ -0,0 +1,76 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.SiteModel; + +/** + * Handles single Site JSON responses + * Example: + * "visibility": "PUBLIC", + * "guid": "79e140e1-5039-4efa-acaf-c22b5ba7c947", + * "description": "Description1470255221170", + * "id": "0-C2291-1470255221170", + * "title": "0-C2291-1470255221170" + */ +public class RestSiteModel extends SiteModel implements IRestModel +{ + private String role; + + public String getPreset() + { + return preset; + } + + public void setPreset(String preset) + { + this.preset = preset; + } + + private String preset; + + @JsonProperty(value = "entry") + RestSiteModel model; + + @Override + public RestSiteModel onModel() + { + return model; + } + + public String getRole() + { + return role; + } + + public void setRole(String role) + { + this.role = role; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteModelsCollection.java new file mode 100644 index 0000000000..91390e1cbd --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSiteModelsCollection.java @@ -0,0 +1,95 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import static org.alfresco.utility.report.log.Step.STEP; + +import java.util.List; + +import org.alfresco.rest.core.RestModels; +import org.alfresco.utility.model.SiteModel; + +/** + * Handle collection of + * Example: +{ + "list": { + "pagination": { + "count": 100, + "hasMoreItems": true, + "totalItems": 269, + "skipCount": 0, + "maxItems": 100 + }, + "entries": [{ + "entry": { + "visibility": "PUBLIC", + "guid": "79e140e1-5039-4efa-acaf-c22b5ba7c947", + "description": "Description1470255221170", + "id": "0-C2291-1470255221170", + "title": "0-C2291-1470255221170" + } + }, + ] +} + * + */ +public class RestSiteModelsCollection extends RestModels +{ + + /** + * Get site from sites list + * + * @param siteId + * @return the site model or null if a site with this id wasn't found + */ + public RestSiteModel getSite(String siteId) + { + STEP(String.format("REST API: Get site with '%s' id", siteId)); + List sites = getEntries(); + + for (RestSiteModel site : sites) + { + if (site.onModel().getId().equals(siteId)) + { + return site.onModel(); + } + } + + return null; + } + + /** + * Get site from sites list + * + * @param siteId + * @return + */ + public RestSiteModel getSite(SiteModel siteModel) + { + return getSite(siteModel.getId()); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSitePersonMembershipRequestModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSitePersonMembershipRequestModel.java new file mode 100644 index 0000000000..73c6577877 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSitePersonMembershipRequestModel.java @@ -0,0 +1,112 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestSitePersonMembershipRequestModel extends TestModel implements IRestModel +{ + private String id; + private String createdAt; + private String modifiedAt; + private String message; + private RestSiteModel site; + + @JsonProperty(value = "person") + private RestPersonModel person; + + @JsonProperty(value = "entry") + RestSitePersonMembershipRequestModel model; + + public RestPersonModel getPersonModel() + { + return person; + } + + public void setPersonModel(RestPersonModel person) + { + this.person = person; + } + + @Override + public RestSitePersonMembershipRequestModel onModel() + { + return model; + } + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + public String getCreatedAt() + { + return createdAt; + } + + public void setCreatedAt(String createdAt) + { + this.createdAt = createdAt; + } + + public String getMessage() + { + return message; + } + + public void setMessage(String message) + { + this.message = message; + } + + public RestSiteModel getSite() + { + return site; + } + + public void setSite(RestSiteModel site) + { + this.site = site; + } + + public String getModifiedAt() + { + return modifiedAt; + } + + public void setModifiedAt(String modifiedAt) + { + this.modifiedAt = modifiedAt; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSitePersonMembershipRequestModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSitePersonMembershipRequestModelsCollection.java new file mode 100644 index 0000000000..8aa5495641 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSitePersonMembershipRequestModelsCollection.java @@ -0,0 +1,73 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +/** + * Handle collection of + * + *{"list": { + "entries": [{"entry": { + "createdAt": "2018-03-08T07:51:54.948+0000", + "site": { + "visibility": "MODERATED", + "guid": "9d633bed-de72-414e-b188-c8e0ca42235a", + "description": "siteModerated-sHrfyEhnJcBqElEMODERATED", + "id": "siteModerated-sHrfyEhnJcBqElE", + "preset": "site-dashboard", + "title": "siteModerated-sHrfyEhnJcBqElE" + }, + "person": { + "firstName": "testUser-jvagwleqUCYSLeG FirstName", + "lastName": "LN-testUser-jvagwleqUCYSLeG", + "capabilities": { + "isMutable": true, + "isGuest": false, + "isAdmin": false + }, + "emailNotificationsEnabled": true, + "company": {}, + "id": "testUser-jvagwleqUCYSLeG", + "enabled": true, + "email": "testUser-jvagwleqUCYSLeG@tas-automation.org" + }, + "id": "siteModerated-sHrfyEhnJcBqElE", + "message": "Please accept me" + }}], + "pagination": { + "maxItems": 100, + "hasMoreItems": false, + "totalItems": 1, + "count": 1, + "skipCount": 0 + } + }} + */ +public class RestSitePersonMembershipRequestModelsCollection extends RestModels +{ + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestStatusInfoModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestStatusInfoModel.java new file mode 100644 index 0000000000..9bfe2f899b --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestStatusInfoModel.java @@ -0,0 +1,115 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'tsalvado' on '2021-08-18 21:15' from 'Alfresco Content Services REST API' swagger file + * Generated from 'Alfresco Content Services REST API' swagger file + * Base Path {@linkplain /alfresco/api} + */ +public class RestStatusInfoModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestStatusInfoModel model; + + @Override + public RestStatusInfoModel onModel() + { + return model; + } + + + @JsonProperty(required = true) + private boolean isReadOnly; + + @JsonProperty(required = true) + private boolean isAuditEnabled; + + @JsonProperty(required = true) + private boolean isQuickShareEnabled; + + @JsonProperty(required = true) + private boolean isThumbnailGenerationEnabled; + + @JsonProperty(required = true) + private boolean isDirectAccessUrlEnabled; + + public boolean getIsReadOnly() + { + return this.isReadOnly; + } + + public void setIsReadOnly(boolean isReadOnly) + { + this.isReadOnly = isReadOnly; + } + + public boolean getIsAuditEnabled() + { + return this.isAuditEnabled; + } + + public void setIsAuditEnabled(boolean isAuditEnabled) + { + this.isAuditEnabled = isAuditEnabled; + } + + public boolean getIsQuickShareEnabled() + { + return this.isQuickShareEnabled; + } + + public void setIsQuickShareEnabled(boolean isQuickShareEnabled) + { + this.isQuickShareEnabled = isQuickShareEnabled; + } + + public boolean getIsThumbnailGenerationEnabled() + { + return this.isThumbnailGenerationEnabled; + } + + public void setIsThumbnailGenerationEnabled(boolean isThumbnailGenerationEnabled) + { + this.isThumbnailGenerationEnabled = isThumbnailGenerationEnabled; + } + + public boolean getIsDirectAccessUrlEnabled() + { + return this.isDirectAccessUrlEnabled; + } + + public void setIsDirectAccessUrlEnabled(boolean isDirectAccessUrlEnabled) + { + this.isDirectAccessUrlEnabled = isDirectAccessUrlEnabled; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSubscriberModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSubscriberModel.java new file mode 100644 index 0000000000..3225f89238 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSubscriberModel.java @@ -0,0 +1,182 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2017 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Base Path {@linkplain /alfresco/api/-default-/private/alfresco/versions/1} + * + * @author Meenal Bhave + * { + * "entry": { + * "createdAt": "2017-08-11T14:18:22.765+0000", + * "syncService": { + * "id": "0", + * "uri": "https://localhost:9090/alfresco", + * "config": { + * "filters": { + * "nodeAspects": [ + * "rma:filePlanComponent", + * "sf:*", + * "smf:*", + * "cm:workingcopy" + * ], + * "smartFolderNodeAspects": [ + * "sf:*", + * "smf:*" + * ], + * "nodeTypesWhitelist": [ + * "dod:filePlan", + * "hwf:rejectedCloudTask", + * "imap:imapBody", + * "st:site" + * ], + * "nodeTypes": [ + * "bpm:package", + * "cm:systemfolder", + * "cm:failedThumbnail" + * ] + * }, + * "dsyncClientVersionMin": "1.0.1", + * "repoInfo": { + * "versionLabel": "5.2.2", + * "edition": "Enterprise" + * } + * } + * }, + * "deviceOS": "windows", + * "syncServiceId": "0", + * "id": "089e45bd-a059-41f2-885e-c51f487956d6" + * } + * } + */ +public class RestSubscriberModel extends TestModel implements IRestModel +{ + + public RestSubscriberModel() + { + } + + public RestSubscriberModel(String deviceOS, String clientVersion) + { + super(); + this.deviceOS = deviceOS; + this.clientVersion = clientVersion; + } + + @JsonProperty(value = "entry") + RestSubscriberModel model; + + @Override + public RestSubscriberModel onModel() + { + return model; + } + + @JsonProperty(required = true) + private String createdAt; + + @JsonProperty(required = true) + private RestSyncServiceModel syncService; + + @JsonProperty(required = true) + private String deviceOS; + + @JsonProperty(required = true) + private String syncServiceId; + + @JsonProperty(required = true) + private String id; + + @JsonProperty(required = false) + private String clientVersion; + + public String getClientVersion() + { + return clientVersion; + } + + public String getCreatedAt() + { + return createdAt; + } + + public void setCreatedAt(String createdAt) + { + this.createdAt = createdAt; + } + + public RestSyncServiceModel getSyncService() + { + return syncService; + } + + public void setSyncService(RestSyncServiceModel syncService) + { + this.syncService = syncService; + } + + public String getDeviceOS() + { + return deviceOS; + } + + public void setDeviceOS(String deviceOS) + { + this.deviceOS = deviceOS; + } + + public String getSyncServiceId() + { + return syncServiceId; + } + + public void setSyncServiceId(String syncServiceId) + { + this.syncServiceId = syncServiceId; + } + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSubscriberModelCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSubscriberModelCollection.java new file mode 100644 index 0000000000..f468a790c8 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSubscriberModelCollection.java @@ -0,0 +1,184 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2017 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +/** + * Handle collection of + * + * @author meenal bhave + * Example: + * { + "list": { + "pagination": { + "count": 20, + "hasMoreItems": false, + "totalItems": 20, + "skipCount": 0, + "maxItems": 100 + }, + "entries": [ + { + "entry": { + "createdAt": "2017-07-14T13:52:47.319+0000", + "syncService": { + "id": "0", + "uri": "https://localhost:9090/alfresco", + "config": { + "filters": { + "nodeAspects": [ + "rma:filePlanComponent", + "sf:*", + "smf:*", + "cm:workingcopy" + ], + "smartFolderNodeAspects": [ + "sf:*", + "smf:*" + ], + "nodeTypesWhitelist": [ + + ], + "nodeTypes": [ + "bpm:package", + "cm:systemfolder", + "cm:failedThumbnail" + ] + }, + "dsyncClientVersionMin": "1.0.1", + "repoInfo": { + "versionLabel": "5.2.2", + "edition": "Enterprise" + } + } + }, + "deviceOS": "windows", + "syncServiceId": "0", + "id": "da34e9e5-57c8-4275-b24a-373b9f56e6da" + } + }, + { + "entry": { + "createdAt": "2017-07-14T16:14:29.851+0000", + "syncService": { + "id": "0", + "uri": "https://localhost:9090/alfresco", + "config": { + "filters": { + "nodeAspects": [ + "rma:filePlanComponent", + "sf:*", + "smf:*", + "cm:workingcopy" + ], + "smartFolderNodeAspects": [ + "sf:*", + "smf:*" + ], + "nodeTypesWhitelist": [ + "dod:filePlan", + "hwf:rejectedCloudTask", + "imap:imapBody", + "st:site" + ], + "nodeTypes": [ + "bpm:package", + "cm:systemfolder", + "cm:failedThumbnail", + "rma:rmsite" + ] + }, + "dsyncClientVersionMin": "1.0.1", + "repoInfo": { + "versionLabel": "5.2.2", + "edition": "Enterprise" + } + } + }, + "deviceOS": "windows", + "syncServiceId": "0", + "id": "7c53fef9-d6fd-4657-830a-475850d6f04e" + } + }, + { + "entry": { + "createdAt": "2017-07-21T13:19:11.792+0000", + "syncService": { + "id": "0", + "uri": "https://localhost:9090/alfresco", + "config": { + "filters": { + "nodeAspects": [ + "rma:filePlanComponent", + "sf:*", + "smf:*", + "cm:workingcopy" + ], + "smartFolderNodeAspects": [ + "sf:*", + "smf:*" + ], + "nodeTypesWhitelist": [ + "dod:filePlan", + "hwf:rejectedCloudTask", + "imap:imapBody", + "st:site", + "resetpasswordwf:requestPasswordResetTask", + "rma:hold", + "rma:recordCategory", + "hwf:approvedCloudTask" + ], + "nodeTypes": [ + "bpm:package", + "cm:systemfolder", + "cm:failedThumbnail" + ] + }, + "dsyncClientVersionMin": "1.0.1", + "repoInfo": { + "versionLabel": "5.2.2", + "edition": "Enterprise" + } + } + }, + "deviceOS": "windows", + "syncServiceId": "0", + "id": "d9141278-8105-4986-a3f6-c003fdb3925e" + } + } + */ +public class RestSubscriberModelCollection extends RestModels +{ +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncNodeSubscriptionModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncNodeSubscriptionModel.java new file mode 100644 index 0000000000..6c87284168 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncNodeSubscriptionModel.java @@ -0,0 +1,131 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2017 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Base Path {@linkplain /alfresco/api/-default-/private/alfresco/versions/1} + * + * @author Meenal Bhave + * { + "entry": { + "deviceSubscriptionId": "012d6bf6-8b11-4dc3-bd45-6e4f77b48f67", + "createdAt": "2017-08-11T15:54:41.444+0000", + "targetPath": "/Company Home/Data Dictionary", + "state": "VALID", + "id": "5d120857-e155-44bc-9d1f-97ead5631090", + "targetNodeId": "20ad767c-4d86-4d9f-91a6-2e82fffa4e87" + } +} + */ +public class RestSyncNodeSubscriptionModel extends TestModel implements IRestModel +{ + + public RestSyncNodeSubscriptionModel() + { + } + + public RestSyncNodeSubscriptionModel(String targetNodeId, String subscriptionType) + { + super(); + this.createdAt = targetNodeId; + this.targetNodeId = subscriptionType; + } + + @JsonProperty(value = "entry") + RestSyncNodeSubscriptionModel model; + + @Override + public RestSyncNodeSubscriptionModel onModel() + { + return model; + } + + @JsonProperty(required = true) + private String deviceSubscriptionId; + + @JsonProperty(required = true) + private String createdAt; + + @JsonProperty(required = true) + private String targetPath; + + @JsonProperty(required = true) + private String state; + + @JsonProperty(required = true) + private String id; + + @JsonProperty(required = true) + private String targetNodeId; + + public RestSyncNodeSubscriptionModel getModel() + { + return model; + } + + public String getDeviceSubscriptionId() + { + return deviceSubscriptionId; + } + + public String getCreatedAt() + { + return createdAt; + } + + public String getTargetPath() + { + return targetPath; + } + + public String getState() + { + return state; + } + + public String getId() + { + return id; + } + + public String getTargetNodeId() + { + return targetNodeId; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncNodeSubscriptionModelCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncNodeSubscriptionModelCollection.java new file mode 100644 index 0000000000..369175fd0c --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncNodeSubscriptionModelCollection.java @@ -0,0 +1,79 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2017 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +/** + * Handle collection of + * + * @author meenal bhave + * Example: + * { + "list": { + "pagination": { + "count": 2, + "hasMoreItems": false, + "totalItems": 2, + "skipCount": 0, + "maxItems": 100 + }, + "entries": [ + { + "entry": { + "deviceSubscriptionId": "012d6bf6-8b11-4dc3-bd45-6e4f77b48f67", + "createdAt": "2017-07-28T10:15:35.461+0000", + "targetPath": "/Company Home/Data Dictionary", + "state": "VALID", + "id": "f1c346a9-4ba1-4357-bced-f9ad2164db43", + "targetNodeId": "20ad767c-4d86-4d9f-91a6-2e82fffa4e87" + } + }, + { + "entry": { + "deviceSubscriptionId": "012d6bf6-8b11-4dc3-bd45-6e4f77b48f67", + "createdAt": "2017-08-11T15:54:41.444+0000", + "targetPath": "/Company Home/Data Dictionary", + "state": "VALID", + "id": "5d120857-e155-44bc-9d1f-97ead5631090", + "targetNodeId": "20ad767c-4d86-4d9f-91a6-2e82fffa4e87" + } + } + ] + } +} + */ +public class RestSyncNodeSubscriptionModelCollection extends RestModels +{ +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceComponentModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceComponentModel.java new file mode 100644 index 0000000000..d77b3d55f5 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceComponentModel.java @@ -0,0 +1,90 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2017 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +package org.alfresco.rest.model; + +import org.alfresco.utility.model.TestModel; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Base Path {@linkplain /alfresco/healthcheck} + * + * @author Meenal Bhave + * Example: + * + "healthCheckComponent": { + "healthy": true, + "message": "ActiveMQ connection Ok" + } +} + */ +public class RestSyncServiceComponentModel extends TestModel +{ + + public RestSyncServiceComponentModel() + { + } + + @JsonProperty(required = true) + private Boolean healthy; + + @JsonProperty + private String message; + + @JsonProperty + private int duration; + + @JsonProperty + private String timestamp; + + public Boolean getHealthy() + { + return healthy; + } + + public String getMessage() + { + return message; + } + + public int getDuration() + { + return duration; + } + + public String getTimestamp() + { + return timestamp; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceConfigFiltersModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceConfigFiltersModel.java new file mode 100644 index 0000000000..d49c86b3fb --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceConfigFiltersModel.java @@ -0,0 +1,132 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2017 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +package org.alfresco.rest.model; + +import org.alfresco.utility.model.TestModel; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Base Path {@linkplain /alfresco/api/-default-/private/alfresco/versions/1} + * + * @author Meenal Bhave + * Example: + * "filters": { + * "nodeAspects": [ + * "rma:filePlanComponent", + * "sf:*", + * "smf:*", + * "cm:workingcopy" + * ], + * "smartFolderNodeAspects": [ + * "sf:*", + * "smf:*" + * ], + * "nodeTypesWhitelist": [ + * "dod:filePlan", + * "hwf:rejectedCloudTask", + * "imap:imapBody", + * "st:site" + * ], + * "nodeTypes": [ + * "bpm:package", + * "cm:systemfolder", + * "cm:failedThumbnail" + * ] + * }, + * "dsyncClientVersionMin": "1.0.1", + * "repoInfo": { + * "versionLabel": "5.2.2", + * "edition": "Enterprise" + * } + */ +public class RestSyncServiceConfigFiltersModel extends TestModel +{ + + public RestSyncServiceConfigFiltersModel() + { + } + + @JsonProperty(required = true) + private String[] nodeAspects; + + @JsonProperty + private String[] smartFolderNodeAspects; + + @JsonProperty(required = true) + private String[] nodeTypesWhitelist; + + @JsonProperty(required = true) + private String[] nodeTypes; + + public String[] getNodeAspects() + { + return nodeAspects; + } + + public void setNodeAspects(String[] nodeAspects) + { + this.nodeAspects = nodeAspects; + } + + public String[] getSmartFolderNodeAspects() + { + return smartFolderNodeAspects; + } + + public void setSmartFolderNodeAspects(String[] smartFolderNodeAspects) + { + this.smartFolderNodeAspects = smartFolderNodeAspects; + } + + public String[] getNodeTypesWhitelist() + { + return nodeTypesWhitelist; + } + + public void setNodeTypesWhitelist(String[] nodeTypesWhitelist) + { + this.nodeTypesWhitelist = nodeTypesWhitelist; + } + + public String[] getNodeTypes() + { + return nodeTypes; + } + + public void setNodeTypes(String[] nodeTypes) + { + this.nodeTypes = nodeTypes; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceConfigModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceConfigModel.java new file mode 100644 index 0000000000..04c5380648 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceConfigModel.java @@ -0,0 +1,111 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2017 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +package org.alfresco.rest.model; + +import org.alfresco.utility.model.TestModel; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Base Path {@linkplain /alfresco/api/-default-/private/alfresco/versions/1} + * + * @author Meenal Bhave + * Example: + * "config": { + "filters": { + "nodeAspects": [ + "rma:filePlanComponent", + "sf:*", + "smf:*", + "cm:workingcopy" + ], + "smartFolderNodeAspects": [ + "sf:*", + "smf:*" + ], + "nodeTypesWhitelist": [ + "dod:filePlan", + "hwf:rejectedCloudTask", + "imap:imapBody", + "st:site" + ], + "nodeTypes": [ + "bpm:package", + "cm:systemfolder", + "cm:failedThumbnail" + ] + }, + "dsyncClientVersionMin": "1.0.1", + "repoInfo": { + "versionLabel": "5.2.2", + "edition": "Enterprise" + } + } + */ +public class RestSyncServiceConfigModel extends TestModel +{ + + public RestSyncServiceConfigModel() + { + } + + @JsonProperty(required = true) + private String dsyncClientVersionMin; + + @JsonProperty(required = true) + private RestSyncServiceConfigFiltersModel filters; + + @JsonProperty(required = true) + private RestSyncServiceRepoInfoModel repoInfo; + + private RestIdentityServiceConfigurationModel identityServiceConfig; + + public String getDsyncClientVersionMin() + { + return dsyncClientVersionMin; + } + + public RestSyncServiceConfigFiltersModel getFilters() + { + return filters; + } + + public RestSyncServiceRepoInfoModel getRepoInfo() + { + return repoInfo; + } + + public RestIdentityServiceConfigurationModel getIdentityServiceConfig() { + return identityServiceConfig; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceHealthCheckModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceHealthCheckModel.java new file mode 100644 index 0000000000..32f5c368a8 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceHealthCheckModel.java @@ -0,0 +1,149 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2017 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +package org.alfresco.rest.model; + +import org.alfresco.utility.model.TestModel; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Base Path {@linkplain /alfresco/healthcheck} + * + * @author Meenal Bhave + * Example: + * { + "activeMQConnection": { + "healthy": true, + "message": "ActiveMQ connection Ok" + }, + "databaseConnection": { + "healthy": true, + "message": "Database connection Ok" + }, + "deadlocks": { + "healthy": true + }, + "eventsHealthCheck": { + "healthy": true, + "message": "Ok" + }, + "minimumClientVersion": { + "healthy": true, + "message": "1.0.1" + }, + "repositoryConnection": { + "healthy": true, + "message": "Repository connection Ok" + }, + "syncServiceIdCheck": { + "healthy": true, + "message": "41ca6903-3b40-3154-b9ae-a406d83e02c9" + }, + "versionCheck": { + "healthy": true, + "message": "2.2-SNAPSHOT (2017-10-04T08:41:58Z)" + } +} + */ +public class RestSyncServiceHealthCheckModel extends TestModel +{ + + public RestSyncServiceHealthCheckModel() + { + } + + @JsonProperty(required = true) + private RestSyncServiceComponentModel activeMQConnection; + + @JsonProperty(required = true) + private RestSyncServiceComponentModel databaseConnection; + + @JsonProperty(required = true) + private RestSyncServiceComponentModel deadlocks; + + @JsonProperty(required = true) + private RestSyncServiceComponentModel eventsHealthCheck; + + @JsonProperty(required = true) + private RestSyncServiceComponentModel minimumClientVersion; + + @JsonProperty(required = true) + private RestSyncServiceComponentModel repositoryConnection; + + @JsonProperty(required = true) + private RestSyncServiceComponentModel syncServiceIdCheck; + + @JsonProperty(required = true) + private RestSyncServiceComponentModel versionCheck; + + public RestSyncServiceComponentModel getActiveMQConnection() + { + return activeMQConnection; + } + + public RestSyncServiceComponentModel getDatabaseConnection() + { + return databaseConnection; + } + + public RestSyncServiceComponentModel getDeadlocks() + { + return deadlocks; + } + + public RestSyncServiceComponentModel getEventsHealthCheck() + { + return eventsHealthCheck; + } + + public RestSyncServiceComponentModel getMinimumClientVersion() + { + return minimumClientVersion; + } + + public RestSyncServiceComponentModel getRepositoryConnection() + { + return repositoryConnection; + } + + public RestSyncServiceComponentModel getSyncServiceIdCheck() + { + return syncServiceIdCheck; + } + + public RestSyncServiceComponentModel getVersionCheck() + { + return versionCheck; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceModel.java new file mode 100644 index 0000000000..8b17b55b96 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceModel.java @@ -0,0 +1,119 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2017 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +package org.alfresco.rest.model; + +import org.alfresco.utility.model.TestModel; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Base Path {@linkplain /alfresco/api/-default-/private/alfresco/versions/1} + * + * @author Meenal Bhave + * Example: + * "syncService": { + * "id": "0", + * "uri": "https://localhost:9090/alfresco", + * "config": { + * "filters": { + * "nodeAspects": [ + * "rma:filePlanComponent", + * "sf:*", + * "smf:*", + * "cm:workingcopy" + * ], + * "smartFolderNodeAspects": [ + * "sf:*", + * "smf:*" + * ], + * "nodeTypesWhitelist": [ + * "dod:filePlan", + * "hwf:rejectedCloudTask", + * "imap:imapBody", + * "st:site" + * ], + * "nodeTypes": [ + * "bpm:package", + * "cm:systemfolder", + * "cm:failedThumbnail" + * ] + * }, + * "dsyncClientVersionMin": "1.0.1", + * "repoInfo": { + * "versionLabel": "5.2.2", + * "edition": "Enterprise" + * } + * } + * } + */ +public class RestSyncServiceModel extends TestModel +{ + + public RestSyncServiceModel() + { + } + + @JsonProperty(required = true) + private String id; + + @JsonProperty(required = true) + private String uri; + + @JsonProperty(required = true) + private RestSyncServiceConfigModel config; + + private RestIdentityServiceConfigurationModel identityServiceConfig; + + public String getId() + { + return id; + } + + public String getUri() + { + return uri; + } + + public RestSyncServiceConfigModel getConfig() + { + return config; + } + + public RestIdentityServiceConfigurationModel getIdentityServiceConfig() { + return identityServiceConfig; + } + + public void setIdentityServiceConfig(RestIdentityServiceConfigurationModel identityServiceConfig) { + this.identityServiceConfig = identityServiceConfig; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceRepoInfoModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceRepoInfoModel.java new file mode 100644 index 0000000000..59d6b18aa0 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncServiceRepoInfoModel.java @@ -0,0 +1,85 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2017 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +package org.alfresco.rest.model; + +import org.alfresco.utility.model.TestModel; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Base Path {@linkplain /alfresco/api/-default-/private/alfresco/versions/1} + * + * @author Meenal Bhave + * Example: + * "repoInfo": { + * "versionLabel": "5.2.2", + * "edition": "Enterprise" + * } + */ +public class RestSyncServiceRepoInfoModel extends TestModel +{ + + public RestSyncServiceRepoInfoModel() + { + } + + @JsonProperty(required = true) + private String versionLabel; + + @JsonProperty(required = true) + private String edition; + + @JsonProperty(required = true) + private boolean clusterEnabled; + + public boolean isClusterEnabled() + { + return clusterEnabled; + } + + public String getVersionLabel() + { + return versionLabel; + } + + public void setVersionLabel(String versionLabel) + { + this.versionLabel = versionLabel; + } + + public String getEdition() + { + return edition; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncSetChangesModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncSetChangesModel.java new file mode 100644 index 0000000000..8eba9a7c03 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncSetChangesModel.java @@ -0,0 +1,334 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2017 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +package org.alfresco.rest.model; + +import org.alfresco.utility.model.TestModel; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Base Path {@linkplain /alfresco/api/-default-/private/alfresco/versions/1} + * + * @author Meenal Bhave + * Example: + * "changes": [ + { + "conflict": false, + "skip": false, + "id": "1", + "username": "admin", + "type": "DELETE_REPOS", + "name": "2", + "toName": null, + "parentNodeIds": [ + "1007f928-3d95-402f-a9ac-35300c66f3fa", + "02a172dd-3156-4443-a216-d11bcd082ccc", + "e1f3777a-4eb3-4e49-9e65-ec52dbf21032", + "859d721e-07b4-4b8f-8a9e-122d45a1f9bb", + "5c9b0f55-eb3a-48ba-8532-c2877548291e", + "c0a5ad7b-cf36-47f1-85a6-6c0aafe242df" + ], + "toParentNodeIds": [], + "path": "/Company Home/Sites/primary/documentLibrary/5/2", + "toPath": null, + "nodeId": "aa667a0c-03bb-44b8-a65c-bdc95a90a6ac", + "eventTimestamp": 1505838692779, + "checksum": "dummyChecksum", + "size": -1, + "nodeType": "cm:folder", + "nodeTimestamp": 1505838597992, + "error": false, + "aspects": [ + "cm:titled", + "cm:auditable", + "sys:referenceable", + "sys:pendingDelete", + "sys:localized" + ], + "seqNo": 0, + "parentGroup": null, + "permission": null, + "async": false, + "authority": null, + "cascade": false + "folderChange": false + } + ] + */ + +public class RestSyncSetChangesModel extends TestModel +{ + + public RestSyncSetChangesModel() + { + } + + @JsonProperty(required = true) + private Boolean conflict; + + @JsonProperty(required = true) + private Boolean skip; + + @JsonProperty(required = true) + private String id; + + @JsonProperty(required = true) + private String username; + + @JsonProperty(required = true) + private String type; + + @JsonProperty(required = true) + private String name; + + @JsonProperty(required = true) + private String toName; + + @JsonProperty(required = true) + private String[] parentNodeIds; + + @JsonProperty(required = true) + private String[] toParentNodeIds; + + @JsonProperty(required = true) + private String path; + + @JsonProperty(required = true) + private String toPath; + + @JsonProperty(required = true) + private String nodeId; + + @JsonProperty(required = true) + private String eventTimestamp; + + @JsonProperty(required = true) + private String checksum; + + @JsonProperty(required = true) + private Integer size; + + @JsonProperty(required = true) + private String nodeType; + + @JsonProperty(required = true) + private String nodeTimestamp; + + @JsonProperty(required = true) + private Boolean error; + + @JsonProperty(required = true) + private String[] aspects; + + @JsonProperty(required = true) + private Integer seqNo; + + @JsonProperty(required = true) + private String parentGroup; + + @JsonProperty(required = true) + private String permission; + + @JsonProperty(required = true) + private Boolean async; + + @JsonProperty(required = true) + private String authority; + + @JsonProperty(required = true) + private Boolean cascade; + + @JsonProperty(required = true) + private boolean recordFromCollabSite; + + @JsonProperty(required = true) + private int numberOfSecondaryAssocs; + + @JsonProperty(required = true) + private boolean folderChange; + + + + public Boolean getConflict() + { + return conflict; + } + + public Boolean getSkip() + { + return skip; + } + + public String getId() + { + return id; + } + + public String getUsername() + { + return username; + } + + public String getType() + { + return type; + } + + public String getName() + { + return name; + } + + public String getToName() + { + return toName; + } + + public String[] getParentNodeIds() + { + return parentNodeIds; + } + + public String[] getToParentNodeIds() + { + return toParentNodeIds; + } + + public String getPath() + { + return path; + } + + public String getToPath() + { + return toPath; + } + + public String getNodeId() + { + return nodeId; + } + + public String getEventTimestamp() + { + return eventTimestamp; + } + + public String getCheckSum() + { + return checksum; + } + + public Integer getSize() + { + return size; + } + + public String getNodeType() + { + return nodeType; + } + + public String getNodeTimeStamp() + { + return nodeTimestamp; + } + + public Boolean getError() + { + return error; + } + + public String[] getAspects() + { + return aspects; + } + + public Integer getSeqNo() + { + return seqNo; + } + + public String getParentGroup() + { + return parentGroup; + } + + public String getPermissions() + { + return permission; + } + + public Boolean getAsync() + { + return async; + } + + public String getAuthority() + { + return authority; + } + + public Boolean getCascade() + { + return cascade; + } + + public boolean getRecordFromCollabSite() + { + return recordFromCollabSite; + } + + public void setRecordFromCollabSite(boolean recordFromCollabSite) + { + this.recordFromCollabSite = recordFromCollabSite; + } + + public int getNumberOfSecondaryAssocs() + { + return numberOfSecondaryAssocs; + } + + public void setNumberOfSecondaryAssocs(int numberOfSecondaryAssocs) + { + this.numberOfSecondaryAssocs = numberOfSecondaryAssocs; + } + + public boolean isFolderChange() { + return folderChange; + } + + public void setFolderChange(boolean folderChange) { + this.folderChange = folderChange; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncSetGetModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncSetGetModel.java new file mode 100644 index 0000000000..d467ad5a9f --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncSetGetModel.java @@ -0,0 +1,110 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2017 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +package org.alfresco.rest.model; + +import org.alfresco.utility.model.TestModel; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Base Path {@linkplain /alfresco/api/-default-/private/alfresco/versions/1} + * + * @author Meenal Bhave + * Example: + * { + * "syncId": "8151", + * "status": "ready", + * "changes": [], + * "resets": [], + * "moreChanges": false, + * "message": "optional" + * } + */ + +public class RestSyncSetGetModel extends TestModel +{ + + public RestSyncSetGetModel() + { + } + + @JsonProperty + private String syncId; + + @JsonProperty(required = true) + private String status; + + // This field is only displayed when there is an error and syncID can not be returned e.g. sync db is down etc + @JsonProperty(required = false) + private String message; + + @JsonProperty(required = true) + private Boolean moreChanges; + + @JsonProperty(required = false) + private RestSyncSetChangesModel[] changes; + + @JsonProperty(required = false) + private RestSyncSetResetsModel[] resets; + + public String getSyncId() + { + return syncId; + } + + public String getStatus() + { + return status; + } + + public boolean getMoreChanges() + { + return moreChanges; + } + + public RestSyncSetChangesModel[] getChanges() + { + return changes; + } + + public RestSyncSetResetsModel[] getResets() + { + return resets; + } + + public String getMessage() + { + return message; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncSetRequestModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncSetRequestModel.java new file mode 100644 index 0000000000..da86853351 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncSetRequestModel.java @@ -0,0 +1,97 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2017 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +package org.alfresco.rest.model; + +import org.alfresco.utility.model.TestModel; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Base Path {@linkplain /alfresco/api/-default-/private/alfresco/versions/1} + * + * @author Meenal Bhave + * Example: + * { + * "syncId": "8096", + * "url": "/api/-default-/private/alfresco/versions/1/subscribers/925a2663-bc86-466d-9a49-95e9e8df7cde/subscriptions/7cfbd62d-2f9d-4c4e-bc3d-14234ae53d9e/sync/8096", + * "status": "ok", + * "message": null, + * "error": null + * } + */ + +public class RestSyncSetRequestModel extends TestModel +{ + + public RestSyncSetRequestModel() + { + } + + @JsonProperty(required = false) + private String message; + + @JsonProperty(required = false) + private String error; + + private String syncId; + + private String status; + + private String url; + + public String getSyncId() + { + return syncId; + } + + public String getUrl() + { + return url; + } + + public String getStatus() + { + return status; + } + + public String getMessage() + { + return message; + } + + public String getError() + { + return error; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncSetResetsModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncSetResetsModel.java new file mode 100644 index 0000000000..891b527043 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestSyncSetResetsModel.java @@ -0,0 +1,93 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2017 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +package org.alfresco.rest.model; + +import org.alfresco.utility.model.TestModel; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Base Path {@linkplain /alfresco/api/-default-/private/alfresco/versions/1} + * + * @author Meenal Bhave + * Example: + * "resets": [ + * { + * "subscriptionId": "7787ac59-ec71-43c0-b97a-ebdba0254759", + * "resetAll": false, + * "resetReason": "Stale", + * "timestamp": 1502811227880 + * } + * ] + */ + +public class RestSyncSetResetsModel extends TestModel +{ + + public RestSyncSetResetsModel() + { + } + + @JsonProperty(required = true) + private String subscriptionId; + + @JsonProperty(required = true) + private String resetReason; + + @JsonProperty(required = true) + private Boolean resetAll; + + @JsonProperty(required = true) + private String timeStamp; + + public String getSubscriptionId() + { + return subscriptionId; + } + + public String getResetReason() + { + return resetReason; + } + + public Boolean getIsResetAll() + { + return resetAll; + } + + public String getTimeStamp() + { + return timeStamp; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTagModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTagModel.java new file mode 100644 index 0000000000..f214b57fee --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTagModel.java @@ -0,0 +1,76 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import static org.alfresco.utility.report.log.Step.STEP; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TagModel; +import org.testng.Assert; + +/** + * Handles single Tag Entry JSON response + * "entry": + * { + * "tag":"addedtag-c7444-1474370805346" + * "id":"f45c4d06-f4df-42d7-a118-29121557d284" + * } + * + * @author Corina Nechifor + */ +public class RestTagModel extends TagModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestTagModel model; + + protected Integer count; + + public RestTagModel onModel() + { + return model; + } + + public RestTagModel assertResponseIsNotEmpty() + { + STEP(String.format("REST API: Assert get tags response is not empty")); + Assert.assertFalse(getId().isEmpty(), "Get tags response is empty."); + + return this; + } + + public Integer getCount() + { + return count; + } + + public void setCount(Integer count) + { + this.count = count; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTagModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTagModelsCollection.java new file mode 100644 index 0000000000..4f451b7d59 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTagModelsCollection.java @@ -0,0 +1,51 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + + +/** + * Handles collection of Tags + * + * "entries": + * [ + * {"entry": + * { "tag":"addedtag-c7444-1474370805346", + * "id":"f45c4d06-f4df-42d7-a118-29121557d284"} + * }, + * {"entry": + * {"tag":"addedtag-c7444-1474370863151", + * "id":"c05bdec5-1051-4413-9db6-0d3797f1cce5"} + * } + * + * @author Corina Nechifor + * + */ +public class RestTagModelsCollection extends RestModels +{ + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTargetModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTargetModel.java new file mode 100644 index 0000000000..ed6cb86bea --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTargetModel.java @@ -0,0 +1,108 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class RestTargetModel extends TestModel implements IRestModel +{ + @Override + public RestTargetModel onModel() + { + return model; + } + + @JsonProperty(value = "target") + RestTargetModel model; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private RestSiteModel site; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private RestFolderModel folder; + + @JsonInclude(JsonInclude.Include.NON_NULL) + private RestFileModel file; + + public RestTargetModel() + { + } + + public RestTargetModel(RestSiteModel site) + { + super(); + this.site = site; + } + + public RestTargetModel(RestSiteModel site, RestFolderModel folder, RestFileModel file) + { + super(); + this.site = site; + this.folder = folder; + this.file = file; + } + + @JsonInclude(JsonInclude.Include.NON_NULL) + public RestSiteModel getSite() + { + return site; + } + + @JsonInclude(JsonInclude.Include.NON_NULL) + public void setSite(RestSiteModel site) + { + this.site = site; + } + + @JsonInclude(JsonInclude.Include.NON_NULL) + public RestFolderModel getFolder() + { + return folder; + } + + @JsonInclude(JsonInclude.Include.NON_NULL) + public void setFolder(RestFolderModel folder) + { + this.folder = folder; + } + + @JsonInclude(JsonInclude.Include.NON_NULL) + public RestFileModel getFile() + { + return file; + } + + @JsonInclude(JsonInclude.Include.NON_NULL) + public void setFile(RestFileModel file) + { + this.file = file; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTaskModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTaskModel.java new file mode 100644 index 0000000000..26610a1c1e --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTaskModel.java @@ -0,0 +1,207 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TaskModel; + +/** + * Handles single Task JSON response + * Example: + * "entry": { + "id": "string", + "processId": "string", + "processDefinitionId": "string", + "activityDefinitionId": "string", + "name": "string", + "description": "string", + "dueAt": "2016-10-11T09:53:02.549Z", + "startedAt": "2016-10-11T09:53:02.549Z", + "endedAt": "2016-10-11T09:53:02.549Z", + "durationInMs": 0, + "priority": 0, + "owner": "string", + "assignee": "string", + "formResourceKey": "string", + "state": "unclaimed", + "variables": [ + { + "scope": "string", + "name": "string", + "value": 0, + "type": "string" + } + ] + } + * + * @author Cristina Axinte + * + */ +public class RestTaskModel extends TaskModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestTaskModel model; + + @Override + public RestTaskModel onModel() + { + return model; + } + + private String processDefinitionId; + private String activityDefinitionId; + private String name; + private String startedAt; + private String endedAt; + private Integer durationInMs; + private String owner; + private String formResourceKey; + private String state; + private String description; + @JsonProperty(value = "priority") + private Integer priorityTask; + @JsonInclude(JsonInclude.Include.NON_NULL) + private RestVariableModelsCollection variables; + + public RestVariableModelsCollection getVariables() + { + return variables; + } + + public void setVariables(RestVariableModelsCollection variables) + { + this.variables = variables; + } + + public String getProcessDefinitionId() + { + return processDefinitionId; + } + + public void setProcessDefinitionId(String processDefinitionId) + { + this.processDefinitionId = processDefinitionId; + } + + public String getActivityDefinitionId() + { + return activityDefinitionId; + } + + public void setActivityDefinitionId(String activityDefinitionId) + { + this.activityDefinitionId = activityDefinitionId; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public String getStartedAt() + { + return startedAt; + } + + public void setStartedAt(String startedAt) + { + this.startedAt = startedAt; + } + + public String getEndedAt() + { + return endedAt; + } + + public void setEndedAt(String endedAt) + { + this.endedAt = endedAt; + } + + public Integer getDurationInMs() + { + return durationInMs; + } + + public void setDurationInMs(Integer durationInMs) + { + this.durationInMs = durationInMs; + } + + public String getOwner() + { + return owner; + } + + public String getFormResourceKey() + { + return formResourceKey; + } + + public void setFormResourceKey(String formResourceKey) + { + this.formResourceKey = formResourceKey; + } + + public String getState() + { + return state; + } + + public void setState(String state) + { + this.state = state; + } + + public Integer getPriorityTask() + { + return priorityTask; + } + + public void setPriorityTask(Integer priorityTask) + { + this.priorityTask = priorityTask; + } + + public String getDescription() + { + return description; + } + + public void setDescription(String description) + { + this.description = description; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTaskModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTaskModelsCollection.java new file mode 100644 index 0000000000..dc65dcaf12 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTaskModelsCollection.java @@ -0,0 +1,91 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import static org.alfresco.utility.report.log.Step.STEP; + +import java.util.List; + +import org.alfresco.rest.core.RestModels; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; + +/** + * Handle collection of + * + * @author Critina Axinte + */ +public class RestTaskModelsCollection extends RestModels +{ + public RestTaskModel getTaskModelByAssignee(UserModel assigneeName) + { + List tasksList = getEntries(); + + for (RestTaskModel taskModel: tasksList) + { + if (taskModel.onModel().getAssignee().equals(assigneeName.getUsername())) + { + STEP(String.format("REST API: Get task with assignee '%s'", assigneeName.getUsername())); + return taskModel.onModel(); + } + } + + return null; + } + + public RestTaskModel getTaskModelByDescription(SiteModel siteModel) + { + List tasksList = getEntries(); + + for (RestTaskModel taskModel: tasksList) + { + if (taskModel.onModel().getDescription().equals(String.format("Request to join %s site", siteModel.getId()))) + { + STEP(String.format("REST API: Get task with site name '%s'", siteModel.getId())); + return taskModel.onModel(); + } + } + + return null; + } + + public RestTaskModel getTaskModelByProcess(ProcessModel process) + { + List tasksList = getEntries(); + + for (RestTaskModel taskModel: tasksList) + { + if (taskModel.onModel().getProcessId().equals(process.getId())) + { + STEP(String.format("REST API: Get task with processId '%s'", process.getId())); + return taskModel.onModel(); + } + } + + return null; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTextResponse.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTextResponse.java new file mode 100644 index 0000000000..89923713f0 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTextResponse.java @@ -0,0 +1,60 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestResponse; +import org.json.simple.JSONObject; + +import com.google.gson.JsonObject; +import io.restassured.response.Response; + +/** + * Process RestReponse of type application/text + * @author Meenal Bhave + */ +public class RestTextResponse extends RestResponse +{ + + public RestTextResponse(Response response) + { + super(response); + } + + public JsonObject getJsonObject() + { + return this.getResponse().jsonPath().get(); + } + + public String getJsonValueByPath(String path) + { + return this.getResponse().jsonPath().get(path).toString(); + } + + public JSONObject getJsonObjectByPath(String path) + { + return new JSONObject(this.getResponse().jsonPath().get(path)); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTicketBodyModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTicketBodyModel.java new file mode 100644 index 0000000000..55eca8c609 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTicketBodyModel.java @@ -0,0 +1,71 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated from 'Alfresco Authentication REST API' swagger file + * Base Path {@linkplain /alfresco/api/-default-/public/authentication/versions/1} + */ +public class RestTicketBodyModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestTicketBodyModel model; + + @Override + public RestTicketBodyModel onModel() + { + return model; + } + + private String userId; + private String password; + + public String getUserId() + { + return this.userId; + } + + public void setUserId(String userId) + { + this.userId = userId; + } + + public String getPassword() + { + return this.password; + } + + public void setPassword(String password) + { + this.password = password; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTicketModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTicketModel.java new file mode 100644 index 0000000000..90fe75e98c --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTicketModel.java @@ -0,0 +1,71 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated from 'Alfresco Authentication REST API' swagger file + * Base Path {@linkplain /alfresco/api/-default-/public/authentication/versions/1} + */ +public class RestTicketModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestTicketModel model; + + @Override + public RestTicketModel onModel() + { + return model; + } + + private String id; + private String userId; + + public String getId() + { + return this.id; + } + + public void setId(String id) + { + this.id = id; + } + + public String getUserId() + { + return this.userId; + } + + public void setUserId(String userId) + { + this.userId = userId; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTypeModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTypeModel.java new file mode 100644 index 0000000000..690dbe34ea --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTypeModel.java @@ -0,0 +1,30 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +public class RestTypeModel extends RestAbstractClassModel +{ +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTypesCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTypesCollection.java new file mode 100644 index 0000000000..c722dd104a --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestTypesCollection.java @@ -0,0 +1,32 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +public class RestTypesCollection extends RestModels +{ +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestVariableModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestVariableModel.java new file mode 100644 index 0000000000..2a39287171 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestVariableModel.java @@ -0,0 +1,119 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.TestModel; + +/** + * Handles a single Variable JSON response + * Example: + * { + * "scope": "string", + * "name": "string", + * "value": 0, + * "type": "string" + * } + * + * @author Cristina Axinte + */ +public class RestVariableModel extends TestModel implements IRestModel +{ + private String scope; + private String name; + private Object value; + private String type; + + @JsonProperty(value = "entry") + RestVariableModel model; + + public RestVariableModel() + { + } + + public RestVariableModel(String scope, String name, String type, Object value) + { + this.scope = scope; + this.name = name; + this.type = type; + this.value = value; + } + + public String getScope() + { + return scope; + } + + public void setScope(String scope) + { + this.scope = scope; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + + public Object getValue() + { + return value; + } + + public void setValue(Object value) + { + this.value = value; + } + + public String getType() + { + return type; + } + + public void setType(String type) + { + this.type = type; + } + + public static RestVariableModel getRandomTaskVariableModel(String scope, String type) + { + return new RestVariableModel(scope, RandomData.getRandomName("name"), type, RandomData.getRandomName("value")); + } + + @Override + public RestVariableModel onModel() + { + return model; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestVariableModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestVariableModelsCollection.java new file mode 100644 index 0000000000..b2c2bd0388 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestVariableModelsCollection.java @@ -0,0 +1,66 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import static org.alfresco.utility.report.log.Step.STEP; + +import java.util.List; + +import org.alfresco.rest.core.RestModels; + +/** + * Handles a collection of JSON response + * Example: + * "variables": [ + { + "scope": "string", + "name": "string", + "value": 0, + "type": "string" + } + ] + + * @author Cristina Axinte + * + */ +public class RestVariableModelsCollection extends RestModels +{ + public RestVariableModel getVariableByName(String variableName) + { + STEP(String.format("REST API: Get variable with name '%s'", variableName)); + List variableList = getEntries(); + + for (RestVariableModel variableEntry: variableList) + { + if (variableEntry.onModel().getName().equals(variableName)) + { + return variableEntry.onModel(); + } + } + + return null; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestVersionInfoModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestVersionInfoModel.java new file mode 100644 index 0000000000..84ec8d5472 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestVersionInfoModel.java @@ -0,0 +1,141 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * 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 RestVersionInfoModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestVersionInfoModel model; + + @Override + public RestVersionInfoModel onModel() + { + return model; + } + + + @JsonProperty(required = true) + private String major; + + @JsonProperty(required = true) + private String minor; + + @JsonProperty(required = true) + private String patch; + + @JsonProperty(required = true) + private String hotfix; + + @JsonProperty(required = true) + private int schema; + + @JsonProperty(required = true) + private String label; + + @JsonProperty(required = true) + private String display; + + public String getMajor() + { + return this.major; + } + + public void setMajor(String major) + { + this.major = major; + } + + public String getMinor() + { + return this.minor; + } + + public void setMinor(String minor) + { + this.minor = minor; + } + + public String getPatch() + { + return this.patch; + } + + public void setPatch(String patch) + { + this.patch = patch; + } + + public String getHotfix() + { + return this.hotfix; + } + + public void setHotfix(String hotfix) + { + this.hotfix = hotfix; + } + + public int getSchema() + { + return this.schema; + } + + public void setSchema(int schema) + { + this.schema = schema; + } + + public String getLabel() + { + return this.label; + } + + public void setLabel(String label) + { + this.label = label; + } + + public String getDisplay() + { + return this.display; + } + + public void setDisplay(String display) + { + this.display = display; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestVersionModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestVersionModel.java new file mode 100644 index 0000000000..4b092fc751 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestVersionModel.java @@ -0,0 +1,184 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestVersionModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestVersionModel model; + + @Override + public RestVersionModel onModel() + { + return model; + } + + @JsonProperty(required = true) + private String id; + + private String versionComment; + + @JsonProperty(required = true) + private String name; + + @JsonProperty(required = true) + private String nodeType; + + @JsonProperty(required = true) + private boolean isFolder; + + @JsonProperty(required = true) + private boolean isFile; + + @JsonProperty(required = true) + private String modifiedAt; + + @JsonProperty(required = true) + private RestByUserModel modifiedByUser; + + private RestContentModel content; + + private List aspectNames; + + private Object properties; + + public String getId() + { + return id; + } + + public void setId(String id) + { + this.id = id; + } + + public String getVersionComment() + { + return versionComment; + } + + public void setVersionComment(String versionComment) + { + this.versionComment = versionComment; + } + + 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 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 RestContentModel getContent() + { + return content; + } + + public void setContent(RestContentModel content) + { + this.content = content; + } + + public List getAspectNames() + { + return aspectNames; + } + + public void setAspectNames(List aspectNames) + { + this.aspectNames = aspectNames; + } + + public Object getProperties() + { + return properties; + } + + public void setProperties(Object properties) + { + this.properties = properties; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestVersionModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestVersionModelsCollection.java new file mode 100644 index 0000000000..b0c0448643 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/RestVersionModelsCollection.java @@ -0,0 +1,33 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import org.alfresco.rest.core.RestModels; + +public class RestVersionModelsCollection extends RestModels +{ + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/body/RestNodeLockBodyModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/body/RestNodeLockBodyModel.java new file mode 100644 index 0000000000..0a456110b7 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/body/RestNodeLockBodyModel.java @@ -0,0 +1,90 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model.body; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +public class RestNodeLockBodyModel extends TestModel implements IRestModel +{ + + @JsonProperty(value = "entry") + RestNodeLockBodyModel model; + + @Override + public RestNodeLockBodyModel onModel() + { + return model; + } + + @JsonProperty + private int timeToExpire; + + @JsonProperty + private String type; + + @JsonProperty + private String lifetime; + + public String getLifetime() + { + return lifetime; + } + + public void setLifetime(String lifetime) + { + this.lifetime = lifetime; + } + + public int getTimeToExpire() + { + return timeToExpire; + } + + /* + * Set in seconds lock time + * if lock time = 0 or not set, the lock never expires + */ + public void setTimeToExpire(int timeToExpire) + { + this.timeToExpire = timeToExpire; + } + + public String getType() + { + return type; + } + + public void setType(String type) + { + this.type = type; + } + + + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/builder/NodesBuilder.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/builder/NodesBuilder.java new file mode 100644 index 0000000000..d628fa47ae --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/builder/NodesBuilder.java @@ -0,0 +1,165 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model.builder; + +import java.util.LinkedList; +import java.util.List; + +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestNodeBodyModel; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.model.RepoTestModel; + +/** + * Builder for creating nested nodes using REST v1 + * No assertion is made in order to use this builder also for negative testing + * + * @author Paul Brodner + */ +public class NodesBuilder +{ + private List nodes = new LinkedList<>(); + private RestWrapper restWrapper; + private RepoTestModel lastNode; + + public NodeDetail getNode(String prefix) + { + for(NodeDetail node : nodes) + { + if(node.getPrefix().equals(prefix)) + return node; + } + return null; + } + /** + * How you can use to create nested nodes: + * will create in Admin's Repository: + * - F1-P-randomname> + * - F1-P-randomname + * - F3-P-randomname + * ------file1-randomname + * ------file2-randomname + * ------F3-randomname + * + * restClient.authenticateUser(dataUser.getAdminUser()).withCoreAPI() + .usingNode(ContentModel.my()) + .createHierarcy() + .folder("F1-P") + .folder("F2-P") + .folder("F3-P") + .file("file1") + .file("file2") + .folder("F4") + * + * + * @param restWrapper + * @param repoModel + */ + public NodesBuilder(RestWrapper restWrapper, RepoTestModel repoModel) + { + this.restWrapper = restWrapper; + this.lastNode = repoModel; + } + + public NodeDetail folder(String prefix) + { + NodeDetail n = new NodeDetail(prefix, lastNode.getNodeRef(), "cm:folder"); + nodes.add(n); + return n; + } + + public class NodeDetail + { + private RestNodeModel parentNodeModel; + private String id; + private String prefix; + private String name; + + public ContentModel toContentModel() + { + ContentModel cm = new ContentModel(); + cm.setNodeRef(getId()); + return cm; + } + public NodeDetail(String prefix, String parentId, String nodeType) + { + this.prefix = prefix; + this.name = RandomData.getRandomName(prefix); + + RestNodeBodyModel model = new RestNodeBodyModel(); + model.setName(name); + model.setNodeType(nodeType); + + // define the parent + ContentModel parent = new ContentModel(); + parent.setNodeRef(parentId); + + RestNodeModel newModel = restWrapper.withCoreAPI().usingNode(parent).createNode(model); + this.id = newModel.getId(); + + if (nodeType.equals("cm:content")) + { + RestNodeModel tmp = new RestNodeModel(); + tmp.setId(parentId); + parentNodeModel = tmp; + } + else + parentNodeModel = newModel; + + } + + public NodeDetail folder(String prefix) + { + NodeDetail n = new NodeDetail(prefix, parentNodeModel.getId(), "cm:folder"); + nodes.add(n); + return n; + } + + public NodeDetail file(String prefix) + { + NodeDetail n = new NodeDetail(prefix, parentNodeModel.getId(), "cm:content"); + nodes.add(n); + return n; + } + + public String getId() + { + return id; + } + + public String getName() + { + return name; + } + + public String getPrefix() + { + return prefix; + } + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/ignore-models b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/ignore-models new file mode 100644 index 0000000000..bae3a13e50 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/model/ignore-models @@ -0,0 +1,12 @@ +# Any line that will start with # will be considered one comment +# Empty lines are also ignored +# Use this file if you want to ignore models from YAML file +#---------------------------------------------------------- +SiteBodyCreate +Error +# this is SiteModel (exist in Utility project) +SiteModel +#NodeBodyCreate/NodeBodyUpdate are created as NodeBody +NodeBodyCreate +NodeBodyUpdate +Node \ No newline at end of file diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Actions.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Actions.java new file mode 100644 index 0000000000..a5163ff3be --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Actions.java @@ -0,0 +1,94 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import java.io.Serializable; +import java.util.Map; + +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestActionConstraintModel; +import org.alfresco.rest.model.RestActionDefinitionModel; +import org.alfresco.rest.model.RestActionDefinitionModelsCollection; +import org.alfresco.utility.model.RepoTestModel; +import org.json.JSONObject; +import org.springframework.http.HttpMethod; + +public class Actions extends ModelRequest +{ + public Actions(RestWrapper restWrapper) + { + super(restWrapper); + } + + /** + * List available actions using GET on '/action-definitions' + */ + public RestActionDefinitionModelsCollection listActionDefinitions() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "action-definitions?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestActionDefinitionModelsCollection.class, request); + } + + /** + * Execute action with parameters using POST on '/action-executions' + */ + public JSONObject executeAction(String actionDefinitionId, RepoTestModel targetNode, Map params) + { + String postBody = JsonBodyGenerator.executeActionPostBody(actionDefinitionId, targetNode, params); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "action-executions"); + return restWrapper.processJson(request); + } + + /** + * Execute action without parameters using POST on '/action-executions' + */ + public JSONObject executeAction(String actionDefinitionId, RepoTestModel targetNode) + { + String postBody = JsonBodyGenerator.executeActionPostBody(actionDefinitionId, targetNode); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "action-executions"); + return restWrapper.processJson(request); + } + + /** + * Get specific action definition using GET on '/action-definitions/{actionDefinitionId}' + */ + public RestActionDefinitionModel getActionDefinitionById(String actionDefinitionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "action-definitions/".concat(actionDefinitionId)); + return restWrapper.processModel(RestActionDefinitionModel.class, request); + } + + /** + * Get specific action constraint using GET on '/action-parameter-constraints/{actionConstraintName}' + */ + public RestActionConstraintModel getActionConstraintByName(String actionConstraintName) + { + final RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "action-parameter-constraints/".concat(actionConstraintName)); + return restWrapper.processModel(RestActionConstraintModel.class, request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/AdminConsole.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/AdminConsole.java new file mode 100644 index 0000000000..a0fde73226 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/AdminConsole.java @@ -0,0 +1,50 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.core.RestWrapper; +import org.springframework.http.HttpMethod; + +import io.restassured.RestAssured; + +public class AdminConsole extends ModelRequest { + + public AdminConsole(RestWrapper restWrapper) + { + super(restWrapper); + RestAssured.basePath = "alfresco/service/api/server"; + restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath); + } + + // Method for getting repository info from Admin Console + public RestResponse getAdminConsoleRepoInfo() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, ""); + return restWrapper.process(request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Audit.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Audit.java new file mode 100644 index 0000000000..310491a3a7 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Audit.java @@ -0,0 +1,154 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ + +package org.alfresco.rest.requests; + +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestAuditAppModelsCollection; +import org.alfresco.rest.model.RestAuditEntryModel; +import org.alfresco.rest.model.RestAuditAppModel; +import org.alfresco.rest.model.RestAuditEntryModelsCollection; +import org.springframework.http.HttpMethod; + +/** + * Declares all Rest API under the /audit-applications path + * + */ +public class Audit extends ModelRequest +{ + + public Audit(RestWrapper restWrapper) + { + super(restWrapper); + } + + + /** + * Gets a list of audit applications in this repository using GET call on "/audit-applications" + * + * @return + * @throws JsonToModelConversionException + */ + public RestAuditAppModelsCollection getAuditApplications() throws JsonToModelConversionException + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "audit-applications?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestAuditAppModelsCollection.class, request); + } + + /** + * Retrieves an audit application info with ID using GET call on "/audit-applications/{auditApplicationId}" + * + * @param auditApplicationId + * @return + */ + public RestAuditAppModel getAuditApp(RestAuditAppModel restAuditAppModel) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "audit-applications/{auditApplicationId}?{parameters}", restAuditAppModel.getId(), restWrapper.getParameters()); + return restWrapper.processModel(RestAuditAppModel.class, request); + } + + /** + * Retrieves a list of audit entries for audit application auditApplicationId using GET call on "/audit-applications/{auditApplicationId}/audit-entries" + * + * @param auditApplicationId + * @return + */ + public RestAuditEntryModelsCollection listAuditEntriesForAnAuditApplication(String auditApplicationId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "audit-applications/{auditApplicationId}/audit-entries?{parameters}", auditApplicationId, restWrapper.getParameters()); + return restWrapper.processModels(RestAuditEntryModelsCollection.class, request); + } + + /** + * Disable or re-enable the audit application auditApplicationId using PUT call on "/audit-applications/{auditApplicationId}" + * + * @param restAuditAppModel + * @param key + * @param value + * @return + */ + public RestAuditAppModel updateAuditApp(RestAuditAppModel restAuditAppModel, String key, String value) + { + String postBody = JsonBodyGenerator.keyValueJson(key, value); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "audit-applications/{auditApplicationId}",restAuditAppModel.getId()); + return restWrapper.processModel(RestAuditAppModel.class, request); + } + + /** + * Retrieves an audit entry auditEntryId for audit application auditApplicationId using GET call on "/audit-applications/{auditApplicationId}/audit-entries/{auditEntryId}" + * + * @param auditApplicationId + * @param auditEntryId + * @return + */ + public RestAuditEntryModel getAuditEntryForAnAuditApplication(String auditApplicationId, String auditEntryId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "audit-applications/{auditApplicationId}/audit-entries/{auditEntryId}?{parameters}", auditApplicationId, auditEntryId, restWrapper.getParameters()); + return restWrapper.processModel(RestAuditEntryModel.class, request); + } + + /** + * Deletes an audit entry auditEntryId for audit application auditApplicationId using DELETE call on "/audit-applications/{auditApplicationId}/audit-entries/{auditEntryId}" + * + * @param auditApplicationId + * @param auditEntryId + * @return + */ + public void deleteAuditEntryForAnAuditApplication(String auditApplicationId, String auditEntryId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "audit-applications/{auditApplicationId}/audit-entries/{auditEntryId}", auditApplicationId, auditEntryId); + restWrapper.processEmptyModel(request); + } + + /** + * Deletes audit entries for audit application auditApplicationId using DELETE call on "/audit-applications/{auditApplicationId}/audit-entries" + * + * @param auditApplicationId + * @return + */ + public void deleteAuditEntriesForAnAuditApplication(String auditApplicationId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "audit-applications/{auditApplicationId}/audit-entries?{parameters}", auditApplicationId, restWrapper.getParameters()); + restWrapper.processEmptyModel(request); + } + + /** + * Retrieves a list of audit entries for a node nodeId using GET call on "/nodes/{nodeId}/audit-entries" + * + * @param nodeId + * @return + */ + public RestAuditEntryModelsCollection listAuditEntriesForNode(String nodeId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/audit-entries?{parameters}", nodeId, restWrapper.getParameters()); + return restWrapper.processModels(RestAuditEntryModelsCollection.class, request); + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/ContentStorageInformation.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/ContentStorageInformation.java new file mode 100644 index 0000000000..2a4edd6a76 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/ContentStorageInformation.java @@ -0,0 +1,237 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2021 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ +package org.alfresco.rest.requests; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestArchiveContentRequestModel; +import org.alfresco.rest.model.RestContentStorageInfoModel; +import org.alfresco.rest.model.RestRestoreArchivedContentRequestModel; +import org.alfresco.utility.model.TestModel; +import org.springframework.http.HttpMethod; + +public class ContentStorageInformation extends ModelRequest +{ + private static final String BASE_PATH = "nodes/{nodeId}/storage-info/{contentPropName}"; + private static final String VERSIONS_BASE_PATH = "nodes/{nodeId}/versions/{versionId}/storage-info/{contentPropName}"; + private static final String ARCHIVE_PATH_SUFFIX = "/archive"; + private static final String ARCHIVE_RESTORE_PATH_SUFFIX = "/archive-restore"; + + private String nodeId; + private String contentPropName; + private String versionId; + + public ContentStorageInformation(RestWrapper restWrapper) + { + super(restWrapper); + } + + + public ContentStorageInformation withNodeId(String nodeId) + { + this.nodeId = nodeId; + return this; + } + + public ContentStorageInformation withContentPropName(String contentPropName) + { + this.contentPropName = contentPropName; + return this; + } + + public ContentStorageInformation withVersionId(String versionId) + { + this.versionId = versionId; + return this; + } + + /** + * Get Content Storage Properties using GET call on "nodes/{nodeId}/storage-info/{contentPropName}" + * @return + */ + public RestContentStorageInfoModel getStorageInfo() + { + return getStorageInfo(nodeId, contentPropName); + } + + /** + * Get Content Version Storage Properties using GET call on "nodes/{nodeId}/versions/{versionId}/storage-info/{contentPropName}" + * @return + */ + public RestContentStorageInfoModel getVersionStorageInfo() + { + return getVersionStorageInfo(nodeId, versionId, contentPropName); + } + + /** + * Get Content Storage Properties using GET call on "nodes/{nodeId}/storage-info/{contentPropName}" + * @param nodeId The nodeId + * @param contentPropName The content property QNAME ie. "cm:content" + * @return + */ + public RestContentStorageInfoModel getStorageInfo(String nodeId, String contentPropName) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, BASE_PATH, nodeId, contentPropName); + return restWrapper.processModel(RestContentStorageInfoModel.class, request); + } + + /** + * Get Content Version Storage Properties using GET call on "nodes/{nodeId}/versions/{versionId}/storage-info/{contentPropName}" + * @param nodeId The nodeId + * @param versionId The versionId + * @param contentPropName The content property QNAME ie. "cm:content" + * @return object of {@link RestContentStorageInfoModel} + */ + public RestContentStorageInfoModel getVersionStorageInfo(String nodeId, String versionId, String contentPropName) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, VERSIONS_BASE_PATH, nodeId, versionId, contentPropName); + return restWrapper.processModel(RestContentStorageInfoModel.class, request); + } + + /** + * Send content to archive using POST call on "nodes/{nodeId}/storage-info/{contentPropName}/archive" + * + * @param archiveContentRequest The request body + * @return + */ + public RestResponse requestArchiveContent(RestArchiveContentRequestModel archiveContentRequest) + { + return requestArchiveContent(nodeId, contentPropName, archiveContentRequest); + } + + /** + * Send version content to archive using POST call on "nodes/{nodeId}/versions/{versionId}/storage-info/{contentPropName}/archive" + * + * @param archiveContentRequest The request body + * @return + */ + public RestResponse requestArchiveVersionContent(RestArchiveContentRequestModel archiveContentRequest) + { + return requestArchiveVersionContent(nodeId, contentPropName, versionId, archiveContentRequest); + } + + /** + * Send content to archive using POST call on "nodes/{nodeId}/storage-info/{contentPropName}/archive" + * + * @param nodeId The nodeId + * @param contentPropName The content property QNAME ie. "cm:content" + * @param archiveContentRequest The request body + * @return + */ + public RestResponse requestArchiveContent(String nodeId, String contentPropName, RestArchiveContentRequestModel archiveContentRequest) + { + RestRequest request = createRestRequestWithBody(HttpMethod.POST, archiveContentRequest, BASE_PATH + ARCHIVE_PATH_SUFFIX, nodeId, contentPropName); + return restWrapper.process(request); + } + + /** + * Send version content to archive using POST call on "nodes/{nodeId}/versions/{versionId}/storage-info/{contentPropName}/archive" + * + * @param nodeId The nodeId + * @param contentPropName The content property QNAME ie. "cm:content" + * @param versionId The versionId + * @param archiveContentRequest The request body + * @return + */ + public RestResponse requestArchiveVersionContent(String nodeId, String contentPropName, String versionId, RestArchiveContentRequestModel archiveContentRequest) + { + RestRequest request = createRestRequestWithBody(HttpMethod.POST, archiveContentRequest, VERSIONS_BASE_PATH + ARCHIVE_PATH_SUFFIX, nodeId, versionId, contentPropName); + return restWrapper.process(request); + } + + /** + * Restore content from archive using POST call on "nodes/{nodeId}/storage-info/{contentPropName}/archive-restore" + * + * @param restoreArchivedContentRequest The request body + * @return + */ + public RestResponse requestRestoreContentFromArchive(RestRestoreArchivedContentRequestModel restoreArchivedContentRequest) + { + return requestRestoreContentFromArchive(nodeId, contentPropName, restoreArchivedContentRequest); + } + + /** + * Restore version content from archive using POST call on "nodes/{nodeId}/storage-info/versions/{versionId}/{contentPropName}/archive-restore" + * + * @param restoreArchivedContentRequest The request body + * @return + */ + public RestResponse requestRestoreVersionContentFromArchive(RestRestoreArchivedContentRequestModel restoreArchivedContentRequest) + { + return requestRestoreVersionContentFromArchive(nodeId, contentPropName, versionId, restoreArchivedContentRequest); + } + + /** + * Restore content from archive using POST call on "nodes/{nodeId}/storage-info/{contentPropName}/archive-restore" + * + * @param nodeId The nodeId + * @param contentPropName The content property QNAME ie. "cm:content" + * @param restoreArchivedContentRequest The request body + * @return + */ + public RestResponse requestRestoreContentFromArchive(String nodeId, String contentPropName, RestRestoreArchivedContentRequestModel restoreArchivedContentRequest) + { + RestRequest request = createRestRequestWithBody(HttpMethod.POST, restoreArchivedContentRequest, BASE_PATH + + ARCHIVE_RESTORE_PATH_SUFFIX, nodeId, contentPropName); + return restWrapper.process(request); + } + + /** + * Restore version content from archive using POST call on "nodes/{nodeId}/storage-info/{contentPropName}/archive-restore" + * + * @param nodeId The nodeId + * @param contentPropName The content property QNAME ie. "cm:content" + * @param versionId The versionId + * @param restoreArchivedContentRequest The request body + * @return + */ + public RestResponse requestRestoreVersionContentFromArchive(String nodeId, String contentPropName, String versionId, + RestRestoreArchivedContentRequestModel restoreArchivedContentRequest) + { + RestRequest request = createRestRequestWithBody(HttpMethod.POST, restoreArchivedContentRequest, VERSIONS_BASE_PATH + + ARCHIVE_RESTORE_PATH_SUFFIX, nodeId, versionId, contentPropName); + return restWrapper.process(request); + } + + private RestRequest createRestRequestWithBody(HttpMethod httpMethod, TestModel request, String path, String... pathParams) + { + if (request != null) + { + return RestRequest.requestWithBody(httpMethod, request.toJson(), path, pathParams); + } + else + { + return RestRequest.simpleRequest(httpMethod, path, pathParams); + } + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/CustomAspectModelManager.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/CustomAspectModelManager.java new file mode 100644 index 0000000000..c4961b13e2 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/CustomAspectModelManager.java @@ -0,0 +1,111 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestCustomAspectModel; +import org.alfresco.utility.model.CustomAspectModel; +import org.alfresco.utility.model.CustomAspectPropertiesModel; +import org.alfresco.utility.model.CustomContentModel; +import org.springframework.http.HttpMethod; + +/** + * @author Bogdan Bocancea + */ +public class CustomAspectModelManager extends ModelRequest +{ + private CustomContentModel customContentModel; + private CustomAspectModel customAspectModel; + private CustomModelProperties customProperties = new CustomModelProperties(restWrapper); + + + public CustomAspectModelManager(CustomContentModel customContentModel, CustomAspectModel aspectModel, RestWrapper restWrapper) + { + super(restWrapper); + this.customContentModel = customContentModel; + this.customAspectModel = aspectModel; + } + + public RestCustomAspectModel getAspect() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "cmm/{modelName}/aspects/{aspectName}?{parameters}", + this.customContentModel.getName(), this.customAspectModel.getName(), restWrapper.getParameters()); + return restWrapper.processModel(RestCustomAspectModel.class, request); + } + + public void addProperty(CustomAspectPropertiesModel propertyModel) + { + customProperties.addProperty(propertyModel, this.customContentModel, true, + this.customAspectModel.getName(), false, null); + } + + public void addPropertyWithMinMaxValueConstraint(CustomAspectPropertiesModel propertyModel, int minValue, int maxValue) + { + customProperties.addProperty(propertyModel, this.customContentModel, true, this.customAspectModel.getName(), +true, customProperties.createMinMaxValueConstraintArray(minValue, maxValue)); + } + + public void addPropertyWithMinMaxLengthConstraint(CustomAspectPropertiesModel propertyModel, int minLength, int maxLength) + { + customProperties.addProperty(propertyModel, this.customContentModel, true, this.customAspectModel.getName(), +true, customProperties.createMinMaxLengthConstraint(minLength, maxLength)); + } + + public void addPropertyWithListOfValues(CustomAspectPropertiesModel propertyModel, boolean sorted, String... listOfValues) + { + customProperties.addProperty(propertyModel, this.customContentModel, true, this.customAspectModel.getName(), +true, customProperties.createListOfValuesConstraint(sorted, listOfValues)); + } + + public void addPropertyWithRegularExpression(CustomAspectPropertiesModel propertyModel, String regex) + { + customProperties.addProperty(propertyModel, this.customContentModel, true, this.customAspectModel.getName(), + true, customProperties.createRegexConstraint(regex)); + } + + public void deleteAspectProperty(CustomAspectPropertiesModel propertyModel) + { + String body = JsonBodyGenerator.defineJSON() + .add("name", this.customAspectModel.getName()).build().toString(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, body, + "cmm/{modelName}/aspects/{aspectName}?select=props&delete={propertyName}", + this.customContentModel.getName(), + this.customAspectModel.getName(), + propertyModel.getName()); + restWrapper.processEmptyModel(request); + } + + public void deleteAspect() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, + "cmm/{modelName}/aspects/{aspectName}", + this.customContentModel.getName(), + this.customAspectModel.getName()); + restWrapper.processEmptyModel(request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/CustomModelManager.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/CustomModelManager.java new file mode 100644 index 0000000000..7bb4545d30 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/CustomModelManager.java @@ -0,0 +1,120 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestCustomAspectModel; +import org.alfresco.rest.model.RestCustomModel; +import org.alfresco.rest.model.RestCustomTypeModel; +import org.alfresco.rest.model.RestGroupsModelsCollection; +import org.alfresco.utility.model.CustomAspectModel; +import org.alfresco.utility.model.CustomAspectPropertiesModel; +import org.alfresco.utility.model.CustomContentModel; +import org.springframework.http.HttpMethod; + +import javax.json.Json; +import javax.json.JsonArrayBuilder; +import javax.json.JsonObject; + +/** + * @author Bogdan Bocancea + */ +public class CustomModelManager extends ModelRequest +{ + private CustomContentModel customContentModel; + + public CustomModelManager(RestWrapper restWrapper) + { + super(restWrapper); + } + + public CustomModelManager(CustomContentModel customContentModel, RestWrapper restWrapper) + { + super(restWrapper); + this.customContentModel = customContentModel; + } + + /** + * Create a new custom model + * + * @param customContentModel + * @return {@link RestCustomModel} + */ + public RestCustomModel createCustomModel(CustomContentModel customContentModel) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, customContentModel.toJson(), + "cmm?{parameters}", restWrapper.getParameters()); + return restWrapper.processModel(RestCustomModel.class, request); + } + + /** + * Retrieve one model using GET call on "cmm/{modelName}" + * + * @return {@link RestCustomModel} + */ + public RestCustomModel getModel() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "cmm/{modelName}?{parameters}", this.customContentModel.getName(), + restWrapper.getParameters()); + return restWrapper.processModel(RestCustomModel.class, request); + } + + public void activateModel() + { + String json = JsonBodyGenerator.keyValueJson("status", "ACTIVE"); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, json, "cmm/{modelName}?select=status", this.customContentModel.getName()); + restWrapper.processEmptyModel(request); + } + + public void deactivateModel() + { + String json = JsonBodyGenerator.keyValueJson("status", "DRAFT"); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, json, "cmm/{modelName}?select=status", this.customContentModel.getName()); + restWrapper.processEmptyModel(request); + } + + public void deleteModel() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "cmm/{modelName}", this.customContentModel.getName()); + restWrapper.processEmptyModel(request); + } + + public RestCustomAspectModel createAspect(CustomAspectModel aspectModel) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, aspectModel.toJson(), + "cmm/{modelName}/aspects?{parameters}", this.customContentModel.getName(), restWrapper.getParameters()); + return restWrapper.processModel(RestCustomAspectModel.class, request); + } + + public RestCustomTypeModel createCustomType(RestCustomTypeModel customType) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, customType.toJson(), + "cmm/{modelName}/types?{parameters}", this.customContentModel.getName(), restWrapper.getParameters()); + return restWrapper.processModel(RestCustomTypeModel.class, request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/CustomModelProperties.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/CustomModelProperties.java new file mode 100644 index 0000000000..d2a7ee496f --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/CustomModelProperties.java @@ -0,0 +1,189 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.utility.model.CustomAspectPropertiesModel; +import org.alfresco.utility.model.CustomContentModel; +import org.apache.commons.lang3.StringUtils; +import org.springframework.http.HttpMethod; + +import javax.json.JsonArrayBuilder; +import javax.json.JsonObjectBuilder; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; + +/** + * @author Bogdan Bocancea + */ +public class CustomModelProperties extends ModelRequest +{ + public CustomModelProperties(RestWrapper restWrapper) + { + super(restWrapper); + } + + public void addProperty(CustomAspectPropertiesModel propertyModel, + CustomContentModel customContentModel, + boolean isAspect, + String aspectOrTypeName, + boolean hasConstraints, + JsonArrayBuilder constraintsArray) + { + JsonArrayBuilder array; + if(hasConstraints) + { + array = getPropertiesArray(propertyModel, true, constraintsArray); + } + else + { + array = getPropertiesArray(propertyModel, false, null); + } + + String body = JsonBodyGenerator.defineJSON() + .add("name", aspectOrTypeName) + .add("properties", array).build().toString(); + String urlPath; + if(isAspect) + { + urlPath = "cmm/{modelName}/aspects/{aspectName}?select=props"; + } + else + { + urlPath = "cmm/{modelName}/types/{typeName}?select=props"; + } + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, body, urlPath, + customContentModel.getName(), aspectOrTypeName); + restWrapper.processEmptyModel(request); + } + + private JsonArrayBuilder getPropertiesArray(CustomAspectPropertiesModel propertyModel, boolean hasConstraints, JsonArrayBuilder constraintsArray) + { + JsonArrayBuilder array = JsonBodyGenerator.defineJSONArray();; + if(hasConstraints) + { + array.add(JsonBodyGenerator.defineJSON() + .add("name", propertyModel.getName()) + .add("title", propertyModel.getTitle()) + .add("description", propertyModel.getDescription()) + .add("dataType", propertyModel.getDataType()) + .add("multiValued", propertyModel.isMultiValued()) + .add("mandatory", propertyModel.isMandatory()) + .add("mandatoryEnforced", propertyModel.isMandatoryEnforced()) + .add("constraints", constraintsArray)); + } + else + { + array.add(JsonBodyGenerator.defineJSON() + .add("name", propertyModel.getName()) + .add("title", propertyModel.getTitle()) + .add("description", propertyModel.getDescription()) + .add("dataType", propertyModel.getDataType()) + .add("multiValued", propertyModel.isMultiValued()) + .add("mandatory", propertyModel.isMandatory()) + .add("mandatoryEnforced", propertyModel.isMandatoryEnforced())); + } + return array; + } + + public JsonArrayBuilder createMinMaxValueConstraintArray(int minValue, int maxValue) + { + JsonArrayBuilder constraintsArray = JsonBodyGenerator.defineJSONArray(); + JsonObjectBuilder param1 = JsonBodyGenerator.defineJSON() + .add("name", "minValue") + .add("simpleValue", Integer.valueOf(minValue)); + JsonObjectBuilder param2 = JsonBodyGenerator.defineJSON() + .add("name", "maxValue") + .add("simpleValue", Integer.valueOf(maxValue)); + JsonArrayBuilder parameters = JsonBodyGenerator.defineJSONArray(); + parameters.add(0, param1).add(1, param2); + constraintsArray.add(JsonBodyGenerator.defineJSON() + .add("name", "MINMAX_" + UUID.randomUUID()) + .add("type", "MINMAX") + .add("parameters", parameters)); + return constraintsArray; + } + + public JsonArrayBuilder createMinMaxLengthConstraint(int minLength, int maxLength) + { + JsonArrayBuilder constraintsArray = JsonBodyGenerator.defineJSONArray(); + JsonObjectBuilder param1 = JsonBodyGenerator.defineJSON() + .add("name", "minLength") + .add("simpleValue", Integer.valueOf(minLength)); + JsonObjectBuilder param2 = JsonBodyGenerator.defineJSON() + .add("name", "maxLength") + .add("simpleValue", Integer.valueOf(maxLength)); + JsonArrayBuilder parameters = JsonBodyGenerator.defineJSONArray(); + parameters.add(0, param1).add(1, param2); + constraintsArray.add(JsonBodyGenerator.defineJSON() + .add("name", "LENGTH_" + UUID.randomUUID()) + .add("type", "LENGTH") + .add("parameters", parameters)); + return constraintsArray; + } + + public JsonArrayBuilder createListOfValuesConstraint(boolean sorted, String... listOfValues) + { + JsonArrayBuilder valuesArray = JsonBodyGenerator.defineJSONArray(); + Arrays.stream(listOfValues).forEach(valuesArray::add); + JsonArrayBuilder constraintsArray = JsonBodyGenerator.defineJSONArray(); + JsonObjectBuilder param1 = JsonBodyGenerator.defineJSON() + .add("name", "allowedValues") + .add("listValue", valuesArray); + JsonObjectBuilder param2 = JsonBodyGenerator.defineJSON() + .add("name", "sorted") + .add("simpleValue", Boolean.valueOf(sorted)); + JsonArrayBuilder parameters = JsonBodyGenerator.defineJSONArray(); + parameters.add(0, param1).add(1, param2); + constraintsArray.add(JsonBodyGenerator.defineJSON() + .add("name", "LIST_" + UUID.randomUUID()) + .add("type", "LIST") + .add("parameters", parameters)); + return constraintsArray; + } + + public JsonArrayBuilder createRegexConstraint(String regex) + { + JsonArrayBuilder constraintsArray = JsonBodyGenerator.defineJSONArray(); + JsonObjectBuilder param1 = JsonBodyGenerator.defineJSON() + .add("name", "expression") + .add("simpleValue", regex); + JsonObjectBuilder param2 = JsonBodyGenerator.defineJSON() + .add("name", "requiresMatch") + .add("simpleValue", true); + JsonArrayBuilder parameters = JsonBodyGenerator.defineJSONArray(); + parameters.add(0, param1).add(1, param2); + constraintsArray.add(JsonBodyGenerator.defineJSON() + .add("name", "REGEX_" + UUID.randomUUID()) + .add("type", "REGEX") + .add("parameters", parameters)); + return constraintsArray; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/CustomTypeManager.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/CustomTypeManager.java new file mode 100644 index 0000000000..90cb4373f3 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/CustomTypeManager.java @@ -0,0 +1,90 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestCustomTypeModel; +import org.alfresco.utility.model.CustomAspectPropertiesModel; +import org.alfresco.utility.model.CustomContentModel; +import org.springframework.http.HttpMethod; + +/** + * @author Bogdan Bocancea + */ +public class CustomTypeManager extends ModelRequest +{ + private CustomContentModel customContentModel; + private RestCustomTypeModel customTypeModel; + private CustomModelProperties customProperties = new CustomModelProperties(restWrapper); + + public CustomTypeManager(CustomContentModel customContentModel, RestCustomTypeModel customTypeModel, RestWrapper restWrapper) + { + super(restWrapper); + this.customContentModel = customContentModel; + this.customTypeModel = customTypeModel; + } + + public RestCustomTypeModel getCustomType() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "cmm/{modelName}/types/{typeName}?{parameters}", + this.customContentModel.getName(), this.customTypeModel.getName(), restWrapper.getParameters()); + return restWrapper.processModel(RestCustomTypeModel.class, request); + } + + public void addProperty(CustomAspectPropertiesModel propertyModel) + { + customProperties.addProperty(propertyModel, this.customContentModel, false, + this.customTypeModel.getName(), false, null); + } + + public void addPropertyWithMinMaxValueConstraint(CustomAspectPropertiesModel propertyModel, int minValue, int maxValue) + { + customProperties.addProperty(propertyModel, this.customContentModel, false, this.customTypeModel.getName(), + true, customProperties.createMinMaxValueConstraintArray(minValue, maxValue)); + } + + public void addPropertyWithMinMaxLengthConstraint(CustomAspectPropertiesModel propertyModel, int minLength, int maxLength) + { + customProperties.addProperty(propertyModel, this.customContentModel, false, this.customTypeModel.getName(), + true, customProperties.createMinMaxLengthConstraint(minLength, maxLength)); + } + + public void addPropertyWithListOfValues(CustomAspectPropertiesModel propertyModel, boolean sorted, String... listOfValues) + { + customProperties.addProperty(propertyModel, this.customContentModel, false, this.customTypeModel.getName(), + true, customProperties.createListOfValuesConstraint(sorted, listOfValues)); + } + + public void deleteCustomType() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, + "cmm/{modelName}/types/{typeName}", + this.customContentModel.getName(), + this.customTypeModel.getName()); + restWrapper.processEmptyModel(request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Deployments.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Deployments.java new file mode 100644 index 0000000000..f304a10b25 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Deployments.java @@ -0,0 +1,90 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestDeploymentModelsCollection; +import org.springframework.http.HttpMethod; + +/** + * Created by Claudia Agache on 10/4/2016. + */ +public class Deployments extends ModelRequest +{ + RestDeploymentModel deployment; + + public Deployments(RestWrapper restWrapper) + { + super(restWrapper); + } + + public Deployments(RestDeploymentModel deployment, RestWrapper restWrapper) + { + super(restWrapper); + this.deployment = deployment; + } + + /** + * Retrieve 100 deployments (this is the default size when maxItems is not specified) from Alfresco using GET call on "/deployments" + * + * @return + * @throws JsonToModelConversionException + */ + public RestDeploymentModelsCollection getDeployments() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "deployments?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestDeploymentModelsCollection.class, request); + } + + /** + * Delete the specified deployment from Alfresco using DELETE call on "/deployments/{deploymentId}" + * + * @return + * @throws JsonToModelConversionException + */ + public void deleteDeployment() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "deployments/{deploymentId}", deployment.getId()); + restWrapper.processEmptyModel(request); + } + + /** + * Retrieve the specified deployment from Alfresco using GET call on "/deployments/{deploymentId}" + * + * @return + * @throws JsonToModelConversionException + */ + public RestDeploymentModel getDeployment() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "deployments/{deploymentId}?{parameters}", + deployment.getId(), restWrapper.getParameters()); + return restWrapper.processModel(RestDeploymentModel.class, request); + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Downloads.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Downloads.java new file mode 100644 index 0000000000..c2c94ca660 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Downloads.java @@ -0,0 +1,79 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestDownloadsModel; +import org.springframework.http.HttpMethod; + + +/** + * Methods for Rest API under the /downloads path + */ + +public class Downloads extends ModelRequest { + + RestDownloadsModel downloadsModel; + + public Downloads(RestWrapper restWrapper) + { + super(restWrapper); + } + + public Downloads(RestDownloadsModel downloadsModel, RestWrapper restWrapper) + { + super(restWrapper); + this.downloadsModel = downloadsModel; + } + + /** + * Get download details using POST call on "downloads" + */ + public RestDownloadsModel createDownload(String postBody) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "downloads"); + return restWrapper.processModel(RestDownloadsModel.class, request); + } + + /** + * Get download details using GET call on "downloads/{downloadId}" + */ + public RestDownloadsModel getDownload() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "downloads/{downloadId}", downloadsModel.getId()); + return restWrapper.processModel(RestDownloadsModel.class, request); + } + + /** + * Cancel download using DELETE call on "downloads/{downloadId}" + */ + public void cancelDownload() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "downloads/{downloadId}", downloadsModel.getId()); + restWrapper.processEmptyModel(request);; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/FolderRules.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/FolderRules.java new file mode 100644 index 0000000000..051f9b48b4 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/FolderRules.java @@ -0,0 +1,136 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2022 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ +package org.alfresco.rest.requests; + +import static org.alfresco.rest.core.JsonBodyGenerator.arrayToJson; + +import java.util.List; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestRuleModel; +import org.alfresco.rest.model.RestRuleModelsCollection; +import org.springframework.http.HttpMethod; + +public class FolderRules extends ModelRequest +{ + private static final String BASE_PATH = "nodes/{nodeId}/rule-sets/{ruleSetId}/rules"; + private static final String RULE_ID_PATH = "/{ruleId}"; + + private String nodeId; + private String ruleSetId; + + public FolderRules withNodeId(String nodeId) + { + this.nodeId = nodeId; + return this; + } + + public FolderRules withRuleSetId(String ruleSetId) + { + this.ruleSetId = ruleSetId; + return this; + } + + public FolderRules(RestWrapper restWrapper) + { + super(restWrapper); + } + + /** + * Gets a list of rules for the folder node using GET call on "nodes/{nodeId}/rule-sets/{ruleSetId}/rules" + * @return + */ + public RestRuleModelsCollection getListOfRules() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, BASE_PATH, nodeId, ruleSetId); + return restWrapper.processModels(RestRuleModelsCollection.class, request); + } + + /** + * Gets a single rule definition for the folder node using GET call on "nodes/{nodeId}/rule-sets/{ruleSetId}/rules/{ruleId}" + * @return + */ + public RestRuleModel getSingleRule(String ruleId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, BASE_PATH + RULE_ID_PATH, nodeId, ruleSetId, ruleId); + return restWrapper.processModel(RestRuleModel.class, request); + } + + /** + * Create several rules. + * + * @param ruleModels The list of rules. + * @return The same list of rules with some data populated by the repository. + */ + public RestRuleModelsCollection createListOfRules(List ruleModels) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, arrayToJson(ruleModels), BASE_PATH, nodeId, ruleSetId); + return restWrapper.processModels(RestRuleModelsCollection.class, request); + } + + /** + * Create a single rule. + * + * @param ruleModel The rule to create. + * @return The created rule with some data populated by the repository. + */ + public RestRuleModel createSingleRule(RestRuleModel ruleModel) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, ruleModel.toJson(), BASE_PATH, nodeId, ruleSetId); + return restWrapper.processModel(RestRuleModel.class, request); + } + + /** + * Update a rule. + * + * @param ruleId The id of the rule to update. + * @param ruleModel The updated rule definition. + * @return The updated rule with some data populated by the repository. + */ + public RestRuleModel updateRule(String ruleId, RestRuleModel ruleModel) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, ruleModel.toJson(), BASE_PATH + RULE_ID_PATH, nodeId, ruleSetId, ruleId); + return restWrapper.processModel(RestRuleModel.class, request); + } + + /** + * Deletes a rule definition for the folder node using DELETE call on "nodes/{nodeId}/rule-sets/{ruleSetId}/rules/{ruleId}" + * @param ruleId The id of the rule to delete. + * @return void + */ + public void deleteRule(String ruleId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, BASE_PATH + RULE_ID_PATH, nodeId, ruleSetId, ruleId); + restWrapper.processEmptyModel(request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Groups.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Groups.java new file mode 100644 index 0000000000..82e5a6bb4d --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Groups.java @@ -0,0 +1,116 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestGroupMember; +import org.alfresco.rest.model.RestGroupMemberModelsCollection; +import org.alfresco.rest.model.RestGroupsModel; +import org.alfresco.rest.model.RestGroupsModelsCollection; +import org.springframework.http.HttpMethod; + +public class Groups extends ModelRequest +{ + + public Groups(RestWrapper restWrapper) + { + super(restWrapper); + } + + /** + * List existing groups using GET on '/groups + */ + public RestGroupsModelsCollection listGroups() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "groups?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestGroupsModelsCollection.class, request); + } + + /** + * Create a group using POST on '/groups + */ + public RestGroupsModel createGroup(String groupBodyCreate) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, groupBodyCreate, "groups?{parameters}", restWrapper.getParameters()); + return restWrapper.processModel(RestGroupsModel.class, request); + } + + /** + * Retrieve group details using GET on '/groups/{groupId} + */ + public RestGroupsModel getGroupDetail(String groupId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "groups/{groupId}?{parameters}", groupId, restWrapper.getParameters()); + return restWrapper.processModel(RestGroupsModel.class, request); + } + + /** + * Delete a group using DELETE on '/groups/{groupId} + */ + public void deleteGroup(String groupId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "groups/{groupId}?{parameters}", groupId, restWrapper.getParameters()); + restWrapper.processEmptyModel(request); + } + + /** + * Update group details using PUT on '/groups/{groupId} + */ + public RestGroupsModel updateGroupDetails(String groupId, String groupBodyUpdate) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, groupBodyUpdate, "groups/{groupId}?{parameters}", groupId, restWrapper.getParameters()); + return restWrapper.processModel(RestGroupsModel.class, request); + } + + /** + * List memberships of a group using GET on '/groups/{groupId}/members + */ + public RestGroupMemberModelsCollection listGroupMemberships(String groupId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "groups/{groupId}/members?{parameters}", groupId, restWrapper.getParameters()); + return restWrapper.processModels(RestGroupMemberModelsCollection.class, request); + } + + /** + * Create a group membership using POST on '/groups/{groupId}/members + */ + public RestGroupMember createGroupMembership (String groupId, String groupMembershipBodyCreate) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, groupMembershipBodyCreate, "groups/{groupId}/members?{parameters}", groupId, + restWrapper.getParameters()); + return restWrapper.processModel(RestGroupMember.class, request); + } + + /** + * Delete a group membership using DELETE on '/groups/{groupId}/members/{groupMemberId} + */ + public void deleteGroupMembership(String groupId, String groupMemberId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "groups/{groupId}/members/{groupMemberId}", groupId, groupMemberId); + restWrapper.processEmptyModel(request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/ModelRequest.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/ModelRequest.java new file mode 100644 index 0000000000..5e85b699c8 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/ModelRequest.java @@ -0,0 +1,71 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import org.alfresco.rest.core.RestWrapper; + +public abstract class ModelRequest +{ + protected RestWrapper restWrapper; + + public ModelRequest(RestWrapper restWrapper) + { + this.restWrapper = restWrapper; + } + + @SuppressWarnings("unchecked") + public Request usingParams(String... parameters) + { + restWrapper.withParams(parameters); + return (Request) this; + } + + /** + * Use "include=path" in the URL query. + *

+ * Nb. Replaces any existing parameters. + */ + public Request includePath() + { + return include("path"); + } + + /** + * Specify fields to include in the response. + *

+ * Nb. Replaces any existing parameters. + */ + @SuppressWarnings ("unchecked") + public Request include(String... includes) + { + String includeString = Arrays.stream(includes).collect(Collectors.joining(",")); + restWrapper.withParams("include=" + includeString); + return (Request) this; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Networks.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Networks.java new file mode 100644 index 0000000000..1e1153d5ee --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Networks.java @@ -0,0 +1,80 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestNetworkModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.UserModel; +import org.json.JSONObject; +import org.springframework.http.HttpMethod; + +/** + * Declares all Rest API under the /networks path + * + */ +public class Networks extends ModelRequest +{ + public Networks(RestWrapper restWrapper) + { + super(restWrapper); + } + + /** + * Retrieve details for the current user network using GET call on "networks/{networkId}" + * + * @return + */ + public RestNetworkModel getNetwork() + { + return getNetwork(restWrapper.getTestUser()); + } + + /** + * Retrieve details of a specific network using GET call on "networks/{networkId}" + * + * @return + */ + public RestNetworkModel getNetwork(UserModel tenant) + { + Utility.checkObjectIsInitialized(tenant.getDomain(), "tenant.getDomain()"); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "networks/{networkId}", tenant.getDomain()); + return restWrapper.processModel(RestNetworkModel.class, request); + } + + /** + * Retrieve details of a specific network using GET call with parameters on "networks/{networkId}?{parameters}" + * + * @return JSONObject + */ + public JSONObject getNetworkWithParams(UserModel tenant) + { + Utility.checkObjectIsInitialized(tenant.getDomain(), "tenant.getDomain()"); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "networks/{networkId}?{parameters}", tenant.getDomain(), restWrapper.getParameters()); + return restWrapper.processJson(request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Node.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Node.java new file mode 100644 index 0000000000..bfe72e3860 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Node.java @@ -0,0 +1,1109 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ + +package org.alfresco.rest.requests; + +import static org.alfresco.rest.requests.RuleSettings.IS_INHERITANCE_ENABLED; +import static org.springframework.http.HttpMethod.PUT; + +import javax.json.JsonArrayBuilder; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +import io.restassured.http.ContentType; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestActionDefinitionModelsCollection; +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestCommentModelsCollection; +import org.alfresco.rest.model.RestNodeAssocTargetModel; +import org.alfresco.rest.model.RestNodeAssociationModel; +import org.alfresco.rest.model.RestNodeAssociationModelCollection; +import org.alfresco.rest.model.RestNodeBodyModel; +import org.alfresco.rest.model.RestNodeBodyMoveCopyModel; +import org.alfresco.rest.model.RestNodeChildAssocModelCollection; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.RestNodeModelsCollection; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.rest.model.RestRatingModelsCollection; +import org.alfresco.rest.model.RestRenditionInfoModel; +import org.alfresco.rest.model.RestRenditionInfoModelCollection; +import org.alfresco.rest.model.RestRuleExecutionModel; +import org.alfresco.rest.model.RestRuleSetLinkModel; +import org.alfresco.rest.model.RestRuleSetModel; +import org.alfresco.rest.model.RestRuleSetModelsCollection; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.rest.model.RestVersionModel; +import org.alfresco.rest.model.RestVersionModelsCollection; +import org.alfresco.rest.model.body.RestNodeLockBodyModel; +import org.alfresco.rest.model.builder.NodesBuilder; +import org.alfresco.utility.Utility; +import org.alfresco.utility.model.RepoTestModel; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.testng.reporters.Files; + +/** + * Declares all Rest API under the /nodes path + * + */ +public class Node extends ModelRequest +{ + private static final String RULE_SETS_URI = "nodes/{nodeId}/rule-sets"; + private static final String RULE_SET_BY_ID = RULE_SETS_URI + "/{ruleSetId}"; + + private RepoTestModel repoModel; + + public Node(RestWrapper restWrapper) + { + super(restWrapper); + } + + public Node(RepoTestModel repoModel, RestWrapper restWrapper) + { + super(restWrapper); + this.repoModel = repoModel; + Utility.checkObjectIsInitialized(this.repoModel.getNodeRef(), "repoModel.getNodeRef()"); + } + + /** + * Retrieve details for a specific node using GET call on "nodes/{nodeId}" + * + * @param nodeId + * @return + * @throws JsonToModelConversionException + */ + public RestNodeModel getNode() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModel(RestNodeModel.class, request); + } + + /** + * Retrieve comments for a specific node using GET call on "nodes/{nodeId}/comments" + * + * @param nodeId + * @return + * @throws JsonToModelConversionException + */ + public RestCommentModelsCollection getNodeComments() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/comments?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModels(RestCommentModelsCollection.class, request); + } + + /** + * Publish one new comment on a specific node using POST call on "nodes/{nodeId}/comments" + * + * @param node + * @param commentContent + * @return + */ + public RestCommentModel addComment(String commentContent) + { + String postBody = JsonBodyGenerator.keyValueJson("content", commentContent); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/comments", repoModel.getNodeRef()); + return restWrapper.processModel(RestCommentModel.class, request); + } + + /** + * Publish multiple comments on a specific node using POST call on "nodes/{nodeId}/comments" + * + * @param contentModel + * @param comments + * @return + */ + public RestCommentModelsCollection addComments(String... comments) + { + JsonArrayBuilder array = JsonBodyGenerator.defineJSONArray(); + for (String comment : comments) + { + array.add(JsonBodyGenerator.defineJSON().add("content", comment)); + } + String postBody = array.build().toString(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/comments", repoModel.getNodeRef()); + return restWrapper.processModels(RestCommentModelsCollection.class, request); + } + + /** + * Update a comment for a specific node using PUT call on nodes/{nodeId}/comments/{commentId} + * + * @param nodeId + * @param commentId + * @param commentContent + * @return + * @throws JsonToModelConversionException + */ + public RestCommentModel updateComment(RestCommentModel commentModel, String commentContent) + { + String postBody = JsonBodyGenerator.keyValueJson("content", commentContent); + RestRequest request = RestRequest.requestWithBody(PUT, postBody, "nodes/{nodeId}/comments/{commentId}?{parameters}", repoModel.getNodeRef(), commentModel.getId(), restWrapper.getParameters()); + request.setContentType("UTF-8"); + RestCommentModel response = restWrapper.processModel(RestCommentModel.class, request); + return response; + } + + /** + * Delete a comment for a specific node using DELETE call on nodes/{nodeId}/comments/{commentId} + * + * @param nodeId + * @param commentId + * @return + * @throws JsonToModelConversionException + */ + public void deleteComment(RestCommentModel comment) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "nodes/{nodeId}/comments/{commentId}", repoModel.getNodeRef(), comment.getId()); + restWrapper.processEmptyModel(request); + } + + /** + * Like a document using POST call on "nodes/{nodeId}/ratings" + * + * @return + */ + public RestRatingModel likeDocument() + { + String postBody = JsonBodyGenerator.likeRating(true); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/ratings", repoModel.getNodeRef()); + return restWrapper.processModel(RestRatingModel.class, request); + } + + public RestRatingModel dislikeDocument() + { + String postBody = JsonBodyGenerator.likeRating(false); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/ratings", repoModel.getNodeRef()); + return restWrapper.processModel(RestRatingModel.class, request); + } + + /** + * POST call on "nodes/{nodeId}/ratings" using an invalid rating body + * + * @return + */ + public RestRatingModel addInvalidRating(String jsonBody) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, jsonBody, "nodes/{nodeId}/ratings", repoModel.getNodeRef()); + return restWrapper.processModel(RestRatingModel.class, request); + } + + /** + * Add five star rate to a document using POST call on "nodes/{nodeId}/ratings" + * + * @param stars + * @return + */ + public RestRatingModel rateStarsToDocument(int stars) + { + String postBody = JsonBodyGenerator.fiveStarRating(stars); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/ratings", repoModel.getNodeRef()); + return restWrapper.processModel(RestRatingModel.class, request); + } + + /** + * Retrieve node ratings using GET call on "nodes/{nodeId}/ratings" + * + * @return + */ + public RestRatingModelsCollection getRatings() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/ratings?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModels(RestRatingModelsCollection.class, request); + } + + /** + * Delete like rating using DELETE call on "nodes/{nodeId}/ratings/{ratingId}" + * + * @return + */ + public void deleteLikeRating() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "nodes/{nodeId}/ratings/{ratingId}", repoModel.getNodeRef(), "likes"); + restWrapper.processEmptyModel(request); + } + + /** + * Try to delete invalid rating using DELETE call on "nodes/{nodeId}/ratings/{ratingId}" + * + * @return + */ + public void deleteInvalidRating(String rating) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "nodes/{nodeId}/ratings/{ratingId}", repoModel.getNodeRef(), rating); + restWrapper.processEmptyModel(request); + } + + /** + * + * Get like rating of a document using GET call on "nodes/{nodeId}/ratings/{ratingId}" + */ + public RestRatingModel getLikeRating() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/ratings/{ratingId}?{parameters}", repoModel.getNodeRef(), "likes", restWrapper.getParameters()); + return restWrapper.processModel(RestRatingModel.class, request); + } + + /** + * Delete fivestar rating using DELETE call on "nodes/{nodeId}/ratings/{ratingId}" + * + * @return + */ + public void deleteFiveStarRating() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "nodes/{nodeId}/ratings/{ratingId}", repoModel.getNodeRef(), "fiveStar"); + restWrapper.processEmptyModel(request); + } + + /** + * + * Get fivestar rating of a document using GET call on "nodes/{nodeId}/ratings/{ratingId}" + * @return + */ + public RestRatingModel getFiveStarRating() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/ratings/{ratingId}?{parameters}", repoModel.getNodeRef(), "fiveStar", restWrapper.getParameters()); + return restWrapper.processModel(RestRatingModel.class, request); + } + + /** + * Adds a tag to the given content node + * + * @param contentModel + * @param tag + * @return + */ + public RestTagModel addTag(String tag) + { + String postBody = JsonBodyGenerator.keyValueJson("tag", tag); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/tags", repoModel.getNodeRef()); + return restWrapper.processModel(RestTagModel.class, request); + } + + /** + * Adds multiple tags to the given content node + * + * @param contentModel + * @param tags + * @return + */ + public RestTagModelsCollection addTags(String... tags) + { + String postBody = "["; + for (String tag : tags) + { + postBody += JsonBodyGenerator.keyValueJson("tag", tag) + ","; + } + postBody = postBody.substring(0, postBody.length() - 1) + "]"; + + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/tags", repoModel.getNodeRef()); + return restWrapper.processModels(RestTagModelsCollection.class, request); + } + + + /** + * Deletes a tag for a specific content node using DELETE call on nodes/{nodeId}/tags/{tagId} + * + * @param content + * @param tag + * @return + * @throws JsonToModelConversionException + */ + public void deleteTag(RestTagModel tag) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "nodes/{nodeId}/tags/{tagId}", repoModel.getNodeRef(), tag.getId()); + restWrapper.processEmptyModel(request); + } + + /** + * Get node tags using GET call on 'nodes/{nodeId}/tags' + * + * @param tag + * @return + */ + public RestTagModelsCollection getNodeTags() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/tags?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModels(RestTagModelsCollection.class, request); + } + + /** + * Create new nodes using POST call on 'nodes/{nodeId}/children + * + * @param node + * @return + */ + public RestNodeModel createNode(RestNodeBodyModel node) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, node.toJson(), "nodes/{nodeId}/children?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModel(RestNodeModel.class, request); + } + + /** + * Create new nodes using POST call on 'nodes/{nodeId}/children + * + * You need to specify first the multipart call {@link RestWrapper#usingMultipartFile(java.io.File)} + * + * usingMultipartFile(new File("your-local-file.txt")).withCoreAPI().usingNode(ContentModel.my()).createNode(); + * @return + */ + public RestNodeModel createNode() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.POST, "nodes/{nodeId}/children", repoModel.getNodeRef()); + return restWrapper.processModel(RestNodeModel.class, request); + } + + /** + * Retrieve content for a specific node using GET call on "nodes/{nodeId}/content" + * + * @return + */ + public RestResponse getNodeContent() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/content?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.process(request); + } + + /** + * Retrieve content for a specific node using GET call on "nodes/{nodeId}/content" + * + * @return + * @param nodeId + */ + public RestResponse getNodeContent(String nodeId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/content?{parameters}", nodeId, restWrapper.getParameters()); + return restWrapper.process(request); + } + + /** + * Create node rendition using POST call on '/nodes/{nodeId}/renditions' + * + * @param renditionId id of rendition to be created + * @return + */ + public void createNodeRendition(String renditionId) + { + String postBody = JsonBodyGenerator.keyValueJson("id", renditionId); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/renditions", repoModel.getNodeRef()); + restWrapper.processEmptyModel(request); + } + + /** + * Create node version rendition using POST call on '/nodes/{nodeId}/versions/{versionId}/renditions' + * + * @param renditionId id of rendition to be created + * @param versionId version id of node + * @return + */ + public void createNodeVersionRendition(String renditionId, String versionId) + { + String postBody = JsonBodyGenerator.keyValueJson("id", renditionId); + RestRequest request = RestRequest + .requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/versions/{versionId}/renditions", + repoModel.getNodeRef(), versionId); + restWrapper.processEmptyModel(request); + } + + /** + * Check if specified rendition exists and if not + * create node rendition using POST call on '/nodes/{nodeId}/renditions' + * + * @param renditionId id of rendition to be created + * @return + */ + public void createNodeRenditionIfNotExists(String renditionId) + { + getNodeRendition(renditionId); + if (Integer.valueOf(restWrapper.getStatusCode()).equals(HttpStatus.OK.value())) + { + String postBody = JsonBodyGenerator.keyValueJson("id", renditionId); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/renditions", repoModel.getNodeRef()); + restWrapper.processEmptyModel(request); + } + } + + /** + * Get node rendition using GET call on '/nodes/{nodeId}/renditions/{renditionId} + * + * @param renditionId id of rendition to be retrieved + * @return + */ + public RestRenditionInfoModel getNodeRendition(String renditionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/renditions/{renditionId}", repoModel.getNodeRef(), renditionId); + return restWrapper.processModel(RestRenditionInfoModel.class, request); + } + + /** + * Get node version rendition using GET call on '/nodes/{nodeId}/versions/{versionId}renditions/{renditionId} + * + * @param renditionId id of rendition to be retrieved + * @param versionId versionId of the node + * @return + */ + public RestRenditionInfoModel getNodeVersionRendition(String renditionId, String versionId) + { + RestRequest request = RestRequest + .simpleRequest(HttpMethod.GET, "nodes/{nodeId}/versions/{versionId}/renditions/{renditionId}", + repoModel.getNodeRef(), versionId, renditionId); + return restWrapper.processModel(RestRenditionInfoModel.class, request); + } + + /** + * Get node rendition using GET call on 'nodes/{nodeId}/renditions/{renditionId} Please note that it retries to get + * the renditions response several times because on the alfresco server the rendition can take a while to be created. + * + * @return + */ + public RestRenditionInfoModel getNodeRenditionUntilIsCreated(String renditionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/renditions/{renditionId}", repoModel.getNodeRef(), renditionId); + RestRenditionInfoModel renditions = restWrapper.processModel(RestRenditionInfoModel.class, request); + int retry = 0; + if (Integer.valueOf(restWrapper.getStatusCode()).equals(HttpStatus.OK.value())) + { + while (renditions.getStatus().equals("NOT_CREATED") && retry < Utility.retryCountSeconds - 8) + { + Utility.waitToLoopTime(1); + renditions = restWrapper.processModel(RestRenditionInfoModel.class, request); + retry++; + } + } + return renditions; + } + + /** + * Get node version rendition using GET call on 'nodes/{nodeId}/versions/{versionId}/renditions/{renditionId} Please note that it retries to get + * the renditions response several times because on the alfresco server the rendition can take a while to be created. + * + * @return + */ + public RestRenditionInfoModel getNodeVersionRenditionUntilIsCreated(String renditionId, String versionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/versions/{versionId}/renditions/{renditionId}", repoModel.getNodeRef(), versionId, renditionId); + RestRenditionInfoModel renditions = restWrapper.processModel(RestRenditionInfoModel.class, request); + int retry = 0; + if (Integer.valueOf(restWrapper.getStatusCode()).equals(HttpStatus.OK.value())) + { + while (renditions.getStatus().equals("NOT_CREATED") && retry < Utility.retryCountSeconds - 8) + { + Utility.waitToLoopTime(1); + renditions = restWrapper.processModel(RestRenditionInfoModel.class, request); + retry++; + } + } + return renditions; + } + + /** + * Get node rendition content using GET call on + * 'nodes/{nodeId}/renditions/{renditionId}/content Please note that it + * retries to get the renditions response several times because on the + * alfresco server the rendition can take a while to be created. + * + * @return + */ + public RestResponse getNodeRenditionContentUntilIsCreated(String renditionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/renditions/{renditionId}/content", repoModel.getNodeRef(), + renditionId); + RestResponse response = restWrapper.process(request); + int retry = 0; + //Multiplied by '4' because AI rendition test cases need more time (~30 seconds) - see ACS-2158 + while (Integer.valueOf(response.getStatusCode()).equals(HttpStatus.NOT_FOUND.value()) && retry < (4 * Utility.retryCountSeconds)) + { + Utility.waitToLoopTime(1); + response = restWrapper.process(request); + retry++; + } + + return response; + } + + /** + * Get node version rendition content using GET call on + * 'nodes/{nodeId}/versions/{versionId}/renditions/{renditionId}/content Please note that it + * retries to get the renditions response several times because on the + * alfresco server the rendition can take a while to be created. + * + * @return + */ + public RestResponse getNodeVersionRenditionContentUntilIsCreated(String renditionId, String versionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/versions/{versionId}/renditions/{renditionId}/content", repoModel.getNodeRef(), + versionId, renditionId); + RestResponse response = restWrapper.process(request); + int retry = 0; + while (Integer.valueOf(response.getStatusCode()).equals(HttpStatus.NOT_FOUND.value()) && retry < Utility.retryCountSeconds) + { + Utility.waitToLoopTime(1); + response = restWrapper.process(request); + retry++; + } + + return response; + } + + /** + * Get node rendition content using GET call on + * 'nodes/{nodeId}/renditions/{renditionId}/content + * + * @return + */ + public RestResponse getNodeRenditionContent(String renditionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/renditions/{renditionId}/content", repoModel.getNodeRef(), + renditionId); + return restWrapper.process(request); + } + + /** + * Get node version rendition content using GET call on + * 'nodes/{nodeId}/versions/{versionId}/renditions/{renditionId}/content + * + * @return + */ + public RestResponse getNodeVersionRenditionContent(String renditionId, String versionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/versions/{versionId}/renditions/{renditionId}/content", repoModel.getNodeRef(), + versionId, renditionId); + return restWrapper.process(request); + } + + /** + * Get rendition information for available renditions for the node using GET call on + * 'nodes/{nodeId}/renditions' + * @return + */ + public RestRenditionInfoModelCollection getNodeRenditionsInfo() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/renditions?{parameters}", repoModel.getNodeRef(), + restWrapper.getParameters()); + return restWrapper.processModels(RestRenditionInfoModelCollection.class, request); + } + + /** + * Get rendition information for available renditions for the node version using GET call on + * 'nodes/{nodeId}/versions/{versionId}/renditions' + * @return + */ + public RestRenditionInfoModelCollection getNodeVersionRenditionsInfo(String versionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/versions/{versionId}/renditions?{parameters}", repoModel.getNodeRef(), + versionId, restWrapper.getParameters()); + return restWrapper.processModels(RestRenditionInfoModelCollection.class, request); + } + + + /** + * Delete the rendition identified by renditionId using DELETE call on "/nodes/{nodeId}/renditions/{renditionId}" + * + * @param renditionId id of rendition to delete + */ + public void deleteNodeRendition(String renditionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "nodes/{nodeId}/renditions/{renditionId}", repoModel.getNodeRef(), renditionId); + restWrapper.processEmptyModel(request); + } + + /** + * Get a node's children using GET call 'nodes/{nodeId}/children + * + * @return a collection of nodes + */ + public RestNodeModelsCollection listChildren() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/children?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModels(RestNodeModelsCollection.class, request); + } + + /** + * Move a node to a target folder + * + * @param moveBody a {@link RestNodeBodyMoveCopyModel} containing at least the target parent id + * @return the moved node's new information + */ + public RestNodeModel move(RestNodeBodyMoveCopyModel moveBody) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, moveBody.toJson(), "nodes/{nodeId}/move?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModel(RestNodeModel.class, request); + } + + /** + * Copy a node to a target folder + * + * @param copyBody a {@link RestNodeBodyMoveCopyModel} containing at least the target parent id + * @return the moved node's new information + */ + public RestNodeModel copy(RestNodeBodyMoveCopyModel copyBody) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, copyBody.toJson(), + "nodes/{nodeId}/copy?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModel(RestNodeModel.class, request); + } + + + /** + * Lock a specific node using POST call on "nodes/{nodeId}/lock" + * + * @return + */ + public RestNodeModel lockNode(RestNodeLockBodyModel lockBody) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, lockBody.toJson(), "nodes/{nodeId}/lock?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModel(RestNodeModel.class, request); + } + + /** + * Unlock a specific node using POST call on "nodes/{nodeId}/unlock" + * + * @return + */ + public RestNodeModel unlockNode() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.POST, "nodes/{nodeId}/unlock?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModel(RestNodeModel.class, request); + } + + /** + * @return {@link NodesBuilder} - help you define new nodes using rest API calls + */ + public NodesBuilder defineNodes() + { + return new NodesBuilder(restWrapper, this.repoModel); + } + + /** + * Update a specific node using PUT call on "nodes/{nodeId}" + * + * @param putBody + * @return + */ + public RestNodeModel updateNode(String putBody) + { + RestRequest request = RestRequest.requestWithBody(PUT, putBody, "nodes/{nodeId}?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + request.setContentType("UTF-8"); + return restWrapper.processModel(RestNodeModel.class, request); + } + + /** + * Retrieve targets for a specific node using GET call on "nodes/{nodeId}/targets + * + * @return + */ + public RestNodeAssociationModelCollection getNodeTargets() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/targets?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModels(RestNodeAssociationModelCollection.class, request); + } + + /** + * Create new target nodes using POST call on '/nodes/{nodeId}/targets' + * + * @param target + * @return + */ + public RestNodeAssocTargetModel createTargetForNode(RestNodeAssocTargetModel target) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, target.toJson(), "nodes/{nodeId}/targets?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModel(RestNodeAssocTargetModel.class, request); + } + + /** + * Delete a target for a specific node using DELETE call on + * nodes/{nodeId}/targets/{targetId} + * + * @param target + */ + public void deleteTarget(RestNodeAssocTargetModel target) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "nodes/{nodeId}/targets/{targetId}", repoModel.getNodeRef(), + target.getTargetId()); + restWrapper.processEmptyModel(request); + } + + /** + * Get sources for a specific node using GET call on GET /nodes/{nodeId}/sources + * + * @return + */ + public RestNodeAssociationModelCollection getNodeSources() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "/nodes/{nodeId}/sources?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModels(RestNodeAssociationModelCollection.class, request); + } + + /** + * Updates the content of the node with identifier nodeId using PUT call "/nodes/{nodeId}/content" + * + * @param nodeContent + * @return + */ + public RestNodeModel updateNodeContent(File nodeContent) + { + try + { + restWrapper.usingContentType(ContentType.BINARY); + String body = Files.readFile(new FileInputStream(nodeContent)); + RestRequest request = RestRequest.requestWithBody(PUT, body, "nodes/{nodeId}/content?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + request.setContentType("UTF-8"); + restWrapper.usingContentType(ContentType.JSON); + return restWrapper.processModel(RestNodeModel.class, request); + } + catch (IOException e) + { + throw new RuntimeException("Unexpected error when reading content file.", e); + } + } + + /** + * Copies the node nodeId to the parent folder node targetParentId using POST call "nodes/{nodeId}/copy" + * + * @param postBody + * @return + */ + public RestNodeModel copyNode(String postBody) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/copy?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModel(RestNodeModel.class, request); + } + + /** + * Get a node's parents using GET call 'nodes/{nodeId}/parents + * + * @return a collection of nodes + */ + public RestNodeAssociationModelCollection getParents() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/parents?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModels(RestNodeAssociationModelCollection.class, request); + } + + /** + * Get a node's secondary children using GET call 'nodes/{nodeId}/secondary-children + * + * @return a collection of nodes + */ + public RestNodeAssociationModelCollection getSecondaryChildren() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/secondary-children?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModels(RestNodeAssociationModelCollection.class, request); + } + + /** + * Create secondary children association using POST call 'nodes/{nodeId}/secondary-children + * Use a list of secondary children nodes + * + * @return a collection of nodes + */ + public RestNodeChildAssocModelCollection createSecondaryChildren(String secondaryChildren) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, secondaryChildren, "nodes/{nodeId}/secondary-children?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModels(RestNodeChildAssocModelCollection.class, request); + } + + /** + * Delete secondary children using DELETE call 'nodes/{nodeId}/secondary-children/{childId} + * + * @return a collection of nodes + */ + public void deleteSecondaryChild(RestNodeAssociationModel child) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "nodes/{nodeId}/secondary-children/{childId}?{parameters}", repoModel.getNodeRef(), child.getId(), restWrapper.getParameters()); + restWrapper.processEmptyModel(request); + } + + /** + * Gets the version history as an ordered list for the specified nodeId using GET call 'nodes/{nodeId}/versions + * + * @return + */ + public RestVersionModelsCollection listVersionHistory() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/versions?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModels(RestVersionModelsCollection.class, request); + } + + /** + * Delete the version identified by versionId for nodeId using DELETE call 'nodes/{nodeId}versions/{versionId} + * + * @param versionId + */ + public void deleteNodeVersion(String versionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "nodes/{nodeId}/versions/{versionId}", repoModel.getNodeRef(), versionId); + restWrapper.processEmptyModel(request); + } + + /** + * Gets the version information versionId for node nodeId using GET call 'nodes/{nodeId}/versions/{versionId} + * + * @param versionId + * @return + */ + public RestVersionModel getVersionInformation(String versionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/versions/{versionId}", repoModel.getNodeRef(), versionId); + return restWrapper.processModel(RestVersionModel.class, request); + } + + /** + * Gets the content for versionId of node nodeId using GET call 'nodes/{nodeId}/versions/{versionId}/content + * + * @param versionId + * @return + */ + public RestResponse getVersionContent(String versionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/versions/{versionId}/content?{parameters}", repoModel.getNodeRef(), versionId, restWrapper.getParameters()); + return restWrapper.process(request); + } + + /** + * Revert the version identified by versionId and nodeId to the node using POST call 'nodes/{nodeId}/versions/{versionId}/revert + * + * @param versionId + * @param postBody + * @return + */ + public RestVersionModel revertVersion(String versionId, String postBody) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/versions/{versionId}/revert?{parameters}", repoModel.getNodeRef(), versionId, restWrapper.getParameters()); + return restWrapper.processModel(RestVersionModel.class, request); + } + + /** + * Delete a specific node using DELETE call on nodes/{nodeId} + * + * @param nodeModel + * @return + */ + public void deleteNode(RestNodeModel nodeModel) + { + deleteNode(nodeModel.getId()); + } + + + /** + * Delete a specific node using DELETE call on nodes/{nodeId} + * + * @param nodeId + * @return + */ + public void deleteNode(String nodeId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "nodes/{nodeId}", nodeId); + restWrapper.processEmptyModel(request); + } + + public RestActionDefinitionModelsCollection getActionDefinitions() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "nodes/{nodeId}/action-definitions?{parameters}", repoModel.getNodeRef(), restWrapper.getParameters()); + return restWrapper.processModels(RestActionDefinitionModelsCollection.class, request); + + } + + /** + * Get Direct Access URL for a node + * @param postBody + * @return + */ + public RestResponse createDirectAccessURL(String postBody) + { + RestRequest request; + if (postBody == null) + { + request = RestRequest.simpleRequest(HttpMethod.POST, "nodes/{nodeId}/request-direct-access-url", this.repoModel.getNodeRef()); + } + else + { + request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "nodes/{nodeId}/request-direct-access-url", this.repoModel.getNodeRef()); + } + + return this.restWrapper.process(request); + } + + /** + * Get Direct Access URL for a specific node rendition E.g "pdf" + * @param renditionId + * @return + */ + public RestResponse createDirectAccessURLforRendition(String renditionId) + { + RestRequest request = RestRequest + .simpleRequest(HttpMethod.POST, "nodes/{nodeId}/renditions/{renditionId}/request-direct-access-url", this.repoModel.getNodeRef(), renditionId); + return this.restWrapper.process(request); + } + + /** + * Get Direct Access URL for a specific node version. E.g "1.1" + * @param versionId + * @return + */ + public RestResponse createDirectAccessURLforVersion(String versionId) + { + RestRequest request = RestRequest + .simpleRequest(HttpMethod.POST, "nodes/{nodeId}/versions/{versionId}/request-direct-access-url", this.repoModel.getNodeRef(), versionId); + return this.restWrapper.process(request); + } + + /** + * Get Direct Access URL for a specific node version rendition. E.g ("1.1", "pdf") + * @param versionId + * @param renditionId + * @return + */ + public RestResponse createDirectAccessURLforVersionAndRendition(String versionId, String renditionId) + { + RestRequest request = RestRequest + .simpleRequest(HttpMethod.POST, "nodes/{nodeId}/versions/{versionId}/renditions/{renditionId}/request-direct-access-url", this.repoModel.getNodeRef(), versionId, renditionId); + return this.restWrapper.process(request); + } + + public ContentStorageInformation usingStorageInfo(String contentPropName) + { + return new ContentStorageInformation(restWrapper) + .withNodeId(repoModel.getNodeRef()) + .withContentPropName(contentPropName); + } + + public ContentStorageInformation usingVersionStorageInfo(String contentPropName, String versionId) + { + return new ContentStorageInformation(restWrapper) + .withNodeId(repoModel.getNodeRef()) + .withContentPropName(contentPropName) + .withVersionId(versionId); + } + + public FolderRules usingDefaultRuleSet() + { + return usingRuleSet("-default-"); + } + + public FolderRules usingRuleSet(String ruleSetId) + { + return new FolderRules(restWrapper) + .withNodeId(repoModel.getNodeRef()) + .withRuleSetId(ruleSetId); + } + + /** + * Get the rule sets defined on a folder. + * + * @return The list of rule sets. + */ + public RestRuleSetModelsCollection getListOfRuleSets() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, RULE_SETS_URI, + repoModel.getNodeRef()); + return restWrapper.processModels(RestRuleSetModelsCollection.class, request); + } + + /** + * Get the specified rule set from a folder. + * + * @param ruleSetId The id of the rule set. + * @return The specified rule set. + */ + public RestRuleSetModel getRuleSet(String ruleSetId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, RULE_SET_BY_ID, + repoModel.getNodeRef(), ruleSetId); + return restWrapper.processModel(RestRuleSetModel.class, request); + } + + /** + * Update a rule set on this folder - for example to reorder the rules. + * + * @param ruleSet The updated rule set. + * @return The updated rule set returned by the server. + */ + public RestRuleSetModel updateRuleSet(RestRuleSetModel ruleSet) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, ruleSet.toJson(), RULE_SET_BY_ID, + repoModel.getNodeRef(), ruleSet.getId()); + return restWrapper.processModel(RestRuleSetModel.class, request); + } + + /** + * Get the default rule set from a folder. + * + * @return The specified rule set. + */ + public RestRuleSetModel getDefaultRuleSet() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, RULE_SET_BY_ID, + repoModel.getNodeRef(), "-default-"); + return restWrapper.processModel(RestRuleSetModel.class, request); + } + + public RuleSettings usingRuleSetting(String ruleSettingKey) + { + return new RuleSettings(restWrapper) + .withNodeId(repoModel.getNodeRef()) + .withRuleSettingKey(ruleSettingKey); + } + + public RuleSettings usingIsInheritanceEnabledRuleSetting() + { + return usingRuleSetting(IS_INHERITANCE_ENABLED); + } + + public RestRuleSetLinkModel createRuleLink(RestRuleSetLinkModel body) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, body.toJson(), "nodes/{nodeId}/rule-set-links", repoModel.getNodeRef()); + return restWrapper.processModel(RestRuleSetLinkModel.class, request); + } + + /** + * Try to delete a ruleset link performing a DELETE call on "/nodes/{folderNodeId}/rule-set-links/{rulesetId}" + * + * @param ruleSetId the id of the ruleset to be unlinked from the folder + * @return + */ + public void unlinkRuleSet(String ruleSetId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "nodes/{nodeId}/rule-set-links/{ruleSetId}", repoModel.getNodeRef(), ruleSetId); + restWrapper.processEmptyModel(request); + } + + /** + * Trigger rules on a folder performing POST call on "/nodes/{folderNodeId}/rule-executions" + * + * @param body - rules execution request + * @return execution result + */ + public RestRuleExecutionModel executeRules(RestRuleExecutionModel body) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, body.toJson(), "nodes/{nodeId}/rule-executions", repoModel.getNodeRef()); + return restWrapper.processModel(RestRuleExecutionModel.class, request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/People.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/People.java new file mode 100644 index 0000000000..83207435af --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/People.java @@ -0,0 +1,520 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import static io.restassured.RestAssured.given; + +import java.io.File; + +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.exception.EmptyJsonResponseException; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestActivityModelsCollection; +import org.alfresco.rest.model.RestFavoriteSiteModel; +import org.alfresco.rest.model.RestGroupsModelsCollection; +import org.alfresco.rest.model.RestNetworkModel; +import org.alfresco.rest.model.RestNetworkModelsCollection; +import org.alfresco.rest.model.RestPersonFavoritesModel; +import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; +import org.alfresco.rest.model.RestPersonModel; +import org.alfresco.rest.model.RestPreferenceModel; +import org.alfresco.rest.model.RestPreferenceModelsCollection; +import org.alfresco.rest.model.RestSiteEntry; +import org.alfresco.rest.model.RestSiteMembershipModelsCollection; +import org.alfresco.rest.model.RestSiteMembershipRequestModel; +import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.utility.Utility; +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.HttpMethod; +import org.springframework.http.HttpStatus; + +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import io.restassured.response.ValidatableResponse; + +/** + * Declares all Rest API under the /people path + */ + +public class People extends ModelRequest +{ + UserModel person; + + public People(UserModel person, RestWrapper restWrapper) + { + super(restWrapper); + this.person = person; + Utility.checkObjectIsInitialized(this.person, "person"); + } + + /** + * Retrieve details of a specific person using GET call on "people/{personId}" + */ + public RestPersonModel getPerson() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}?{parameters}", this.person.getUsername(), restWrapper.getParameters()); + return restWrapper.processModel(RestPersonModel.class, request); + } + + /** + * Update a person properties using PUT call on "people/{personId}" + */ + public RestPersonModel updatePerson(String putBody) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, putBody, "people/{personId}", this.person.getUsername()); + return restWrapper.processModel(RestPersonModel.class, request); + } + + /** + * Retrieve list of activities for a specific person using GET call on "people/{personId}/activities" + * Please note that it retries to get the list of activities several times before returning the empty list. The list of activities are not displayed as + * they are created. + */ + public RestActivityModelsCollection getPersonActivitiesUntilEntriesCountIs(int expectedNoOfEntries) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/activities?{parameters}", this.person.getUsername(), restWrapper.getParameters()); + RestActivityModelsCollection activityCollection = restWrapper.processModels(RestActivityModelsCollection.class, request); + int retry = 0; + if (Integer.valueOf(restWrapper.getStatusCode()).equals(HttpStatus.OK.value())) + { + while ((activityCollection.isEmpty() || activityCollection.getPagination().getCount() != expectedNoOfEntries) && retry < Utility.retryCountSeconds + 20) + { + Utility.waitToLoopTime(2); + activityCollection = restWrapper.processModels(RestActivityModelsCollection.class, request); + retry++; + } + } + return activityCollection; + } + + /** + * Retrieve list of activities for a specific person using GET call on "people/{personId}/activities" without retry + */ + public RestActivityModelsCollection getPersonActivities() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/activities?{parameters}", this.person.getUsername(), restWrapper.getParameters()); + return restWrapper.processModels(RestActivityModelsCollection.class, request); + } + + /** + * Retrieve preferences of a specific person using GET call on "people/{personId}/preferences" + */ + public RestPreferenceModelsCollection getPersonPreferences() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/preferences?{parameters}", this.person.getUsername(), restWrapper.getParameters()); + return restWrapper.processModels(RestPreferenceModelsCollection.class, request); + } + + /** + * Retrieve the current site membership requests for a specific person using GET call on "/people/{personId}/site-membership-requests" + */ + public RestSiteMembershipRequestModelsCollection getSiteMembershipRequests() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/site-membership-requests?{parameters}", this.person.getUsername(), restWrapper.getParameters()); + return restWrapper.processModels(RestSiteMembershipRequestModelsCollection.class, request); + } + + /** + * Retrieve a specific person's favorite sites using GET call on "people/{personId}/favorite-sites" + */ + public RestSiteModelsCollection getFavoriteSites() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/favorite-sites?{parameters}", this.person.getUsername(), restWrapper.getParameters()); + return restWrapper.processModels(RestSiteModelsCollection.class, request); + } + + /** + * Add a favorite site for a specific person using POST call on "people/{personId}/favorite-sites" + */ + public RestFavoriteSiteModel addFavoriteSite(SiteModel site) + { + String postBody = JsonBodyGenerator.keyValueJson("id", site.getId()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "people/{personId}/favorite-sites", this.person.getUsername()); + return restWrapper.processModel(RestFavoriteSiteModel.class, request); + } + + /** + * Retrieve a specific preference of a specific person using GET call on "people/{personId}/preferences/{preferenceName}" + */ + public RestPreferenceModel getPersonPreferenceInformation(String preferenceName) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/preferences/{preferenceName}?{parameters}", this.person.getUsername(), preferenceName, restWrapper.getParameters()); + return restWrapper.processModel(RestPreferenceModel.class, request); + } + + /** + * Remove a specific site from favorite sites list of a person using DELETE call on "people/{personId}/favorite-sites/{siteId}" + */ + public void removeFavoriteSite(SiteModel site) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "people/{personId}/favorite-sites/{siteId}", this.person.getUsername(), site.getId()); + restWrapper.processEmptyModel(request); + } + + /** + * Returns information on favorite site siteId of person personId. GET call on "people/{personId}/favorite-sites/{siteId}" + */ + public RestSiteModel getFavoriteSite(SiteModel site) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/favorite-sites/{siteId}?{parameters}", this.person.getUsername(), site.getId(), restWrapper.getParameters()); + return restWrapper.processModel(RestSiteModel.class, request); + } + + /** + * Delete site member with DELETE call on "people/{personId}/sites/{siteId}" + */ + public void deleteSiteMember(SiteModel site) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "people/{personId}/sites/{siteId}", person.getUsername(), site.getId()); + restWrapper.processEmptyModel(request); + } + + /** + * Add new site membership request using POST call on "people/{personId}/site-membership-requests" + */ + public RestSiteMembershipRequestModel addSiteMembershipRequest(String siteMembershipRequest) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, siteMembershipRequest, "people/{personId}/site-membership-requests", this.person.getUsername()); + return restWrapper.processModel(RestSiteMembershipRequestModel.class, request); + } + + /** + * Add new site membership request using POST call on "people/{personId}/site-membership-requests" + */ + public RestSiteMembershipRequestModel addSiteMembershipRequest(SiteModel siteModel) + { + String json = JsonBodyGenerator.siteMemberhipRequest("Please accept me", siteModel, "New request"); + return addSiteMembershipRequest(json); + } + + /** + * Add new site membership request using POST call on "people/{personId}/site-membership-requests" + */ + public RestSiteMembershipRequestModel addSiteMembershipRequest(String message, SiteModel siteModel, String title) + { + String json = JsonBodyGenerator.siteMemberhipRequest(message, siteModel, title); + return addSiteMembershipRequest(json); + } + + /** + * Get site membership information using GET call on "/people/{personId}/sites" + */ + + public RestSiteMembershipModelsCollection getSitesMembershipInformation() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/sites?{parameters}", person.getUsername(), restWrapper.getParameters()); + return restWrapper.processModels(RestSiteMembershipModelsCollection.class, request); + } + + /** + * Retrieve site membership information for a person using GET call on "people/{personId}/sites/{siteId}" + */ + public RestSiteEntry getSiteMembership(SiteModel site) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/sites/{siteId}?{parameters}", person.getUsername(), site.getId(), restWrapper.getParameters()); + return restWrapper.processModel(RestSiteEntry.class, request); + } + + /** + * Retrieve site membership request details for a person/site using GET call on "people/{personId}/site-membership-requests/{siteId}" + */ + public RestSiteMembershipRequestModel getSiteMembershipRequest(SiteModel site) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/site-membership-requests/{siteId}?{parameters}", person.getUsername(), + site.getId(), restWrapper.getParameters()); + return restWrapper.processModel(RestSiteMembershipRequestModel.class, request); + } + + /** + * Delete site membership request with DELETE call on "/people/{personId}/site-membership-requests/{siteId}" + */ + public void deleteSiteMembershipRequest(SiteModel site) throws JsonToModelConversionException, EmptyJsonResponseException + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "people/{personId}/site-membership-requests/{siteId}", person.getUsername(), + site.getId()); + restWrapper.processEmptyModel(request); + } + + /** + * Update site membership request using PUT call on "people/{personId}/site-membership-requests/{siteId}" + */ + public RestSiteMembershipRequestModel updateSiteMembershipRequest(SiteModel siteModel, String message) + { + String json = JsonBodyGenerator.siteMemberhipRequest(message, siteModel, "New request"); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, json, "people/{personId}/site-membership-requests/{siteId}", person.getUsername(), + siteModel.getId()); + return restWrapper.processModel(RestSiteMembershipRequestModel.class, request); + } + + /** + * Retrieve favorite site for a specific user using GET call on "people/{personId}/favorites/{favoriteId}" + */ + public RestPersonFavoritesModel getFavorite(String favoriteId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/favorites/{favoriteId}?{parameters}", this.person.getUsername(), favoriteId, restWrapper.getParameters()); + return restWrapper.processModel(RestPersonFavoritesModel.class, request); + } + + /** + * Retrieve specific favorites for a specific user using GET call on "people/{personId}/favorites" + */ + public RestPersonFavoritesModelsCollection getFavorites() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/favorites?{parameters}", this.person.getUsername(), restWrapper.getParameters()); + return restWrapper.processModels(RestPersonFavoritesModelsCollection.class, request); + } + + /** + * Add a folder to favorites for a specific user using POST call on "people/{personId}/favorites" + */ + public RestPersonFavoritesModel addFolderToFavorites(FolderModel folderModel) + { + String jsonPost = JsonBodyGenerator.targetFolderWithGuid(folderModel); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, jsonPost, "people/{personId}/favorites?{parameters}", this.person.getUsername(), + restWrapper.getParameters()); + return restWrapper.processModel(RestPersonFavoritesModel.class, request); + } + + /** + * Add a folder to favorites for a specific user using POST call on "people/{personId}/favorites" + */ + public RestPersonFavoritesModel addFileToFavorites(FileModel fileModel) + { + String jsonPost = JsonBodyGenerator.targetFileWithGuid(fileModel); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, jsonPost, "people/{personId}/favorites?{parameters}", this.person.getUsername(), + restWrapper.getParameters()); + return restWrapper.processModel(RestPersonFavoritesModel.class, request); + } + + /** + * Add a site to favorites for a specific user using POST call on "people/{personId}/favorites" + */ + public RestPersonFavoritesModel addSiteToFavorites(SiteModel siteModel) + { + String jsonPost = JsonBodyGenerator.targetSiteWithGuid(siteModel); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, jsonPost, "people/{personId}/favorites?{parameters}", this.person.getUsername(), + restWrapper.getParameters()); + return restWrapper.processModel(RestPersonFavoritesModel.class, request); + } + + /** + * Delete site from favorites for a specific user using DELETE call on "people/{personId}/favorites/{favoriteId}" + */ + public RestWrapper deleteSiteFromFavorites(SiteModel site) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "people/{personId}/favorites/{favoriteId}", this.person.getUsername(), site.getGuid()); + restWrapper.processEmptyModel(request); + return restWrapper; + } + + /** + * Delete a folder from favorites for a specific user using DELETE call on "people/{personId}/favorites/{favoriteId}" + */ + public RestWrapper deleteFolderFromFavorites(FolderModel folderModel) + { + String jsonPost = JsonBodyGenerator.targetFolderWithGuid(folderModel); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.DELETE, jsonPost, "people/{personId}/favorites/{favoriteId}", this.person.getUsername(), + folderModel.getNodeRef()); + restWrapper.processEmptyModel(request); + return restWrapper; + } + + /** + * Delete a file from favorites for a specific user using DELETE call on "people/{personId}/favorites/{favoriteId}" + */ + public RestWrapper deleteFileFromFavorites(FileModel fileModel) + { + String jsonPost = JsonBodyGenerator.targetFileWithGuid(fileModel); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.DELETE, jsonPost, "people/{personId}/favorites/{favoriteId}", this.person.getUsername(), + fileModel.getNodeRef()); + restWrapper.processEmptyModel(request); + return restWrapper; + } + + /** + * Retrieve details of the current user network using GET call on "people/{personId}/networks/{networkId}" + */ + public RestNetworkModel getNetwork() + { + return getNetwork(person); + } + + /** + * Retrieve details of a specific network using GET call on "people/{personId}/networks/{networkId}" + */ + public RestNetworkModel getNetwork(UserModel tenant) + { + Utility.checkObjectIsInitialized(tenant.getDomain(), "tenant.getDomain()"); + String personId = tenant.getUsername().contains("-me-@")? "-me-" : tenant.getUsername(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/networks/{networkId}?{parameters}", personId, tenant.getDomain(), restWrapper.getParameters()); + return restWrapper.processModel(RestNetworkModel.class, request); + } + + /** + * Retrieve details of all networks related to the current person using GET call on "people/{personId}/networks" + */ + public RestNetworkModelsCollection getNetworks() + { + return getNetworks(person); + } + + /** + * Retrieve details of all networks related to a specific person using GET call on "people/{personId}/networks" + */ + public RestNetworkModelsCollection getNetworks(UserModel tenant) + { + String personId = tenant.getUsername().contains("-me-@") ? "-me-" : tenant.getUsername(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/networks?{parameters}", personId, restWrapper.getParameters()); + return restWrapper.processModels(RestNetworkModelsCollection.class, request); + } + + /** + * Create new person with given newPerson details using POST call on "people" + */ + public RestPersonModel createPerson(RestPersonModel newPerson) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, newPerson.toJson(), "people"); + return restWrapper.processModel(RestPersonModel.class, request); + } + + /** + * Get people avatar image using GET call on '/people/{personId}/avatar Please note that it retries to get the + * renditions response several times because on the alfresco server the rendition can take a while to be created. + */ + public RestResponse downloadAvatarContent() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/avatar?{parameters}", + this.person.getUsername(), restWrapper.getParameters()); + return restWrapper.process(request); + } + + /** + * Delete avatar image with DELETE call on "/people/{personId}/avatar}" + */ + public void resetAvatarImageRequest() throws JsonToModelConversionException, EmptyJsonResponseException + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "people/{personId}/avatar", this.person.getUsername()); + restWrapper.processEmptyModel(request); + } + + /** + * Update avatar image PUT call on 'people/{nodeId}/children + */ + public ValidatableResponse uploadAvatarContent(String fullServerUrL, File avatarFile) + { + return given().auth().preemptive().basic(person.getUsername(), person.getPassword()).contentType(ContentType.BINARY) + .body(avatarFile).when() + .put(String.format("%s/%s/people/%s/avatar", fullServerUrL, RestAssured.basePath, person.getUsername())) + .then(); + } + + /** + * List group memberships for a person using GET on '/people/{personId}/groups + */ + public RestGroupsModelsCollection listGroupMemberships() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}/groups?{parameters}", this.person.getUsername(), restWrapper.getParameters()); + return restWrapper.processModels(RestGroupsModelsCollection.class, request); + } + + public WhereClause where() + { + return new WhereClause(this); + } + +/** + * Construct the Where clause of getFavorites + * You can use the where parameter to restrict the list in the response to entries of a specific kind. The where parameter takes a value. The value is a + * single predicate that can include one or more EXISTS conditions. The EXISTS condition uses a single operand to limit the list to include entries that + * include that one property. The property values are:- + * target/file + * target/folder + * target/site + * Usage: + * where.. targetFileExist().or().targetSiteExist().filterAnd().getFavorites(...) + * At this point this method is working only with @link {@link RestFavoritesApi#getFavorites(UserModel) method. + * + * @author paul.brodner + */ + public class WhereClause + { + String whereClause = "where=(%s))"; + StringBuilder expression = new StringBuilder(); + private People people; + + public WhereClause(People people) + { + this.people = people; + } + + public WhereClause targetFileExist() + { + expression.append("EXISTS(target/file)").append(" "); + return this; + } + + public WhereClause targetFolderExist() + { + expression.append("EXISTS(target/folder)").append(" "); + return this; + } + + public WhereClause targetSiteExist() + { + expression.append(" EXISTS(target/site)").append(" "); + return this; + } + + public WhereClause invalidWhereParameter(String invalidParameter) + { + expression.append(invalidParameter).append(" "); + return this; + } + + public WhereClause or() + { + expression.append("OR").append(" "); + return this; + } + + public RestPersonFavoritesModelsCollection getFavorites() + { + restWrapper.withParams(String.format(whereClause, expression)); + return people.getFavorites(); + } + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/ProcessDefinitions.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/ProcessDefinitions.java new file mode 100644 index 0000000000..352104c443 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/ProcessDefinitions.java @@ -0,0 +1,106 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestFormModelsCollection; +import org.alfresco.rest.model.RestHtmlResponse; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; +import org.alfresco.utility.Utility; +import org.springframework.http.HttpMethod; + +/** + * Declares all Rest API under the /process-definitions path + * + */ +public class ProcessDefinitions extends ModelRequest +{ + RestProcessDefinitionModel processDefinition; + + public ProcessDefinitions(RestWrapper restWrapper) + { + super(restWrapper); + } + + public ProcessDefinitions(RestProcessDefinitionModel processDefinition, RestWrapper restWrapper) + { + super(restWrapper); + this.processDefinition = processDefinition; + } + + /** + * Retrieve 100 process definitions (this is the default size when maxItems is not specified) from Alfresco using GET call on "/process-definitions" + * + * @return + * @throws JsonToModelConversionException + */ + public RestProcessDefinitionModelsCollection getAllProcessDefinitions() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "process-definitions?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestProcessDefinitionModelsCollection.class, request); + } + + /** + * Retrieves a process definition using GET call on "/process-definitions/{processDefinitionId}" + * + * @return + */ + public RestProcessDefinitionModel getProcessDefinition() + { + Utility.checkObjectIsInitialized(processDefinition, "processDefinition"); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "process-definitions/{processDefinitionId}?{parameters}", + processDefinition.getId(), restWrapper.getParameters()); + return restWrapper.processModel(RestProcessDefinitionModel.class, request); + } + + /** + * Retrieves an image that represents a single process definition using GET call on "/process-definitions/{processDefinitionId}/image" + * + * @return + */ + public RestHtmlResponse getProcessDefinitionImage() + { + Utility.checkObjectIsInitialized(processDefinition, "processDefinition"); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "process-definitions/{processDefinitionId}/image", processDefinition.getId()); + return restWrapper.processHtmlResponse(request); + } + + /** + * Retrieves start form type definitions using GET call on "/process-definitions/{processDefinitionId}/start-form-model" + * + * @return + */ + public RestFormModelsCollection getProcessDefinitionStartFormModel() + { + Utility.checkObjectIsInitialized(processDefinition, "processDefinition.onModel()"); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "process-definitions/{processDefinitionId}/start-form-model?{parameters}", + processDefinition.getId(), restWrapper.getParameters()); + return restWrapper.processModels(RestFormModelsCollection.class, request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Processes.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Processes.java new file mode 100644 index 0000000000..5a36f055ae --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Processes.java @@ -0,0 +1,267 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import javax.json.JsonArrayBuilder; + +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; +import org.alfresco.rest.model.RestProcessVariableCollection; +import org.alfresco.rest.model.RestProcessVariableModel; +import org.alfresco.rest.model.RestTaskModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.UserModel; +import org.springframework.http.HttpMethod; + +/** + * Created by Claudia Agache on 10/11/2016. + */ + +public class Processes extends ModelRequest +{ + private ProcessModel processModel; + public Processes(RestWrapper restWrapper) + { + super(restWrapper); + } + + public Processes(ProcessModel processModel, RestWrapper restWrapper) { + this(restWrapper); + this.processModel = processModel; + } + + /** + * Retrieve 100 processes (this is the default size when maxItems is not specified) from Alfresco using GET call on "/processes" + * + * @return + * @throws JsonToModelConversionException + */ + public RestProcessModelsCollection getProcesses() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "processes?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestProcessModelsCollection.class, request); + } + + /** + * Retrieve all process variables from Alfresco using GET /processes/{processId}/variables + * + * @return + * @throws JsonToModelConversionException + */ + public RestProcessVariableCollection getProcessVariables() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "processes/{processId}/variables?{parameters}", processModel.getId(), restWrapper.getParameters()); + return restWrapper.processModels(RestProcessVariableCollection.class, request); + } + + /** + * Retrieves the process identified by processId using GET /processes/{processId} + * @return + */ + public RestProcessModel getProcess() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "processes/{processId}?{parameters}", processModel.getId(), restWrapper.getParameters()); + return restWrapper.processModel(RestProcessModel.class, request); + } + + /** + * Delete a process using DELETE call on processes/{processId} + */ + public void deleteProcess() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "processes/{processId}", processModel.getId()); + restWrapper.processEmptyModel(request); + } + + /** + * Starts new process using POST /processes + * + * @param processDefinitionKey + * @param assignee + * @param sendEmailNotifications + * @param priority + * @return + */ + public RestProcessModel addProcess(String processDefinitionKey, UserModel assignee, boolean sendEmailNotifications, Priority priority) + { + String postBody = JsonBodyGenerator.process(processDefinitionKey, assignee, sendEmailNotifications, priority); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "processes"); + return restWrapper.processModel(RestProcessModel.class, request); + } + + /** + * Starts new process with given input body using POST /processes + * + * @param postBody + * @return + */ + public RestProcessModel addProcessWithBody(String postBody) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "processes"); + return restWrapper.processModel(RestProcessModel.class, request); + } + + /** + * Add process variable using POST /processes/{processId}/variables + * + * @param variableModel + * @return + * @throws JsonToModelConversionException + */ + public RestProcessVariableModel addProcessVariable(RestProcessVariableModel variableModel) + { + String postBody = JsonBodyGenerator.processVariable(variableModel); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "processes/{processId}/variables", processModel.getId()); + return restWrapper.processModel(RestProcessVariableModel.class, request); + } + + /** + * Add process variables using POST /processes/{processId}/variables + * + * @param processVariablesModel + * @return + * @throws JsonToModelConversionException + */ + public RestProcessVariableCollection addProcessVariables(RestProcessVariableModel... processVariablesModel) + { + JsonArrayBuilder array = JsonBodyGenerator.defineJSONArray(); + for(RestProcessVariableModel processVariableModel: processVariablesModel) + { + array.add(JsonBodyGenerator.defineJSON().add("name", processVariableModel.getName()) + .add("value", processVariableModel.getValue()) + .add("type", processVariableModel.getType())).toString(); + } + + String postBody = array.build().toString(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "processes/{processId}/variables", processModel.getId()); + return restWrapper.processModels(RestProcessVariableCollection.class, request); + } + + + /** + * Retrieve all process items from Alfresco using GET /processes/{processId}/items + * + * @return + * @throws JsonToModelConversionException + */ + public RestItemModelsCollection getProcessItems() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "processes/{processId}/items?{parameters}", processModel.getId(), restWrapper.getParameters()); + return restWrapper.processModels(RestItemModelsCollection.class, request); + } + + /** + * Delete a process variable using DELETE call on processes/{processId}/variables/{variableName} + * + * @param variableModel + */ + public void deleteProcessVariable(RestProcessVariableModel variableModel) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "processes/{processId}/variables/{variableName}", processModel.getId(), + variableModel.getName()); + restWrapper.processEmptyModel(request); + } + + /** + * Update/Add process variable using PUT /processes/{processId}/variables/{variableName} + * + * @param variableModel + * @return + * @throws JsonToModelConversionException + */ + public RestProcessVariableModel updateProcessVariable(RestProcessVariableModel variableModel) + { + String postBody = JsonBodyGenerator.processVariable(variableModel); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "processes/{processId}/variables/{variableName}", processModel.getId(), + variableModel.getName()); + return restWrapper.processModel(RestProcessVariableModel.class, request); + } + + /** + * Retrieve all tasks of a specified process from Alfresco using GET /processes/{processId}/tasks + * + * @return + * @throws JsonToModelConversionException + */ + public RestTaskModelsCollection getProcessTasks() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "processes/{processId}/tasks?{parameters}", processModel.getId(), restWrapper.getParameters()); + return restWrapper.processModels(RestTaskModelsCollection.class, request); + } + + /** + * Add process item using POST /processes/{processId}/items + * + * @param fileModel + * @return + * @throws JsonToModelConversionException + */ + public RestItemModel addProcessItem(FileModel fileModel) + { + String postBody = JsonBodyGenerator.keyValueJson("id", fileModel.getNodeRefWithoutVersion()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "processes/{processId}/items", processModel.getId()); + return restWrapper.processModel(RestItemModel.class, request); + } + + /** + * Add process items using POST /processes/{processId}/items + * + * @param fileModels + * @return + * @throws JsonToModelConversionException + */ + public RestItemModelsCollection addProcessItems(FileModel... fileModels) + { + JsonArrayBuilder array = JsonBodyGenerator.defineJSONArray(); + for(FileModel fileModel: fileModels) + { + array.add(JsonBodyGenerator.defineJSON().add("id", fileModel.getNodeRefWithoutVersion())); + } + + String postBody = array.build().toString(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "processes/{processId}/items", processModel.getId()); + return restWrapper.processModels(RestItemModelsCollection.class, request); + } + + /** + * Delete a process item using DELETE call on processes/{processId}/items/{itemId} + * + * @param itemModel + */ + public void deleteProcessItem(RestItemModel itemModel) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "processes/{processId}/items/{itemId}", processModel.getId(), itemModel.getId()); + restWrapper.processEmptyModel(request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Queries.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Queries.java new file mode 100644 index 0000000000..a54a4d5638 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Queries.java @@ -0,0 +1,79 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestNodeModelsCollection; +import org.alfresco.rest.model.RestPersonModelsCollection; +import org.alfresco.rest.model.RestSiteModelsCollection; +import org.springframework.http.HttpMethod; + +public class Queries extends ModelRequest +{ + + public Queries(RestWrapper restWrapper) + { + super(restWrapper); + } + + /** + * GET on queries/nodes + * + * @return + */ + public RestNodeModelsCollection findNodes() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "queries/nodes?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestNodeModelsCollection.class, request); + } + + /** + * GET on queries/people + * + * @return + */ + public RestPersonModelsCollection findPeople() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "queries/people?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestPersonModelsCollection.class, request); + } + + /** + * GET on queries/people + * + * @return + */ + public RestSiteModelsCollection findSites() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "queries/sites?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestSiteModelsCollection.class, request); + } + + + + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/RuleSettings.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/RuleSettings.java new file mode 100644 index 0000000000..fbcd1fee15 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/RuleSettings.java @@ -0,0 +1,75 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright 2022 Alfresco Software, Ltd. All rights reserved. + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ +package org.alfresco.rest.requests; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestRuleSettingsModel; +import org.springframework.http.HttpMethod; + +public class RuleSettings extends ModelRequest +{ + public static final String IS_INHERITANCE_ENABLED = "-isInheritanceEnabled-"; + private static final String BASE_PATH = "nodes/{nodeId}/rule-settings/{ruleSettingKey}"; + + private String nodeId; + private String ruleSettingKey; + + public RuleSettings(RestWrapper restWrapper) + { + super(restWrapper); + } + + public RuleSettings withNodeId(String nodeId) + { + this.nodeId = nodeId; + return this; + } + + public RuleSettings withRuleSettingKey(String ruleSettingKey) + { + this.ruleSettingKey = ruleSettingKey; + return this; + } + + public RestRuleSettingsModel retrieveSetting() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, BASE_PATH, nodeId, ruleSettingKey); + return restWrapper.processModel(RestRuleSettingsModel.class, request); + } + + public RestRuleSettingsModel updateSetting(RestRuleSettingsModel ruleSettingsModel) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, ruleSettingsModel.toJson(), BASE_PATH, nodeId, ruleSettingKey); + return restWrapper.processModel(RestRuleSettingsModel.class, request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/SharedLinks.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/SharedLinks.java new file mode 100644 index 0000000000..7f3d1f0fca --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/SharedLinks.java @@ -0,0 +1,212 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import java.util.HashMap; + +import javax.json.JsonArrayBuilder; + +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestRenditionInfoModel; +import org.alfresco.rest.model.RestRenditionInfoModelCollection; +import org.alfresco.rest.model.RestSharedLinksModel; +import org.alfresco.rest.model.RestSharedLinksModelCollection; +import org.alfresco.utility.model.FileModel; +import org.springframework.http.HttpMethod; + +/** + * Declares all Rest API under the /shared-links path + * + * @author Meenal Bhave + */ +public class SharedLinks extends ModelRequest +{ + public SharedLinks(RestWrapper restWrapper) + { + super(restWrapper); + } + + /** + * Retrieve sharedLinks using GET call on /shared-links + * + * @return RestSharedLinksModelCollection + * @throws JsonToModelConversionException + */ + public RestSharedLinksModelCollection getSharedLinks() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "shared-links?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestSharedLinksModelCollection.class, request); + } + + /** + * Retrieve details for a specific sharedLink using GET call on "shared-links/{sharedLinkId}" + * + * @param sharedLinksModel + * @return RestSharedLinkModel + * @throws JsonToModelConversionException + */ + public RestSharedLinksModel getSharedLink(RestSharedLinksModel sharedLinksModel) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "shared-links/{sharedLinkId}?{parameters}", sharedLinksModel.getId(), + restWrapper.getParameters()); + return restWrapper.processModel(RestSharedLinksModel.class, request); + } + + /** + * Retrieve content for a specific sharedLink using GET call on "shared-links/{sharedLinkId}/content" + * + * @param sharedLinksModel + * @return RestResponse + */ + public RestResponse getSharedLinkContent(RestSharedLinksModel sharedLinksModel) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "shared-links/{sharedLinkId}/content?{parameters}", sharedLinksModel.getId(), + restWrapper.getParameters()); + return restWrapper.process(request); + } + + /** + * Send email with a specific sharedLink using POST call on "shared-links/{sharedLinkId}/email" + * + * @param sharedLinksModel + * @param postBody + * @return RestResponse + */ + public RestResponse sendSharedLinkEmail(RestSharedLinksModel sharedLinksModel, String postBody) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "shared-links/{sharedLinkId}/email?{parameters}", sharedLinksModel.getId(), + restWrapper.getParameters()); + return restWrapper.process(request); + } + + /** + * Retrieves Renditions for the specified sharedLink + * + * @return RestRenditionInfoModelCollection + * @throws JsonToModelConversionException + */ + public RestRenditionInfoModelCollection getSharedLinkRenditions(RestSharedLinksModel sharedLinksModel) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "shared-links/{sharedLinkId}/renditions?{parameters}", sharedLinksModel.getId(), + restWrapper.getParameters()); + return restWrapper.processModels(RestRenditionInfoModelCollection.class, request); + } + + /** + * Retrieves specific Rendition for the specified sharedLink + * + * @param sharedLinksModel + * @param renditionId + * @return RestRenditionInfoModel + * @throws JsonToModelConversionException + */ + public RestRenditionInfoModel getSharedLinkRendition(RestSharedLinksModel sharedLinksModel, String renditionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "shared-links/{sharedLinkId}/renditions/{renditionId}?{parameters}", + sharedLinksModel.getId(), renditionId, restWrapper.getParameters()); + return restWrapper.processModel(RestRenditionInfoModel.class, request); + } + + /** + * Retrieve rendition content for the specified sharedLink using GET call on "shared-links/{sharedLinkId}/renditions/{renditionId}/content" + * + * @param sharedLinksModel + * @param renditionId + * @return RestRenditionInfoModel + */ + public RestResponse getSharedLinkRenditionContent(RestSharedLinksModel sharedLinksModel, String renditionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "shared-links/{sharedLinkId}/renditions/{renditionId}/content?{parameters}", + sharedLinksModel.getId(), renditionId, restWrapper.getParameters()); + return restWrapper.process(request); + } + + /** + * Removes SharedLink for the specified file, the sharedlink is deleted, file is unshared as a result + * + * @param RestSharedLinksModel + * @return void + */ + public void deleteSharedLink(RestSharedLinksModel sharedLinksModel) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "shared-links/{sharedLinkId}", sharedLinksModel.getId()); + restWrapper.processEmptyModel(request); + } + + /** + * Creates SharedLink for the specified file + * + * @param file + * @return RestSharedLinksModel + */ + public RestSharedLinksModel createSharedLink(FileModel file) + { + String postBody = JsonBodyGenerator.keyValueJson("nodeId", file.getNodeRefWithoutVersion()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "shared-links?{parameters}", restWrapper.getParameters()); + return restWrapper.processModel(RestSharedLinksModel.class, request); + } + + /** + * Creates SharedLink for all the specified files + * + * @param file list + * @return RestSharedLinksModelCollection + */ + public RestSharedLinksModelCollection createSharedLinks(FileModel... files) + { + JsonArrayBuilder array = JsonBodyGenerator.defineJSONArray(); + for (FileModel file : files) + { + array.add(JsonBodyGenerator.defineJSON().add("nodeId", file.getNodeRefWithoutVersion())); + } + String postBody = array.build().toString(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "shared-links?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestSharedLinksModelCollection.class, request); + + } + + /** + * Creates SharedLink for the specified file, with the given expiry date + * + * @param file + * @param expiryDate: format: "2027-03-23T23:00:00.000+0000"; + * @return RestSharedLinksModel + */ + public RestSharedLinksModel createSharedLinkWithExpiryDate(FileModel file, String expiryDate) + { + HashMap body = new HashMap(); + body.put("nodeId", file.getNodeRefWithoutVersion()); + body.put("expiresAt", expiryDate); + String postBody = JsonBodyGenerator.keyValueJson(body); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "shared-links?{parameters}", restWrapper.getParameters()); + return restWrapper.processModel(RestSharedLinksModel.class, request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Site.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Site.java new file mode 100644 index 0000000000..19abe2ec47 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Site.java @@ -0,0 +1,348 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import java.util.List; + +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestSiteContainerModel; +import org.alfresco.rest.model.RestSiteContainerModelsCollection; +import org.alfresco.rest.model.RestSiteMemberModel; +import org.alfresco.rest.model.RestSiteMemberModelsCollection; +import org.alfresco.rest.model.RestSiteGroupModel; +import org.alfresco.rest.model.RestSiteGroupModelsCollection; +import org.alfresco.rest.model.RestSiteModel; +import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.rest.model.RestSitePersonMembershipRequestModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; +import org.springframework.http.HttpMethod; + +/** + * Declares all Rest API under the /sites path + * + */ +public class Site extends ModelRequest +{ + private SiteModel site; + + public Site(SiteModel site, RestWrapper restWrapper) + { + super(restWrapper); + this.site = site; + } + + /** + * Retrieve one site using GET call on "sites/{siteId}" + * + * @return + * @throws JsonToModelConversionException + */ + public RestSiteModel getSite() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}?{parameters}", this.site.getId(), restWrapper.getParameters()); + return restWrapper.processModel(RestSiteModel.class, request); + } + + /** + * Retrieve one site using GET call on "sites/{siteId}" along with relations parameter + * + * @return + * @throws JsonToModelConversionException + */ + public List getSiteWithRelations() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}?{parameters}", this.site.getId(), restWrapper.getParameters()); + return restWrapper.processRelationsJson(request); + } + + /** + * Retrieve 100 sites (this is the default size when maxItems is not specified) from Alfresco using GET call on TestGroup.SITES + * + * @return + * @throws JsonToModelConversionException + */ + public RestSiteModelsCollection getSites() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestSiteModelsCollection.class, request); + } + + /** + * Retrieve sites using GET call on "sites/{siteId}" along with relations parameter + * + * @return + * @throws JsonToModelConversionException + */ + public List> getSitesWithRelations() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites?{parameters}", restWrapper.getParameters()); + return restWrapper.processSitesRelationsJson(request); + } + + /** + * Add new site member using POST call on "/sites/{siteId}/members" + * + * @param person {@link UserModel} + * @return + * @throws JsonToModelConversionException + */ + public RestSiteMemberModel addPerson(UserModel person) + { + String siteMemberBody = JsonBodyGenerator.siteMember(person); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, siteMemberBody, "sites/{siteId}/members?{parameters}", site.getId(), restWrapper.getParameters()); + return restWrapper.processModel(RestSiteMemberModel.class, request); + } + + /** + * Retrieve all members of a site using GET call on "sites/{siteId}/members" + * + * @return + * @throws JsonToModelConversionException + */ + public RestSiteMemberModelsCollection getSiteMembers() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}/members?{parameters}", site.getId(), restWrapper.getParameters()); + return restWrapper.processModels(RestSiteMemberModelsCollection.class, request); + } + + /** + * Retrieve specific member of a site using GET call on "sites/{siteId}/members/{personId}" + * + * @param user A model containing the username to look for. + * @return + * @throws JsonToModelConversionException + */ + public RestSiteMemberModel getSiteMember(UserModel user) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}/members/{personId}?{parameters}", site.getId(), user.getUsername(), restWrapper.getParameters()); + return restWrapper.processModel(RestSiteMemberModel.class, request); + } + + /** + * Update site member role with PUT call on "sites/{siteId}/members/{personId}" + * @param siteMember + * @return + * @throws JsonToModelConversionException + */ + public RestSiteMemberModel updateSiteMember(UserModel siteMember) + { + String json = JsonBodyGenerator.keyValueJson("role", siteMember.getUserRole().toString()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, json, "sites/{siteId}/members/{personId}", site.getId(), siteMember.getUsername()); + return restWrapper.processModel(RestSiteMemberModel.class, request); + } + + /** + * Delete site member with DELETE call on "sites/{siteId}/members/{personId}" + * @param person + */ + public void deleteSiteMember(UserModel person) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "sites/{siteId}/members/{personId}", site.getId(), person.getUsername()); + restWrapper.processEmptyModel(request); + } + + /** + * Retrieve all containers of a site using GET call on "sites/{siteId}/containers" + * + * @return + * @throws JsonToModelConversionException + */ + public RestSiteContainerModelsCollection getSiteContainers() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}/containers?{parameters}", site.getId(), restWrapper.getParameters()); + return restWrapper.processModels(RestSiteContainerModelsCollection.class, request); + } + + /** + * Retrieve specific container of a site using GET call on "sites/{siteId}/containers/{containerId}" + * + * @param container A model containing the folderId to look for. + * @return + * @throws JsonToModelConversionException + */ + public RestSiteContainerModel getSiteContainer(RestSiteContainerModel container) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}/containers/{containerId}?{parameters}", site.getId(), container.getFolderId(), restWrapper.getParameters()); + return restWrapper.processModel(RestSiteContainerModel.class, request); + } + + /** + * Retrieve specific container of a site using GET call on "sites/{siteId}/containers/{containerId}" + * + * @param containerFolder The id of the container to look for. + * @return + * @throws JsonToModelConversionException + */ + public RestSiteContainerModel getSiteContainer(String containerFolder) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}/containers/{containerId}?{parameters}", site.getId(), containerFolder, restWrapper.getParameters()); + return restWrapper.processModel(RestSiteContainerModel.class, request); + } + + /** + * Create a collaboration site + * + * @return the properties of the created site + */ + public RestSiteModel createSite() + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, site.toJson(), "sites?{parameters}", restWrapper.getParameters()); + return restWrapper.processModel(RestSiteModel.class, request); + } + + /** + * Update a site: Site title, description, visibility can be updated + * Body: + * { + * "title": "string", + * "description": "string", + * "visibility": "PRIVATE" + * } + * + * Response: + * { + * "entry": { + * "id": "string", + * "guid": "string", + * "title": "string", + * "description": "string", + * "visibility": "PRIVATE", + * "preset": "string", + * "role": "SiteConsumer" + * } + * } + * + * @return the properties of an updated site + */ + public RestSiteModel updateSite(SiteModel site) + { + String siteBody = JsonBodyGenerator.updateSiteRequest(site); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, siteBody, "sites/{siteId}", site.getId()); + return restWrapper.processModel(RestSiteModel.class, request); + } + + /** + * Get site membership requests by using GET /site-membership-requests + * + * @return site memberships + */ + public RestSitePersonMembershipRequestModelsCollection getSiteMemberships() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "site-membership-requests?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestSitePersonMembershipRequestModelsCollection.class, request); + } + + /** + * Approve a site membership request by using POST call on /sites/{siteId}/site-membership-requests/{inviteeId}/approve + * + * @param siteMember + */ + public RestResponse approveSiteMembership(UserModel siteMember) + { + String json = JsonBodyGenerator.keyValueJson("role", siteMember.getUserRole().toString()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, json, "sites/{siteId}/site-membership-requests/{inviteeId}/approve", site.getId(), siteMember.getUsername()); + return restWrapper.process(request); + } + + /** + * Reject a site membership request by using POST call /sites/{siteId}/site-membership-requests/{inviteeId}/reject + * + * @param siteMember + */ + public RestResponse rejectSiteMembership(UserModel siteMember) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.POST, "sites/{siteId}/site-membership-requests/{inviteeId}/reject", site.getId(), siteMember.getUsername()); + return restWrapper.process(request); + } + + /** + * Retrieve all group membership of a site using GET call on "sites/{siteId}/group-members" + * + * @return RestSiteGroupModelsCollection + * @throws JsonToModelConversionException + */ + public RestSiteGroupModelsCollection getSiteGroups() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}/group-members?{parameters}", site.getId(), restWrapper.getParameters()); + return restWrapper.processModels(RestSiteGroupModelsCollection.class, request); + } + + /** + * Add new site group membership using POST call on "sites/{siteId}/group-members" + * + * @param authorityId The authorityId of the group + * @param role role to assign + * @return + * @throws JsonToModelConversionException + */ + public RestSiteGroupModel addSiteGroup(String authorityId, UserRole role) + { + String siteMemberBody = JsonBodyGenerator.siteGroup(authorityId, role); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, siteMemberBody, "sites/{siteId}/group-members?{parameters}", site.getId(), restWrapper.getParameters()); + return restWrapper.processModel(RestSiteGroupModel.class, request); + } + + /** + * Retrieve specific group membership of a site using GET call on "sites/{siteId}/group-members/{groupId}" + * + * @param groupId + * @return RestSiteGroupModel + */ + public RestSiteGroupModel getSiteGroup(String groupId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "sites/{siteId}/group-members/{groupId}", site.getId(), groupId); + return restWrapper.processModel(RestSiteGroupModel.class, request); + } + + /** + * Update site group membership role with PUT call on "sites/{siteId}/group-members/{groupId}" + * @param groupId + * @return RestSiteGroupModel + * @throws JsonToModelConversionException + */ + public RestSiteGroupModel updateSiteGroup(String groupId, UserRole role) + { + String json = JsonBodyGenerator.keyValueJson("role", role.toString()); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, json, "sites/{siteId}/group-members/{groupId}", site.getId(), groupId); + return restWrapper.processModel(RestSiteGroupModel.class, request); + } + + /** + * Delete site group membership with DELETE call on "sites/{siteId}/group-members/{groupId}" + * @param groupId + */ + public void deleteSiteGroup(String groupId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "sites/{siteId}/group-members/{groupId}", site.getId(), groupId); + restWrapper.processEmptyModel(request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Tags.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Tags.java new file mode 100644 index 0000000000..6812eb99c8 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Tags.java @@ -0,0 +1,85 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.model.RestTagModelsCollection; +import org.springframework.http.HttpMethod; + +public class Tags extends ModelRequest +{ + RestTagModel tag; + + public Tags(RestTagModel tag, RestWrapper restWrapper) + { + super(restWrapper); + this.tag = tag; + } + + /** + * Retrieves 100 tags (this is the default size when maxItems is not specified) from Alfresco using GET call on "/tags" + * + * @return + * @throws JsonToModelConversionException + */ + public RestTagModelsCollection getTags() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tags?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestTagModelsCollection.class, request); + } + + /** + * Retrieves a tag with ID using GET call on using GET call on "/tags/{tagId}" + * + * @param tag + * @return + */ + public RestTagModel getTag() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tags/{tagId}?{parameters}", tag.getId(), restWrapper.getParameters()); + return restWrapper.processModel(RestTagModel.class, request); + } + + /** + * Update a tag using PUT call on tags/{tagId} + * + * @param tag + * @param newTag + * @return + * @throws JsonToModelConversionException + */ + public RestTagModel update(String newTag) + { + String postBody = JsonBodyGenerator.keyValueJson("tag", newTag); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tags/{tagId}", tag.getId()); + + return restWrapper.processModel(RestTagModel.class, request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Task.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Task.java new file mode 100644 index 0000000000..83f4aca7b0 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Task.java @@ -0,0 +1,269 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import javax.json.JsonArrayBuilder; +import javax.json.JsonObject; + +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestCandidateModelsCollection; +import org.alfresco.rest.model.RestFormModelsCollection; +import org.alfresco.rest.model.RestItemModel; +import org.alfresco.rest.model.RestItemModelsCollection; +import org.alfresco.rest.model.RestTaskModel; +import org.alfresco.rest.model.RestTaskModelsCollection; +import org.alfresco.rest.model.RestVariableModel; +import org.alfresco.rest.model.RestVariableModelsCollection; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.TaskModel; +import org.springframework.http.HttpMethod; + +public class Task extends ModelRequest +{ + private TaskModel task; + + public Task(RestWrapper restWrapper) + { + super(restWrapper); + } + + public Task(RestWrapper restWrapper, TaskModel task) + { + super(restWrapper); + this.task = task; + } + + /** + * Retrieve a list of tasks visible for the authenticated user using GET call on "/tasks" + * + * @return + */ + public RestTaskModelsCollection getTasks() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestTaskModelsCollection.class, request); + } + + /** + * Retrieve the tasks identified by taskId using GET call on "/tasks/{taskId}" + * + * @param taskId + * @return + */ + public RestTaskModel getTask() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}?{parameters}", task.getId(), restWrapper.getParameters()); + return restWrapper.processModel(RestTaskModel.class, request); + } + + /** + * Update task using PUT put /tasks/{taskId} call + * + * @param newStateValue + * @return + * @throws JsonToModelConversionException + */ + public RestTaskModel updateTask(String newStateValue) + { + return updateTask(JsonBodyGenerator.defineJSON().add("state", newStateValue).build()); + } + + /** + * Update task using PUT put /tasks/{taskId} cal + * + * @param inputJson the json used as input for PUT call + * @return + */ + public RestTaskModel updateTask(JsonObject inputJson) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, inputJson.toString(), "tasks/{taskId}?{parameters}", task.getId(), restWrapper.getParameters()); + return restWrapper.processModel(RestTaskModel.class, request); + } + + /** + * Retrieve the task variables using GET call on "/tasks/{taskId}/variables" + * + * @param taskId + * @return + */ + public RestVariableModelsCollection getTaskVariables() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}/variables?{parameters}", task.getId(), restWrapper.getParameters()); + return restWrapper.processModels(RestVariableModelsCollection.class, request); + } + + /** + * Update/Add task variable using PUT put /tasks/{taskId}/variables/{variableName} call + * + * @param taskId + * @param variableName + * @return + * @throws JsonToModelConversionException + */ + public RestVariableModel updateTaskVariable(RestVariableModel variableModel) + { + String postBody = JsonBodyGenerator.taskVariable(variableModel); + RestRequest request = RestRequest.requestWithBody(HttpMethod.PUT, postBody, "tasks/{taskId}/variables/{variableName}", task.getId(), + variableModel.getName()); + return restWrapper.processModel(RestVariableModel.class, request); + } + + /** + * Add task variable using POST /tasks/{taskId}/variables call + * + * @param taskId + * @return + * @throws JsonToModelConversionException + */ + public RestVariableModel addTaskVariable(RestVariableModel variableModel) + { + String postBody = JsonBodyGenerator.taskVariable(variableModel); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "tasks/{taskId}/variables", task.getId()); + return restWrapper.processModel(RestVariableModel.class, request); + } + + /** + * Add task variables using POST /tasks/{taskId}/variables call + * + * @param taskId + * @return + * @throws JsonToModelConversionException + */ + public RestVariableModelsCollection addTaskVariables(RestVariableModel... taskVariablesModel) + { + JsonArrayBuilder array = JsonBodyGenerator.defineJSONArray(); + for(RestVariableModel taskVariableModel: taskVariablesModel) + { + array.add(JsonBodyGenerator.defineJSON().add("scope", taskVariableModel.getScope()).add("name", taskVariableModel.getName()) + .add("type", taskVariableModel.getType()).add("value", taskVariableModel.getValue().toString())); + } + + String postBody = array.build().toString(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "tasks/{taskId}/variables", task.getId()); + return restWrapper.processModels(RestVariableModelsCollection.class, request); + } + + /** + * Delete task variable using DELETE /tasks/{taskId}/variables/{variableName} call + * + * @param taskId + * @param variableName + * @return + * @throws JsonToModelConversionException + */ + public void deleteTaskVariable(RestVariableModel variableModel) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "tasks/{taskId}/variables/{variableName} ", task.getId(), + variableModel.getName()); + restWrapper.processEmptyModel(request); + } + + /** + * Add task item using POST /tasks/{taskId}/items + * + * @param processId + * @return + * @throws JsonToModelConversionException + */ + public RestItemModel addTaskItem(FileModel fileModel) + { + String postBody = JsonBodyGenerator.keyValueJson("id", fileModel.getNodeRef().split(";")[0]); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "tasks/{taskId}/items", task.getId()); + return restWrapper.processModel(RestItemModel.class, request); + } + + /** + * Add task items using POST /tasks/{taskId}/items + * + * @param fileModels + * @return + * @throws JsonToModelConversionException + */ + public RestItemModelsCollection addTaskItems(FileModel... fileModels) + { + JsonArrayBuilder array = JsonBodyGenerator.defineJSONArray(); + for(FileModel fileModel: fileModels) + { + array.add(JsonBodyGenerator.defineJSON().add("id", fileModel.getNodeRef().split(";")[0])); + } + + String postBody = array.build().toString(); + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "tasks/{taskId}/items", task.getId()); + return restWrapper.processModels(RestItemModelsCollection.class, request); + } + + + /** + * Retrieve the task items using GET call on "/tasks/{taskId}/items" + * + * @param taskId + * @return + */ + public RestItemModelsCollection getTaskItems() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}/items?{parameters}", task.getId(), restWrapper.getParameters()); + return restWrapper.processModels(RestItemModelsCollection.class, request); + } + + /** + * Retrieves models of the task form type definition + * @param taskModel + * @return + */ + public RestFormModelsCollection getTaskFormModel() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}/task-form-model?{parameters}", task.getId(), restWrapper.getParameters()); + return restWrapper.processModels(RestFormModelsCollection.class, request); + } + + /** + * Delete a task item using DELETE call on tasks/{taskId}/items/{itemId} + * + * @param taskId + * @param itemId + */ + public void deleteTaskItem(RestItemModel itemModel) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "tasks/{taskId}/items/{itemId}", task.getId(), + itemModel.getId()); + restWrapper.processEmptyModel(request); + } + + /** + * Retrieve the task candidates (users and groups) using GET call on "/tasks/{taskId}/candidates" + * + * @param taskId + * @return + */ + public RestCandidateModelsCollection getTaskCandidates() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tasks/{taskId}/candidates?{parameters}", task.getId(), restWrapper.getParameters()); + return restWrapper.processModels(RestCandidateModelsCollection.class, request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Tenant.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Tenant.java new file mode 100644 index 0000000000..3c38f38d86 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Tenant.java @@ -0,0 +1,75 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import static io.restassured.RestAssured.given; +import static org.alfresco.utility.report.log.Step.STEP; + +import org.alfresco.rest.core.RestProperties; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.UserModel; +import org.springframework.http.HttpStatus; + +import io.restassured.http.ContentType; +import io.restassured.response.Response; +import io.restassured.specification.RequestSpecification; + +/** + * Declares all Rest API under the /alfresco/service/api/tenants path + * + */ +public class Tenant extends ModelRequest +{ + private RestProperties restProperties; + + public Tenant(RestWrapper restWrapper, RestProperties restProperties) + { + super(restWrapper); + this.restProperties = restProperties; + } + /** + * Create tenant using POST call on "http://{server}:{port}/alfresco/service/api/tenants" + * + * @param userModel + * @return + * @throws JsonToModelConversionException + */ + public void createTenant(UserModel userModel) + { + STEP(String.format("DATAPREP: Create new tenant %s", userModel.getDomain())); + String json = String.format("{\"tenantDomain\": \"%s\", \"tenantAdminPassword\": \"%s\"}", userModel.getDomain(), DataUser.PASSWORD); + RequestSpecification request = given().auth().basic(restWrapper.getTestUser().getUsername(), restWrapper.getTestUser().getPassword()) + .contentType(ContentType.JSON); + Response returnedResponse = request.contentType(ContentType.JSON).body(json) + .post(String.format("%s/%s", restProperties.envProperty().getFullServerUrl(), "alfresco/service/api/tenants")).andReturn(); + if (!Integer.valueOf(returnedResponse.getStatusCode()).equals(HttpStatus.OK.value())) + { + throw new IllegalStateException(String.format("Tenant is not created: %s", returnedResponse.asString())); + } + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Trashcan.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Trashcan.java new file mode 100644 index 0000000000..fc4427ecbe --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/Trashcan.java @@ -0,0 +1,141 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.RestNodeModelsCollection; +import org.alfresco.rest.model.RestRenditionInfoModel; +import org.alfresco.rest.model.RestRenditionInfoModelCollection; +import org.alfresco.utility.model.RepoTestModel; +import org.springframework.http.HttpMethod; + +public class Trashcan extends ModelRequest +{ + public Trashcan(RestWrapper restWrapper) + { + super(restWrapper); + } + + /** + * GET on deleted-nodes + * + * @return RestNodeModelsCollection + */ + public RestNodeModelsCollection findDeletedNodes() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "deleted-nodes?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestNodeModelsCollection.class, request); + } + + /** + * Gets a node from trashcan using GET call on "deleted-nodes/{nodeId}" + * + * @param repoModel + * @return RestNodeModel + */ + public RestNodeModel findDeletedNode(RepoTestModel repoModel) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "deleted-nodes/{nodeId}?{parameters}", repoModel.getNodeRefWithoutVersion(), restWrapper.getParameters()); + return restWrapper.processModel(RestNodeModel.class, request); + } + + /** + * Delete node from trashcan using DELETE call on "deleted-nodes/{nodeId}" + * + * @param repoModel + * @return + */ + public void deleteNodeFromTrashcan(RepoTestModel repoModel) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "deleted-nodes/{nodeId}", repoModel.getNodeRefWithoutVersion()); + restWrapper.processEmptyModel(request); + } + + /** + * Restore node from trashcan using POST call on "deleted-nodes/{nodeId}/restore" + * + * @param repoModel + * @return RestNodeModel + */ + public RestNodeModel restoreNodeFromTrashcan(RepoTestModel repoModel) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.POST, "deleted-nodes/{nodeId}/restore?{parameters}", repoModel.getNodeRefWithoutVersion(), restWrapper.getParameters()); + return restWrapper.processModel(RestNodeModel.class, request); + } + + /** + * Gets a trashcan node content using GET call on "deleted-nodes/{nodeId}/content" + * + * @param repoModel + * @return RestResponse + */ + public RestResponse getDeletedNodeContent(RepoTestModel repoModel) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "deleted-nodes/{nodeId}/content?{parameters}", repoModel.getNodeRefWithoutVersion(), restWrapper.getParameters()); + return restWrapper.process(request); + } + + /** + * Gets all trashcan node renditions using GET call on "/deleted-nodes/{nodeId}/renditions" + * + * @param repoModel + * @return RestRenditionInfoModelCollection + */ + public RestRenditionInfoModelCollection getDeletedNodeRenditions(RepoTestModel repoModel) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "deleted-nodes/{nodeId}/renditions?{parameters}", repoModel.getNodeRefWithoutVersion(), restWrapper.getParameters()); + return restWrapper.processModels(RestRenditionInfoModelCollection.class, request); + } + + /** + * Gets a single trashcan node rendition using GET call on "/deleted-nodes/{nodeId}/renditions/{renditionId}" + * + * @param repoModel + * @param renditionId + * @return RestRenditionInfoModel + */ + public RestRenditionInfoModel getDeletedNodeRendition(RepoTestModel repoModel, String renditionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "deleted-nodes/{nodeId}/renditions/{renditionId}?{parameters}", repoModel.getNodeRefWithoutVersion(), renditionId, restWrapper.getParameters()); + return restWrapper.processModel(RestRenditionInfoModel.class, request); + } + + /** + * Gets a single trashcan node rendition content using GET call on "/deleted-nodes/{nodeId}/renditions/{renditionId}/content" + * + * @param repoModel + * @param renditionId + * @return RestResponse + */ + public RestResponse getDeletedNodeRenditionContent(RepoTestModel repoModel, String renditionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "deleted-nodes/{nodeId}/renditions/{renditionId}/content?{parameters}", repoModel.getNodeRefWithoutVersion(), renditionId, restWrapper.getParameters()); + return restWrapper.process(request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/aosAPI/RestAosAPI.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/aosAPI/RestAosAPI.java new file mode 100644 index 0000000000..5f73b18834 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/aosAPI/RestAosAPI.java @@ -0,0 +1,52 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests.aosAPI; + +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.requests.ModelRequest; +import org.alfresco.rest.requests.cmisAPI.RestCmisAPI; + +import io.restassured.RestAssured; + +/** + * @author Catalin Gornea + * + * Perform AOS rest API calls "alfresco/aos" + * + * Take a look at {@link org.alfresco.rest.aos.AosApiTest} + * @since 5.2.0-8 + */ + +public class RestAosAPI extends ModelRequest +{ + + public RestAosAPI(RestWrapper restWrapper) + { + super(restWrapper); + RestAssured.basePath = "alfresco/aos"; + restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/authAPI/RestAuthAPI.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/authAPI/RestAuthAPI.java new file mode 100644 index 0000000000..be46b76892 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/authAPI/RestAuthAPI.java @@ -0,0 +1,64 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests.authAPI; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestTicketBodyModel; +import org.alfresco.rest.model.RestTicketModel; +import org.alfresco.rest.requests.ModelRequest; +import org.springframework.http.HttpMethod; + +import io.restassured.RestAssured; + +public class RestAuthAPI extends ModelRequest +{ + public RestAuthAPI(RestWrapper restWrapper) + { + super(restWrapper); + RestAssured.basePath = "alfresco/api/-default-/public/authentication/versions/1"; + restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath); + } + + public RestTicketModel createTicket(RestTicketBodyModel ticketBody) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, ticketBody.toJson(), "tickets"); + return restWrapper.processModel(RestTicketModel.class, request); + } + + public RestTicketModel getTicket() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "tickets/-me-"); + return restWrapper.processModel(RestTicketModel.class, request); + } + + public void removeTicket() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "tickets/-me-"); + restWrapper.processEmptyModel(request); + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/cmisAPI/RestCmisAPI.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/cmisAPI/RestCmisAPI.java new file mode 100644 index 0000000000..7e5b9bcf57 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/cmisAPI/RestCmisAPI.java @@ -0,0 +1,92 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests.cmisAPI; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.requests.ModelRequest; +import org.alfresco.utility.model.ContentModel; +import org.springframework.http.HttpMethod; + +import io.restassured.RestAssured; + +/** + * @author Paul Brodner + * + * Perform CMIS rest API calls "alfresco/api/-default-/public/cmis/versions/1.1/browser" + * + * Take a look at {@link org.alfresco.rest.cmis.CmisBrowserTest} + * @since 5.2.0-8 + */ +public class RestCmisAPI extends ModelRequest { + + public RestCmisAPI(RestWrapper restWrapper) + { + super(restWrapper); + RestAssured.basePath = "alfresco/api/-default-/public/cmis/versions/1.1/browser"; + restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath); + } + + /** + * @param objectCmisLocation + * @return object + */ + public RestResponse getRootObjectByLocation(ContentModel contentModel) + { + return getRootObjectByLocation(contentModel.getName()); + } + + /** + * @param objectCmisLocation + * @return object + */ + public RestResponse getRootObjectByLocation(String objectName) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "root/Shared/{objectName}?{parameters}", objectName, restWrapper.getParameters()); + return restWrapper.process(request); + } + + /** + * @param objectId + * @return object + */ + public RestResponse getRootObjectByID(ContentModel contentModel) + { + return getRootObjectByID(contentModel.getNodeRef()); + } + + /** + * @param objectId + * @return object + */ + public RestResponse getRootObjectByID(String objectID) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "root?objectid={objectId}?{parameters}", objectID, restWrapper.getParameters()); + return restWrapper.process(request); + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/coreAPI/RestCoreAPI.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/coreAPI/RestCoreAPI.java new file mode 100644 index 0000000000..21864e92e3 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/coreAPI/RestCoreAPI.java @@ -0,0 +1,235 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests.coreAPI; + +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestDownloadsModel; +import org.alfresco.rest.model.RestSiteModelsCollection; +import org.alfresco.rest.model.RestTagModel; +import org.alfresco.rest.model.RestTagModelsCollection; +import org.alfresco.rest.requests.Actions; +import org.alfresco.rest.requests.Audit; +import org.alfresco.rest.requests.ContentStorageInformation; +import org.alfresco.rest.requests.Downloads; +import org.alfresco.rest.requests.Groups; +import org.alfresco.rest.requests.ModelRequest; +import org.alfresco.rest.requests.Networks; +import org.alfresco.rest.requests.Node; +import org.alfresco.rest.requests.People; +import org.alfresco.rest.requests.Queries; +import org.alfresco.rest.requests.SharedLinks; +import org.alfresco.rest.requests.Site; +import org.alfresco.rest.requests.Tags; +import org.alfresco.rest.requests.Trashcan; +import org.alfresco.utility.model.RepoTestModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.UserModel; + +import io.restassured.RestAssured; + +/** + * Defines the entire Rest Core API + * {@link https://api-explorer.alfresco.com/api-explorer/} select "Core API" + */ +public class RestCoreAPI extends ModelRequest +{ + public RestCoreAPI(RestWrapper restWrapper) + { + super(restWrapper); + RestAssured.basePath = "alfresco/api/-default-/public/alfresco/versions/1"; + restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath); + } + + /** + * Provides DSL on all REST calls under sites/{siteId}/... API path + * + * @param siteId + * @return {@link Site} + */ + public Site usingSite(String siteId) + { + return new Site(new SiteModel(siteId), restWrapper); + } + + /** + * Provides DSL on all REST calls under sites/{siteId}/... API path + * + * @param SiteModel + * @return {@link Site} + */ + public Site usingSite(SiteModel siteModel) + { + return new Site(siteModel, restWrapper); + } + + /** + * Provides DSL on all REST calls under /sites API path + * + * @return {@link Site} + */ + public RestSiteModelsCollection getSites() + { + return new Site(null, restWrapper).getSites(); + } + + /** + * Provides DSL on all REST calls under /nodes API path + * + * @return {@link Node} + */ + public Node usingResource(RepoTestModel node) + { + return new Node(node, restWrapper); + } + + /** + * synonym for {@link #usingResource(RepoTestModel)} + * + * @param node + * @return + */ + public Node usingNode(RepoTestModel node) + { + return new Node(node, restWrapper); + } + + public Node usingNode() + { + return new Node(restWrapper); + } + + public ContentStorageInformation usingStorageInfo() + { + return new ContentStorageInformation(restWrapper); + } + + /** + * Provides DSL of all REST calls under /people API path + * + * @return {@link People} + */ + public People usingUser(UserModel person) + { + return new People(person, restWrapper); + } + + /** + * Make REST calls using current authenticated user, but using -me- instead of username + * + * @return {@link People} + */ + public People usingMe() + { + UserModel userModel = new UserModel("-me-", restWrapper.getTestUser().getPassword()); + userModel.setDomain(restWrapper.getTestUser().getDomain()); + userModel.setUserRole(restWrapper.getTestUser().getUserRole()); + return new People(userModel, restWrapper); + } + + /** + * Make REST calls using current authenticated user. + * This is set on the {@link #authenticateUser(UserModel)} call + * + * @return {@link People} + */ + public People usingAuthUser() + { + return new People(restWrapper.getTestUser(), restWrapper); + } + + /** + * Provides DSL on all REST calls under /network API path + * + * @return {@link Networks} + */ + public Networks usingNetworks() + { + return new Networks(restWrapper); + } + + public Tags usingTag(RestTagModel tag) + { + return new Tags(tag, restWrapper); + } + + public RestTagModelsCollection getTags() + { + return new Tags(null, restWrapper).getTags(); + } + + public RestTagModel getTag(RestTagModel tag) + { + return new Tags(tag, restWrapper).getTag(); + } + + public Queries usingQueries() + { + return new Queries(restWrapper); + } + + public Audit usingAudit() + { + return new Audit(restWrapper); + } + + public Trashcan usingTrashcan() + { + return new Trashcan(restWrapper); + } + + /** + * SharedLinks api endpoint + * + * @author meenal bhave + * @return SharedLinks api endpoint + */ + + public SharedLinks usingSharedLinks() + { + return new SharedLinks(restWrapper); + } + + public Groups usingGroups() + { + return new Groups(restWrapper); + } + + + public Actions usingActions() + { + return new Actions(restWrapper); + } + + public Downloads usingDownloads() + { + return new Downloads(restWrapper); + } + + public Downloads usingDownloads(RestDownloadsModel downloadsModel) + { + return new Downloads(downloadsModel, restWrapper); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/discoveryAPI/RestDiscoveryAPI.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/discoveryAPI/RestDiscoveryAPI.java new file mode 100644 index 0000000000..0b08e7e1d3 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/discoveryAPI/RestDiscoveryAPI.java @@ -0,0 +1,53 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests.discoveryAPI; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestDiscoveryModel; +import org.alfresco.rest.requests.ModelRequest; +import org.springframework.http.HttpMethod; + +import io.restassured.RestAssured; + +public class RestDiscoveryAPI extends ModelRequest { + + public RestDiscoveryAPI(RestWrapper restWrapper) + { + super(restWrapper); + RestAssured.basePath = "alfresco/api/discovery"; + restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath); + } + + // Method for getting repository info. The call is executed on root api path + public RestDiscoveryModel getRepositoryInfo() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, ""); + return restWrapper.processModel(RestDiscoveryModel.class, request); + } + +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/modelAPI/RestModelAPI.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/modelAPI/RestModelAPI.java new file mode 100644 index 0000000000..4b982fe757 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/modelAPI/RestModelAPI.java @@ -0,0 +1,96 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests.modelAPI; + +import io.restassured.RestAssured; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.*; +import org.alfresco.rest.requests.ModelRequest; +import org.springframework.http.HttpMethod; + +/** + * Defines the entire Rest Model API + * {@link https://api-explorer.alfresco.com/api-explorer/} select "Model API" + */ +public class RestModelAPI extends ModelRequest +{ + public RestModelAPI(RestWrapper restWrapper) + { + super(restWrapper); + RestAssured.basePath = "alfresco/api/-default-/public/alfresco/versions/1"; + restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath); + } + + /** + * Retrieve all aspects using GET call on "aspects" + * + * @return RestAspectsCollection + * @throws JsonToModelConversionException + */ + public RestAspectsCollection getAspects() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "aspects?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestAspectsCollection.class, request); + } + + /** + * Retrieve aspect by id using GET call on "aspects/{aspectId}" + * + * @return RestAspectModel + * @throws JsonToModelConversionException + */ + public RestAspectModel getAspect(String aspectId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "aspects/{aspectId}?{parameters}", aspectId, restWrapper.getParameters()); + return restWrapper.processModel(RestAspectModel.class, request); + } + + /** + * Retrieve all types using GET call on "types" + * + * @return RestTypesCollection + * @throws JsonToModelConversionException + */ + public RestTypesCollection getTypes() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "types?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestTypesCollection.class, request); + } + + /** + * Retrieve Type by id using GET call on "types/{typeId}" + * + * @return RestTypeModel + * @throws JsonToModelConversionException + */ + public RestTypeModel getType(String typeId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "types/{typeId}?{parameters}", typeId, restWrapper.getParameters()); + return restWrapper.processModel(RestTypeModel.class, request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/privateAPI/RestPrivateAPI.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/privateAPI/RestPrivateAPI.java new file mode 100644 index 0000000000..2948aba761 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/privateAPI/RestPrivateAPI.java @@ -0,0 +1,162 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests.privateAPI; + +import io.restassured.RestAssured; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestCustomTypeModel; +import org.alfresco.rest.model.RestSubscriberModel; +import org.alfresco.rest.model.RestSyncNodeSubscriptionModel; +import org.alfresco.rest.requests.CustomAspectModelManager; +import org.alfresco.rest.requests.CustomModelManager; +import org.alfresco.rest.requests.CustomTypeManager; +import org.alfresco.rest.requests.ModelRequest; +import org.alfresco.rest.requests.Node; +import org.alfresco.rest.requests.syncServiceAPI.Healthcheck; +import org.alfresco.rest.requests.syncServiceAPI.Subscribers; +import org.alfresco.rest.requests.syncServiceAPI.Subscriptions; +import org.alfresco.rest.requests.syncServiceAPI.Sync; +import org.alfresco.utility.model.CustomAspectModel; +import org.alfresco.utility.model.CustomContentModel; +import org.alfresco.utility.model.RepoTestModel; + +/** + * @author Bogdan Bocancea + */ +public class RestPrivateAPI extends ModelRequest +{ + public RestPrivateAPI(RestWrapper restWrapper) + { + super(restWrapper); + RestAssured.basePath = "alfresco/api/-default-/private/alfresco/versions/1"; + restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath); + } + + /** + * Provides DSL on all REST calls under cmm/{modelName}/... API path + * + * @param customContentModel {@link CustomContentModel} + * @return {@link CustomModelManager} + */ + public CustomModelManager usingCustomModel(CustomContentModel customContentModel) + { + return new CustomModelManager(customContentModel, restWrapper); + } + + public CustomModelManager usingCustomModel() + { + return new CustomModelManager(restWrapper); + } + + /** + * Provides DSL on all REST calls under cmm/{modelName}/aspects/{aspectName}... API path + * + * @param customContentModel {@link CustomContentModel} + * @param aspectModel {@link CustomAspectModel} + * @return {@link CustomAspectModelManager} + */ + public CustomAspectModelManager usingAspect(CustomContentModel customContentModel, CustomAspectModel aspectModel) + { + return new CustomAspectModelManager(customContentModel, aspectModel, restWrapper); + } + + /** + * Provides DSL on all REST calls under cmm/{modelName}/types/{typeName}... API path + * + * @param customContentModel {@link CustomContentModel} + * @param customType {@link RestCustomTypeModel} + * @return {@link CustomTypeManager} + */ + public CustomTypeManager usingCustomType(CustomContentModel customContentModel, RestCustomTypeModel customType) + { + return new CustomTypeManager(customContentModel, customType, restWrapper); + } + + /** + * Provides DSL on all REST calls under subscribers/ API path + * + * @return {@link Subscribers} + */ + public Subscribers withSubscribers() + { + return new Subscribers(restWrapper); + } + + /** + * Provides DSL on all REST calls under subscribers/{subscriberId}/ API path + * + * @return {@link Subscribers} + */ + public Subscriptions withSubscriber(RestSubscriberModel subscriber) + { + return new Subscriptions(subscriber, restWrapper); + } + + /** + * Provides DSL on all REST calls under subscribers/{subscriberId}/ API path + * + * @return {@link Subscribers} + */ + public Subscriptions withSubscriber(String subscriberID) + { + RestSubscriberModel s = new RestSubscriberModel(); + s.setId(subscriberID); + return new Subscriptions(s, restWrapper); + } + + /** + * Provides DSL on all REST calls under subscribers/{subscriberId}/subscriptions/ API path + * + * @return {@link Subscribers} + */ + public Sync withSubscription(RestSyncNodeSubscriptionModel nodeSubscription) + { + RestSubscriberModel s = new RestSubscriberModel(); + s.setId(nodeSubscription.getDeviceSubscriptionId()); + return new Sync(nodeSubscription, restWrapper); + } + /** + * Provides DSL on all REST calls under subscribers/ API path + * + * @return {@link Subscribers} + */ + public Healthcheck doHealthCheck() + { + return new Healthcheck(restWrapper); + } + + /** + * Provides DSL on all REST calls under nodes/ API path + * + * @param node + * @return + */ + public Node usingNode(RepoTestModel node) + { + return new Node(node, restWrapper); + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SearchAPI.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SearchAPI.java new file mode 100644 index 0000000000..2ef3d3e13a --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SearchAPI.java @@ -0,0 +1,73 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.requests.search; + +import io.restassured.RestAssured; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.requests.ModelRequest; +import org.alfresco.rest.search.SearchRequest; +import org.alfresco.rest.search.SearchResponse; +import org.springframework.http.HttpMethod; +/** + * Wrapper for Search API. + * @author Michael Suzuki + * + */ +public class SearchAPI extends ModelRequest +{ + public SearchAPI(RestWrapper restWrapper) + { + super(restWrapper); + restWrapper.configureAlfrescoEndpoint(); + RestAssured.basePath = "alfresco/api/-default-/public/search/versions/1"; + restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath); + } + + public SearchResponse search(SearchRequest queryBody) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, queryBody.toJson(), "search"); + return restWrapper.processModels(SearchResponse.class, request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SearchSQLAPI.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SearchSQLAPI.java new file mode 100644 index 0000000000..883757906d --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SearchSQLAPI.java @@ -0,0 +1,207 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.requests.search; + +import javax.json.JsonArrayBuilder; +import javax.json.JsonObjectBuilder; + +import io.restassured.RestAssured; + +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.requests.ModelRequest; +import org.alfresco.rest.search.SearchSqlRequest; +import org.springframework.http.HttpMethod; + + +/** + * Wrapper for Search SQL API. + * + * @author Meenal Bhave + * + * Request POST + * End point: /sql + * PostBody: + * { + * "stmt":"Select SITE from alfresco where SITE = 'swsdp' limit 2", + * "locales":["ja"], + * "timezone":"Israel", + * "includeMetadata":true, + * "format":"", + * "limit": 100 + * } + * Response in json format: + * { + * "list": { + * "pagination": { + * "count": 3, + * "hasMoreItems": false, + * "totalItems": 3, + * "skipCount": 0, + * "maxItems": 100 + * }, + * "entries": [ + * { + * "entry": [ + * { + * "label": "aliases", + * "value": "{\"SITE\":\"SITE\"}" + * }, + * { + * "label": "isMetadata", + * "value": "true" + * }, + * { + * "label": "fields", + * "value": "[\"SITE\"]" + * } + * ] + * }, + * { + * "entry": [ + * { + * "label": "SITE", + * "value": "[\"swsdp\"]" + * } + * ] + * }, + * { + * "entry": [ + * { + * "label": "SITE", + * "value": "[\"swsdp\"]" + * } + * ] + * } + * ] + * } + * } + * + * Response in solr format + * { + * "result-set": { + * "docs": [ + * { + * "aliases": { + * "SITE": "SITE" + * }, + * "isMetadata": true, + * "fields": [ + * "SITE" + * ] + * }, + * { + * "SITE": [ + * "swsdp" + * ] + * }, + * { + * "SITE": [ + * "swsdp" + * ] + * }, + * { + * "RESPONSE_TIME": 79, + * "EOF": true + * } + * ] + * } + * } + */ +public class SearchSQLAPI extends ModelRequest +{ + public SearchSQLAPI(RestWrapper restWrapper) + { + super(restWrapper); + restWrapper.configureAlfrescoEndpoint(); + RestAssured.basePath = "alfresco/api/-default-/public/search/versions/1"; + restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath); + } + + public RestResponse searchSql(SearchSqlRequest query) + { + String stmt = (null == query.getSql() || query.getSql().isEmpty()) ? "" : query.getSql(); + + String format = (null == query.getFormat() || query.getFormat().isEmpty()) ? "" : query.getFormat(); + + JsonArrayBuilder array = JsonBodyGenerator.defineJSONArray(); + if (query.getLocales() != null) + { + for (String locale : query.getLocales()) + { + array.add(locale); + } + } + + String timezone = (null == query.getTimezone() || query.getTimezone().isEmpty()) ? "" : query.getTimezone(); + + Boolean includeMetadata = (query.getIncludeMetadata() != null && query.getIncludeMetadata()); + + Integer limit = null == query.getLimit() ? 0 : query.getLimit(); + + JsonArrayBuilder filterQueries = null; + if (query.getFilterQueries() != null) + { + filterQueries = JsonBodyGenerator.defineJSONArray(); + for (String filterQuery : query.getFilterQueries()) + { + filterQueries.add(filterQuery); + } + } + + JsonObjectBuilder builder = JsonBodyGenerator.defineJSON() + .add("stmt", stmt) + .add("format", format) + .add("locales", array) + .add("timezone", timezone) + .add("includeMetadata", includeMetadata) + .add("limit", limit); + if (filterQueries != null) + { + builder.add("filterQueries", filterQueries); + } + String postBody = builder.build().toString(); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "sql"); + return restWrapper.process(request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SearchSQLJDBC.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SearchSQLJDBC.java new file mode 100644 index 0000000000..99894d0594 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SearchSQLJDBC.java @@ -0,0 +1,120 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.requests.search; + +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Properties; + +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.requests.ModelRequest; +import org.alfresco.rest.search.SearchSqlJDBCRequest; +import io.restassured.RestAssured; + + +/** + * Wrapper for Search SQL using JDBC connection. + * + * @author Meenal Bhave + * + * Request POST JDBC + * End point: /sql + */ +public class SearchSQLJDBC extends ModelRequest +{ + public SearchSQLJDBC(RestWrapper restWrapper) + { + super(restWrapper); + RestAssured.basePath = "alfresco/api/-default-/public/search/versions/1/sql"; + restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath); + } + + public ResultSet executeQueryViaJDBC(SearchSqlJDBCRequest query) throws SQLException + { + + StringBuilder connectionString = new StringBuilder() + .append(RestAssured.baseURI + .replaceAll("http", "jdbc:alfresco") + .replaceAll("https", "jdbc:alfresco")) + .append(":") + .append(RestAssured.port) + .append("/") + .append(RestAssured.basePath) + .append("/"); + + String sql = (null == query.getSql() || query.getSql().isEmpty()) ? "" : query.getSql(); + + Properties auth = new Properties(); + auth.put("user", query.getAuthUser().getUsername()); + auth.put("password", query.getAuthUser().getPassword()); + + try + { + query.setConnection(DriverManager.getConnection(connectionString.toString(), auth)); + query.setStmt(query.getConnection().createStatement()); + query.setResultSet(query.getStmt().executeQuery(sql)); + } + catch (SQLException eSql) + { + query.setErrorDetails(eSql.getMessage()); + } + + return query.getResultSet(); + } + + public void clearSearchQuery(SearchSqlJDBCRequest query) throws SQLException + { + if (query.getResultSet() != null) + { + query.getResultSet().close(); + } + + if (query.getStmt() != null) + { + query.getStmt().close(); + } + + if (query.getConnection() != null) + { + query.getConnection().close(); + } + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/ShardInfoAPI.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/ShardInfoAPI.java new file mode 100644 index 0000000000..991f2a7842 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/ShardInfoAPI.java @@ -0,0 +1,86 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2005-2018 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.requests.search; + +import com.fasterxml.jackson.core.JsonProcessingException; +import io.restassured.RestAssured; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.requests.ModelRequest; +import org.alfresco.rest.search.RestShardInfoModelCollection; +import org.springframework.http.HttpMethod; + +/** + * Wrapper for Shard Info API. + * + * @author Tuna Aksoy + */ +public class ShardInfoAPI extends ModelRequest +{ + /** + * Constructor + * + * @param restWrapper Rest Wrapper + */ + public ShardInfoAPI(RestWrapper restWrapper) + { + super(restWrapper); + restWrapper.configureAlfrescoEndpoint(); + RestAssured.basePath = "alfresco/api/-default-/private/search/versions/1"; + restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath); + } + + /** + * Get Info about the shard groups + * + * @return {@link RestShardInfoModelCollection} Information about shard groups + * @throws JsonProcessingException + */ + public RestShardInfoModelCollection getInfo() throws JsonProcessingException + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "info"); + return restWrapper.processModels(RestShardInfoModelCollection.class, request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SolrAPI.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SolrAPI.java new file mode 100644 index 0000000000..792e1132e5 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SolrAPI.java @@ -0,0 +1,131 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.requests.search; + +import java.util.ArrayList; +import java.util.List; + +import io.restassured.RestAssured; +import io.restassured.http.Header; +import io.restassured.http.Headers; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestTextResponse; +import org.alfresco.rest.requests.ModelRequest; +import org.springframework.http.HttpMethod; + +/** + * Wrapper for solr API. + * + * @author Meenal Bhave + */ +public class SolrAPI extends ModelRequest +{ + public SolrAPI(RestWrapper restWrapper) + { + super(restWrapper); + RestAssured.basePath = "solr/alfresco"; + + restWrapper.configureSolrEndPoint(); + restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath); + } + + public RestTextResponse getConfig() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "config?{parameters}", restWrapper.getParameters()); + return restWrapper.processTextResponse(request); + } + + public RestTextResponse getConfigOverlay() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "config/overlay?{parameters}", restWrapper.getParameters()); + return restWrapper.processTextResponse(request); + } + + public RestTextResponse getConfigParams() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "config/params?{parameters}", restWrapper.getParameters()); + return restWrapper.processTextResponse(request); + } + + public RestTextResponse postConfig(String queryBody) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, queryBody, "config"); + return restWrapper.processTextResponse(request); + } + + /** + * Executes an action (like "delete") on SOLR alfresco core + * @param urlActionPath some action name (like "delete") + * @param queryBody parameters for the action + */ + public RestTextResponse postAction(String urlActionPath, String queryBody) + { + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, queryBody, urlActionPath); + return restWrapper.processTextResponse(request); + } + + public RestTextResponse getSelectQuery() + { + List
headers = new ArrayList
(); + headers.add(new Header("Content-Type", "application/xml")); + Headers header = new Headers(headers); + restWrapper.setResponseHeaders(header); + restWrapper.configureRequestSpec().setUrlEncodingEnabled(false); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "select?q={parameters}", restWrapper.getParameters()); + return restWrapper.processTextResponse(request); + } + + /** + * Executes a query in SOLR using JSON format for the results + */ + public RestTextResponse getSelectQueryJson() + { + List
headers = new ArrayList
(); + headers.add(new Header("Content-Type", "application/json")); + Headers header = new Headers(headers); + restWrapper.setResponseHeaders(header); + restWrapper.configureRequestSpec().setUrlEncodingEnabled(false); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "select?q={parameters}&wt=json", restWrapper.getParameters()); + return restWrapper.processTextResponse(request); + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SolrAdminAPI.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SolrAdminAPI.java new file mode 100644 index 0000000000..93a3002f73 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/search/SolrAdminAPI.java @@ -0,0 +1,83 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2020 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.requests.search; + +import java.util.ArrayList; +import java.util.List; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.requests.ModelRequest; +import org.springframework.http.HttpMethod; + +import io.restassured.RestAssured; +import io.restassured.http.Header; +import io.restassured.http.Headers; + +/** + * Wrapper for SOLR Admin REST API + * + * @author aborroy + * + */ +public class SolrAdminAPI extends ModelRequest +{ + public SolrAdminAPI(RestWrapper restWrapper) + { + super(restWrapper); + RestAssured.basePath = "solr/admin"; + + restWrapper.configureSolrEndPoint(); + restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath); + } + + public RestResponse getAction(String action) + { + List
headers = new ArrayList
(); + headers.add(new Header("Content-Type", "application/json")); + Headers header = new Headers(headers); + restWrapper.setResponseHeaders(header); + restWrapper.configureRequestSpec().setUrlEncodingEnabled(false); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, + "cores?action=" + action + "&wt=json&{parameters}", restWrapper.getParameters()); + return restWrapper.process(request); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/syncServiceAPI/Healthcheck.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/syncServiceAPI/Healthcheck.java new file mode 100644 index 0000000000..2ede23be05 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/syncServiceAPI/Healthcheck.java @@ -0,0 +1,59 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests.syncServiceAPI; + +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestSyncServiceHealthCheckModel; +import org.alfresco.rest.requests.ModelRequest; +import org.alfresco.rest.requests.privateAPI.RestPrivateAPI; +import org.springframework.http.HttpMethod; + +/** + * Declares all Rest API under the /healthcheck path + * + * @author Meenal Bhave + */ +public class Healthcheck extends ModelRequest +{ + public Healthcheck(RestWrapper restWrapper) + { + super(restWrapper); + restWrapper.configureSyncServiceEndPoint(); + restWrapper.configureRequestSpec().setBasePath("alfresco/"); + } + + /** + * Get Healthcheck using GET call on alfresco/healthcheck + * @return {@link RestSyncServiceHealthCheckModel} + */ + public RestSyncServiceHealthCheckModel getHealthcheck() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "healthcheck?{parameters}", restWrapper.getParameters()); + return restWrapper.processModelWithoutEntryObject(RestSyncServiceHealthCheckModel.class, request); + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/syncServiceAPI/Subscribers.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/syncServiceAPI/Subscribers.java new file mode 100644 index 0000000000..dd7d884bc3 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/syncServiceAPI/Subscribers.java @@ -0,0 +1,79 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests.syncServiceAPI; + +import java.util.HashMap; + +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestSubscriberModel; +import org.alfresco.rest.model.RestSubscriberModelCollection; +import org.alfresco.rest.requests.ModelRequest; +import org.alfresco.rest.requests.privateAPI.RestPrivateAPI; +import org.springframework.http.HttpMethod; + +/** + * Declares all Rest API under the /subscribers path + * + * @author Meenal Bhave + */ +public class Subscribers extends ModelRequest +{ + public Subscribers(RestWrapper restWrapper) + { + super(restWrapper); + } + + /** + * Get Subscription(s) using GET call on /subscribers + * @return {@link RestSubscriberModelCollection} + */ + public RestSubscriberModelCollection getSubscribers() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "subscribers?{parameters}", restWrapper.getParameters()); + return restWrapper.processModels(RestSubscriberModelCollection.class, request); + } + + /** + * POST Create Device Subscription using POST call on /subscribers + * + * @param deviceOS + * @param clientVersion + * @return {@link RestSubscriberModel} + */ + public RestSubscriberModel registerDevice(String deviceOS, String clientVersion) + { + HashMap body = new HashMap(); + body.put("deviceOS", deviceOS); + body.put("clientVersion", clientVersion); + String postBody = JsonBodyGenerator.keyValueJson(body); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, "subscribers?{parameters}", restWrapper.getParameters()); + return restWrapper.processModel(RestSubscriberModel.class, request); + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/syncServiceAPI/Subscriptions.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/syncServiceAPI/Subscriptions.java new file mode 100644 index 0000000000..d659345b8a --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/syncServiceAPI/Subscriptions.java @@ -0,0 +1,134 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests.syncServiceAPI; + +import java.util.HashMap; + +import javax.json.JsonArrayBuilder; + +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestSubscriberModel; +import org.alfresco.rest.model.RestSyncNodeSubscriptionModel; +import org.alfresco.rest.model.RestSyncNodeSubscriptionModelCollection; +import org.alfresco.rest.requests.ModelRequest; +import org.alfresco.rest.requests.privateAPI.RestPrivateAPI; +import org.alfresco.utility.Utility; +import org.springframework.http.HttpMethod; + +/** + * Declares all Rest API under the /subscribers//subscriptions/ path + * + * @author Meenal Bhave + */ +public class Subscriptions extends ModelRequest +{ + public enum TYPE + { + BOTH, CONTENT, METADATA + } + + private RestSubscriberModel subscriber; + private String subscriptionsURL = "subscribers/{deviceSubscriptionId}/subscriptions"; + String nodeSubscriptionURL = subscriptionsURL + "/{nodeSubscriptionId}"; + String params = "?{parameters}"; + + public Subscriptions(RestSubscriberModel subscriber, RestWrapper restWrapper) + { + super(restWrapper); + this.subscriber = subscriber; + Utility.checkObjectIsInitialized(this.subscriber, "Subscriber Device"); + } + + /** + * Create Node Subscriptions for multiple targets using POST call on /subscribers/{deviceSubscriptionId}/subscriptions + * + * @param targetNodeIds: one or more + * @return RestSyncNodeSubscriptionModel + * @throws EmptyJsonResponseException, JsonToModelConversionException + */ + public RestSyncNodeSubscriptionModelCollection subscribeToNodes(String... targetNodeIds) + { + + JsonArrayBuilder array = JsonBodyGenerator.defineJSONArray(); + for (String targetNodeId : targetNodeIds) + { + array.add(JsonBodyGenerator.defineJSON().add("targetNodeId", targetNodeId).add("subscriptionType", TYPE.BOTH.toString())); + } + + String postBody = array.build().toString(); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, subscriptionsURL + params, this.subscriber.getId(), + restWrapper.getParameters()); + + return restWrapper.processModels(RestSyncNodeSubscriptionModelCollection.class, request); + } + + /** + * Create Node Subscription for the specified target node using POST call on /subscribers/{deviceSubscriptionId}/subscriptions + * + * @param targetNodeId + * @param subscriberType + * @return + */ + public RestSyncNodeSubscriptionModel subscribeToNode(String targetNodeId, TYPE subscriberType) + { + HashMap body = new HashMap(); + body.put("targetNodeId", targetNodeId); + body.put("subscriptionType", subscriberType.toString()); + String postBody = JsonBodyGenerator.keyValueJson(body); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, subscriptionsURL + params, this.subscriber.getId(), + restWrapper.getParameters()); + return restWrapper.processModel(RestSyncNodeSubscriptionModel.class, request); + } + + /** + * Get NODE Subscription(s) using GET call on /subscribers/{deviceSubscriptionId}/subscriptions + * + * @return {@link RestSyncNodeSubscriptionModelCollection} + */ + public RestSyncNodeSubscriptionModelCollection getSubscriptions() + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, subscriptionsURL + params, this.subscriber.getId(), restWrapper.getParameters()); + return restWrapper.processModels(RestSyncNodeSubscriptionModelCollection.class, request); + } + + /** + * Get NODE Subscription using GET call on /subscribers/{deviceSubscriptionId}/subscriptions/{nodeSubscriptionId} + * + * @return RestSyncNodeSubscriptionModelCollection + * @throws EmptyJsonResponseException, JsonToModelConversionException + */ + public RestSyncNodeSubscriptionModel getSubscription(String nodeSubscriptionId) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, nodeSubscriptionURL + params, this.subscriber.getId(), nodeSubscriptionId, + restWrapper.getParameters()); + return restWrapper.processModel(RestSyncNodeSubscriptionModel.class, request); + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/syncServiceAPI/Sync.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/syncServiceAPI/Sync.java new file mode 100644 index 0000000000..e8ecd607b7 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/syncServiceAPI/Sync.java @@ -0,0 +1,121 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests.syncServiceAPI; + +import java.util.List; + +import javax.json.JsonArrayBuilder; + +import org.alfresco.rest.core.JsonBodyGenerator; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestSyncNodeSubscriptionModel; +import org.alfresco.rest.model.RestSyncSetChangesModel; +import org.alfresco.rest.model.RestSyncSetGetModel; +import org.alfresco.rest.model.RestSyncSetRequestModel; +import org.alfresco.rest.requests.ModelRequest; +import org.alfresco.rest.requests.privateAPI.RestPrivateAPI; +import org.alfresco.utility.Utility; +import org.springframework.http.HttpMethod; + +import io.restassured.http.ContentType; + +/** + * Declares all Rest API under the /subscribers//subscriptions//sync path + * + * @author Meenal Bhave + */ +public class Sync extends ModelRequest +{ + String subscriber; + RestSyncNodeSubscriptionModel subscription; + String requestSyncURL = "subscribers/{deviceSubscriptionId}/subscriptions/{nodeSubscriptionId}/sync"; + String syncSetURL = requestSyncURL + "/{syncId}"; + + public Sync(RestSyncNodeSubscriptionModel subscription, RestWrapper restWrapper) + { + super(restWrapper); + restWrapper.configureSyncServiceEndPoint(); + this.subscription = subscription; + this.subscriber = subscription.getDeviceSubscriptionId(); + Utility.checkObjectIsInitialized(this.subscription, "Node Subscription"); + } + + /** + * Request sync for the specified subscriber/subscription using POST call on /subscribers/{deviceSubscriptionId}/subscriptions/{nodeSubscriptionId}/sync + * + * @param nodeSubscriptionId + * @param clientChanges + * @return + */ + public RestSyncSetRequestModel startSync(RestSyncNodeSubscriptionModel nodeSubscriptionModel, List clientChanges, String clientVersion) + { + JsonArrayBuilder array = JsonBodyGenerator.defineJSONArray(); + for (RestSyncSetChangesModel change : clientChanges) + { + array.add(JsonBodyGenerator.defineJSON().add("changes", change.toJson())); + } + + String postBody = JsonBodyGenerator.defineJSON().add("changes", array.build()).add("clientVersion", clientVersion).build().toString(); + + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, requestSyncURL, this.subscriber, nodeSubscriptionModel.getId(), + restWrapper.getParameters()); + + // This step is necessary for this request. Without it, empty json response is returned + restWrapper.configureRequestSpec().setContentType(ContentType.JSON.withCharset(request.getContentType())); + RestSyncSetRequestModel model = restWrapper.processModelWithoutEntryObject(RestSyncSetRequestModel.class, request); + restWrapper.initializeRequestSpecBuilder(); + return model; + } + + public RestWrapper endSync(RestSyncNodeSubscriptionModel nodeSubscriptionModel, RestSyncSetRequestModel sync) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, syncSetURL, this.subscriber, nodeSubscriptionModel.getId(), + sync.getSyncId(), restWrapper.getParameters()); + + restWrapper.processEmptyModel(request); + restWrapper.initializeRequestSpecBuilder(); + return restWrapper; + } + + /** + * Gets the Change Set for the specified subscriber/subscription and SyncId using GET call on + * /subscribers/{deviceSubscriptionId}/subscriptions/{nodeSubscriptionId}/sync + * + * @param syncRequest + * @return + */ + public RestSyncSetGetModel getSync(RestSyncNodeSubscriptionModel nodeSubscriptionModel, RestSyncSetRequestModel sync) + { + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, syncSetURL, this.subscriber, nodeSubscriptionModel.getId(), sync.getSyncId(), + restWrapper.getParameters()); + + RestSyncSetGetModel model = restWrapper.processModelWithoutEntryObject(RestSyncSetGetModel.class, request); + restWrapper.initializeRequestSpecBuilder(); + return model; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/workflowAPI/RestWorkflowAPI.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/workflowAPI/RestWorkflowAPI.java new file mode 100644 index 0000000000..9fc0f8716d --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/requests/workflowAPI/RestWorkflowAPI.java @@ -0,0 +1,162 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests.workflowAPI; + +import javax.json.JsonObject; + +import org.alfresco.dataprep.CMISUtil.Priority; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestDeploymentModelsCollection; +import org.alfresco.rest.model.RestProcessDefinitionModel; +import org.alfresco.rest.model.RestProcessDefinitionModelsCollection; +import org.alfresco.rest.model.RestProcessModel; +import org.alfresco.rest.model.RestProcessModelsCollection; +import org.alfresco.rest.model.RestTaskModelsCollection; +import org.alfresco.rest.requests.Deployments; +import org.alfresco.rest.requests.ModelRequest; +import org.alfresco.rest.requests.ProcessDefinitions; +import org.alfresco.rest.requests.Processes; +import org.alfresco.rest.requests.Task; +import org.alfresco.utility.model.ProcessModel; +import org.alfresco.utility.model.TaskModel; +import org.alfresco.utility.model.UserModel; + +import io.restassured.RestAssured; + +/** + * Defines the entire Rest Workflow API + * {@link https://api-explorer.alfresco.com/api-explorer/} select "Workflow API" + */ +public class RestWorkflowAPI extends ModelRequest +{ + public RestWorkflowAPI(RestWrapper restWrapper) + { + super(restWrapper); + RestAssured.basePath = "alfresco/api/-default-/public/workflow/versions/1"; + restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath); + } + + /** + * Provides DSL on all REST calls under /processes/{processId}/... API path + * + * @return {@link RestProcessModel} + */ + public RestProcessModel addProcess(String processDefinitionKey, UserModel assignee, boolean sendEmailNotifications, Priority priority) + { + return new Processes(restWrapper).addProcess(processDefinitionKey, assignee, sendEmailNotifications, priority); + } + + /** + * Provides DSL on all REST calls under /processes/{processId}/... API path + * + * @return {@link RestProcessModel} + */ + public RestProcessModel addProcessWithBody(JsonObject postBody) + { + return new Processes(restWrapper).addProcessWithBody(postBody.toString()); + } + + /** + * Provides DSL on all REST calls under /tasks/{taskId}/... API path + * + * @return {@link Task} + */ + public Task usingTask(TaskModel task) + { + return new Task(restWrapper, task); + } + + /** + * Provides get all process /processesof current user logged in + * + * @return {@link RestProcessModelsCollection} + */ + public RestProcessModelsCollection getProcesses() + { + return new Processes(restWrapper).getProcesses(); + } + + /** + * Provides all deployments of current user logged in + * + * @return {@link RestDeploymentModelsCollection} + */ + public RestDeploymentModelsCollection getDeployments() + { + return new Deployments(restWrapper).getDeployments(); + } + + /** + * Provides DSL on all REST calls under /deployments/{deploymentID} API path + * + * @return {@link Deployments} + */ + public Deployments usingDeployment(RestDeploymentModel deployment) + { + return new Deployments(deployment, restWrapper); + } + + /** + * Provides all ProcessDefinitions of current user logged in + * + * @return {@link RestProcessDefinitionModelsCollection} + */ + public RestProcessDefinitionModelsCollection getAllProcessDefinitions() + { + return new ProcessDefinitions(restWrapper).getAllProcessDefinitions(); + } + + /** + * Provides DSL on all REST calls under /process-definition/{processDefinitionID} API path + * + * @return {@link ProcessDefinitions} + */ + public ProcessDefinitions usingProcessDefinitions(RestProcessDefinitionModel processDefinition) + { + return new ProcessDefinitions(processDefinition, restWrapper); + } + + /** + * Provides DSL on all REST calls under /process-definition/{processDefinitionID} API path + * + * @return {@link Processes} + */ + public Processes usingProcess(ProcessModel processModel) + { + return new Processes(processModel, restWrapper); + } + + /** + * Provides all tasks of the current user + * + * @return {@link RestTaskModelsCollection} + */ + public RestTaskModelsCollection getTasks() + { + return new Task(restWrapper, null).getTasks(); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/Context.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/Context.java new file mode 100644 index 0000000000..93eb6dd81e --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/Context.java @@ -0,0 +1,70 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import org.alfresco.utility.model.TestModel; + +/** + * Search response sample. + * { + * "context": {"consistency": {"lastTxId": 1123}} + * } + **/ +public class Context extends TestModel +{ + + private Integer lastTxId; + + public Integer getLastTxId() + { + return lastTxId; + } + + public void setLastTxId(Integer lastTxId) + { + this.lastTxId = lastTxId; + } + + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/FacetFieldBucket.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/FacetFieldBucket.java new file mode 100644 index 0000000000..3ff5b89deb --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/FacetFieldBucket.java @@ -0,0 +1,110 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Pojo to represent facet field bucket response. + * {"count":1,"label":"small"}, + **/ +public class FacetFieldBucket extends TestModel implements IRestModel +{ + + private String label; + private String display; + private String filterQuery; + private int count; + + + public FacetFieldBucket() {} + + public String getLabel() + { + return label; + } + + public void setLabel(String label) + { + this.label = label; + } + + public String getDisplay() + { + return display; + } + + public void setDisplay(String display) + { + this.display = display; + } + + public int getCount() + { + return count; + } + + public void setCount(int count) + { + this.count = count; + } + + public String getFilterQuery() + { + return filterQuery; + } + + public void setFilterQuery(String filterQuery) + { + this.filterQuery = filterQuery; + } + + @Override + public FacetFieldBucket onModel() + { + // TODO Auto-generated method stub + return null; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/FacetFieldQuery.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/FacetFieldQuery.java new file mode 100644 index 0000000000..5c061c4180 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/FacetFieldQuery.java @@ -0,0 +1,85 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import org.alfresco.utility.model.TestModel; + +/** + * Pojo to represent facet field query. + * {"",""}, + **/ +public class FacetFieldQuery extends TestModel +{ + + private String field; + private String prefix; + + public FacetFieldQuery() {} + public FacetFieldQuery(String field) + { + this.field = field; + } + public FacetFieldQuery(String field, String prefix) + { + this.field = field; + this.prefix = prefix; + } + public String getField() + { + return field; + } + public void setField(String field) + { + this.field = field; + } + public String getPrefix() + { + return prefix; + } + public void setPrefix(String prefix) + { + this.prefix = prefix; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/FacetInterval.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/FacetInterval.java new file mode 100644 index 0000000000..b18bf5ef86 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/FacetInterval.java @@ -0,0 +1,89 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import java.util.List; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Represents a facet interval. + */ + +public class FacetInterval extends TestModel implements IRestModel +{ + private String field; + private String label; + private List sets; + + public FacetInterval() + { + } + + public FacetInterval(String field, String label, List sets) + { + this.field = field; + this.label = label; + this.sets = sets; + } + + public String getField() + { + return field; + } + + public String getLabel() + { + return label; + } + + public List getSets() + { + return sets; + } + + public void setField(String field) + { + this.field = field; + } + + public void setLabel(String label) + { + this.label = label; + } + + public void setSets(List sets) + { + this.sets = sets; + } + + @Override + public FacetInterval onModel() + { + return null; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/FacetQuery.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/FacetQuery.java new file mode 100644 index 0000000000..19a8293d29 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/FacetQuery.java @@ -0,0 +1,96 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import org.alfresco.utility.model.TestModel; + +/** + * Pojo to represent facet query. + * {"query": "content.size:[o TO 102400]", "label": "small"}, + **/ +public class FacetQuery extends TestModel +{ + + private String query; + private String label; + private String group; + + public FacetQuery() {} + public FacetQuery(String query,String label) + { + this.query = query; + this.label = label; + } + public FacetQuery(String query,String label, String group) + { + this.query = query; + this.label = label; + this.group = group; + } + + public String getQuery() + { + return query; + } + public void setQuery(String query) + { + this.query = query; + } + public String getLabel() + { + return label; + } + public void setLabel(String label) + { + this.label = label; + } + public String getGroup() + { + return group; + } + public void setGroup(String group) + { + this.group = group; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/Pagination.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/Pagination.java new file mode 100644 index 0000000000..43afef3556 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/Pagination.java @@ -0,0 +1,107 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import org.alfresco.utility.model.TestModel; + +/** + * Search response sample. + * "pagination": { + * "maxItems": 100, + * "hasMoreItems": false, + * "totalItems": 0, + * "count": 0, + * "skipCount": 0 + * }, + **/ +public class Pagination extends TestModel +{ + + private Integer maxItems; + private Integer totalItems; + private Integer count; + private Integer skipCount; + private boolean hasMoreItems; + public Integer getMaxItems() + { + return maxItems; + } + public void setMaxItems(Integer maxItems) + { + this.maxItems = maxItems; + } + public Integer getTotalItems() + { + return totalItems; + } + public void setTotalItems(Integer totalItems) + { + this.totalItems = totalItems; + } + public Integer getCount() + { + return count; + } + public void setCount(Integer count) + { + this.count = count; + } + public Integer getSkipCount() + { + return skipCount; + } + public void setSkipCount(Integer skipCount) + { + this.skipCount = skipCount; + } + public boolean isHasMoreItems() + { + return hasMoreItems; + } + public void setHasMoreItems(boolean hasMoreItems) + { + this.hasMoreItems = hasMoreItems; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/ResponseHighLightModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/ResponseHighLightModel.java new file mode 100644 index 0000000000..896e77603d --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/ResponseHighLightModel.java @@ -0,0 +1,84 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import java.util.List; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; +/** + * Pojo which represents the search response that includes the highlighting info. + * @author Michael Suzuki + * + */ +public class ResponseHighLightModel extends TestModel implements IRestModel +{ + private ResponseHighLightModel model; + private String field; + private List snippets; + + public String getField() + { + return field; + } + public void setField(String field) + { + this.field = field; + } + public List getSnippets() + { + return snippets; + } + public void setSnippets(List snippets) + { + this.snippets = snippets; + } + @Override + public ResponseHighLightModel onModel() + { + return model; + } + + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestGenericBucketModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestGenericBucketModel.java new file mode 100644 index 0000000000..2305fd0008 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestGenericBucketModel.java @@ -0,0 +1,139 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'gethin' on '2017-03-17 13:23' 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 +{ + @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 metrics; + private Object bucketInfo; + /** + Additional list of embedded GenericFacetResponse + */ + + private List facets; + + 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 getMetrics() + { + return this.metrics; + } + + public void setMetrics(List metrics) + { + this.metrics = metrics; + } + + public List getFacets() + { + return this.facets; + } + + public void setFacets(List facets) + { + this.facets = facets; + } + + public Object getBucketInfo() + { + return bucketInfo; + } + + public void setFacetInfo(Object bucketInfo) + { + this.bucketInfo = bucketInfo; + } + +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestGenericFacetResponseModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestGenericFacetResponseModel.java new file mode 100644 index 0000000000..655d8061b0 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestGenericFacetResponseModel.java @@ -0,0 +1,97 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'gethin' on '2017-03-17 12:44' 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 RestGenericFacetResponseModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestGenericFacetResponseModel model; + + @Override + public RestGenericFacetResponseModel onModel() + { + return model; + } + + /** + The facet type, eg. interval, range, field, query1 + */ + + private String type; + /** + The field name or its explicit label, if provided on the request + */ + + private String label; + /** + An array of buckets and values + */ + + private List buckets; + + public String getType() + { + return this.type; + } + + public void setType(String type) + { + this.type = type; + } + + public String getLabel() + { + return this.label; + } + + public void setLabel(String label) + { + this.label = label; + } + + public List getBuckets() + { + return this.buckets; + } + + public void setBuckets(List buckets) + { + this.buckets = buckets; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestGenericMetricModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestGenericMetricModel.java new file mode 100644 index 0000000000..d0686548b0 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestGenericMetricModel.java @@ -0,0 +1,80 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'gethin' on '2017-03-17 13:23' 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 RestGenericMetricModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestGenericMetricModel model; + + @Override + public RestGenericMetricModel onModel() + { + return model; + } + + /** + The type of metric, e.g. count + */ + + private String type; + /** + The metric value, e.g. + */ + + private Object value; + + public String getType() + { + return this.type; + } + + public void setType(String type) + { + this.type = type; + } + + public Object getValue() + { + return this.value; + } + + public void setValue(Object value) + { + this.value = value; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestInstanceModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestInstanceModel.java new file mode 100644 index 0000000000..ccf802d2c0 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestInstanceModel.java @@ -0,0 +1,281 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2005-2018 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +/** + * Representation of a shard instance + * + * @author Tuna Aksoy + */ +public class RestInstanceModel +{ + /** Base Url */ + private String baseUrl; + + /** Host */ + private String host; + + /** Last indexed change set date */ + private String lastIndexedChangesetDate; + + /** Last indexed change set Id */ + private Long lastIndexedChangesetId; + + /** Last indexed transaction date */ + private String lastIndexedTransactionDate; + + /** Last indexed transaction Id */ + private Long lastIndexedTransactionId; + + /** Last update date */ + private String lastUpdateDate; + + /** Port */ + private Integer port; + + /** State */ + private String state; + + /** Mode */ + private String mode; + + /** Transactions remaining */ + private Long transactionsRemaining; + + /** Sharding Parameters */ + private String shardParams; + + /** + * @return the baseUrl + */ + public String getBaseUrl() + { + return this.baseUrl; + } + + /** + * @param baseUrl the baseUrl to set + */ + public void setBaseUrl(String baseUrl) + { + this.baseUrl = baseUrl; + } + + /** + * @return the host + */ + public String getHost() + { + return this.host; + } + + /** + * @param host the host to set + */ + public void setHost(String host) + { + this.host = host; + } + + /** + * @return the lastIndexedChangesetDate + */ + public String getLastIndexedChangesetDate() + { + return this.lastIndexedChangesetDate; + } + + /** + * @param lastIndexedChangesetDate the lastIndexedChangesetDate to set + */ + public void setLastIndexedChangesetDate(String lastIndexedChangesetDate) + { + this.lastIndexedChangesetDate = lastIndexedChangesetDate; + } + + /** + * @return the lastIndexedChangesetId + */ + public Long getLastIndexedChangesetId() + { + return this.lastIndexedChangesetId; + } + + /** + * @param lastIndexedChangesetId the lastIndexedChangesetId to set + */ + public void setLastIndexedChangesetId(Long lastIndexedChangesetId) + { + this.lastIndexedChangesetId = lastIndexedChangesetId; + } + + /** + * @return the lastIndexedTransactionDate + */ + public String getLastIndexedTransactionDate() + { + return this.lastIndexedTransactionDate; + } + + /** + * @param lastIndexedTransactionDate the lastIndexedTransactionDate to set + */ + public void setLastIndexedTransactionDate(String lastIndexedTransactionDate) + { + this.lastIndexedTransactionDate = lastIndexedTransactionDate; + } + + /** + * @return the lastIndexedTransactionId + */ + public Long getLastIndexedTransactionId() + { + return this.lastIndexedTransactionId; + } + + /** + * @param lastIndexedTransactionId the lastIndexedTransactionId to set + */ + public void setLastIndexedTransactionId(Long lastIndexedTransactionId) + { + this.lastIndexedTransactionId = lastIndexedTransactionId; + } + + /** + * @return the lastUpdateDate + */ + public String getLastUpdateDate() + { + return this.lastUpdateDate; + } + + /** + * @param lastUpdateDate the lastUpdateDate to set + */ + public void setLastUpdateDate(String lastUpdateDate) + { + this.lastUpdateDate = lastUpdateDate; + } + + /** + * @return the port + */ + public Integer getPort() + { + return this.port; + } + + /** + * @param port the port to set + */ + public void setPort(Integer port) + { + this.port = port; + } + + /** + * @return the state + */ + public String getState() + { + return this.state; + } + + /** + * @param state the state to set + */ + public void setState(String state) + { + this.state = state; + } + + /** + * @return the mode + */ + public String getMode() + { + return this.mode; + } + + /** + * @param mode the mode to set + */ + public void setMode(String mode) + { + this.mode = mode; + } + + /** + * @return the transactionsRemaining + */ + public Long getTransactionsRemaining() + { + return this.transactionsRemaining; + } + + /** + * @param transactionsRemaining the transactionsRemaining to set + */ + public void setTransactionsRemaining(Long transactionsRemaining) + { + this.transactionsRemaining = transactionsRemaining; + } + + /** + * @return the shardParams + */ + public String getShardParams() + { + return this.shardParams; + } + + /** + * @param shardParams the shardParams to set + */ + public void setShardParams(String shardParams) + { + this.shardParams = shardParams; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFacetFieldModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFacetFieldModel.java new file mode 100644 index 0000000000..f723cb19e5 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFacetFieldModel.java @@ -0,0 +1,234 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'gethin' on '2017-03-23 10:59' 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 RestRequestFacetFieldModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRequestFacetFieldModel model; + + @Override + public RestRequestFacetFieldModel onModel() + { + return model; + } + + public RestRequestFacetFieldModel() + { + super(); + } + + public RestRequestFacetFieldModel(String field) + { + super(); + this.field = field; + } + + public RestRequestFacetFieldModel(String field, String prefix) + { + super(); + this.field = field; + this.prefix = prefix; + } + + public RestRequestFacetFieldModel(String field, String label, Integer minCount) + { + super(); + this.setField(field); + this.setLabel(label); + + if (minCount != null) + { + this.setMincount(minCount); + } + } + + /** + The facet field + */ + + private String field; + /** + A label to include in place of the facet field + */ + + private String label; + /** + Restricts the possible constraints to only indexed values with a specified prefix. + */ + + private String prefix; + + private String sort; + + private String method; + /** + When true, count results that match the query but which have no facet value for the field (in addition to the Term-based constraints). + */ + + private boolean missing; + + private int limit; + + private int offset; + /** + The minimum count required for a facet field to be included in the response. + */ + + private int mincount; + + private int facetEnumCacheMinDf; + /** + Filter Queries with tags listed here will not be included in facet counts. +This is used for multi-select facetting. + + */ + + private List excludeFilters; + + public String getField() + { + return this.field; + } + + public void setField(String field) + { + this.field = field; + } + + public String getLabel() + { + return this.label; + } + + public void setLabel(String label) + { + this.label = label; + } + + public String getPrefix() + { + return this.prefix; + } + + public void setPrefix(String prefix) + { + this.prefix = prefix; + } + + public String getSort() + { + return this.sort; + } + + public void setSort(String sort) + { + this.sort = sort; + } + + public String getMethod() + { + return this.method; + } + + public void setMethod(String method) + { + this.method = method; + } + + public boolean getMissing() + { + return this.missing; + } + + public void setMissing(boolean missing) + { + this.missing = missing; + } + + public int getLimit() + { + return this.limit; + } + + public void setLimit(int limit) + { + this.limit = limit; + } + + public int getOffset() + { + return this.offset; + } + + public void setOffset(int offset) + { + this.offset = offset; + } + + public int getMincount() + { + return this.mincount; + } + + public void setMincount(int mincount) + { + this.mincount = mincount; + } + + public int getFacetEnumCacheMinDf() + { + return this.facetEnumCacheMinDf; + } + + public void setFacetEnumCacheMinDf(int facetEnumCacheMinDf) + { + this.facetEnumCacheMinDf = facetEnumCacheMinDf; + } + + public List getExcludeFilters() + { + return this.excludeFilters; + } + + public void setExcludeFilters(List excludeFilters) + { + this.excludeFilters = excludeFilters; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFacetFieldsModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFacetFieldsModel.java new file mode 100644 index 0000000000..65d09492f5 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFacetFieldsModel.java @@ -0,0 +1,68 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'gethin' on '2017-03-23 10:41' 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 RestRequestFacetFieldsModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRequestFacetFieldsModel model; + + @Override + public RestRequestFacetFieldsModel onModel() + { + return model; + } + + /** + Define specific fields on which to facet (adds SOLR facet.field and f..facet.* options) + + */ + + private List facets; + + public List getFacets() + { + return this.facets; + } + + public void setFacets(List facets) + { + this.facets = facets; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFacetIntervalsModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFacetIntervalsModel.java new file mode 100644 index 0000000000..782e18acef --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFacetIntervalsModel.java @@ -0,0 +1,82 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'gethin' on '2017-03-01 12:12' 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 RestRequestFacetIntervalsModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRequestFacetIntervalsModel model; + + @Override + public RestRequestFacetIntervalsModel onModel() + { + return model; + } + + /** + Sets the intervals for all fields. + */ + + private List sets; + /** + Specifies the fields to facet by interval. + */ + + private List intervals; + + public List getSets() + { + return this.sets; + } + + public void setSets(List sets) + { + this.sets = sets; + } + + public List getIntervals() + { + return this.intervals; + } + + public void setIntervals(List intervals) + { + this.intervals = intervals; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFacetSetModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFacetSetModel.java new file mode 100644 index 0000000000..1b0a0b158c --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFacetSetModel.java @@ -0,0 +1,125 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'gethin' on '2017-03-01 12:12' 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 RestRequestFacetSetModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRequestFacetSetModel model; + + @Override + public RestRequestFacetSetModel onModel() + { + return model; + } + + /** + A label to use to identify the set + */ + + private String label; + /** + The start of the range + */ + + private String start; + /** + The end of the range + */ + + private String end; + /** + When true, the set will include values greater or equal to "start" + */ + + private boolean startInclusive = true; + /** + When true, the set will include values less than or equal to "end" + */ + + private boolean endInclusive = true; + + public String getLabel() + { + return this.label; + } + + public void setLabel(String label) + { + this.label = label; + } + + public String getStart() + { + return this.start; + } + + public void setStart(String start) + { + this.start = start; + } + + public String getEnd() + { + return this.end; + } + + public void setEnd(String end) + { + this.end = end; + } + + public boolean isStartInclusive() + { + return this.startInclusive; + } + + public void setStartInclusive(boolean startInclusive) + { + this.startInclusive = startInclusive; + } + + public boolean isEndInclusive() + { + return this.endInclusive; + } + + public void setEndInclusive(boolean endInclusive) + { + this.endInclusive = endInclusive; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFieldsModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFieldsModel.java new file mode 100644 index 0000000000..7252e9d4ad --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFieldsModel.java @@ -0,0 +1,89 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'msuzuki' on '2017-02-24 09:26' from 'Alfresco Content Services REST API' swagger file + * Generated from 'Alfresco Content Services REST API' swagger file + * Base Path {@linkplain /alfresco/api/-default-/public/search/versions/1} + */ +public class RestRequestFieldsModel extends TestModel implements IRestModel +{ + public RestRequestFieldsModel(){} + + public RestRequestFieldsModel(String fieldValue) + { + this.field = fieldValue; + } + + @JsonProperty(value = "entry") + RestRequestFieldsModel model; + + @Override + public RestRequestFieldsModel onModel() + { + return model; + } + @JsonProperty(required = true) + private String field; + + public String getField() + { + return field; + } + + public void setField(String field) + { + this.field = field; + } + + + +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFilterQueryModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFilterQueryModel.java new file mode 100644 index 0000000000..0077171bc4 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestFilterQueryModel.java @@ -0,0 +1,95 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Hacked together by 'gethin' on '2017-03-23 10:59' from 'Alfresco Search REST API' swagger file + * Base Path {@linkplain /alfresco/api/-default-/public/search/versions/1} + */ +public class RestRequestFilterQueryModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRequestFilterQueryModel model; + + @Override + public RestRequestFilterQueryModel onModel() + { + return model; + } + + public RestRequestFilterQueryModel() + { + super(); + } + + public RestRequestFilterQueryModel(String query) + { + super(); + this.query = query; + } + + public RestRequestFilterQueryModel(String query, List tags) + { + super(); + this.query = query; + this.tags = tags; + } + + /** + The filter query + */ + + private String query; + private List tags; + + public String getQuery() + { + return this.query; + } + + public void setQuery(String query) + { + this.query = query; + } + + public List getTags() + { + return this.tags; + } + + public void setTags(List tags) + { + this.tags = tags; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestHighlightModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestHighlightModel.java new file mode 100644 index 0000000000..1030de6ca6 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestHighlightModel.java @@ -0,0 +1,172 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'msuzuki' on '2017-02-23 13:41' 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 RestRequestHighlightModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRequestHighlightModel model; + + @Override + public RestRequestHighlightModel onModel() + { + return model; + } + + /** + The string used to mark the start of a highlight in a fragment. + */ + + private String prefix; + /** + The string used to mark the end of a highlight in a fragment. + */ + + private String postfix; + /** + The maximum number of distinct highlight snippets to return for each highlight field. + */ + + private int snippetCount; + /** + The character length of each snippet. + */ + + private int fragmentSize; + /** + The number of characters to be considered for highlighting. Matches after this count will not be shown. + */ + + private int maxAnalyzedChars; + /** + If fragments over lap they can be merged into one larger fragment + */ + + private boolean mergeContiguous; + /** + Should phrases be identified. + */ + + private boolean usePhraseHighlighter; + /** + The fields to highlight and field specific configuration properties for each field + */ + + private List fields; + + public String getPrefix() + { + return this.prefix; + } + + public void setPrefix(String prefix) + { + this.prefix = prefix; + } + + public String getPostfix() + { + return this.postfix; + } + + public void setPostfix(String postfix) + { + this.postfix = postfix; + } + + public int getSnippetCount() + { + return this.snippetCount; + } + + public void setSnippetCount(int snippetCount) + { + this.snippetCount = snippetCount; + } + + public int getFragmentSize() + { + return this.fragmentSize; + } + + public void setFragmentSize(int fragmentSize) + { + this.fragmentSize = fragmentSize; + } + + public int getMaxAnalyzedChars() + { + return this.maxAnalyzedChars; + } + + public void setMaxAnalyzedChars(int maxAnalyzedChars) + { + this.maxAnalyzedChars = maxAnalyzedChars; + } + + public boolean getMergeContiguous() + { + return this.mergeContiguous; + } + + public void setMergeContiguous(boolean mergeContiguous) + { + this.mergeContiguous = mergeContiguous; + } + + public boolean getUsePhraseHighlighter() + { + return this.usePhraseHighlighter; + } + + public void setUsePhraseHighlighter(boolean usePhraseHighlighter) + { + this.usePhraseHighlighter = usePhraseHighlighter; + } + + public List getFields() + { + return this.fields; + } + + public void setFields(List fields) + { + this.fields = fields; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestPivotModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestPivotModel.java new file mode 100644 index 0000000000..f088f0f814 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestPivotModel.java @@ -0,0 +1,79 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'gethin' on '2017-03-23 10:07' 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 RestRequestPivotModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRequestPivotModel model; + + @Override + public RestRequestPivotModel onModel() + { + return model; + } + + /** + A key corresponding to a matching field facet label. + */ + + private String key; + + private List pivots; + + public String getKey() + { + return this.key; + } + + public void setKey(String key) + { + this.key = key; + } + + public List getPivots() + { + return this.pivots; + } + + public void setPivots(List pivots) + { + this.pivots = pivots; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestQueryModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestQueryModel.java new file mode 100644 index 0000000000..3138a75c7d --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestQueryModel.java @@ -0,0 +1,98 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'msuzuki' on '2017-02-21 15:39' 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 RestRequestQueryModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRequestQueryModel model; + + @Override + public RestRequestQueryModel onModel() + { + return model; + } + + /** + The query language in which the query is written. + */ + + private String language; + /** + The exact search request typed in by the user + */ + + private String userQuery; + /** + The query which may have been generated in some way from the userQuery + */ + + + @JsonProperty(required = true) + private String query; + + public String getLanguage() + { + return this.language; + } + + public void setLanguage(String language) + { + this.language = language; + } + + public String getUserQuery() + { + return this.userQuery; + } + + public void setUserQuery(String userQuery) + { + this.userQuery = userQuery; + } + + public String getQuery() + { + return this.query; + } + + public void setQuery(String query) + { + this.query = query; + } + +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestStatsModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestStatsModel.java new file mode 100644 index 0000000000..b12d4d4338 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestRequestStatsModel.java @@ -0,0 +1,303 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'gethin' on '2017-05-05 09:54' from 'Alfresco Content Services REST API' swagger file + * Generated from 'Alfresco Content Services REST API' swagger file + * Base Path {@linkplain /alfresco/api/-default-/public/search/versions/1} + */ + +/* + From Jackson 2.8 this annotation is required to make sure that defaults are read from the actual field values, + as opposing to field type defaults. For example, the default for boolean primitive is "false", + but the default for the "min" field in this class is "true". + This configuration does not affect the product and is only related to test framework and how it serializes the request into JSON. + See org.alfresco.utility.model.TestModel#toJson + Note: This change was required for org.alfresco.test.search.functional.searchServices.search.StatsSearchTest + */ +@JsonInclude(JsonInclude.Include.NON_DEFAULT) +public class RestRequestStatsModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestRequestStatsModel model; + + @Override + public RestRequestStatsModel onModel() + { + return model; + } + + /** + The stats field + */ + + private String field; + /** + A label to include for reference the stats field + */ + + private String label; + /** + The minimum value of the field + */ + + private boolean min = true; + /** + The maximum value of the field + */ + + private boolean max = true; + /** + The sum of all values of the field + */ + + private boolean sum = true; + /** + The Number of values found + */ + + private boolean countValues = true; + /** + The Number which do not have a value for this field + */ + + private boolean missing = true; + /** + The average + */ + + private boolean mean = true; + /** + Standard deviation + */ + + private boolean stddev = true; + /** + Sum of all values squared + */ + + private boolean sumOfSquares = true; + /** + The set of all distinct values for the field (This can be very expensive to calculate) + */ + + private boolean distinctValues; + /** + The Number of distinct values (This can be very expensive to calculate) + */ + + private boolean countDistinct; + /** + A statistical approximation of the Number of distinct values + */ + + private boolean cardinality; + /** + Number between 0.0 and 1.0 indicating how aggressively the algorithm should try to be accurate. Used with boolean cardinality flag. + */ + + private Number cardinalityAccuracy; + /** + A list of filters to exclude + */ + + private List excludeFilters; + /** + A list of percentile values, e.g. "1,99,99.9" + */ + + private List percentiles; + + public String getField() + { + return this.field; + } + + public void setField(String field) + { + this.field = field; + } + + public String getLabel() + { + return this.label; + } + + public void setLabel(String label) + { + this.label = label; + } + + public boolean getMin() + { + return this.min; + } + + public void setMin(boolean min) + { + this.min = min; + } + + public boolean getMax() + { + return this.max; + } + + public void setMax(boolean max) + { + this.max = max; + } + + public boolean getSum() + { + return this.sum; + } + + public void setSum(boolean sum) + { + this.sum = sum; + } + + public boolean getCountValues() + { + return this.countValues; + } + + public void setCountValues(boolean countValues) + { + this.countValues = countValues; + } + + public boolean getMissing() + { + return this.missing; + } + + public void setMissing(boolean missing) + { + this.missing = missing; + } + + public boolean getMean() + { + return this.mean; + } + + public void setMean(boolean mean) + { + this.mean = mean; + } + + public boolean getStddev() + { + return this.stddev; + } + + public void setStddev(boolean stddev) + { + this.stddev = stddev; + } + + public boolean getSumOfSquares() + { + return this.sumOfSquares; + } + + public void setSumOfSquares(boolean sumOfSquares) + { + this.sumOfSquares = sumOfSquares; + } + + public boolean getDistinctValues() + { + return this.distinctValues; + } + + public void setDistinctValues(boolean distinctValues) + { + this.distinctValues = distinctValues; + } + + public boolean getCountDistinct() + { + return this.countDistinct; + } + + public void setCountDistinct(boolean countDistinct) + { + this.countDistinct = countDistinct; + } + + public boolean getCardinality() + { + return this.cardinality; + } + + public void setCardinality(boolean cardinality) + { + this.cardinality = cardinality; + } + + public Number getCardinalityAccuracy() + { + return this.cardinalityAccuracy; + } + + public void setCardinalityAccuracy(Number cardinalityAccuracy) + { + this.cardinalityAccuracy = cardinalityAccuracy; + } + + public List getExcludeFilters() + { + return this.excludeFilters; + } + + public void setExcludeFilters(List excludeFilters) + { + this.excludeFilters = excludeFilters; + } + + public List getPercentiles() + { + return this.percentiles; + } + + public void setPercentiles(List percentiles) + { + this.percentiles = percentiles; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestResponseConsistencyModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestResponseConsistencyModel.java new file mode 100644 index 0000000000..81633e30ac --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestResponseConsistencyModel.java @@ -0,0 +1,65 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'msuzuki' on '2017-02-23 11:20' 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 RestResponseConsistencyModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestResponseConsistencyModel model; + + @Override + public RestResponseConsistencyModel onModel() + { + return model; + } + + /** + The id of the last indexed transaction + */ + + private int lastTxId; + + public int getLastTxId() + { + return this.lastTxId; + } + + public void setLastTxId(int lastTxId) + { + this.lastTxId = lastTxId; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestResultBucketsModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestResultBucketsModel.java new file mode 100644 index 0000000000..64fba33743 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestResultBucketsModel.java @@ -0,0 +1,82 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'gethin' on '2017-03-01 12:12' 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 RestResultBucketsModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestResultBucketsModel model; + + @Override + public RestResultBucketsModel onModel() + { + return model; + } + + /** + The field name or its explicit label, if provided on the request + */ + + private String label; + /** + An array of buckets and values + */ + + private List buckets; + + public String getLabel() + { + return this.label; + } + + public void setLabel(String label) + { + this.label = label; + } + + public List getBuckets() + { + return this.buckets; + } + + public void setBuckets(List buckets) + { + this.buckets = buckets; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestResultSetContextModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestResultSetContextModel.java new file mode 100644 index 0000000000..627a43ff58 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestResultSetContextModel.java @@ -0,0 +1,141 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * Generated by 'gethin' on '2017-03-01 14:46' 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 RestResultSetContextModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + RestResultSetContextModel model; + + @Override + public RestResultSetContextModel onModel() + { + return model; + } + + + private RestResponseConsistencyModel consistency; + /** + The counts from facet queries + */ + + private List facetQueries; + /** + The counts from field facets + */ + + private List facetsFields; + /** + The counts from facet intervals + */ + + private List facets; + /** + Suggested corrections + +If zero results were found for the original query then a single entry of type "searchInsteadFor" will be returned. +If alternatives were found that return more results than the original query they are returned as "didYouMean" options. +The highest quality suggestion is first. + + */ + + private SpellCheckModel spellCheck; + + private SearchRequest request; + + public RestResponseConsistencyModel getConsistency() + { + return this.consistency; + } + + public void setConsistency(RestResponseConsistencyModel consistency) + { + this.consistency = consistency; + } + + public List getFacetQueries() + { + return this.facetQueries; + } + + public void setFacetQueries(List facetQueries) + { + this.facetQueries = facetQueries; + } + + public List getFacetsFields() + { + return this.facetsFields; + } + + public void setFacetsFields(List facetsFields) + { + this.facetsFields = facetsFields; + } + + public List getFacets() + { + return this.facets; + } + + public void setFacets(List facets) + { + this.facets = facets; + } + + public SpellCheckModel getSpellCheck() + { + return this.spellCheck; + } + + public void setSpellCheck(SpellCheckModel spellCheck) + { + this.spellCheck = spellCheck; + } + + public SearchRequest getRequest() + { + return request; + } + + public void setRequest(SearchRequest request) + { + this.request = request; + } +} + diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestShardInfoModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestShardInfoModel.java new file mode 100644 index 0000000000..0de0c73f42 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestShardInfoModel.java @@ -0,0 +1,354 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2005-2018 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +/** + * POJO representing shard info model + * + * @author Tuna Aksoy + */ +public class RestShardInfoModel extends TestModel implements IRestModel +{ + /** Model */ + @JsonProperty(value = "entry") + RestShardInfoModel model; + + /** + * @see org.alfresco.rest.core.IRestModel#onModel() + */ + @Override + public RestShardInfoModel onModel() + { + return model; + } + + /** + * @return the model + */ + public RestShardInfoModel getModel() + { + return this.model; + } + + /** + * @param model the model to set + */ + public void setModel(RestShardInfoModel model) + { + this.model = model; + } + + /** Template */ + private String template; + + /** Low instance shards */ + private String lowInstanceShards; + + /** Missing shards */ + private String missingShards; + + /** Max repository transaction Id */ + private Long maxRepositoryTransactionId; + + /** Max live instances */ + private Integer maxLiveInstances; + + /** Remaining Transactions */ + private Long remainingTransactions; + + /** Number of shards */ + private Integer numberOfShards; + + /** Min active instances */ + private Integer minActiveInstances; + + /** Max change set Id */ + private Long maxChangesetId; + + /** Mode */ + private String mode; + + /** Stores */ + private String stores; + + /** Has content */ + private Boolean hasContent; + + /** Shard method */ + private String shardMethod; + + /** Shards */ + private List shards; + + /** + * @return the template + */ + public String getTemplate() + { + return this.template; + } + + /** + * @param template the template to set + */ + public void setTemplate(String template) + { + this.template = template; + } + + /** + * @return the lowInstanceShards + */ + public String getLowInstanceShards() + { + return this.lowInstanceShards; + } + + /** + * @param lowInstanceShards the lowInstanceShards to set + */ + public void setLowInstanceShards(String lowInstanceShards) + { + this.lowInstanceShards = lowInstanceShards; + } + + /** + * @return the missingShards + */ + public String getMissingShards() + { + return this.missingShards; + } + + /** + * @param missingShards the missingShards to set + */ + public void setMissingShards(String missingShards) + { + this.missingShards = missingShards; + } + + /** + * @return the maxRepositoryTransactionId + */ + public Long getMaxRepositoryTransactionId() + { + return this.maxRepositoryTransactionId; + } + + /** + * @param maxRepositoryTransactionId the maxRepositoryTransactionId to set + */ + public void setMaxRepositoryTransactionId(Long maxRepositoryTransactionId) + { + this.maxRepositoryTransactionId = maxRepositoryTransactionId; + } + + /** + * @return the maxLiveInstances + */ + public Integer getMaxLiveInstances() + { + return this.maxLiveInstances; + } + + /** + * @param maxLiveInstances the maxLiveInstances to set + */ + public void setMaxLiveInstances(Integer maxLiveInstances) + { + this.maxLiveInstances = maxLiveInstances; + } + + /** + * @return the remainingTransactions + */ + public Long getRemainingTransactions() + { + return this.remainingTransactions; + } + + /** + * @param remainingTransactions the remainingTransactions to set + */ + public void setRemainingTransactions(Long remainingTransactions) + { + this.remainingTransactions = remainingTransactions; + } + + /** + * @return the numberOfShards + */ + public Integer getNumberOfShards() + { + return this.numberOfShards; + } + + /** + * @param numberOfShards the numberOfShards to set + */ + public void setNumberOfShards(Integer numberOfShards) + { + this.numberOfShards = numberOfShards; + } + + /** + * @return the minActiveInstances + */ + public Integer getMinActiveInstances() + { + return this.minActiveInstances; + } + + /** + * @param minActiveInstances the minActiveInstances to set + */ + public void setMinActiveInstances(Integer minActiveInstances) + { + this.minActiveInstances = minActiveInstances; + } + + /** + * @return the maxChangesetId + */ + public Long getMaxChangesetId() + { + return this.maxChangesetId; + } + + /** + * @param maxChangesetId the maxChangesetId to set + */ + public void setMaxChangesetId(Long maxChangesetId) + { + this.maxChangesetId = maxChangesetId; + } + + /** + * @return the mode + */ + public String getMode() + { + return this.mode; + } + + /** + * @param mode the mode to set + */ + public void setMode(String mode) + { + this.mode = mode; + } + + /** + * @return the stores + */ + public String getStores() + { + return this.stores; + } + + /** + * @param stores the stores to set + */ + public void setStores(String stores) + { + this.stores = stores; + } + + /** + * @return the hasContent + */ + public Boolean getHasContent() + { + return this.hasContent; + } + + /** + * @param hasContent the hasContent to set + */ + public void setHasContent(Boolean hasContent) + { + this.hasContent = hasContent; + } + + /** + * @return the shardMethod + */ + public String getShardMethod() + { + return this.shardMethod; + } + + /** + * @param shardMethod the shardMethod to set + */ + public void setShardMethod(String shardMethod) + { + this.shardMethod = shardMethod; + } + + /** + * @return the shards + */ + public List getShards() + { + return this.shards; + } + + /** + * @param shards the shards to set + */ + public void setShards(List shards) + { + this.shards = shards; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestShardInfoModelCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestShardInfoModelCollection.java new file mode 100644 index 0000000000..a3d2c87208 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestShardInfoModelCollection.java @@ -0,0 +1,55 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2005-2018 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import org.alfresco.rest.core.RestModels; + +/** + * Object that represent shard info response collection. + * + * @author Tuna Aksoy + */ +public class RestShardInfoModelCollection extends RestModels +{ +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestShardModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestShardModel.java new file mode 100644 index 0000000000..f7d56b759a --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/RestShardModel.java @@ -0,0 +1,73 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2005-2018 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import java.util.List; + +/** + * Representation of a shard + * + * @author Tuna Aksoy + */ +public class RestShardModel +{ + /** Shard instances */ + private List instances; + + /** + * @return the instances + */ + public List getInstances() + { + return this.instances; + } + + /** + * @param instances the instances to set + */ + public void setInstances(List instances) + { + this.instances = instances; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchNodeModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchNodeModel.java new file mode 100644 index 0000000000..86215aedb1 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchNodeModel.java @@ -0,0 +1,330 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import java.util.List; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.rest.model.RestByUserModel; +import org.alfresco.rest.model.RestContentModel; +import org.alfresco.utility.model.TestModel; +/** + * Object that represent search response entry. + * @author Michael Suzuki + * + */ +public class SearchNodeModel extends TestModel implements IRestModel +{ + @JsonProperty(value = "entry") + SearchNodeModel model; + @JsonProperty(required = true) + private SearchScoreModel search; + @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; + + @JsonProperty + private Boolean isLocked; + + @JsonProperty + private Map association; + + @JsonProperty(required = true) + private String modifiedAt; + + @JsonProperty(required = true) + private RestByUserModel modifiedByUser; + + @JsonProperty(required = true) + private String createdAt; + + @JsonProperty(required = true) + private RestByUserModel createdByUser; + + private String parentId; + + private Boolean isLink; + + private RestContentModel content; + + private List aspectNames; + + private Object properties; + + private List allowableOperations; + + private Object path; + + @JsonProperty + private Object permissions; + + private String location; + + public Map getAssociation() + { + return association; + } + + public void setAssociation(Map association) + { + this.association = association; + } + + public SearchScoreModel getSearch() + { + return search; + } + + public void setSearch(SearchScoreModel search) + { + this.search = search; + } + + @Override + public SearchNodeModel onModel() + { + return model; + } + + public SearchNodeModel getModel() + { + return model; + } + + public void setModel(SearchNodeModel 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 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 setIsLink(Boolean isLink) + { + this.isLink = isLink; + } + + public RestContentModel getContent() + { + return content; + } + + public void setContent(RestContentModel content) + { + this.content = content; + } + + public List getAspectNames() + { + return aspectNames; + } + + public void setAspectNames(List aspectNames) + { + this.aspectNames = aspectNames; + } + + public Object getProperties() + { + return properties; + } + + public void setProperties(Object properties) + { + this.properties = properties; + } + + public List getAllowableOperations() + { + return allowableOperations; + } + + public void setAllowableOperations(List 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 String getLocation() + { + return location; + } + + public void setLocation(String location) + { + this.location = location; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchNodeModelsCollection.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchNodeModelsCollection.java new file mode 100644 index 0000000000..d81dbd97e3 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchNodeModelsCollection.java @@ -0,0 +1,37 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.search; + +import org.alfresco.rest.core.RestModels; +/** + * Object that represent search response collection. + * @author Michael Suzuki + * + */ +public class SearchNodeModelsCollection extends RestModels +{ + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchRequest.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchRequest.java new file mode 100644 index 0000000000..33539f899a --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchRequest.java @@ -0,0 +1,282 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.alfresco.rest.model.RestRequestRangesModel; +import org.alfresco.rest.model.RestRequestSpellcheckModel; +import org.alfresco.utility.model.TestModel; + +import java.util.ArrayList; +import java.util.List; + +/** + * Search Query object. + * @author msuzuki + * + */ +public class SearchRequest extends TestModel +{ + @JsonProperty(value = "query") + RestRequestQueryModel query; + String language; + Pagination paging; + List fields; + RestRequestHighlightModel highlight; + RestRequestFilterQueryModel filterQueries; + RestRequestFacetFieldsModel facetFields; + RestRequestFacetIntervalsModel facetIntervals; + List facetQueries; + RestRequestSpellcheckModel spellcheck; + Boolean includeRequest = false; + List pivots; + List stats; + List ranges; + String facetFormat; + List include; + List sort; + + public SearchRequest() + { + } + + public SearchRequest(RestRequestQueryModel query) + { + this.query = query; + } + public SearchRequest(RestRequestQueryModel query,RestRequestHighlightModel highlight) + { + this.query = query; + this.highlight = highlight; + } + + public RestRequestQueryModel getQuery() + { + return query; + } + + public void setQuery(RestRequestQueryModel query) + { + this.query = query; + } + + public String getLanguage() + { + return language; + } + + public void setLanguage(String language) + { + this.language = language; + } + + /** + * Returns the include options in this request. + * + * @return the include options in this request. + */ + public List getInclude() + { + return include; + } + + /** + * Sets the include options within this request. + * + * @param options the include options. + */ + public void setInclude(final List options) + { + this.include = options; + } + + public RestRequestHighlightModel getHighlight() + { + return highlight; + } + public void setHighlight(RestRequestHighlightModel highlight) + { + this.highlight = highlight; + } + + public RestRequestFacetFieldsModel getFacetFields() + { + return facetFields; + } + public void setFacetFields(RestRequestFacetFieldsModel facetFields) + { + this.facetFields = facetFields; + } + public List getFacetQueries() + { + return facetQueries; + } + public void setFacetQueries(List facetQueries) + { + this.facetQueries = facetQueries; + } + + public RestRequestFacetIntervalsModel getFacetIntervals() + { + return facetIntervals; + } + + public void setFacetIntervals(RestRequestFacetIntervalsModel facetIntervals) + { + this.facetIntervals = facetIntervals; + } + + public RestRequestSpellcheckModel getSpellcheck() + { + return spellcheck; + } + public void setSpellcheck(RestRequestSpellcheckModel spellcheck) + { + this.spellcheck = spellcheck; + } + + public Boolean getIncludeRequest() + { + return includeRequest; + } + + public void setIncludeRequest(Boolean includeRequest) + { + this.includeRequest = includeRequest; + } + + public List getPivots() + { + return pivots; + } + + public void setPivots(List pivots) + { + this.pivots = pivots; + } + + public List getStats() + { + return stats; + } + + public void setStats(List stats) + { + this.stats = stats; + } + + public Pagination getPaging() + { + return paging; + } + + public void setPaging(Pagination paging) + { + this.paging = paging; + } + + public RestRequestFilterQueryModel getFilterQueries() + { + return filterQueries; + } + + public void setFilterQueries(RestRequestFilterQueryModel filterQueries) + { + this.filterQueries = filterQueries; + } + public List getRanges() + { + return ranges; + } + + public void setRanges(List ranges) + { + this.ranges = ranges; + } + + public String getFacetFormat() + { + return facetFormat; + } + + public void setFacetFormat(String facetFormat) + { + this.facetFormat = facetFormat; + } + + public List getFields() + { + return fields; + } + + public void setFields(List fields) + { + this.fields = fields; + } + + public List getSort() + { + if (sort == null) + { + sort = new ArrayList<>(); + } + return sort; + } + + /** + * Adds a new sort clause to this request. + * The method uses a fluent approach and it returns the same {@link SearchRequest} instance. + * + * @param type the sort clause type (e.g. FIELD) + * @param fieldname the field name. + * @param ascending the sort criterion. + * @return this {@link SearchRequest} instance. + */ + public SearchRequest addSortClause(String type, String fieldname, boolean ascending) + { + getSort().add(SortClause.from(type, fieldname, ascending)); + + return this; + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchResponse.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchResponse.java new file mode 100644 index 0000000000..1bc83cb3e7 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchResponse.java @@ -0,0 +1,78 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import org.alfresco.rest.core.RestModels; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Search response sample. + * {"list": { + * "entries": [], + * "pagination": { + * "maxItems": 100, + * "hasMoreItems": false, + * "totalItems": 0, + * "count": 0, + * "skipCount": 0 + * }, + * "context": {"consistency": {"lastTxId": 1123}} + * }} + **/ +public class SearchResponse extends RestModels +{ + @JsonProperty(value = "entry") + SearchResponse model; + private RestResultSetContextModel context; + public RestResultSetContextModel getContext() + { + return context; + } + public void setContext(RestResultSetContextModel context) + { + this.context = context; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchScoreModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchScoreModel.java new file mode 100644 index 0000000000..59269cfc78 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchScoreModel.java @@ -0,0 +1,91 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; +/** + * Object that represents the search score. + * @author Michael Suzuki + * + */ +public class SearchScoreModel extends TestModel implements IRestModel +{ + + @JsonProperty(required = true) + private float score; + + private List highlight; + + public float getScore() + { + return score; + } + + public void setScore(float score) + { + this.score = score; + } + + @Override + public SearchScoreModel onModel() + { + return this; + } + + public List getHighlight() + { + return highlight; + } + + public void setHighlight(List highlight) + { + this.highlight = highlight; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchSqlJDBCRequest.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchSqlJDBCRequest.java new file mode 100644 index 0000000000..ea24563fe3 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchSqlJDBCRequest.java @@ -0,0 +1,136 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.Statement; +import org.alfresco.utility.model.TestModel; +import org.alfresco.utility.model.UserModel; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Search SQL Query object for JDBC connection. + * + * @author Meenal Bhave + * + * Request POST + * End point: /sql + * PostBody: + * { + * "stmt":"Select SITE from alfresco where SITE = 'swsdp' limit 2" + * } + */ +public class SearchSqlJDBCRequest extends TestModel +{ + @JsonProperty(required = true) + + String sql; + Connection connection; + Statement stmt; + ResultSet resultSet; + UserModel authUser; + String errorDetails; + + public String getSql() + { + return sql; + } + + public void setSql(String sql) + { + this.sql = sql; + } + + public Statement getStmt() + { + return stmt; + } + + public void setStmt(Statement stmt) + { + this.stmt = stmt; + } + + public Connection getConnection() + { + return connection; + } + + public void setConnection(Connection con) + { + this.connection = con; + } + + public ResultSet getResultSet() + { + return resultSet; + } + + public void setResultSet(ResultSet rs) + { + this.resultSet = rs; + } + + public UserModel getAuthUser() + { + return authUser; + } + + public void setAuthUser(UserModel usermodel) + { + this.authUser = usermodel; + } + + public String getErrorDetails() + { + return errorDetails; + } + + public void setErrorDetails(String errorDetails) + { + this.errorDetails = errorDetails; + } + + public SearchSqlJDBCRequest() + { + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchSqlRequest.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchSqlRequest.java new file mode 100644 index 0000000000..96e3351d6d --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SearchSqlRequest.java @@ -0,0 +1,149 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2018 Alfresco Software Limited. + * This file is part of Alfresco + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.alfresco.utility.model.TestModel; + +/** + * Search SQL Query object. + * + * @author Meenal Bhave + * + * Request POST + * End point: /sql + * PostBody: + * { + * "stmt":"Select SITE from alfresco where SITE = 'swsdp' limit 2", + * "locales":["en-Uk"], + * "timezone":"Israel", + * "includeMetadata":true, + * "format":"solr", + * "limit":100, + * "filterQueries":["-ASPECT:ASPECT_CLASSIFIED"] + * } + */ +public class SearchSqlRequest extends TestModel +{ + @JsonProperty(required = true) + String stmt; + + String[] locales; + String timezone; + Boolean includeMetadata; + String format; + Integer limit; + String[] filterQueries; + + public String getSql() + { + return stmt; + } + + public void setSql(String sql) + { + this.stmt = sql; + } + + public String[] getLocales() + { + return locales; + } + + public void setLocales(String[] locales) + { + this.locales = locales; + } + + public String getTimezone() + { + return timezone; + } + + public void setTimezone(String timezone) + { + this.timezone = timezone; + } + + public Boolean getIncludeMetadata() + { + return includeMetadata; + } + + public void setIncludeMetadata(Boolean includeMetadata) + { + this.includeMetadata = includeMetadata; + } + + public String getFormat() + { + return format; + } + + public void setFormat(String format) + { + this.format = format; + } + + public Integer getLimit() + { + return limit; + } + + public void setLimit(Integer limit) + { + this.limit = limit; + } + + public String[] getFilterQueries() + { + return filterQueries; + } + + public void setFilterQuery(String[] filterQueries) + { + this.filterQueries = filterQueries; + } + + public SearchSqlRequest() + { + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SortClause.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SortClause.java new file mode 100644 index 0000000000..3e6f738262 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SortClause.java @@ -0,0 +1,122 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Object representation of a single sort clause. + * + *
+ *  "sort": [
+ *     {
+ *       "type": "FIELD",
+ *       "field": "string",
+ *       "ascending": false
+ *     }
+ *   ]
+ * 
+ */ +public class SortClause +{ + + private String type; + private String field; + private boolean ascending; + + public SortClause() + { + } + + @JsonCreator + public SortClause(@JsonProperty("type") String type, + @JsonProperty("field") String field, + @JsonProperty("ascending") boolean ascending) + { + this.type = type; + this.field = field; + this.ascending = ascending; + } + + public String getType() + { + return type; + } + + public String getField() + { + return field; + } + + public boolean isAscending() + { + return ascending; + } + + public void setType(String type) { + this.type = type; + } + + public void setField(String field) { + this.field = field; + } + + public void setAscending(boolean ascending) { + this.ascending = ascending; + } + + /** + * Shortcut method for creating a sort clause. + * + * @param type the sort type (e.g. FIELD) + * @param fieldname the field name. + * @param ascending ascending (true) or descending (false). + * @return a new {@link SortClause} instance. + */ + public static SortClause from(String type, String fieldname, boolean ascending) + { + return new SortClause(type, fieldname, ascending); + } +} diff --git a/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SpellCheckModel.java b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SpellCheckModel.java new file mode 100644 index 0000000000..6c8e91d416 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/java/org/alfresco/rest/search/SpellCheckModel.java @@ -0,0 +1,89 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +/* + * Copyright (C) 2017 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.rest.search; + +import java.util.List; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; +/** + * Object that represents the spell check model response. + * @author Michael Suzuki + * + */ +public class SpellCheckModel extends TestModel implements IRestModel +{ + + private String type; + + private List suggestions; + + public String getType() + { + return type; + } + + public void setType(String type) + { + this.type = type; + } + + public List getSuggestions() + { + return suggestions; + } + + public void setSuggestions(List suggestions) + { + this.suggestions = suggestions; + } + + @Override + public SpellCheckModel onModel() + { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/packaging/tests/tas-restapi/src/main/resources/alfresco-restapi-context.xml b/packaging/tests/tas-restapi/src/main/resources/alfresco-restapi-context.xml new file mode 100644 index 0000000000..7d492e69f2 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/resources/alfresco-restapi-context.xml @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/packaging/tests/tas-restapi/src/main/resources/default.properties b/packaging/tests/tas-restapi/src/main/resources/default.properties new file mode 100644 index 0000000000..268003078d --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/resources/default.properties @@ -0,0 +1,88 @@ +# dataprep related +alfresco.scheme=http +alfresco.server=localhost +alfresco.port=8081 + +# sync service related +sync.scheme=http +sync.server=localhost +sync.port=9090 + +# Solr Server Settings +solr.scheme=http +solr.server=localhost +solr.port=8083 + +#Solr Indexing Time +solrWaitTimeInSeconds=20 + +# credentials +admin.user=admin +admin.password=admin + +# Identity Service configuration +# set this property to run tests using AIS +# identity-service.auth-server-url=http://localhost:8999/auth + +# in containers we cannot access directly JMX, so we will use http://jolokia.org agent +# disabling this we will use direct JMX calls to server +jmx.useJolokiaAgent=false + +# Server Health section +# in ServerHealth#isServerReachable() - could also be shown. +# enable this option to view if on server there are tenants or not +serverHealth.showTenants=false + +# TEST MANAGEMENT SECTION - Test Rail +# +# (currently supporting Test Rail v5.2.1.3472 integration) +# +# Example of configuration: +# ------------------------------------------------------ +# if testManagement.enabled=true we enabled TestRailExecutorListener (if used in your suite xml file) +# testManagement.updateTestExecutionResultsOnly=true (this will just update the results of a test: no step will be updated - good for performance) +# testManagement.endPoint=https://alfresco.testrail.com/ +# testManagement.username= +# testManagement.apiKey= +# testManagement.project= +# testManagement.includeOnlyTestCasesExecuted=true #if you want to include in your run ONLY the test cases that you run, then set this value to false +# testManagement.rateLimitInSeconds=1 #is the default rate limit after what minimum time, should we upload the next request. http://docs.gurock.com/testrail-api2/introduction #Rate Limit +# testManagement.suiteId=23 (the id of the Master suite) +# ------------------------------------------------------ +testManagement.enabled=false +testManagement.endPoint=https://alfresco.testrail.com/ +testManagement.username= +testManagement.apiKey= +testManagement.project= +testManagement.includeOnlyTestCasesExecuted=true +testManagement.rateLimitInSeconds=1 +testManagement.testRun=MyTestRunInTestRail +testManagement.suiteId=12 + +# The location of the reports path +reports.path=./target/reports + +# +# Database Section +# You should provide here the database URL, that can be a differed server as alfresco. +# https://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html +# +# Current supported db.url: +# +# MySQL: +# db.url = jdbc:mysql://${alfresco.server}:3306/alfresco +# +# PostgreSQL: +# db.url = jdbc:postgresql://:3306/alfresco +# +# Oracle: +# db.url = jdbc:oracle://:3306/alfresco +# +# MariaDB: +# db.url = jdbc:mariadb://:3306/alfresco +# +db.url = jdbc:mysql://${alfresco.server}:3306/alfresco +db.username = alfresco +db.password = alfresco + diff --git a/packaging/tests/tas-restapi/src/main/resources/log4j.properties b/packaging/tests/tas-restapi/src/main/resources/log4j.properties new file mode 100644 index 0000000000..00e9b5a114 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/resources/log4j.properties @@ -0,0 +1,26 @@ +# Root logger option +log4j.rootLogger=INFO, file, stdout + +# Direct log messages to a log file +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=./target/reports/alfresco-tas.log +log4j.appender.file.MaxBackupIndex=10 +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n + +# Direct log messages to stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n + +# TestRail particular log file +# Direct log messages to a log file +log4j.appender.testrailLog=org.apache.log4j.RollingFileAppender +log4j.appender.testrailLog.File=./target/reports/alfresco-testrail.log +log4j.appender.testrailLog.MaxBackupIndex=10 +log4j.appender.testrailLog.layout=org.apache.log4j.PatternLayout +log4j.appender.testrailLog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n + +log4j.category.testrail=INFO, testrailLog +log4j.additivity.testrail=false \ No newline at end of file diff --git a/packaging/tests/tas-restapi/src/main/resources/rest-model.ftl b/packaging/tests/tas-restapi/src/main/resources/rest-model.ftl new file mode 100644 index 0000000000..ed309b4726 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/resources/rest-model.ftl @@ -0,0 +1,55 @@ +package org.alfresco.rest.model; + +import java.util.List; + +import org.alfresco.rest.core.IRestModel; +import org.alfresco.utility.model.TestModel; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Generated by '${author}' on '${date}' from '${yamlTitle}' swagger file + * Generated from '${yamlTitle}' swagger file + * Base Path {@linkplain ${yamlBasePath}} + */ +public class ${name} extends TestModel implements IRestModel<${name}> +{ + @JsonProperty(value = "entry") + ${name} model; + + @Override + public ${name} onModel() + { + return model; + } + +<#if properties??> +<#list properties as p> + <#if p.getDescription()??> + /** + ${p.getDescription()} + */ + + + <#if p.isRequired()==true> + @JsonProperty(required = true) + + private ${p.getType()} ${p.getName()}; + + +<#if properties??> +<#list properties as p> + + public ${p.getType()} get${p.getNameCapitalized()}() + { + return this.${p.getName()}; + } + + public void set${p.getNameCapitalized()}(${p.getType()} ${p.getName()}) + { + this.${p.getName()} = ${p.getName()}; + } + + +} + diff --git a/packaging/tests/tas-restapi/src/main/resources/rest-request.ftl b/packaging/tests/tas-restapi/src/main/resources/rest-request.ftl new file mode 100644 index 0000000000..d964ff7852 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/resources/rest-request.ftl @@ -0,0 +1,12 @@ + public RestReturnedModel ${operationId}() throws Exception + { +<#if httpMethod == "POST"> + RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, "add-here-json-post-body-u-can-use-JsonBodyGenerator-or-generate-the-model-for-further-use", "${pathUrl}"); +<#elseif httpMethod == "DELETE"> + RestRequest request = RestRequest.simpleRequest(HttpMethod.DELETE, "${pathUrl}"); +<#else> + RestRequest request = RestRequest.simpleRequest(HttpMethod.${httpMethod}, "${pathUrl}?{parameters}", "add-1st-argument-here-or-remove-this", restWrapper.getParameters()); + + return restWrapper.processModel(RestReturnedModel.class, request); + } +------------------------------------------------------------ diff --git a/packaging/tests/tas-restapi/src/main/resources/tas-demo-suite.xml b/packaging/tests/tas-restapi/src/main/resources/tas-demo-suite.xml new file mode 100644 index 0000000000..a49a428347 --- /dev/null +++ b/packaging/tests/tas-restapi/src/main/resources/tas-demo-suite.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/core/RestRequestUnitTest.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/core/RestRequestUnitTest.java new file mode 100644 index 0000000000..cd99468495 --- /dev/null +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/core/RestRequestUnitTest.java @@ -0,0 +1,129 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.core; + +import static org.alfresco.rest.core.RestRequest.requestWithBody; +import static org.alfresco.rest.core.RestRequest.simpleRequest; +import static org.springframework.http.HttpMethod.GET; +import static org.springframework.http.HttpMethod.POST; +import static org.testng.Assert.assertEquals; + +import java.util.MissingFormatArgumentException; + +import io.restassured.RestAssured; +import org.testng.annotations.Test; + +/** Unit tests for {@link RestRequest}. */ +public class RestRequestUnitTest +{ + @Test + public void testSimpleRequest_emptyPathAndParams() + { + RestRequest restRequest = simpleRequest(GET, ""); + + assertEquals(restRequest.getPath(), "", "Unexpected path"); + } + + @Test + public void testSimpleRequest_pathWithEqualParamsAndGroups() + { + RestRequest restRequest = simpleRequest(GET, "nodes/{nodeId}", "nodeId"); + + assertEquals(restRequest.getPath(), "nodes/{nodeId}", "Unexpected path"); + } + + @Test + public void testSimpleRequest_pathWithMoreParamsThanGroups() + { + RestRequest restRequest = simpleRequest(GET, "nodes/{nodeId}", "nodeId", "key1=value1", "key2=value2"); + + assertEquals(restRequest.getPath(), "nodes/{nodeId}?{parameter0}&{parameter1}", "Unexpected path"); + } + + @Test(expectedExceptions = MissingFormatArgumentException.class) + public void testSimpleRequest_pathWithFewerParamsThanGroups() + { + simpleRequest(GET, "nodes/{nodeId}"); + } + + @Test + public void testSetPath() + { + RestRequest restRequest = simpleRequest(GET, "nodes/{nodeId}", "nodeId"); + + restRequest.setPath("nodes"); + + assertEquals(restRequest.getPath(), "nodes?{parameter0}", "Unexpected path"); + } + + @Test + public void testSetPathParams() + { + RestRequest restRequest = simpleRequest(GET, "nodes/{nodeId}", "nodeId"); + + Object[] pathParams = {"nodeId", "key=value"}; + restRequest.setPathParams(pathParams); + + assertEquals(restRequest.getPath(), "nodes/{nodeId}?{parameter0}", "Unexpected path"); + } + + @Test + public void testRequestWithBody_pathWithEqualParamsAndGroups() + { + RestRequest restRequest = requestWithBody(POST, "BODY", "nodes/{nodeId}", "nodeId"); + + assertEquals(restRequest.getPath(), "nodes/{nodeId}", "Unexpected path"); + } + + @Test + public void testRequestWithBody_pathWithMoreParamsThanGroups() + { + RestRequest restRequest = requestWithBody(GET, "BODY", "nodes/{nodeId}", "nodeId", "key1=value1", "key2=value2"); + + assertEquals(restRequest.getPath(), "nodes/{nodeId}?{parameter0}&{parameter1}", "Unexpected path"); + } + + @Test (expectedExceptions = MissingFormatArgumentException.class) + public void testRequestWithBody_pathWithFewerParamsThanGroups() + { + requestWithBody(POST, "BODY", "nodes/{nodeId}"); + } + + @Test + public void testToString() + { + RestAssured.baseURI = "BASE"; + RestAssured.port = 1234; + RestAssured.basePath = "BASE_PATH"; + + RestRequest restRequest = requestWithBody(GET, "BODY", "nodes/{nodeId}", "nodeId", "key1=value1", "key2=value2"); + + String expected = "Request: GET BASE:1234/BASE_PATH/nodes/nodeId?key1=value1&key2=value2\nbody:BODY\n"; + assertEquals(restRequest.toString(), expected, "Unexpected toString representation"); + + RestAssured.reset(); + } +} diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/core/RestWrapperUnitTest.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/core/RestWrapperUnitTest.java new file mode 100644 index 0000000000..0002dada1a --- /dev/null +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/core/RestWrapperUnitTest.java @@ -0,0 +1,77 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.core; + +import static org.testng.Assert.assertEquals; + +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** Unit tests for {@link RestWrapper}. */ +public class RestWrapperUnitTest +{ + private RestWrapper restWrapper; + + @BeforeMethod + public void setUp() + { + restWrapper = new RestWrapper(); + } + + @Test + public void testWithParams_noParams() + { + restWrapper.withParams(); + + assertEquals(restWrapper.getParameters(), "", "Expected empty parameters"); + } + + @Test + public void testWithParams_singleParam() + { + restWrapper.withParams("param=value"); + + assertEquals(restWrapper.getParameters(), "param=value", "Unexpected parameter string"); + } + + @Test + public void testWithParams_multipleParams() + { + restWrapper.withParams("param1=value1", "param2=value2"); + + assertEquals(restWrapper.getParameters(), "param1=value1¶m2=value2", "Unexpected parameter string"); + } + + @Test + public void testWithParams_lastValueWins() + { + // The first call should be overwritten by the second. + restWrapper.withParams("param1=value1"); + restWrapper.withParams("param2=value2"); + + assertEquals(restWrapper.getParameters(), "param2=value2", "Unexpected parameter string"); + } +} diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java index 72e702ec88..14c7857810 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/favorites/GetFavoriteSiteTests.java @@ -1,5 +1,7 @@ package org.alfresco.rest.favorites; +import java.util.UUID; + import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.SiteService; import org.alfresco.rest.RestTest; @@ -189,13 +191,13 @@ public class GetFavoriteSiteTests extends RestTest sites.assertThat().entriesListIsNotEmpty(); } - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, - description = "Verify invalid request returns status 401 when user is empty") - public void getFavoriteSiteWithEmptyPersonId() throws Exception + @Test (groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail (section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, + description = "Verify invalid request returns status 401 when user does not exist") + public void getFavoriteSiteWithFictionalPersonId() { - UserModel emptyUser = new UserModel("", "password"); - restClient.authenticateUser(emptyUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); + UserModel fictionalUser = new UserModel("FictionalUser" + UUID.randomUUID(), "password"); + restClient.authenticateUser(fictionalUser).withCoreAPI().usingAuthUser().getFavoriteSite(siteModel1); restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); } diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/model/ModelAssertionUnitTest.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/model/ModelAssertionUnitTest.java new file mode 100644 index 0000000000..24c5762f7a --- /dev/null +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/model/ModelAssertionUnitTest.java @@ -0,0 +1,357 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.model; + +import static com.google.common.collect.Sets.newHashSet; + +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import com.google.common.collect.ImmutableMap; + +import org.alfresco.rest.core.IRestModel; +import org.testng.annotations.Test; + +public class ModelAssertionUnitTest +{ + private static final String DEFAULT_ID = "1234"; + private static final String DEFAULT_NAME = "test"; + + @Test(groups = "unit") + public void iCanAssertExistingProperty() { + Person p = new Person(DEFAULT_ID); + p.assertThat().field("id").is("1234"); + } + + @Test(groups = "unit") + public void iCanAssertExistingPropertyNegative() { + Person p = new Person(DEFAULT_ID); + p.assertThat().field("id").isNot("12342"); + RestPersonModel rp = new RestPersonModel(); + + rp.getFirstName(); + } + + @Test(groups = "unit", expectedExceptions = AssertionError.class) + public void iHaveOneExceptionThrownWithSelfExplanatoryMessageOnMissingField() { + Person p = new Person(); + p.assertThat().field("id2").is("12342"); + + } + + @Test(groups = "unit") + public void iCanTakeTheValueOfFieldsThatDoesntHaveGetters() { + Person p = new Person(DEFAULT_ID, DEFAULT_NAME); + + p.assertThat().field("name").is("test"); + + } + + @Test(groups = "unit") + public void iCanAssertStringIsEmpty() { + Person p = new Person(DEFAULT_ID); + + // Check no exception when field is empty. + p.assertThat().field("nickname").isEmpty(); + + try { + p.assertThat().field("id").isEmpty(); + fail("Expected exception to be raised."); + } catch (AssertionError e) { + assertTrue(e.getMessage().contains("is NOT empty"), "Expected exception to be about a field not being empty."); + } + } + + @Test(groups = "unit") + public void iCanAssertStringIsNotEmpty() { + Person p = new Person(DEFAULT_ID); + + // Check no exception when field is not empty. + p.assertThat().field("id").isNotEmpty(); + + try { + p.assertThat().field("nickname").isNotEmpty(); + fail("Expected exception to be raised."); + } catch (AssertionError e) { + assertTrue(e.getMessage().contains("is empty"), "Expected exception to be about a field being empty."); + } + } + + @Test(groups = "unit") + public void iCanAssertCollectionIsEmpty() { + Person p = new Person(); + + // Check no exception when field is empty. + p.assertThat().field("previousNames").isEmpty(); + + try { + p.assertThat().field("legs").isEmpty(); + fail("Expected exception to be raised."); + } catch (AssertionError e) { + assertTrue(e.getMessage().contains("is NOT empty"), "Expected exception to be about a field not being empty."); + } + } + + @Test(groups = "unit") + public void iCanAssertCollectionIsNotEmpty() { + Person p = new Person(); + + // Check no exception when field is not empty. + p.assertThat().field("legs").isNotEmpty(); + + try { + p.assertThat().field("previousNames").isNotEmpty(); + fail("Expected exception to be raised."); + } catch (AssertionError e) { + assertTrue(e.getMessage().contains("is empty"), "Expected exception to be about a field being empty."); + } + } + + @Test(groups = "unit") + public void iCanAssertMapIsEmpty() { + Person p = new Person(); + + // Check no exception when field is empty. + p.assertThat().field("carrying").isEmpty(); + + try { + p.assertThat().field("clothing").isEmpty(); + fail("Expected exception to be raised."); + } catch (AssertionError e) { + assertTrue(e.getMessage().contains("is NOT empty"), "Expected exception to be about a field not being empty."); + } + } + + @Test(groups = "unit") + public void iCanAssertMapIsNotEmpty() { + Person p = new Person(); + + // Check no exception when field is not empty. + p.assertThat().field("clothing").isNotEmpty(); + + try { + p.assertThat().field("carrying").isNotEmpty(); + fail("Expected exception to be raised."); + } catch (AssertionError e) { + assertTrue(e.getMessage().contains("is empty"), "Expected exception to be about a field being empty."); + } + } + + @Test(groups = "unit") + public void iCanAssertIntIsNotEmpty() { + Person p = new Person(); + + p.assertThat().field("age").isNotEmpty(); + } + + @Test(groups = "unit") + public void testIsEqualTo_noDifferencesNonIgnoredFields() + { + Person person = new Person(DEFAULT_ID, DEFAULT_NAME); + Person otherPerson = new Person(DEFAULT_ID, DEFAULT_NAME); + + person.assertThat().isEqualTo(otherPerson); + } + + @Test(groups = "unit") + public void testIsEqualTo_differentNameIgnoreName() + { + Person person = new Person(DEFAULT_ID); + Person otherPerson = new Person(DEFAULT_ID, DEFAULT_NAME); + + person.assertThat().isEqualTo(otherPerson, "name"); + } + + @Test(groups = "unit") + public void testIsEqualTo_differentIdAndNameIgnoreIdAndName() + { + Person person = new Person(); + Person otherPerson = new Person(DEFAULT_ID, DEFAULT_NAME); + + person.assertThat().isEqualTo(otherPerson, "id", "name"); + } + + @Test(groups = "unit") + public void testIsEqualTo_differentNameNonIgnoredFields() + { + Person person = new Person(DEFAULT_ID, DEFAULT_NAME); + Person otherPerson = new Person(DEFAULT_ID, "otherName"); + + try { + person.assertThat().isEqualTo(otherPerson); + fail("Expected exception to be raised."); + } catch (AssertionError e) { + assertTrue(e.getMessage().contains("are not equal"), "Expected exception to be about a not equal objects."); + } + } + + @Test(groups = "unit") + public void testIsEqualTo_differentIdNonIgnoredFields() + { + Person person = new Person(); + Person otherPerson = new Person(DEFAULT_ID); + + try { + person.assertThat().isEqualTo(otherPerson); + fail("Expected exception to be raised."); + } catch (AssertionError e) { + assertTrue(e.getMessage().contains("are not equal"), "Expected exception to be about a not equal objects."); + } + } + + @Test(groups = "unit") + public void testIsEqualTo_differentIdAndNameIgnoreName() + { + Person person = new Person(); + Person otherPerson = new Person(DEFAULT_ID, DEFAULT_NAME); + + try { + person.assertThat().isEqualTo(otherPerson, "name"); + fail("Expected exception to be raised."); + } catch (AssertionError e) { + assertTrue(e.getMessage().contains("are not equal"), "Expected exception to be about a not equal objects."); + } + } + + @Test(groups = "unit") + public void testIsEqualTo_differentNicknameIgnoreIdAndName() + { + Person person = new Person(); + Person otherPerson = new Person(); + otherPerson.setNickname("Shaggy"); + + try { + person.assertThat().isEqualTo(otherPerson, "id", "name"); + fail("Expected exception to be raised."); + } catch (AssertionError e) { + assertTrue(e.getMessage().contains("are not equal"), "Expected exception to be about a not equal objects."); + } + } + + @Test(groups = "unit") + public void testIsEqualTo_differentPreviousNamesIgnoreId() + { + Person person = new Person(); + Person otherPerson = new Person(); + otherPerson.setPreviousNames(List.of("Paul")); + + try { + person.assertThat().isEqualTo(otherPerson, "id"); + fail("Expected exception to be raised."); + } catch (AssertionError e) { + assertTrue(e.getMessage().contains("are not equal"), "Expected exception to be about a not equal objects."); + } + } + + public static class Person implements IRestModel { + private String id; + private String name; + private String nickname = ""; + private int age = 42; + private Set legs = newHashSet("left", "right"); + private List previousNames = Collections.emptyList(); + private Map clothing = ImmutableMap.of("head", "hat"); + private Map carrying = Collections.emptyMap(); + + public Person() + { + } + + public Person(String id) + { + this.id = id; + } + + public Person(String id, String name) + { + this.id = id; + this.name = name; + } + + 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 getNickname() { return nickname; } + public void setNickname(String nickname) + { + this.nickname = nickname; + } + public int getAge() { return age; } + public Set getLegs() { return legs; } + public List getPreviousNames() { return previousNames; } + public void setPreviousNames(List previousNames) + { + this.previousNames = previousNames; + } + public Map getClothing() { return clothing; } + public Map getCarrying() { return carrying; } + + @Override + public Person onModel() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String toString() + { + return "Person{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", nickname='" + nickname + '\'' + ", age=" + age + ", legs=" + legs + ", previousNames=" + + previousNames + ", clothing=" + clothing + ", carrying=" + carrying + '}'; + } + + @Override + public boolean equals(Object o) + { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Person person = (Person) o; + return age == person.age && Objects.equals(id, person.id) && Objects.equals(name, person.name) && Objects.equals(nickname, person.nickname) && Objects.equals( + legs, person.legs) && Objects.equals(previousNames, person.previousNames) && Objects.equals(clothing, person.clothing) && Objects.equals(carrying, person.carrying); + } + + @Override + public int hashCode() + { + return Objects.hash(id, name, nickname, age, legs, previousNames, clothing, carrying); + } + } +} diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/requests/ModelRequestUnitTest.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/requests/ModelRequestUnitTest.java new file mode 100644 index 0000000000..a6654ca7ec --- /dev/null +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/requests/ModelRequestUnitTest.java @@ -0,0 +1,99 @@ +/*- + * #%L + * alfresco-tas-restapi + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.requests; + +import static org.mockito.BDDMockito.then; +import static org.mockito.Mockito.CALLS_REAL_METHODS; +import static org.mockito.Mockito.mock; +import static org.mockito.MockitoAnnotations.openMocks; + +import org.alfresco.rest.core.RestWrapper; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +/** Unit tests for {@link ModelRequest}. */ +public class ModelRequestUnitTest +{ + /** Abstract class, so test with mock passing through to real methods. */ + @InjectMocks + private ModelRequest modelRequest = mock(ModelRequest.class, CALLS_REAL_METHODS); + @Mock + private RestWrapper restWrapperMock; + + @BeforeMethod + public void setUp() + { + openMocks(this); + } + + @Test + public void testInclude_empty() + { + modelRequest.include(); + + then(restWrapperMock).should().withParams("include="); + then(restWrapperMock).shouldHaveNoMoreInteractions(); + } + + @Test + public void testInclude_singleInclude() + { + modelRequest.include("field1"); + + then(restWrapperMock).should().withParams("include=field1"); + then(restWrapperMock).shouldHaveNoMoreInteractions(); + } + + + @Test + public void testInclude_multipleIncludes() + { + modelRequest.include("field1", "field2", "field3"); + + then(restWrapperMock).should().withParams("include=field1,field2,field3"); + then(restWrapperMock).shouldHaveNoMoreInteractions(); + } + + @Test + public void testIncludePath() + { + modelRequest.includePath(); + + then(restWrapperMock).should().withParams("include=path"); + then(restWrapperMock).shouldHaveNoMoreInteractions(); + } + + @Test + public void testUsingParams() + { + modelRequest.usingParams("param1=value1", "param2=value2"); + + then(restWrapperMock).should().withParams("param1=value1", "param2=value2"); + then(restWrapperMock).shouldHaveNoMoreInteractions(); + } +} diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/CreateRulesTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/CreateRulesTests.java index 3cfc1902a0..cf4888952b 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/CreateRulesTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/CreateRulesTests.java @@ -26,7 +26,6 @@ package org.alfresco.rest.rules; import static java.util.stream.Collectors.toList; - import static org.alfresco.rest.actions.access.AccessRestrictionUtil.ERROR_MESSAGE_ACCESS_RESTRICTED; import static org.alfresco.rest.actions.access.AccessRestrictionUtil.MAIL_ACTION; import static org.alfresco.rest.rules.RulesTestsUtils.CHECKIN_ACTION; @@ -58,11 +57,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.IntStream; - import javax.json.Json; import javax.json.JsonObject; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestActionBodyExecTemplateModel; import org.alfresco.rest.model.RestActionConstraintModel; import org.alfresco.rest.model.RestCompositeConditionDefinitionModel; @@ -83,7 +80,7 @@ import org.testng.annotations.Test; * Tests for POST /nodes/{nodeId}/rule-sets/{ruleSetId}/rules. */ @Test(groups = {TestGroup.RULES}) -public class CreateRulesTests extends RestTest +public class CreateRulesTests extends RulesRestTest { private UserModel user; private SiteModel site; diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/DeleteRulesTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/DeleteRulesTests.java index 94b36eabce..7fe17b3ac5 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/DeleteRulesTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/DeleteRulesTests.java @@ -26,7 +26,6 @@ package org.alfresco.rest.rules; import static java.util.stream.Collectors.toList; - import static org.alfresco.utility.constants.UserRole.SiteCollaborator; import static org.alfresco.utility.constants.UserRole.SiteContributor; import static org.alfresco.utility.constants.UserRole.SiteManager; @@ -41,7 +40,6 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestRuleModel; import org.alfresco.rest.model.RestRuleModelsCollection; import org.alfresco.utility.model.FolderModel; @@ -56,7 +54,7 @@ import org.testng.annotations.Test; * Tests for DELETE /nodes/{nodeId}/rule-sets/{ruleSetId}/rules/{ruleId}. */ @Test(groups = {TestGroup.RULES}) -public class DeleteRulesTests extends RestTest +public class DeleteRulesTests extends RulesRestTest { private static final String FAKE_NODE_REF = "fake-node-id"; diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/ExecuteRulesTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/ExecuteRulesTests.java index 39764a0379..b5cc2a43c6 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/ExecuteRulesTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/ExecuteRulesTests.java @@ -36,7 +36,6 @@ import java.util.List; import java.util.Map; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestActionBodyExecTemplateModel; import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.model.RestRuleExecutionModel; @@ -56,7 +55,7 @@ import org.testng.annotations.Test; * Tests for POST /nodes/{nodeId}/rule-executions. */ @Test(groups = { TestGroup.RULES}) -public class ExecuteRulesTests extends RestTest +public class ExecuteRulesTests extends RulesRestTest { private UserModel user; diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/GetInheritedRulesTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/GetInheritedRulesTests.java index c45ba4f8a0..20b4051135 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/GetInheritedRulesTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/GetInheritedRulesTests.java @@ -33,7 +33,6 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestRuleModel; import org.alfresco.rest.model.RestRuleModelsCollection; import org.alfresco.rest.model.RestRuleSetLinkModel; @@ -52,7 +51,7 @@ import org.testng.annotations.Test; * Tests for GET /nodes/{nodeId}/rule-sets/{ruleSetId}/rules with rule inheritance. */ @Test(groups = {TestGroup.RULES}) -public class GetInheritedRulesTests extends RestTest +public class GetInheritedRulesTests extends RulesRestTest { private UserModel user; private SiteModel site; diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/GetRuleSetsTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/GetRuleSetsTests.java index aed3d9f0b0..630c1a9dc3 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/GetRuleSetsTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/GetRuleSetsTests.java @@ -36,8 +36,6 @@ import static org.springframework.http.HttpStatus.OK; import java.util.List; import com.google.common.collect.ImmutableMap; - -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestRuleModel; import org.alfresco.rest.model.RestRuleSetLinkModel; import org.alfresco.rest.model.RestRuleSetModel; @@ -57,7 +55,7 @@ import org.testng.annotations.Test; * Tests for GET /nodes/{nodeId}/rule-sets and /nodes/{nodeId}/rule-sets/{ruleSetId}. */ @Test (groups = { TestGroup.RULES }) -public class GetRuleSetsTests extends RestTest +public class GetRuleSetsTests extends RulesRestTest { private UserModel user; private SiteModel site; diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/GetRulesTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/GetRulesTests.java index f33a3e8703..0f4aaeb142 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/GetRulesTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/GetRulesTests.java @@ -26,7 +26,6 @@ package org.alfresco.rest.rules; import static java.util.stream.Collectors.toList; - import static org.alfresco.utility.constants.UserRole.SiteCollaborator; import static org.alfresco.utility.report.log.Step.STEP; import static org.junit.Assert.assertTrue; @@ -39,7 +38,6 @@ import java.util.List; import java.util.stream.IntStream; import java.util.stream.Stream; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestRuleModel; import org.alfresco.rest.model.RestRuleModelsCollection; import org.alfresco.utility.model.FolderModel; @@ -53,7 +51,7 @@ import org.testng.annotations.Test; * Tests for GET /nodes/{nodeId}/rule-sets/{ruleSetId}/rules and GET /nodes/{nodeId}/rule-sets/{ruleSetId}/rules/{ruleId}. */ @Test(groups = {TestGroup.RULES}) -public class GetRulesTests extends RestTest +public class GetRulesTests extends RulesRestTest { private UserModel user; private SiteModel site; diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/ReorderRules.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/ReorderRulesTests.java similarity index 97% rename from packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/ReorderRules.java rename to packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/ReorderRulesTests.java index 7a60dbc70e..58b8ef3420 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/ReorderRules.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/ReorderRulesTests.java @@ -1,203 +1,200 @@ -/* - * #%L - * Alfresco Repository - * %% - * Copyright (C) 2005 - 2022 Alfresco Software Limited - * %% - * This file is part of the Alfresco software. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - * #L% - */ -package org.alfresco.rest.rules; - -import static java.util.stream.Collectors.toList; - -import static org.alfresco.utility.report.log.Step.STEP; -import static org.springframework.http.HttpStatus.FORBIDDEN; -import static org.springframework.http.HttpStatus.OK; - -import java.util.List; -import java.util.stream.IntStream; - -import com.google.common.collect.Lists; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestRuleModel; -import org.alfresco.rest.model.RestRuleSetModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.model.FolderModel; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -@Test (groups = { TestGroup.RULES }) -public class ReorderRules extends RestTest -{ - private UserModel user; - private SiteModel site; - - @BeforeClass (alwaysRun = true) - public void dataPreparation() - { - STEP("Create a user and site."); - user = dataUser.createRandomTestUser(); - site = dataSite.usingUser(user).createPublicRandomSite(); - } - - /** Check we can get the ordered list of rules in a rule set. */ - @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) - public void getOrderedRuleIds() - { - STEP("Create a folder containing three rules in the existing site"); - FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); - List rules = createRulesInFolder(folder, user); - - STEP("Get the default rule set for the folder including the ordered rule ids"); - RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder) - .include("ruleIds").getDefaultRuleSet(); - - List expectedRuleIds = rules.stream().map(RestRuleModel::getId).collect(toList()); - restClient.assertStatusCodeIs(OK); - ruleSet.assertThat().field("ruleIds").is(expectedRuleIds); - } - - /** Check that a user can view the order of the rules in a rule set if they only have read permission. */ - @Test - public void getRuleSetAndRuleIdsWithReadOnlyPermission() - { - STEP("Create a site owned by admin and add user as a consumer"); - SiteModel siteModel = dataSite.usingAdmin().createPrivateRandomSite(); - dataUser.addUserToSite(user, siteModel, UserRole.SiteConsumer); - - STEP("Use admin to create a folder with a rule set and three rules in it"); - FolderModel ruleFolder = dataContent.usingAdmin().usingSite(siteModel).createFolder(); - dataContent.usingAdmin().usingResource(ruleFolder).createFolder(); - List rules = createRulesInFolder(ruleFolder, dataUser.getAdminUser()); - - STEP("Get the rule set with the ordered list of rules"); - RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder) - .include("ruleIds").getDefaultRuleSet(); - - restClient.assertStatusCodeIs(OK); - List ruleIds = rules.stream().map(RestRuleModel::getId).collect(toList()); - ruleSet.assertThat().field("ruleIds").is(ruleIds); - } - - /** Check we can reorder the rules in a rule set. */ - @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) - public void reorderRules() - { - STEP("Create a folder containing three rules in the existing site"); - FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); - List rules = createRulesInFolder(folder, user); - - STEP("Reverse the order of the rules within the rule set"); - List reversedRuleIds = Lists.reverse(rules.stream().map(RestRuleModel::getId).collect(toList())); - RestRuleSetModel ruleSetBody = new RestRuleSetModel(); - ruleSetBody.setId("-default-"); - ruleSetBody.setRuleIds(reversedRuleIds); - RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder) - .include("ruleIds").updateRuleSet(ruleSetBody); - - restClient.assertStatusCodeIs(OK); - ruleSet.assertThat().field("ruleIds").is(reversedRuleIds); - } - - /** Check we can reorder the rules in a rule set by editing the response from the GET. */ - @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) - public void reorderRulesUsingResponseFromGET() - { - STEP("Create a folder containing three rules in the existing site"); - FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); - List rules = createRulesInFolder(folder, user); - - STEP("Get the rule set with its id."); - RestRuleSetModel ruleSetResponse = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder) - .include("ruleIds").getDefaultRuleSet(); - - STEP("Reverse the order of the rules within the rule set"); - ruleSetResponse.setRuleIds(Lists.reverse(ruleSetResponse.getRuleIds())); - RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder) - .include("ruleIds").updateRuleSet(ruleSetResponse); - - restClient.assertStatusCodeIs(OK); - List reversedRuleIds = Lists.reverse(rules.stream().map(RestRuleModel::getId).collect(toList())); - ruleSet.assertThat().field("ruleIds").is(reversedRuleIds); - } - - /** Check that a user cannot reorder the rules in a rule set if they only have read permission. */ - @Test - public void reorderRulesWithoutPermission() - { - STEP("Create a site owned by admin and add user as a consumer"); - SiteModel siteModel = dataSite.usingAdmin().createPrivateRandomSite(); - dataUser.addUserToSite(user, siteModel, UserRole.SiteContributor); - - STEP("Use admin to create a folder with a rule set and three rules in it"); - FolderModel ruleFolder = dataContent.usingAdmin().usingSite(siteModel).createFolder(); - dataContent.usingAdmin().usingResource(ruleFolder).createFolder(); - List rules = createRulesInFolder(ruleFolder, dataUser.getAdminUser()); - - STEP("Try to reorder the rules as the contributor"); - List reversedRuleIds = Lists.reverse(rules.stream().map(RestRuleModel::getId).collect(toList())); - RestRuleSetModel ruleSetBody = new RestRuleSetModel(); - ruleSetBody.setId("-default-"); - ruleSetBody.setRuleIds(reversedRuleIds); - restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder) - .include("ruleIds").updateRuleSet(ruleSetBody); - - restClient.assertStatusCodeIs(FORBIDDEN); - } - - /** Check that a user can reorder the rules in a rule set if they have write permission. */ - @Test - public void reorderRulesWithPermission() - { - STEP("Create a site owned by admin and add user as a collaborator"); - SiteModel siteModel = dataSite.usingAdmin().createPrivateRandomSite(); - dataUser.addUserToSite(user, siteModel, UserRole.SiteCollaborator); - - STEP("Use admin to create a folder with a rule set and three rules in it"); - FolderModel ruleFolder = dataContent.usingAdmin().usingSite(siteModel).createFolder(); - dataContent.usingAdmin().usingResource(ruleFolder).createFolder(); - List rules = createRulesInFolder(ruleFolder, dataUser.getAdminUser()); - - STEP("Try to reorder the rules as the contributor"); - List reversedRuleIds = Lists.reverse(rules.stream().map(RestRuleModel::getId).collect(toList())); - RestRuleSetModel ruleSetBody = new RestRuleSetModel(); - ruleSetBody.setId("-default-"); - ruleSetBody.setRuleIds(reversedRuleIds); - RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder) - .include("ruleIds").updateRuleSet(ruleSetBody); - - restClient.assertStatusCodeIs(OK); - ruleSet.assertThat().field("ruleIds").is(reversedRuleIds); - } - - /** Create three rules in the given folder. */ - private List createRulesInFolder(FolderModel folder, UserModel user) - { - return IntStream.range(0, 3).mapToObj(index -> - { - RestRuleModel ruleModel = rulesUtils.createRuleModelWithDefaultValues(); - return restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).usingDefaultRuleSet().createSingleRule(ruleModel); - }).collect(toList()); - } -} +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.rules; + +import static java.util.stream.Collectors.toList; +import static org.alfresco.utility.report.log.Step.STEP; +import static org.springframework.http.HttpStatus.FORBIDDEN; +import static org.springframework.http.HttpStatus.OK; + +import java.util.List; +import java.util.stream.IntStream; + +import com.google.common.collect.Lists; +import org.alfresco.rest.model.RestRuleModel; +import org.alfresco.rest.model.RestRuleSetModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.model.FolderModel; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test (groups = { TestGroup.RULES }) +public class ReorderRulesTests extends RulesRestTest +{ + private UserModel user; + private SiteModel site; + + @BeforeClass (alwaysRun = true) + public void dataPreparation() + { + STEP("Create a user and site."); + user = dataUser.createRandomTestUser(); + site = dataSite.usingUser(user).createPublicRandomSite(); + } + + /** Check we can get the ordered list of rules in a rule set. */ + @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) + public void getOrderedRuleIds() + { + STEP("Create a folder containing three rules in the existing site"); + FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); + List rules = createRulesInFolder(folder, user); + + STEP("Get the default rule set for the folder including the ordered rule ids"); + RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder) + .include("ruleIds").getDefaultRuleSet(); + + List expectedRuleIds = rules.stream().map(RestRuleModel::getId).collect(toList()); + restClient.assertStatusCodeIs(OK); + ruleSet.assertThat().field("ruleIds").is(expectedRuleIds); + } + + /** Check that a user can view the order of the rules in a rule set if they only have read permission. */ + @Test + public void getRuleSetAndRuleIdsWithReadOnlyPermission() + { + STEP("Create a site owned by admin and add user as a consumer"); + SiteModel siteModel = dataSite.usingAdmin().createPrivateRandomSite(); + dataUser.addUserToSite(user, siteModel, UserRole.SiteConsumer); + + STEP("Use admin to create a folder with a rule set and three rules in it"); + FolderModel ruleFolder = dataContent.usingAdmin().usingSite(siteModel).createFolder(); + dataContent.usingAdmin().usingResource(ruleFolder).createFolder(); + List rules = createRulesInFolder(ruleFolder, dataUser.getAdminUser()); + + STEP("Get the rule set with the ordered list of rules"); + RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder) + .include("ruleIds").getDefaultRuleSet(); + + restClient.assertStatusCodeIs(OK); + List ruleIds = rules.stream().map(RestRuleModel::getId).collect(toList()); + ruleSet.assertThat().field("ruleIds").is(ruleIds); + } + + /** Check we can reorder the rules in a rule set. */ + @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) + public void reorderRules() + { + STEP("Create a folder containing three rules in the existing site"); + FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); + List rules = createRulesInFolder(folder, user); + + STEP("Reverse the order of the rules within the rule set"); + List reversedRuleIds = Lists.reverse(rules.stream().map(RestRuleModel::getId).collect(toList())); + RestRuleSetModel ruleSetBody = new RestRuleSetModel(); + ruleSetBody.setId("-default-"); + ruleSetBody.setRuleIds(reversedRuleIds); + RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder) + .include("ruleIds").updateRuleSet(ruleSetBody); + + restClient.assertStatusCodeIs(OK); + ruleSet.assertThat().field("ruleIds").is(reversedRuleIds); + } + + /** Check we can reorder the rules in a rule set by editing the response from the GET. */ + @Test (groups = { TestGroup.REST_API, TestGroup.RULES }) + public void reorderRulesUsingResponseFromGET() + { + STEP("Create a folder containing three rules in the existing site"); + FolderModel folder = dataContent.usingUser(user).usingSite(site).createFolder(); + List rules = createRulesInFolder(folder, user); + + STEP("Get the rule set with its id."); + RestRuleSetModel ruleSetResponse = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder) + .include("ruleIds").getDefaultRuleSet(); + + STEP("Reverse the order of the rules within the rule set"); + ruleSetResponse.setRuleIds(Lists.reverse(ruleSetResponse.getRuleIds())); + RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(folder) + .include("ruleIds").updateRuleSet(ruleSetResponse); + + restClient.assertStatusCodeIs(OK); + List reversedRuleIds = Lists.reverse(rules.stream().map(RestRuleModel::getId).collect(toList())); + ruleSet.assertThat().field("ruleIds").is(reversedRuleIds); + } + + /** Check that a user cannot reorder the rules in a rule set if they only have read permission. */ + @Test + public void reorderRulesWithoutPermission() + { + STEP("Create a site owned by admin and add user as a consumer"); + SiteModel siteModel = dataSite.usingAdmin().createPrivateRandomSite(); + dataUser.addUserToSite(user, siteModel, UserRole.SiteContributor); + + STEP("Use admin to create a folder with a rule set and three rules in it"); + FolderModel ruleFolder = dataContent.usingAdmin().usingSite(siteModel).createFolder(); + dataContent.usingAdmin().usingResource(ruleFolder).createFolder(); + List rules = createRulesInFolder(ruleFolder, dataUser.getAdminUser()); + + STEP("Try to reorder the rules as the contributor"); + List reversedRuleIds = Lists.reverse(rules.stream().map(RestRuleModel::getId).collect(toList())); + RestRuleSetModel ruleSetBody = new RestRuleSetModel(); + ruleSetBody.setId("-default-"); + ruleSetBody.setRuleIds(reversedRuleIds); + restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder) + .include("ruleIds").updateRuleSet(ruleSetBody); + + restClient.assertStatusCodeIs(FORBIDDEN); + } + + /** Check that a user can reorder the rules in a rule set if they have write permission. */ + @Test + public void reorderRulesWithPermission() + { + STEP("Create a site owned by admin and add user as a collaborator"); + SiteModel siteModel = dataSite.usingAdmin().createPrivateRandomSite(); + dataUser.addUserToSite(user, siteModel, UserRole.SiteCollaborator); + + STEP("Use admin to create a folder with a rule set and three rules in it"); + FolderModel ruleFolder = dataContent.usingAdmin().usingSite(siteModel).createFolder(); + dataContent.usingAdmin().usingResource(ruleFolder).createFolder(); + List rules = createRulesInFolder(ruleFolder, dataUser.getAdminUser()); + + STEP("Try to reorder the rules as the contributor"); + List reversedRuleIds = Lists.reverse(rules.stream().map(RestRuleModel::getId).collect(toList())); + RestRuleSetModel ruleSetBody = new RestRuleSetModel(); + ruleSetBody.setId("-default-"); + ruleSetBody.setRuleIds(reversedRuleIds); + RestRuleSetModel ruleSet = restClient.authenticateUser(user).withPrivateAPI().usingNode(ruleFolder) + .include("ruleIds").updateRuleSet(ruleSetBody); + + restClient.assertStatusCodeIs(OK); + ruleSet.assertThat().field("ruleIds").is(reversedRuleIds); + } + + /** Create three rules in the given folder. */ + private List createRulesInFolder(FolderModel folder, UserModel user) + { + return IntStream.range(0, 3).mapToObj(index -> + { + RestRuleModel ruleModel = rulesUtils.createRuleModelWithDefaultValues(); + return restClient.authenticateUser(user).withPrivateAPI().usingNode(folder).usingDefaultRuleSet().createSingleRule(ruleModel); + }).collect(toList()); + } +} diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/RuleSetLinksTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/RuleSetLinksTests.java index 9dd4d54788..596557b91f 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/RuleSetLinksTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/RuleSetLinksTests.java @@ -35,7 +35,6 @@ import static org.springframework.http.HttpStatus.NO_CONTENT; import static org.springframework.http.HttpStatus.OK; import org.alfresco.dataprep.CMISUtil; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestRuleModel; import org.alfresco.rest.model.RestRuleModelsCollection; import org.alfresco.rest.model.RestRuleSetLinkModel; @@ -54,7 +53,7 @@ import org.testng.annotations.Test; * Tests for /nodes/{nodeId}/rule-set-links. */ @Test(groups = {TestGroup.RULES}) -public class RuleSetLinksTests extends RestTest +public class RuleSetLinksTests extends RulesRestTest { private UserModel user; private SiteModel site; diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/RulesRestTest.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/RulesRestTest.java new file mode 100644 index 0000000000..39dd363001 --- /dev/null +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/RulesRestTest.java @@ -0,0 +1,36 @@ +/* + * #%L + * Alfresco Remote API + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ + +package org.alfresco.rest.rules; + +import org.alfresco.rest.RestTest; +import org.springframework.beans.factory.annotation.Autowired; + +public class RulesRestTest extends RestTest +{ + @Autowired + protected RulesTestsUtils rulesUtils; +} diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/SetInheritanceTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/SetInheritanceTests.java index aeee780598..8858cc50b9 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/SetInheritanceTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/SetInheritanceTests.java @@ -33,7 +33,6 @@ import static org.springframework.http.HttpStatus.FORBIDDEN; import static org.springframework.http.HttpStatus.NOT_FOUND; import static org.springframework.http.HttpStatus.OK; -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestRuleSettingsModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; @@ -46,7 +45,7 @@ import org.testng.annotations.Test; * Tests for GET and PUT /nodes/{nodeId}/rule-settings/{ruleSettingKey}. */ @Test (groups = { TestGroup.RULES }) -public class SetInheritanceTests extends RestTest +public class SetInheritanceTests extends RulesRestTest { private UserModel siteOwner; private SiteModel site; diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/UpdateRulesTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/UpdateRulesTests.java index 17d55ed555..8fb7ad2749 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/UpdateRulesTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/rules/UpdateRulesTests.java @@ -48,8 +48,6 @@ import java.util.List; import java.util.Map; import com.google.common.collect.ImmutableMap; - -import org.alfresco.rest.RestTest; import org.alfresco.rest.model.RestActionBodyExecTemplateModel; import org.alfresco.rest.model.RestCompositeConditionDefinitionModel; import org.alfresco.rest.model.RestRuleModel; @@ -64,7 +62,7 @@ import org.testng.annotations.Test; * Tests for PUT /nodes/{nodeId}/rule-sets/{ruleSetId}/rules. */ @Test (groups = { TestGroup.RULES }) -public class UpdateRulesTests extends RestTest +public class UpdateRulesTests extends RulesRestTest { private UserModel user; private SiteModel site; diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java index fee1aef75d..581066503a 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/containers/GetSiteContainerTests.java @@ -211,30 +211,6 @@ public class GetSiteContainerTests extends RestTest .stackTraceIs(RestErrorModel.STACKTRACE); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get container request for empty siteId returns status code 404") - public void getContainerForEmptySiteId() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite("").getSiteContainer(ContainerName.links.toString()); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, "", ContainerName.links.toString())) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get container request for empty container returns status code 200 and the list of containers") - public void getContainerForEmptyContainer() throws Exception - { - restClient.authenticateUser(testUser) - .withCoreAPI().usingSite(moderatedSiteModel).getSiteContainer(""); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if get container with name containing special chars returns status code 404") diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/GetSiteGroupTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/GetSiteGroupTests.java index 3fd0d483ef..59a0c9c649 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/GetSiteGroupTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/GetSiteGroupTests.java @@ -102,19 +102,6 @@ public class GetSiteGroupTests extends RestTest .assertLastError().containsSummary(String.format("An authority was not found for %s", getId(inexistentGroup))); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify Manager role can get site group for empty siteId") - public void getSiteGroupForEmptySiteId() throws Exception - { - SiteModel emptySite = new SiteModel(""); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(emptySite).getSiteGroup(getId(consumer)); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, "")); - } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify Manager role gets site groups with Manager role and status code is OK (200)") diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/UpdateSiteGroupTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/UpdateSiteGroupTests.java index e143b732d9..02ec0cc0e7 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/UpdateSiteGroupTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/groups/UpdateSiteGroupTests.java @@ -146,16 +146,6 @@ public class UpdateSiteGroupTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format("An authority was not found for %s", getId(nonexistentUser))); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 404 when empty siteId is used") - public void updateSiteMemberUsingEmptySiteId() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI().usingSite("").updateSiteGroup(getId(regularGroup), UserRole.SiteConsumer); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if update site member request returns status code 405 when empty personId is used") diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java index 4c097c9916..f5114e16a1 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/AddSiteMemberTests.java @@ -312,18 +312,6 @@ public class AddSiteMemberTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentSite.getId())); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify that user can not be added to a site if an empty site id is provided and gets status code 404") - public void userIsNotAbleToAddAnotherUserUsingEmptySiteId() throws Exception - { - UserModel testUser = dataUser.createRandomTestUser("testUser"); - testUser.setUserRole(UserRole.SiteManager); - SiteModel inexistentSite = new SiteModel(""); - restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(inexistentSite).addPerson(testUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentSite.getId())); - } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify that inexistent user can not be added to site and gets status code 404") diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java index 41ca764b0b..8727300051 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java @@ -172,19 +172,6 @@ public class GetSiteMemberTests extends RestTest restClient.assertStatusCodeIs(HttpStatus.OK); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Manager role can get site member for empty siteId") - public void getSiteMemberForEmptySiteId() throws Exception - { - SiteModel emptySite = new SiteModel(""); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(emptySite).getSiteMember(consumer); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, consumer.getUsername(), emptySite.getId())); - } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, description = "Verify user with Manager role gets site member with Manager role and status code is OK (200)") diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java index cb2fb09e8e..bc5373ef33 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/UpdateSiteMemberTests.java @@ -190,17 +190,6 @@ public class UpdateSiteMemberTests extends RestTest .and().field("role").is(meUser.getUserRole()); } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if update site member request returns status code 404 when empty siteId is used") - public void updateSiteMemberUsingEmptySiteId() throws Exception - { - restClient.authenticateUser(adminUser).withCoreAPI() - .usingSite("").updateSiteMember(regularUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, description= "Verify if update site member request returns status code 405 when empty personId is used") diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java index 5db98f2c42..c0ff7430ff 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/items/AddProcessItemFullTests.java @@ -36,34 +36,6 @@ public class AddProcessItemFullTests extends RestTest document2 = dataContent.usingUser(adminUser).usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple process items is falling in case of empty process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingMultipleProcessItemsIfEmptyProcessIdIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - processModel.setId(""); - processItems = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItems(testDocument, document); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, "")); - } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding process items is falling in case of empty process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void failedAddingProcessItemsIfEmptyProcessIdIsProvided() throws Exception - { - processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - FileModel testDocument = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); - - processModel.setId(""); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(testDocument); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, "")); - } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process item is falling in case of empty body item value is provided") diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java index 13feac4565..eb4c8463f4 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/items/DeleteProcessItemFullTests.java @@ -36,27 +36,6 @@ public class DeleteProcessItemFullTests extends RestTest siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite(); document = dataContent.usingUser(userWhoStartsProcess).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Try to delete existing process item using empty processId") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessItemUsingEmptyProcessId() throws Exception - { - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI() - .addProcess("activitiAdhoc", assignee, false, Priority.Normal); - document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT); - processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - processModel.setId(""); - restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "The entity with id: ")) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .stackTraceIs(RestErrorModel.STACKTRACE); - } @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Add a new process item, update the item and then delete.") diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java index acda02df2c..d357467eab 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariableFullTests.java @@ -51,21 +51,6 @@ public class AddProcessVariableFullTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); } - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableWithEmptyProcessId() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId(""); - - processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) - .updateProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding process variable in case of having only 'name' field is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java index 8b81bf7598..b4cc076072 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/variables/AddProcessVariablesCoreTests.java @@ -49,21 +49,6 @@ public class AddProcessVariablesCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); } - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW,TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Verify addProcessVariable by any user for empty processID with REST API and status code is NOT_FOUND (404)") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addProcessVariableForEmptyProcessIdIsEmpty() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId(""); - - processVariable = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel) - .addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Adding multiple process variables is falling in case invalid process id is provided") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) @@ -81,21 +66,4 @@ public class AddProcessVariablesCoreTests extends RestTest .assertLastError() .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "invalidProcessID")); } - - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Adding multiple process variables is falling in case empty process id is provided") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void addMultipleProcessVariablesEmptyProcessId() throws Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:int"); - variableModel1 = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel(); - processModel.setId(""); - - restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel) - .addProcessVariables(variableModel1, variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } } diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java index 68cbe1faaa..c7b2a6821b 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/processes/variables/DeleteProcessVariableCoreTests.java @@ -2,7 +2,6 @@ package org.alfresco.rest.workflow.processes.variables; import org.alfresco.dataprep.CMISUtil.DocumentType; import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; import org.alfresco.rest.model.RestErrorModel; import org.alfresco.rest.model.RestProcessModel; import org.alfresco.rest.model.RestProcessVariableModel; @@ -76,27 +75,6 @@ public class DeleteProcessVariableCoreTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, variableModel.getName())); } - @TestRail(section = {TestGroup.REST_API,TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, - description = "Remove process variables with empty processId") - @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) - public void deleteProcessVariableEmptyProcessId() throws JsonToModelConversionException, Exception - { - variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text"); - restProcessModel = restClient.authenticateUser(userWhoStartsTask).withWorkflowAPI() - .getProcesses().getProcessModelByProcessDefId(processModel.getId()); - restClient.withWorkflowAPI().usingProcess(restProcessModel).addProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - restProcessModel.setId(""); - restClient.withWorkflowAPI().usingProcess(restProcessModel).deleteProcessVariable(variableModel); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")) - .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - @TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION, description = "Delete process variable with admin.") @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.REGRESSION }) diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java index b452c82478..0821fad8d8 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/workflow/tasks/items/RemoveTaskItemTests.java @@ -80,21 +80,6 @@ public class RemoveTaskItemTests extends RestTest .assertLastError().containsSummary(String.format(RestErrorModel.PROCESS_ENTITY_NOT_FOUND, "incorrectItemId")); } - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, - description = "Delete existing task item with empty task id") - @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) - public void deleteTaskItemEmptyTaskId() throws Exception - { - taskModel = dataWorkflow.usingUser(userWhoStartsTask).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser); - restClient.authenticateUser(userWhoStartsTask); - document2 = dataContent.usingSite(siteModel).createContent(DocumentType.XML); - taskItem = restClient.withWorkflowAPI().usingTask(taskModel).addTaskItem(document2); - taskModel.setId(""); - restClient.withWorkflowAPI().usingTask(taskModel).deleteTaskItem(taskItem); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "")); - } - @TestRail(section = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Delete existing task item with empty item id") @Test(groups = {TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.REGRESSION }) @@ -252,4 +237,4 @@ public class RemoveTaskItemTests extends RestTest .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) .stackTraceIs(RestErrorModel.STACKTRACE); } -} \ No newline at end of file +} diff --git a/pom.xml b/pom.xml index 56f9864d7d..35b0a39982 100644 --- a/pom.xml +++ b/pom.xml @@ -122,7 +122,6 @@ 2.7.4 3.0.56 5.2.0 - 1.135 1.11 1.7 1.7 @@ -692,9 +691,19 @@ ${dependency.rest-assured.version} - org.alfresco.tas - restapi - ${dependency.tas-restapi.version} + io.rest-assured + json-path + ${dependency.rest-assured.version} + + + io.rest-assured + xml-path + ${dependency.rest-assured.version} + + + io.rest-assured + json-schema-validator + ${dependency.rest-assured.version} org.alfresco.tas