diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 491d1f16..d9a80428 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,12 +3,12 @@ name: Build Pipeline on: [push, pull_request, workflow_dispatch] jobs: - Palladio-ReverseEngineering-SoMoX-RuleEngine: + Palladio-ReverseEngineering-Retriever: uses: PalladioSimulator/Palladio-Build-ActionsPipeline/.github/workflows/build.yml@v3.4 with: use-display-output: true no-caching: true - deploy-updatesite: 'releng/org.palladiosimulator.somox.updatesite/target/repository' + deploy-updatesite: 'releng/org.palladiosimulator.retriever.updatesite/target/repository' secrets: SERVER_SSH_KEY: ${{ secrets.DEPLOYMENT_SERVER_SSH_KEY }} REMOTE_HOST: ${{ secrets.DEPLOYMENT_REMOTE_HOST }} diff --git a/.github/workflows/product.yml b/.github/workflows/product.yml index 06846094..d7a51d8a 100644 --- a/.github/workflows/product.yml +++ b/.github/workflows/product.yml @@ -35,5 +35,5 @@ jobs: - name: Release Products uses: softprops/action-gh-release@v1 with: - files: products/org.palladiosimulator.somox.analyzer.rules.product/target/products/* + files: products/org.palladiosimulator.retriever.product/target/products/* tag_name: ${{ env.release_tag }} diff --git a/.project b/.project index 5ec92b19..8b2347f1 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - Palladio-ReverseEngineering-SoMoX-RuleEngine + Palladio-ReverseEngineering-Retriever diff --git a/Palladio-ReverseEngineering-Retriever-MavenBuild.launch b/Palladio-ReverseEngineering-Retriever-MavenBuild.launch new file mode 100644 index 00000000..6fd448a0 --- /dev/null +++ b/Palladio-ReverseEngineering-Retriever-MavenBuild.launch @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Palladio-ReverseEngineering-SoMoX-RuleEngine-MavenBuild.launch b/Palladio-ReverseEngineering-SoMoX-RuleEngine-MavenBuild.launch deleted file mode 100644 index 84e7ec10..00000000 --- a/Palladio-ReverseEngineering-SoMoX-RuleEngine-MavenBuild.launch +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/README.md b/README.md index 9c660d66..23843fd7 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# Rule Engine for Reverse Engineering +# Retriever > Eclipse plugin for model-driven reverse engineering -[![Build Pipeline](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-SoMoX-RuleEngine/actions/workflows/build.yml/badge.svg)](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-SoMoX-RuleEngine/actions/workflows/build.yml) [![Continual Improvement Process](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-SoMoX-RuleEngine/actions/workflows/quality.yml/badge.svg)](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-SoMoX-RuleEngine/actions/workflows/quality.yml) [![Continuous Product Integration](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-SoMoX-RuleEngine/actions/workflows/product.yml/badge.svg)](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-SoMoX-RuleEngine/actions/workflows/product.yml) +[![Build Pipeline](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-Retriever/actions/workflows/build.yml/badge.svg)](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-Retriever/actions/workflows/build.yml) [![Continual Improvement Process](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-Retriever/actions/workflows/quality.yml/badge.svg)](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-Retriever/actions/workflows/quality.yml) [![Continuous Product Integration](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-Retriever/actions/workflows/product.yml/badge.svg)](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-Retriever/actions/workflows/product.yml) -Reverse engineering of software component models from [heterogeneous artifacts](#discoverers) of the software development process. For this purpose, [technology-specific rules](#rules) are used within the rule engine to automatically extract static components of a system. For this purpose, the heterogeneous artifacts of a software project are first transformed into a model representation. Based on the model, the rule engine applies mappings specified in rule artifacts to each model instance to identify components for the final software architecture model. +Reverse engineering of software component models from [heterogeneous artifacts](#discoverers) of the software development process. For this purpose, [technology-specific rules](#rules) are used within Retriever to automatically extract static components of a system. For this purpose, the heterogeneous artifacts of a software project are first transformed into a model representation. Based on the model, Retriever applies mappings specified in rule artifacts to each model instance to identify components for the final software architecture model. This component extraction supports base components, composite structures, interfaces, ports, and connectors. The candidate components are then used to generate the elements of the target software architecture model, which can then be used for quality prediction purposes in the [Palladio](https://www.palladio-simulator.com/) context. The extracted models are suitable for improving the understanding of existing software and enabling further quality analyses. Software performance, reliability, and maintenance analyses are already available as part of a complementary tool chain. @@ -11,24 +11,23 @@ This component extraction supports base components, composite structures, interf The rules engine is currently under active development. If you are interested in further information or would like to contribute your personal thoughts or requirements, please do not hesitate to contact us. ## Built With -The rule engine for reverse engineering is implemented with the [Eclipse Modeling Framework (EMF)](https://www.eclipse.org/modeling/emf/). It is thus provided as a plug-in for the [Eclipse platform](https://www.eclipse.org/eclipse/). +Retriever is implemented with the [Eclipse Modeling Framework (EMF)](https://www.eclipse.org/modeling/emf/). It is thus provided as a plug-in for the [Eclipse platform](https://www.eclipse.org/eclipse/). Source code based on EMF metamodels is generated during the build process and is therefore not added to the repository. To generate the source code, either the Maven build or the [EMF generation workflow](https://www.eclipse.org/modeling/emf/docs/2.x/tutorials/clibmod/clibmod_emf2.0.html#step2) must be run. The rules for the model-to-model transformations are implemented in [Xtend](https://www.eclipse.org/xtend/), which can be compiled into Java-compatible source code. ### Discoverers -* [CSV Discoverer](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-SoMoX-RuleEngine/blob/master/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/CsvDiscoverer.java) -* [Java Discoverer](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-SoMoX-RuleEngine/blob/master/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/JavaDiscoverer.java) -* [JSON Discoverer](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-SoMoX-RuleEngine/blob/master/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/JsonDiscoverer.java) -* [XML Discoverer](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-SoMoX-RuleEngine/blob/master/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/XmlDiscoverer.java) -* [YAML Discoverer](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-SoMoX-RuleEngine/blob/master/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/YamlDiscoverer.java) +* [CSV Discoverer](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-Retriever/blob/master/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/CsvDiscoverer.java) +* [Java Discoverer](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-Retriever/blob/master/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/JavaDiscoverer.java) +* [JSON Discoverer](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-Retriever/blob/master/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/JsonDiscoverer.java) +* [XML Discoverer](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-Retriever/blob/master/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/XmlDiscoverer.java) +* [YAML Discoverer](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-Retriever/blob/master/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/YamlDiscoverer.java) ### Rules -* [Spring Boot and Framework](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-SoMoX-RuleEngine/tree/master/bundles/org.palladiosimulator.somox.analyzer.rules.spring) -* [Jakarta RESTful Web Services](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-SoMoX-RuleEngine/tree/master/bundles/org.palladiosimulator.somox.analyzer.rules.jax_rs) -* [Maven Project Object Model](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-SoMoX-RuleEngine/tree/master/bundles/org.palladiosimulator.somox.analyzer.rules.maven) - +* [Spring Boot and Framework](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-Retriever/tree/master/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/SpringRules.xtend) +* [Jakarta RESTful Web Services](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-Retriever/tree/master/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/JaxRSRules.xtend) +* [Maven Project Object Model](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-Retriever/tree/master/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/MavenRules.xtend) ### Analyzer * [Docker Vulnerability](https://github.com/FluidTrust/Palladio-ReverseEngineering-Docker-Vulnerability) @@ -45,7 +44,7 @@ The rules for the model-to-model transformations are implemented in [Xtend](http * Install the [Fluent Api Model Generator](https://github.com/PalladioSimulator/Palladio-Addons-FluentApiModelGenerator) from the [update site](https://updatesite.palladio-simulator.com/palladio-addons-fluentapimodelgenerator/nightly/) * Install the [Xtend IDE](https://www.eclipse.org/xtend/download.html) from the [update site](https://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/) * Keep the current installation and, if necessary, change the items to be installed so that they are compatible -* Check out [this repository](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-SoMoX-RuleEngine.git) and [import the existing projects](https://help.eclipse.org/latest/topic/org.eclipse.platform.doc.user/tasks/tasks-importproject.htm) into Eclipse +* Check out [this repository](https://github.com/PalladioSimulator/Palladio-ReverseEngineering-Retriever.git) and [import the existing projects](https://help.eclipse.org/latest/topic/org.eclipse.platform.doc.user/tasks/tasks-importproject.htm) into Eclipse * Make changes to the imported code in Eclipse * Locally verify all projects in the repository with [Maven](https://maven.apache.org/): `mvn clean verify` * Launch a new [Eclipse runtime application](https://help.eclipse.org/latest/topic/org.eclipse.pde.doc.user/guide/tools/launchers/eclipse_application_launcher.htm) @@ -53,11 +52,11 @@ The rules for the model-to-model transformations are implemented in [Xtend](http #### For Direct Use * [Adding these update sites](https://help.eclipse.org/latest/topic/org.eclipse.platform.doc.user/tasks/tasks-127.htm), without any further installation: * The [update site](https://updatesite.palladio-simulator.com/palladio-addons-fluentapimodelgenerator/nightly/) for the [Fluent Api Model Generator](https://github.com/PalladioSimulator/Palladio-Addons-FluentApiModelGenerator) -* Install this Rule Engine from the [update site](https://updatesite.palladio-simulator.com/palladio-reverseengineering-somox-ruleengine/nightly/) +* Install Retriever from the [update site](https://updatesite.palladio-simulator.com/palladio-reverseengineering-retriever/nightly/) * This will automatically install all the required dependencies ### Usage -* Create a new run configuration to launch the rule engine +* Create a new run configuration to launch Retriever * Specify the root directory of the project to be analyzed * Select the technology used there * Specify the directory for saving the PCM instances @@ -78,9 +77,9 @@ Alternatively, you can read the GitHub documentation on how to [create a pull re * Palladio homepage: https://www.palladio-simulator.com/home/ * Comprehensive documentation: https://sdqweb.ipd.kit.edu/wiki/Palladio_Component_Model * Issue tracker: https://palladio-simulator.atlassian.net/jira/ -* Update site: https://updatesite.palladio-simulator.com/palladio-reverseengineering-somox-ruleengine/nightly/ -* Javadoc: https://updatesite.palladio-simulator.com/palladio-reverseengineering-somox-ruleengine/nightly/javadoc/ -* Deprecated build server: https://build.palladio-simulator.com/job/PalladioSimulator/job/Palladio-ReverseEngineering-SoMoX-RuleEngine/ +* Update site: https://updatesite.palladio-simulator.com/palladio-reverseengineering-retriever/nightly/ +* Javadoc: https://updatesite.palladio-simulator.com/palladio-reverseengineering-retriever/nightly/javadoc/ +* Deprecated build server: https://build.palladio-simulator.com/job/PalladioSimulator/job/Palladio-ReverseEngineering-Retriever/ ## Licensing The code in this project is licensed under the [EPL-2.0 License](LICENSE). diff --git a/action.yml b/action.yml index d0dd1dee..1f37b670 100644 --- a/action.yml +++ b/action.yml @@ -1,11 +1,11 @@ -# A GitHub Action that allows to run the RuleEngine on arbitrary GitHub repositories. +# A GitHub Action that allows to run Retriever on arbitrary GitHub repositories. -name: "Run RuleEngine" +name: "Run Retriever" description: | 'Reverse-engineers a project''s source into a Palladio Component Model. - Uploads the PCM as an artifact called `ruleengine`. + Uploads the PCM as an artifact called `retriever`. Within that artifact, the PCM is located at the input `source_path`, - e.g. for `source_path=MyProject/Repository` the output is `[ruleengine]/MyProject/Repository/repository.pcm`.' + e.g. for `source_path=MyProject/Repository` the output is `[retriever]/MyProject/Repository/repository.pcm`.' inputs: source_path: @@ -15,7 +15,7 @@ inputs: rules: description: "The rules to reverse-engineer with, as a comma-separated list" required: true - default: "SPRING,MAVEN" + default: "org.palladiosimulator.retriever.extraction.rules.SpringRules,org.palladiosimulator.retriever.extraction.rules.MavenRules" runs: using: "composite" @@ -31,12 +31,12 @@ runs: run: | TMP_DIR=$(mktemp -d) echo "tmp_dir=$TMP_DIR" >> $GITHUB_ENV - mkdir $TMP_DIR/ruleengine_out + mkdir $TMP_DIR/retriever_out - name: Gather Git Repository Info shell: bash run: | - GIT_INFO_FILE=${{ env.tmp_dir }}/ruleengine_out/git_info.txt + GIT_INFO_FILE=${{ env.tmp_dir }}/retriever_out/git_info.txt echo "GIT_INFO_FILE=$GIT_INFO_FILE" >> $GITHUB_ENV { echo "Git repository information:" @@ -52,9 +52,9 @@ runs: - name: Gather Specific System Information with Neofetch shell: bash run: | - SYSTEM_INFO_FILE=${{ env.tmp_dir }}/ruleengine_out/system_info.txt + SYSTEM_INFO_FILE=${{ env.tmp_dir }}/retriever_out/system_info.txt echo "SYSTEM_INFO_FILE=$SYSTEM_INFO_FILE" >> $GITHUB_ENV - echo "SYSTEM_INFO_FILE=${{ env.tmp_dir }}/ruleengine_out/system_info.txt" >> $GITHUB_ENV + echo "SYSTEM_INFO_FILE=${{ env.tmp_dir }}/retriever_out/system_info.txt" >> $GITHUB_ENV { echo "system information:" neofetch os distro kernel cpu gpu memory --stdout @@ -68,7 +68,7 @@ runs: - name: Run cloc analysis shell: bash run: | - CLOC_INFO_FILE=${{ env.tmp_dir }}/ruleengine_out/cloc.txt + CLOC_INFO_FILE=${{ env.tmp_dir }}/retriever_out/cloc.txt echo "CLOC_INFO_FILE=$CLOC_INFO_FILE" >> $GITHUB_ENV { echo "cloc analysis output:" @@ -85,47 +85,47 @@ runs: ACTION_VERSION=$(echo ${{ github.action_path }} | cut -d / -f 8- -) echo "action_version=$ACTION_VERSION" >> $GITHUB_ENV - - name: Download latest RuleEngine + - name: Download latest Retriever if: env.action_version == 'master' shell: bash run: | - curl -s ${{ github.api_url }}/repos/PalladioSimulator/Palladio-ReverseEngineering-SoMoX-RuleEngine/releases/latest \ + curl -s ${{ github.api_url }}/repos/PalladioSimulator/Palladio-ReverseEngineering-Retriever/releases/latest \ | grep -E 'browser_download_url' \ | grep linux \ | grep x86_64 \ | grep -Eo 'https://[^\"]*' \ - | xargs wget -O "${{ env.tmp_dir }}/ruleengine.zip" + | xargs wget -O "${{ env.tmp_dir }}/retriever.zip" - - name: Download RuleEngine + - name: Download Retriever if: env.action_version != 'master' shell: bash - # Downloads the RuleEngine with the same version that this action has + # Downloads Retriever with the same version that this action has # (not necessarily the most recent one!). run: | - curl -s ${{ github.api_url }}/repos/PalladioSimulator/Palladio-ReverseEngineering-SoMoX-RuleEngine/releases/tags/${{ env.action_version }} \ + curl -s ${{ github.api_url }}/repos/PalladioSimulator/Palladio-ReverseEngineering-Retriever/releases/tags/${{ env.action_version }} \ | grep -E 'browser_download_url' \ | grep linux \ | grep x86_64 \ | grep -Eo 'https://[^\"]*' \ - | xargs wget -O "${{ env.tmp_dir }}/ruleengine.zip" + | xargs wget -O "${{ env.tmp_dir }}/retriever.zip" - - name: Extract RuleEngine + - name: Extract Retriever shell: bash working-directory: ${{ env.tmp_dir }} - run: unzip ruleengine.zip -d ruleengine + run: unzip retriever.zip -d retriever - - name: Execute RuleEngine + - name: Execute Retriever shell: bash - working-directory: ${{ env.tmp_dir }}/ruleengine + working-directory: ${{ env.tmp_dir }}/retriever env: - RULEENGINE_COMMAND: './eclipse -i "${{ github.workspace }}/${{ inputs.source_path }}" -o "${{ env.tmp_dir }}/ruleengine_out" -r "${{ inputs.rules }}"' + RETRIEVER_COMMAND: './eclipse -i "${{ github.workspace }}/${{ inputs.source_path }}" -o "${{ env.tmp_dir }}/retriever_out" -r "${{ inputs.rules }}"' run: | - TIMING_INFO_FILE=${{ env.tmp_dir }}/ruleengine_out/timing.txt + TIMING_INFO_FILE=${{ env.tmp_dir }}/retriever_out/timing.txt echo "TIMING_INFO_FILE=$TIMING_INFO_FILE" >> $GITHUB_ENV - /usr/bin/time -p -o "$TIMING_INFO_FILE" $RULEENGINE_COMMAND + /usr/bin/time -p -o "$TIMING_INFO_FILE" $RETRIEVER_COMMAND # Read and reformat the timing information { - echo "RuleEngine execution time:" + echo "Retriever execution time:" while IFS= read -r line; do case "$line" in real*) echo "Total Elapsed Time (seconds): ${line#* }" ;; @@ -147,7 +147,7 @@ runs: cat $CLOC_INFO_FILE echo cat $TIMING_INFO_FILE - } > ${{ env.tmp_dir }}/ruleengine_out/report.txt + } > ${{ env.tmp_dir }}/retriever_out/report.txt # Delete the original files rm -f $GIT_INFO_FILE $SYSTEM_INFO_FILE $CLOC_INFO_FILE $TIMING_INFO_FILE @@ -157,15 +157,15 @@ runs: working-directory: ${{ env.tmp_dir }} run: | mkdir -p tmp/${{ inputs.source_path }} - mv ruleengine_out/* tmp/${{ inputs.source_path }} - mv tmp/* ruleengine_out + mv retriever_out/* tmp/${{ inputs.source_path }} + mv tmp/* retriever_out rmdir tmp - name: Upload analysis results uses: actions/upload-artifact@v3 with: - name: ruleengine - path: ${{ env.tmp_dir }}/ruleengine_out + name: retriever + path: ${{ env.tmp_dir }}/retriever_out - name: Prepare Eclipse logs for upload if: failure() @@ -173,7 +173,7 @@ runs: working-directory: ${{ env.tmp_dir }} run: | mkdir -p eclipse_logs/${{ inputs.source_path }} - mv ruleengine/configuration/*.log ruleengine/workspace/.metadata/.log eclipse_logs/${{ inputs.source_path }} + mv retriever/configuration/*.log retriever/workspace/.metadata/.log eclipse_logs/${{ inputs.source_path }} - name: Upload Eclipse logs if: failure() diff --git a/bundles/org.palladiosimulator.retriever.core/.classpath b/bundles/org.palladiosimulator.retriever.core/.classpath new file mode 100644 index 00000000..9cec141d --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.core/.classpath @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/.project b/bundles/org.palladiosimulator.retriever.core/.project similarity index 93% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/.project rename to bundles/org.palladiosimulator.retriever.core/.project index 8945c7b5..5173b79c 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/.project +++ b/bundles/org.palladiosimulator.retriever.core/.project @@ -1,6 +1,6 @@ - org.palladiosimulator.somox.analyzer.rules.main + org.palladiosimulator.retriever.core diff --git a/bundles/org.palladiosimulator.retriever.core/META-INF/MANIFEST.MF b/bundles/org.palladiosimulator.retriever.core/META-INF/MANIFEST.MF new file mode 100644 index 00000000..6d0edce8 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.core/META-INF/MANIFEST.MF @@ -0,0 +1,22 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Retriever Core +Bundle-SymbolicName: org.palladiosimulator.retriever.core;singleton:=true +Bundle-Version: 5.2.0.qualifier +Bundle-Vendor: palladiosimulator.org +Automatic-Module-Name: org.palladiosimulator.retriever.core +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Require-Bundle: org.eclipse.jdt.core, + org.palladiosimulator.retriever.extraction, + de.uka.ipd.sdq.workflow.launchconfig, + org.eclipse.debug.ui, + org.eclipse.swt, + org.palladiosimulator.generator.fluent, + org.palladiosimulator.somox.ast2seff, + org.palladiosimulator.retriever.mocore, + org.palladiosimulator.view.plantuml.generator +Export-Package: org.palladiosimulator.retriever.core.cli;uses:="org.eclipse.equinox.app", + org.palladiosimulator.retriever.core.configuration, + org.palladiosimulator.retriever.core.main, + org.palladiosimulator.retriever.core.service, + org.palladiosimulator.retriever.core.workflow diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/build.properties b/bundles/org.palladiosimulator.retriever.core/build.properties similarity index 100% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/build.properties rename to bundles/org.palladiosimulator.retriever.core/build.properties diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/icons/RuleEngine_16x16.gif b/bundles/org.palladiosimulator.retriever.core/icons/Retriever_16x16.gif similarity index 100% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/icons/RuleEngine_16x16.gif rename to bundles/org.palladiosimulator.retriever.core/icons/Retriever_16x16.gif diff --git a/bundles/org.palladiosimulator.retriever.core/plugin.xml b/bundles/org.palladiosimulator.retriever.core/plugin.xml new file mode 100644 index 00000000..95482c0e --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.core/plugin.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/cli/RuleEngineApplication.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/cli/RetrieverApplication.java similarity index 70% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/cli/RuleEngineApplication.java rename to bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/cli/RetrieverApplication.java index 92aead83..715029f0 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/cli/RuleEngineApplication.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/cli/RetrieverApplication.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.cli; +package org.palladiosimulator.retriever.core.cli; import java.nio.file.InvalidPathException; import java.nio.file.Paths; @@ -16,18 +16,18 @@ import org.eclipse.emf.common.util.URI; import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplicationContext; -import org.palladiosimulator.somox.analyzer.rules.configuration.RuleEngineConfigurationImpl; -import org.palladiosimulator.somox.analyzer.rules.engine.Rule; -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; -import org.palladiosimulator.somox.analyzer.rules.engine.ServiceConfiguration; -import org.palladiosimulator.somox.analyzer.rules.service.RuleCollection; -import org.palladiosimulator.somox.analyzer.rules.workflow.RuleEngineJob; -import org.palladiosimulator.somox.discoverer.Discoverer; -import org.palladiosimulator.somox.discoverer.DiscovererCollection; - -public class RuleEngineApplication implements IApplication { - - private static Options createOptions(Set availableRuleIDs) { +import org.palladiosimulator.retriever.core.configuration.RetrieverConfigurationImpl; +import org.palladiosimulator.retriever.core.service.DiscovererCollection; +import org.palladiosimulator.retriever.core.service.RuleCollection; +import org.palladiosimulator.retriever.core.workflow.RetrieverJob; +import org.palladiosimulator.retriever.extraction.engine.Discoverer; +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; +import org.palladiosimulator.retriever.extraction.engine.Rule; +import org.palladiosimulator.retriever.extraction.engine.ServiceConfiguration; + +public class RetrieverApplication implements IApplication { + + private static Options createOptions(final Set availableRuleIDs) { final Options options = new Options(); options .addRequiredOption("i", "input-directory", true, @@ -54,10 +54,10 @@ private static void printHelp(final Options options) { } @Override - public Object start(IApplicationContext context) throws Exception { + public Object start(final IApplicationContext context) throws Exception { - Set availableRules = new RuleCollection().getServices(); - Set availableRuleIDs = availableRules.stream() + final Set availableRules = new RuleCollection().getServices(); + final Set availableRuleIDs = availableRules.stream() .map(Rule::getID) .collect(Collectors.toSet()); @@ -77,7 +77,7 @@ public Object start(IApplicationContext context) throws Exception { printHelp(options); } - RuleEngineConfiguration configuration = new RuleEngineConfigurationImpl(); + final RetrieverConfiguration configuration = new RetrieverConfigurationImpl(); try { configuration.setInputFolder(URI.createFileURI(URI.decode(Paths.get(cmd.getOptionValue("i")) @@ -101,29 +101,29 @@ public Object start(IApplicationContext context) throws Exception { // Enable all discoverers, in case a selected rule depends on them. // TODO: This is unnecessary once rule dependencies are in place - ServiceConfiguration discovererConfig = configuration.getConfig(Discoverer.class); - for (Discoverer discoverer : new DiscovererCollection().getServices()) { + final ServiceConfiguration discovererConfig = configuration.getConfig(Discoverer.class); + for (final Discoverer discoverer : new DiscovererCollection().getServices()) { discovererConfig.select(discoverer); } - ServiceConfiguration ruleConfig = configuration.getConfig(Rule.class); + final ServiceConfiguration ruleConfig = configuration.getConfig(Rule.class); // Extract and check rules - Set requestedRuleIDs = Arrays.stream(cmd.getOptionValue("r") + final Set requestedRuleIDs = Arrays.stream(cmd.getOptionValue("r") .split(",")) .map(String::strip) .collect(Collectors.toSet()); - Set rules = availableRules.stream() + final Set rules = availableRules.stream() .filter(x -> requestedRuleIDs.contains(x.getID())) .collect(Collectors.toSet()); if (rules.isEmpty()) { System.err.println("Invalid rules: " + cmd.getOptionValue("r")); return -1; } - for (Rule rule : rules) { + for (final Rule rule : rules) { ruleConfig.select(rule); } - new RuleEngineJob(configuration).execute(new NullProgressMonitor()); + new RetrieverJob(configuration).execute(new NullProgressMonitor()); return 0; } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/configuration/RuleEngineBlackboardKeys.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverBlackboardKeys.java similarity index 68% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/configuration/RuleEngineBlackboardKeys.java rename to bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverBlackboardKeys.java index 0912e518..fa24347b 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/configuration/RuleEngineBlackboardKeys.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverBlackboardKeys.java @@ -1,11 +1,11 @@ -package org.palladiosimulator.somox.analyzer.rules.configuration; +package org.palladiosimulator.retriever.core.configuration; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; -public final class RuleEngineBlackboardKeys { - private static final String CONFIG_PREFIX = "org.palladiosimulator.somox.analyzer.rules.configuration."; - public static final String RULE_ENGINE_BLACKBOARD_KEY_REPOSITORY = RuleEngineBlackboard.KEY_REPOSITORY; - public static final String RULE_ENGINE_BLACKBOARD_KEY_SEFF_ASSOCIATIONS = RuleEngineBlackboard.KEY_SEFF_ASSOCIATIONS; +public final class RetrieverBlackboardKeys { + private static final String CONFIG_PREFIX = "org.palladiosimulator.retriever.core.configuration."; + public static final String RULE_ENGINE_BLACKBOARD_KEY_REPOSITORY = RetrieverBlackboard.KEY_REPOSITORY; + public static final String RULE_ENGINE_BLACKBOARD_KEY_SEFF_ASSOCIATIONS = RetrieverBlackboard.KEY_SEFF_ASSOCIATIONS; public static final String RULE_ENGINE_AST2SEFF_OUTPUT_REPOSITORY = CONFIG_PREFIX + "ast2seff.output.repository"; public static final String RULE_ENGINE_MOCORE_OUTPUT_REPOSITORY = CONFIG_PREFIX + "mocore.output.repository"; public static final String RULE_ENGINE_MOCORE_OUTPUT_SYSTEM = CONFIG_PREFIX + "mocore.output.system"; @@ -14,7 +14,7 @@ public final class RuleEngineBlackboardKeys { + "mocore.output.resource_environment"; public static final String RULE_LIST_SEPARATOR = ";"; - private RuleEngineBlackboardKeys() throws IllegalAccessException { + private RetrieverBlackboardKeys() throws IllegalAccessException { throw new IllegalAccessException(); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/configuration/RuleEngineConfigurationImpl.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverConfigurationImpl.java similarity index 57% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/configuration/RuleEngineConfigurationImpl.java rename to bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverConfigurationImpl.java index 993ab65f..a2246e11 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/configuration/RuleEngineConfigurationImpl.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverConfigurationImpl.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.configuration; +package org.palladiosimulator.retriever.core.configuration; import java.util.HashMap; import java.util.Map; @@ -7,24 +7,24 @@ import org.apache.log4j.Logger; import org.eclipse.core.runtime.CoreException; import org.eclipse.emf.common.util.URI; -import org.palladiosimulator.somox.analyzer.rules.engine.Rule; -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; -import org.palladiosimulator.somox.analyzer.rules.engine.Service; -import org.palladiosimulator.somox.analyzer.rules.engine.ServiceCollection; -import org.palladiosimulator.somox.analyzer.rules.engine.ServiceConfiguration; -import org.palladiosimulator.somox.analyzer.rules.service.Analyst; -import org.palladiosimulator.somox.analyzer.rules.service.AnalystCollection; -import org.palladiosimulator.somox.analyzer.rules.service.EmptyCollection; -import org.palladiosimulator.somox.analyzer.rules.service.RuleCollection; -import org.palladiosimulator.somox.discoverer.Discoverer; -import org.palladiosimulator.somox.discoverer.DiscovererCollection; +import org.palladiosimulator.retriever.core.service.Analyst; +import org.palladiosimulator.retriever.core.service.AnalystCollection; +import org.palladiosimulator.retriever.core.service.DiscovererCollection; +import org.palladiosimulator.retriever.core.service.EmptyCollection; +import org.palladiosimulator.retriever.core.service.RuleCollection; +import org.palladiosimulator.retriever.extraction.engine.Discoverer; +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; +import org.palladiosimulator.retriever.extraction.engine.Rule; +import org.palladiosimulator.retriever.extraction.engine.Service; +import org.palladiosimulator.retriever.extraction.engine.ServiceCollection; +import org.palladiosimulator.retriever.extraction.engine.ServiceConfiguration; import de.uka.ipd.sdq.workflow.configuration.AbstractComposedJobConfiguration; -public class RuleEngineConfigurationImpl extends AbstractComposedJobConfiguration implements RuleEngineConfiguration { - private static final Logger LOG = Logger.getLogger(RuleEngineConfigurationImpl.class); +public class RetrieverConfigurationImpl extends AbstractComposedJobConfiguration implements RetrieverConfiguration { + private static final Logger LOG = Logger.getLogger(RetrieverConfigurationImpl.class); - private static final String CONFIG_PREFIX = "org.palladiosimulator.somox.analyzer.rules.configuration."; + private static final String CONFIG_PREFIX = "org.palladiosimulator.retriever.core.configuration."; public static final String RULE_ENGINE_INPUT_PATH = "input.path"; public static final String RULE_ENGINE_OUTPUT_PATH = CONFIG_PREFIX + "output.path"; public static final String RULE_ENGINE_SELECTED_RULES = CONFIG_PREFIX + "rules"; @@ -41,51 +41,51 @@ public class RuleEngineConfigurationImpl extends AbstractComposedJobConfiguratio private final Map attributes; - public RuleEngineConfigurationImpl() { + public RetrieverConfigurationImpl() { this(new HashMap<>()); } - public RuleEngineConfigurationImpl(Map attributes) { + public RetrieverConfigurationImpl(final Map attributes) { this.attributes = Objects.requireNonNull(attributes); this.serviceConfigs = new HashMap<>(); ServiceCollection discovererCollection = null; try { discovererCollection = new DiscovererCollection(); - } catch (CoreException e) { + } catch (final CoreException e) { LOG.error("Exception occurred while discovering discoverers!"); discovererCollection = new EmptyCollection<>(); } - ServiceConfiguration discovererConfig = new ServiceConfiguration<>(discovererCollection, + final ServiceConfiguration discovererConfig = new ServiceConfiguration<>(discovererCollection, RULE_ENGINE_SELECTED_DISCOVERERS, RULE_ENGINE_DISCOVERER_CONFIG_PREFIX); - serviceConfigs.put(Discoverer.class, discovererConfig); + this.serviceConfigs.put(Discoverer.class, discovererConfig); ServiceCollection ruleCollection = null; try { ruleCollection = new RuleCollection(); - } catch (CoreException e) { + } catch (final CoreException e) { LOG.error("Exception occurred while discovering rules!"); ruleCollection = new EmptyCollection<>(); } - ServiceConfiguration ruleConfig = new ServiceConfiguration<>(ruleCollection, RULE_ENGINE_SELECTED_RULES, - RULE_ENGINE_RULE_CONFIG_PREFIX); + final ServiceConfiguration ruleConfig = new ServiceConfiguration<>(ruleCollection, + RULE_ENGINE_SELECTED_RULES, RULE_ENGINE_RULE_CONFIG_PREFIX); ruleConfig.addDependencyProvider(discovererConfig); - serviceConfigs.put(Rule.class, ruleConfig); + this.serviceConfigs.put(Rule.class, ruleConfig); ServiceCollection analystCollection = null; try { analystCollection = new AnalystCollection(); - } catch (CoreException e) { + } catch (final CoreException e) { LOG.error("Exception occurred while discovering analysts!"); analystCollection = new EmptyCollection<>(); } - ServiceConfiguration analystConfig = new ServiceConfiguration<>(analystCollection, + final ServiceConfiguration analystConfig = new ServiceConfiguration<>(analystCollection, RULE_ENGINE_SELECTED_ANALYSTS, RULE_ENGINE_ANALYST_CONFIG_PREFIX); analystConfig.addDependencyProvider(discovererConfig); analystConfig.addDependencyProvider(ruleConfig); - serviceConfigs.put(Analyst.class, analystConfig); + this.serviceConfigs.put(Analyst.class, analystConfig); - applyAttributeMap(attributes); + this.applyAttributeMap(attributes); } public void applyAttributeMap(final Map attributeMap) { @@ -94,57 +94,57 @@ public void applyAttributeMap(final Map attributeMap) { } if (attributeMap.get(RULE_ENGINE_INPUT_PATH) != null) { - setInputFolder(URI.createURI((String) attributeMap.get(RULE_ENGINE_INPUT_PATH))); + this.setInputFolder(URI.createURI((String) attributeMap.get(RULE_ENGINE_INPUT_PATH))); } if (attributeMap.get(RULE_ENGINE_OUTPUT_PATH) != null) { - setOutputFolder(URI.createURI((String) attributeMap.get(RULE_ENGINE_OUTPUT_PATH))); + this.setOutputFolder(URI.createURI((String) attributeMap.get(RULE_ENGINE_OUTPUT_PATH))); } - for (ServiceConfiguration serviceConfig : serviceConfigs.values()) { + for (final ServiceConfiguration serviceConfig : this.serviceConfigs.values()) { serviceConfig.applyAttributeMap(attributeMap); } } @Override public Map getAttributes() { - return attributes; + return this.attributes; } @Override public URI getInputFolder() { - return inputFolder; + return this.inputFolder; } @Override public URI getOutputFolder() { - return outputFolder; + return this.outputFolder; } @Override - public void setInputFolder(URI inputFolder) { + public void setInputFolder(final URI inputFolder) { this.inputFolder = inputFolder; } @Override - public void setOutputFolder(URI outputFolder) { + public void setOutputFolder(final URI outputFolder) { this.outputFolder = outputFolder; } @Override - public ServiceConfiguration getConfig(Class serviceClass) { + public ServiceConfiguration getConfig(final Class serviceClass) { // serviceConfig only contains legal mappings @SuppressWarnings("unchecked") - ServiceConfiguration serviceConfig = (ServiceConfiguration) serviceConfigs.get(serviceClass); + final ServiceConfiguration serviceConfig = (ServiceConfiguration) this.serviceConfigs.get(serviceClass); return serviceConfig; } public Map toMap() { final Map result = new HashMap<>(); - result.put(RULE_ENGINE_INPUT_PATH, getInputFolder()); - result.put(RULE_ENGINE_OUTPUT_PATH, getOutputFolder()); + result.put(RULE_ENGINE_INPUT_PATH, this.getInputFolder()); + result.put(RULE_ENGINE_OUTPUT_PATH, this.getOutputFolder()); - for (ServiceConfiguration serviceConfig : serviceConfigs.values()) { + for (final ServiceConfiguration serviceConfig : this.serviceConfigs.values()) { result.putAll(serviceConfig.toMap()); } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverWorkflowConfiguration.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverWorkflowConfiguration.java new file mode 100644 index 00000000..074c1cea --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/configuration/RetrieverWorkflowConfiguration.java @@ -0,0 +1,34 @@ +package org.palladiosimulator.retriever.core.configuration; + +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; + +import de.uka.ipd.sdq.workflow.launchconfig.AbstractWorkflowBasedRunConfiguration; + +/** + * An adapter for RetrieverConfiguration, not more than a formality for use as a type parameter in + * AbstractWorkflowBasedLaunchConfigurationDelegate + * + * @see de.uka.ipd.sdq.workflow.launchconfig.AbstractWorkflowBasedLaunchConfigurationDelegate + */ +public class RetrieverWorkflowConfiguration extends AbstractWorkflowBasedRunConfiguration { + + private RetrieverConfiguration configuration; + + @Override + public void setDefaults() { + this.configuration = new RetrieverConfigurationImpl(); + } + + public RetrieverConfiguration getRetrieverConfiguration() { + return this.configuration; + } + + public void setRetrieverConfiguration(final RetrieverConfiguration configuration) { + this.configuration = configuration; + } + + @Override + public String getErrorMessage() { + return null; + } +} diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverConfigurationDelegate.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverConfigurationDelegate.java new file mode 100644 index 00000000..c15c0565 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverConfigurationDelegate.java @@ -0,0 +1,33 @@ +package org.palladiosimulator.retriever.core.gui; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.palladiosimulator.retriever.core.configuration.RetrieverConfigurationImpl; +import org.palladiosimulator.retriever.core.configuration.RetrieverWorkflowConfiguration; +import org.palladiosimulator.retriever.core.workflow.RetrieverJob; + +import de.uka.ipd.sdq.workflow.Workflow; +import de.uka.ipd.sdq.workflow.jobs.IJob; +import de.uka.ipd.sdq.workflow.launchconfig.AbstractWorkflowBasedLaunchConfigurationDelegate; + +public class RetrieverConfigurationDelegate + extends AbstractWorkflowBasedLaunchConfigurationDelegate { + + @Override + protected IJob createWorkflowJob(final RetrieverWorkflowConfiguration config, final ILaunch launch) + throws CoreException { + return new RetrieverJob(config.getRetrieverConfiguration()); + } + + @Override + protected RetrieverWorkflowConfiguration deriveConfiguration(final ILaunchConfiguration configuration, + final String mode) throws CoreException { + + final RetrieverWorkflowConfiguration analyzerConfiguration = new RetrieverWorkflowConfiguration(); + analyzerConfiguration.setRetrieverConfiguration(new RetrieverConfigurationImpl(configuration.getAttributes())); + + return analyzerConfiguration; + } + +} diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverTab.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverTab.java new file mode 100644 index 00000000..de7c8259 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverTab.java @@ -0,0 +1,247 @@ +package org.palladiosimulator.retriever.core.gui; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.apache.log4j.Logger; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; +import org.eclipse.emf.common.CommonPlugin; +import org.eclipse.emf.common.util.URI; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; +import org.palladiosimulator.retriever.core.configuration.RetrieverConfigurationImpl; +import org.palladiosimulator.retriever.core.service.Analyst; +import org.palladiosimulator.retriever.core.service.AnalystCollection; +import org.palladiosimulator.retriever.core.service.DiscovererCollection; +import org.palladiosimulator.retriever.core.service.EmptyCollection; +import org.palladiosimulator.retriever.core.service.RuleCollection; +import org.palladiosimulator.retriever.extraction.engine.Discoverer; +import org.palladiosimulator.retriever.extraction.engine.Rule; +import org.palladiosimulator.retriever.extraction.engine.ServiceCollection; +import org.palladiosimulator.retriever.extraction.engine.ServiceConfiguration; + +import de.uka.ipd.sdq.workflow.launchconfig.ImageRegistryHelper; +import de.uka.ipd.sdq.workflow.launchconfig.LaunchConfigPlugin; +import de.uka.ipd.sdq.workflow.launchconfig.tabs.TabHelper; + +public class RetrieverTab extends AbstractLaunchConfigurationTab { + + public static final String NAME = "Retriever"; + public static final String PLUGIN_ID = "org.palladiosimulator.retriever.core.gui.LaunchRetriever"; + private static final String FILENAME_TAB_IMAGE_PATH = "icons/Retriever_16x16.gif"; + + private final String defaultPath; + private final ModifyListener modifyListener; + + private Text in; + private Text out; + private final ServiceConfigurationManager discovererConfigManager; + private final ServiceConfigurationView ruleConfigView; + private final ServiceConfigurationView analystConfigView; + + public RetrieverTab() { + // Create the default path of this Eclipse application + this.defaultPath = Paths.get(".") + .toAbsolutePath() + .normalize() + .toString(); + + // Create a listener for GUI modification events + this.modifyListener = e -> { + // e may be null here! + this.setDirty(true); + this.updateLaunchConfigurationDialog(); + }; + + ServiceCollection discovererCollection = null; + try { + discovererCollection = new DiscovererCollection(); + } catch (final CoreException e) { + Logger.getLogger(RetrieverTab.class) + .error("Exception occurred while discovering discoverers!"); + discovererCollection = new EmptyCollection<>(); + } + final ServiceConfiguration discovererConfig = new ServiceConfiguration<>(discovererCollection, + RetrieverConfigurationImpl.RULE_ENGINE_SELECTED_DISCOVERERS, + RetrieverConfigurationImpl.RULE_ENGINE_DISCOVERER_CONFIG_PREFIX); + this.discovererConfigManager = new ServiceConfigurationManager<>(discovererConfig); + + ServiceCollection ruleCollection = null; + try { + ruleCollection = new RuleCollection(); + } catch (final CoreException e) { + Logger.getLogger(RetrieverTab.class) + .error("Exception occurred while discovering rules!"); + ruleCollection = new EmptyCollection<>(); + } + final ServiceConfiguration ruleConfig = new ServiceConfiguration<>(ruleCollection, + RetrieverConfigurationImpl.RULE_ENGINE_SELECTED_RULES, + RetrieverConfigurationImpl.RULE_ENGINE_RULE_CONFIG_PREFIX); + ruleConfig.addDependencyProvider(discovererConfig); + this.ruleConfigView = new ServiceConfigurationView<>(ruleConfig, this.modifyListener); + + ServiceCollection analystCollection = null; + try { + analystCollection = new AnalystCollection(); + } catch (final CoreException e) { + Logger.getLogger(RetrieverTab.class) + .error("Exception occurred while discovering analysts!"); + analystCollection = new EmptyCollection<>(); + } + final ServiceConfiguration analystConfig = new ServiceConfiguration<>(analystCollection, + RetrieverConfigurationImpl.RULE_ENGINE_SELECTED_ANALYSTS, + RetrieverConfigurationImpl.RULE_ENGINE_ANALYST_CONFIG_PREFIX); + analystConfig.addDependencyProvider(discovererConfig); + analystConfig.addDependencyProvider(ruleConfig); + this.analystConfigView = new ServiceConfigurationView<>(analystConfig, this.modifyListener); + + } + + @Override + public Image getImage() { + // TODO create an image + return ImageRegistryHelper.getTabImage(PLUGIN_ID, FILENAME_TAB_IMAGE_PATH); + } + + @Override + public void createControl(final Composite parent) { + // Create a new Composite to hold the page's controls + final Composite container = new Composite(parent, SWT.NONE); + this.setControl(container); + container.setLayout(new GridLayout()); + + // Create file input area for input + this.in = new Text(container, SWT.SINGLE | SWT.BORDER); + TabHelper.createFolderInputSection(container, this.modifyListener, "File In", this.in, "File In", + this.getShell(), this.defaultPath); + + // Create file input area for output + this.out = new Text(container, SWT.SINGLE | SWT.BORDER); + TabHelper.createFolderInputSection(container, this.modifyListener, "File Out", this.out, "File Out", + this.getShell(), this.defaultPath); + + // Create tree view for rule and analyst configuration + // Do not create a view for discoverers, they can always be selected automatically. + // If a discoverer is added that requires configuration, this view has to be added back. + this.ruleConfigView.createControl(container); + this.analystConfigView.createControl(container); + } + + private boolean validateFolderInput(final Text widget) { + if ((widget == null) || (widget.getText() == null) || widget.getText() + .isBlank()) { + return this.error("Blank input."); + } + + try { + final URI uri = getURI(widget); + final Path path = Paths.get(CommonPlugin.asLocalURI(uri) + .devicePath()); + + if (!Files.exists(path)) { + return this.error("The file located by '" + uri + "'does not exist."); + } + } catch (final Exception e) { + return this.error(e.getLocalizedMessage()); + } + return this.error(null); + } + + private boolean error(final String message) { + this.setErrorMessage(message); + return message == null; + } + + private static URI getURI(final Text widget) { + final String text = URI.decode(widget.getText()); + final URI uri = URI.createURI(text); + if (uri.isPlatform() || uri.isFile()) { + return uri; + } + // This is necessary since paths may start with e.g. "C:" which would + // then be interpreted as a URI scheme + return URI.createFileURI(text); + } + + @Override + public boolean isValid(final ILaunchConfiguration launchConfig) { + return this.validateFolderInput(this.in) && this.validateFolderInput(this.out); + } + + @Override + public void initializeFrom(final ILaunchConfiguration configuration) { + this.setText(configuration, this.in, RetrieverConfigurationImpl.RULE_ENGINE_INPUT_PATH); + this.setText(configuration, this.out, RetrieverConfigurationImpl.RULE_ENGINE_OUTPUT_PATH); + + this.discovererConfigManager.initializeFrom(configuration); + this.ruleConfigView.initializeFrom(configuration); + this.analystConfigView.initializeFrom(configuration); + } + + private void setText(final ILaunchConfiguration configuration, final Text textWidget, final String attributeName) { + try { + textWidget.setText(configuration.getAttribute(attributeName, "")); + } catch (final Exception e) { + LaunchConfigPlugin.errorLogger(this.getName(), attributeName, e.getMessage()); + this.error(e.getLocalizedMessage()); + } + } + + @Override + public void performApply(final ILaunchConfigurationWorkingCopy configuration) { + this.setAttribute(configuration, RetrieverConfigurationImpl.RULE_ENGINE_INPUT_PATH, this.in); + this.setAttribute(configuration, RetrieverConfigurationImpl.RULE_ENGINE_OUTPUT_PATH, this.out); + this.discovererConfigManager.performApply(configuration); + this.ruleConfigView.performApply(configuration); + this.analystConfigView.performApply(configuration); + } + + private void setAttribute(final ILaunchConfigurationWorkingCopy configuration, final String attributeName, + final Text textWidget) { + try { + if (textWidget.getText() + .isEmpty()) { + configuration.setAttribute(attributeName, ""); + } else { + configuration.setAttribute(attributeName, getURI(textWidget).toString()); + } + } catch (final Exception e) { + this.error(e.getLocalizedMessage()); + } + } + + @Override + public void setDefaults(final ILaunchConfigurationWorkingCopy configuration) { + this.setText(this.in, this.defaultPath); + this.setAttribute(configuration, RetrieverConfigurationImpl.RULE_ENGINE_INPUT_PATH, this.in); + + this.setText(this.out, this.defaultPath); + this.setAttribute(configuration, RetrieverConfigurationImpl.RULE_ENGINE_OUTPUT_PATH, this.out); + + this.discovererConfigManager.setDefaults(configuration); + this.ruleConfigView.setDefaults(configuration); + this.analystConfigView.setDefaults(configuration); + } + + private void setText(final Text textWidget, final String attributeName) { + try { + textWidget.setText(attributeName); + } catch (final Exception e) { + this.error(e.getMessage()); + } + } + + @Override + public String getName() { + return NAME; + } + +} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/RuleEngineTabGroup.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverTabGroup.java similarity index 69% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/RuleEngineTabGroup.java rename to bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverTabGroup.java index 5097ba96..765dd9f3 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/RuleEngineTabGroup.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/RetrieverTabGroup.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.gui; +package org.palladiosimulator.retriever.core.gui; import java.util.ArrayList; import java.util.List; @@ -9,15 +9,15 @@ import de.uka.ipd.sdq.workflow.launchconfig.tabs.DebugEnabledCommonTab; -public class RuleEngineTabGroup extends AbstractLaunchConfigurationTabGroup { +public class RetrieverTabGroup extends AbstractLaunchConfigurationTabGroup { @Override public void createTabs(final ILaunchConfigurationDialog dialog, final String mode) { final List tabs = new ArrayList<>(); - tabs.add(new RuleEngineIoTab()); + tabs.add(new RetrieverTab()); tabs.add(new DebugEnabledCommonTab()); - setTabs(tabs.toArray(new ILaunchConfigurationTab[0])); + this.setTabs(tabs.toArray(new ILaunchConfigurationTab[0])); } } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/ServiceConfigurationManager.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/ServiceConfigurationManager.java new file mode 100644 index 00000000..9a5619bd --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/ServiceConfigurationManager.java @@ -0,0 +1,54 @@ +package org.palladiosimulator.retriever.core.gui; + +import java.util.Map; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.palladiosimulator.retriever.extraction.engine.Service; +import org.palladiosimulator.retriever.extraction.engine.ServiceConfiguration; + +import de.uka.ipd.sdq.workflow.launchconfig.LaunchConfigPlugin; + +public class ServiceConfigurationManager { + private final ServiceConfiguration serviceConfiguration; + + public ServiceConfigurationManager(final ServiceConfiguration serviceConfiguration) { + this.serviceConfiguration = serviceConfiguration; + } + + public void initializeFrom(final ILaunchConfiguration configuration) { + try { + this.serviceConfiguration.applyAttributeMap(configuration.getAttributes()); + } catch (final CoreException e) { + LaunchConfigPlugin.log(IStatus.ERROR, e.getMessage()); + } + } + + public void performApply(final ILaunchConfigurationWorkingCopy configuration) { + // Update the LaunchConfiguration + this.writeServiceConfigAttributes(configuration); + } + + /** + * Called when a new launch configuration is created, to set the values to sensible defaults. + * + * @param configuration + * the new launch configuration + */ + public void setDefaults(final ILaunchConfigurationWorkingCopy configuration) { + this.writeServiceConfigAttributes(configuration); + } + + private void writeServiceConfigAttributes(final ILaunchConfigurationWorkingCopy configuration) { + final Map attributes = this.serviceConfiguration.toMap(); + for (final Map.Entry attribute : attributes.entrySet()) { + configuration.setAttribute(attribute.getKey(), attribute.getValue()); + } + } + + public ServiceConfiguration getServiceConfiguration() { + return this.serviceConfiguration; + } +} diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/ServiceConfigurationView.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/ServiceConfigurationView.java new file mode 100644 index 00000000..0522251f --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/ServiceConfigurationView.java @@ -0,0 +1,169 @@ +package org.palladiosimulator.retriever.core.gui; + +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.stream.Collectors; + +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.TreeEditor; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeColumn; +import org.eclipse.swt.widgets.TreeItem; +import org.palladiosimulator.retriever.extraction.engine.Service; +import org.palladiosimulator.retriever.extraction.engine.ServiceConfiguration; + +public class ServiceConfigurationView extends ServiceConfigurationManager { + private static final int SERVICE_CONFIGURATION_VALUE_COLUMN = 1; + + private final Map> configTreeItems; + private final Map serviceCheckboxes; + + private final ModifyListener modifyListener; + + public ServiceConfigurationView(final ServiceConfiguration serviceConfiguration, + final ModifyListener modifyListener) { + super(serviceConfiguration); + + this.configTreeItems = new HashMap<>(); + this.serviceCheckboxes = new HashMap<>(); + + this.modifyListener = modifyListener; + } + + public void createControl(final Composite container) { + final Tree tree = new Tree(container, SWT.BORDER | SWT.FULL_SELECTION); + final TreeColumn nameColumn = new TreeColumn(tree, SWT.NONE); + nameColumn.setWidth(200); + final TreeColumn valueColumn = new TreeColumn(tree, SWT.NONE); + valueColumn.setWidth(200); + + tree.addListener(SWT.Selection, + new TreeEditListener(tree, this.modifyListener, SERVICE_CONFIGURATION_VALUE_COLUMN)); + + final List sortedServices = this.getServiceConfiguration() + .getAvailable() + .stream() + .sorted(Comparator.comparing(T::getName)) + .collect(Collectors.toList()); + for (final T service : sortedServices) { + final TreeItem serviceItem = new TreeItem(tree, SWT.NONE); + serviceItem.setText(0, service.getClass() + .getSimpleName()); + this.addCheckboxTo(serviceItem, service); + if (service.getConfigurationKeys() != null) { + final String serviceId = service.getID(); + this.configTreeItems.putIfAbsent(serviceId, new HashMap<>()); + for (final String configKey : service.getConfigurationKeys()) { + final TreeItem propertyItem = new TreeItem(serviceItem, SWT.NONE); + propertyItem.setText(0, configKey); + this.configTreeItems.get(serviceId) + .put(configKey, propertyItem); + } + } + } + } + + private void addCheckboxTo(final TreeItem item, final T service) { + final Tree tree = item.getParent(); + final TreeEditor editor = new TreeEditor(tree); + final Button checkbox = new Button(tree, SWT.CHECK); + checkbox.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(final SelectionEvent e) { + if (((Button) e.getSource()).getSelection()) { + ServiceConfigurationView.this.getServiceConfiguration() + .select(service); + } else { + ServiceConfigurationView.this.getServiceConfiguration() + .deselect(service); + } + ServiceConfigurationView.this.modifyListener.modifyText(null); + } + + @Override + public void widgetDefaultSelected(final SelectionEvent e) { + } + }); + checkbox.pack(); + this.serviceCheckboxes.put(service.getID(), checkbox); + editor.minimumWidth = checkbox.getSize().x; + editor.horizontalAlignment = SWT.LEFT; + editor.setEditor(checkbox, item, SERVICE_CONFIGURATION_VALUE_COLUMN); + } + + @Override + public void initializeFrom(final ILaunchConfiguration configuration) { + super.initializeFrom(configuration); + for (final T service : this.getServiceConfiguration() + .getAvailable()) { + final String id = service.getID(); + this.initializeCheckbox(service, this.serviceCheckboxes.get(id)); + this.initializeTreeItems(service, this.configTreeItems.get(id)); + } + } + + private void initializeCheckbox(final T service, final Button checkbox) { + final boolean selected = this.getServiceConfiguration() + .isManuallySelected(service); + checkbox.setSelection(selected); + } + + private void initializeTreeItems(final T service, final Map treeItems) { + final Map strings = this.getServiceConfiguration() + .getWholeConfig(service.getID()); + for (final Entry entry : treeItems.entrySet()) { + String value = strings.get(entry.getKey()); + if (value == null) { + value = ""; + } + entry.getValue() + .setText(SERVICE_CONFIGURATION_VALUE_COLUMN, value); + } + } + + @Override + public void performApply(final ILaunchConfigurationWorkingCopy configuration) { + // Update the ServiceConfiguration with the values from the tree items + for (final T service : this.getServiceConfiguration() + .getAvailable()) { + for (final Entry entry : this.configTreeItems.get(service.getID()) + .entrySet()) { + final TreeItem treeItem = entry.getValue(); + final String configurationValue = treeItem.getText(SERVICE_CONFIGURATION_VALUE_COLUMN); + this.getServiceConfiguration() + .setConfig(service.getID(), entry.getKey(), configurationValue); + } + } + + super.performApply(configuration); + } + + /** + * Called when a new launch configuration is created, to set the values to sensible defaults. + * + * @param configuration + * the new launch configuration + */ + @Override + public void setDefaults(final ILaunchConfigurationWorkingCopy configuration) { + this.writeServiceConfigAttributes(configuration); + } + + private void writeServiceConfigAttributes(final ILaunchConfigurationWorkingCopy configuration) { + final Map attributes = this.getServiceConfiguration() + .toMap(); + for (final Map.Entry attribute : attributes.entrySet()) { + configuration.setAttribute(attribute.getKey(), attribute.getValue()); + } + } +} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/TreeEditListener.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/TreeEditListener.java similarity index 59% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/TreeEditListener.java rename to bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/TreeEditListener.java index 8036aea8..ae1ffe9b 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/TreeEditListener.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/gui/TreeEditListener.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.gui; +package org.palladiosimulator.retriever.core.gui; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.TreeEditor; @@ -21,60 +21,60 @@ public class TreeEditListener implements Listener { private final ModifyListener modifyListener; private final int column; - public TreeEditListener(Tree tree, ModifyListener modifyListener, int column) { + public TreeEditListener(final Tree tree, final ModifyListener modifyListener, final int column) { this.tree = tree; this.modifyListener = modifyListener; this.column = column; - editor = new TreeEditor(tree); + this.editor = new TreeEditor(tree); } // Editable TreeItems adapted from // https://git.eclipse.org/c/platform/eclipse.platform.swt.git/ // plain/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet111.java @Override - public void handleEvent(Event event) { + public void handleEvent(final Event event) { final TreeItem item = (TreeItem) event.item; - if ((item != null) && (item == lastItem[0]) && (item.getParentItem() != null)) { - boolean showBorder = true; - final Composite composite = new Composite(tree, SWT.NONE); + if ((item != null) && (item == this.lastItem[0]) && (item.getParentItem() != null)) { + final boolean showBorder = true; + final Composite composite = new Composite(this.tree, SWT.NONE); if (showBorder) { composite.setBackground(new Color(0, 0, 0)); } final Text text = new Text(composite, SWT.NONE); final int inset = showBorder ? 1 : 0; composite.addListener(SWT.Resize, e1 -> { - Rectangle rect1 = composite.getClientArea(); + final Rectangle rect1 = composite.getClientArea(); text.setBounds(rect1.x + inset, rect1.y + inset, rect1.width - (inset * 2), rect1.height - (inset * 2)); }); - Listener textListener = e2 -> { + final Listener textListener = e2 -> { switch (e2.type) { case SWT.FocusOut: - item.setText(column, text.getText()); - modifyListener.modifyText(null); + item.setText(this.column, text.getText()); + this.modifyListener.modifyText(null); composite.dispose(); break; case SWT.Verify: - String newText = text.getText(); - String leftText = newText.substring(0, e2.start); - String rightText = newText.substring(e2.end); - GC gc = new GC(text); + final String newText = text.getText(); + final String leftText = newText.substring(0, e2.start); + final String rightText = newText.substring(e2.end); + final GC gc = new GC(text); Point size = gc.textExtent(leftText + e2.text + rightText); gc.dispose(); size = text.computeSize(size.x, SWT.DEFAULT); - editor.horizontalAlignment = SWT.LEFT; - editor.setColumn(column); - Rectangle itemRect = item.getBounds(column), rect2 = tree.getClientArea(); - editor.minimumWidth = Math.max(size.x, itemRect.width) + (inset * 2); - int left = itemRect.x, right = rect2.x + rect2.width; - editor.minimumWidth = Math.min(editor.minimumWidth, right - left); - editor.minimumHeight = size.y + (inset * 2); - editor.layout(); + this.editor.horizontalAlignment = SWT.LEFT; + this.editor.setColumn(this.column); + final Rectangle itemRect = item.getBounds(this.column), rect2 = this.tree.getClientArea(); + this.editor.minimumWidth = Math.max(size.x, itemRect.width) + (inset * 2); + final int left = itemRect.x, right = rect2.x + rect2.width; + this.editor.minimumWidth = Math.min(this.editor.minimumWidth, right - left); + this.editor.minimumHeight = size.y + (inset * 2); + this.editor.layout(); break; case SWT.Traverse: switch (e2.detail) { case SWT.TRAVERSE_RETURN: - item.setText(column, text.getText()); - modifyListener.modifyText(null); + item.setText(this.column, text.getText()); + this.modifyListener.modifyText(null); // FALL THROUGH case SWT.TRAVERSE_ESCAPE: composite.dispose(); @@ -90,12 +90,12 @@ public void handleEvent(Event event) { text.addListener(SWT.FocusOut, textListener); text.addListener(SWT.Traverse, textListener); text.addListener(SWT.Verify, textListener); - editor.setEditor(composite, item); - text.setText(item.getText(column)); + this.editor.setEditor(composite, item); + text.setText(item.getText(this.column)); text.selectAll(); text.setFocus(); } - lastItem[0] = item; + this.lastItem[0] = item; } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/main/RuleEngineAnalyzer.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/main/Retriever.java similarity index 63% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/main/RuleEngineAnalyzer.java rename to bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/main/Retriever.java index 77453f37..3dd32cf2 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/main/RuleEngineAnalyzer.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/main/Retriever.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.main; +package org.palladiosimulator.retriever.core.main; import java.io.File; import java.net.URL; @@ -20,27 +20,27 @@ import org.palladiosimulator.generator.fluent.system.factory.FluentSystemFactory; import org.palladiosimulator.pcm.repository.Repository; import org.palladiosimulator.pcm.repository.RepositoryComponent; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; -import org.palladiosimulator.somox.analyzer.rules.engine.DockerParser; -import org.palladiosimulator.somox.analyzer.rules.engine.Rule; -import org.palladiosimulator.somox.analyzer.rules.engine.PCMInstanceCreator; -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; +import org.palladiosimulator.retriever.extraction.engine.DockerParser; +import org.palladiosimulator.retriever.extraction.engine.PCMInstanceCreator; +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; +import org.palladiosimulator.retriever.extraction.engine.Rule; /** - * The rule engine identifies PCM elements like components and interfaces inside source code via - * rules specified by a user before. The output of this procedure is a - * SourceCodeDecoratorRepositoryModel and a PCMRepository model. For this, the engine needs a - * project directory, an output directory, a Java model and a IRule file. + * Retriever identifies PCM elements like components and interfaces inside source code via rules + * specified by a user before. The output of this procedure is a SourceCodeDecoratorRepositoryModel + * and a PCMRepository model. For this, the engine needs a project directory, an output directory, a + * Java model and a IRule file. * * To use the engine, invoke executeWith(projectPath, outPath, model, rules). To simplify the use, * the engine provides the public methods loadRules() and loadModel(). */ -public class RuleEngineAnalyzer { - private final RuleEngineBlackboard blackboard; +public class Retriever { + private final RetrieverBlackboard blackboard; private static Repository pcm; - public RuleEngineAnalyzer(RuleEngineBlackboard blackboard) { + public Retriever(final RetrieverBlackboard blackboard) { this.blackboard = blackboard; } @@ -53,22 +53,22 @@ public static Repository getPCMRepository() { return pcm; } - public void analyze(RuleEngineConfiguration ruleEngineConfiguration, IProgressMonitor progressMonitor) - throws RuleEngineException { + public void analyze(final RetrieverConfiguration configuration, final IProgressMonitor progressMonitor) + throws RetrieverException { try { - final URI in = CommonPlugin.asLocalURI(ruleEngineConfiguration.getInputFolder()); + final URI in = CommonPlugin.asLocalURI(configuration.getInputFolder()); final Path inPath = Paths.get(in.devicePath()); - final URI out = CommonPlugin.asLocalURI(ruleEngineConfiguration.getOutputFolder()); + final URI out = CommonPlugin.asLocalURI(configuration.getOutputFolder()); final Path outPath = Paths.get(out.devicePath()); - final Set rules = ruleEngineConfiguration.getConfig(Rule.class) + final Set rules = configuration.getConfig(Rule.class) .getSelected(); - executeWith(inPath, outPath, rules, blackboard); - } catch (Exception e) { - throw new RuleEngineException("Analysis did not complete successfully", e); + executeWith(inPath, outPath, rules, this.blackboard); + } catch (final Exception e) { + throw new RetrieverException("Analysis did not complete successfully", e); } } @@ -84,7 +84,8 @@ public void analyze(RuleEngineConfiguration ruleEngineConfiguration, IProgressMo * @param ruleDoc * the object containing the rules */ - public static void executeWith(Path projectPath, Path outPath, List model, Set rules) { + public static void executeWith(final Path projectPath, final Path outPath, final List model, + final Set rules) { executeWith(projectPath, outPath, model, rules); } @@ -98,9 +99,10 @@ public static void executeWith(Path projectPath, Path outPath, List rules, RuleEngineBlackboard blackboard) { + private static void executeWith(final Path projectPath, final Path outPath, final Set rules, + final RetrieverBlackboard blackboard) { // Creates a PCM repository with systems, components, interfaces and roles // Parses the docker-compose file to get a mapping between microservice names and @@ -111,22 +113,23 @@ private static void executeWith(Path projectPath, Path outPath, Set rules, pcm = new PCMInstanceCreator(blackboard).createPCM(mapping); // Create the build file systems - Map repoCompLocations = blackboard.getRepositoryComponentLocations(); - Map invertedEntityLocations = new HashMap<>(); - for (Entry entry : repoCompLocations.entrySet()) { + final Map repoCompLocations = blackboard + .getRepositoryComponentLocations(); + final Map invertedEntityLocations = new HashMap<>(); + for (final Entry entry : repoCompLocations.entrySet()) { invertedEntityLocations.put(entry.getValue(), entry.getKey()); } - FluentSystemFactory create = new FluentSystemFactory(); - for (Entry> entry : blackboard.getSystemAssociations() + final FluentSystemFactory create = new FluentSystemFactory(); + for (final Entry> entry : blackboard.getSystemAssociations() .entrySet()) { // TODO better name - ISystem system = create.newSystem() + final ISystem system = create.newSystem() .withName(entry.getKey() .toString()); boolean hasChildren = false; - for (CompilationUnit compUnit : entry.getValue()) { - RepositoryComponent repoComp = invertedEntityLocations.get(compUnit); + for (final CompilationUnit compUnit : entry.getValue()) { + final RepositoryComponent repoComp = invertedEntityLocations.get(compUnit); // Only compilation units that have been processed by some other rule can be // added to a system if (repoComp != null) { @@ -143,7 +146,7 @@ private static void executeWith(Path projectPath, Path outPath, Set rules, } // Persist the repository at ./pcm.repository - blackboard.addPartition(RuleEngineBlackboard.KEY_REPOSITORY, pcm); + blackboard.addPartition(RetrieverBlackboard.KEY_REPOSITORY, pcm); ModelSaver.saveRepository(pcm, outPath.toString(), "pcm"); } @@ -157,7 +160,7 @@ private static void executeWith(Path projectPath, Path outPath, Set rules, * the path to a .class file containing the rules * @return the rules from the specified (via gui) file system place */ - public static Rule loadRules(String namespace, Path rulesFile) { + public static Rule loadRules(final String namespace, final Path rulesFile) { final File file = rulesFile.toFile(); diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/main/RetrieverException.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/main/RetrieverException.java new file mode 100644 index 00000000..34c405cd --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/main/RetrieverException.java @@ -0,0 +1,19 @@ +package org.palladiosimulator.retriever.core.main; + +/** + * A general exception for Retriever. + * + * @author Florian Bossert + */ +public class RetrieverException extends Exception { + + private static final long serialVersionUID = 8438995877350048404L; + + public RetrieverException(final String message) { + super(message); + } + + public RetrieverException(final String message, final Throwable cause) { + super(message, cause); + } +} diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/Analyst.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/Analyst.java new file mode 100644 index 00000000..dc399fb5 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/Analyst.java @@ -0,0 +1,19 @@ +package org.palladiosimulator.retriever.core.service; + +import java.util.Set; + +import org.palladiosimulator.retriever.extraction.engine.Service; + +/** + * The defining interface of the org.palladiosimulator.retriever.extraction.analyst extension point. + * Implement this interface to extend Retriever by an additional analyst that can then process the + * generated model. + * + * @author Florian Bossert + */ +public interface Analyst extends Service { + @Override + default Set getDependentServices() { + return Set.of(); + } +} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/service/AnalystCollection.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/AnalystCollection.java similarity index 68% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/service/AnalystCollection.java rename to bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/AnalystCollection.java index 21cda1da..034e0c2c 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/service/AnalystCollection.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/AnalystCollection.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.service; +package org.palladiosimulator.retriever.core.service; import java.util.Collections; import java.util.HashSet; @@ -7,24 +7,24 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.Platform; -import org.palladiosimulator.somox.analyzer.rules.engine.ServiceCollection; +import org.palladiosimulator.retriever.extraction.engine.ServiceCollection; public class AnalystCollection implements ServiceCollection { - public static final String EXTENSION_POINT = "org.palladiosimulator.somox.analyzer.rules.analyst"; + public static final String EXTENSION_POINT = "org.palladiosimulator.retriever.extraction.analyst"; private final Set analysts = new HashSet<>(); public AnalystCollection() throws CoreException { - for (IConfigurationElement extension : Platform.getExtensionRegistry() + for (final IConfigurationElement extension : Platform.getExtensionRegistry() .getConfigurationElementsFor(EXTENSION_POINT)) { final Object o = extension.createExecutableExtension("class"); if (o instanceof Analyst) { - analysts.add((Analyst) o); + this.analysts.add((Analyst) o); } } } @Override public Set getServices() { - return Collections.unmodifiableSet(analysts); + return Collections.unmodifiableSet(this.analysts); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/DiscovererCollection.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/DiscovererCollection.java similarity index 73% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/DiscovererCollection.java rename to bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/DiscovererCollection.java index d88fec5c..72bda92d 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/DiscovererCollection.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/DiscovererCollection.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.discoverer; +package org.palladiosimulator.retriever.core.service; import java.util.Collections; import java.util.HashSet; @@ -8,10 +8,11 @@ import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.InvalidRegistryObjectException; import org.eclipse.core.runtime.Platform; -import org.palladiosimulator.somox.analyzer.rules.engine.ServiceCollection; +import org.palladiosimulator.retriever.extraction.engine.Discoverer; +import org.palladiosimulator.retriever.extraction.engine.ServiceCollection; public class DiscovererCollection implements ServiceCollection { - public static final String EXTENSION_POINT = "org.palladiosimulator.somox.discoverer"; + public static final String EXTENSION_POINT = "org.palladiosimulator.retriever.extraction.discoverer"; private final Set discoverer = new HashSet<>(); public DiscovererCollection() throws CoreException, InvalidRegistryObjectException { @@ -19,13 +20,13 @@ public DiscovererCollection() throws CoreException, InvalidRegistryObjectExcepti .getConfigurationElementsFor(EXTENSION_POINT)) { final Object o = extension.createExecutableExtension("class"); if (o instanceof Discoverer) { - discoverer.add((Discoverer) o); + this.discoverer.add((Discoverer) o); } } } @Override public Set getServices() { - return Collections.unmodifiableSet(discoverer); + return Collections.unmodifiableSet(this.discoverer); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/service/EmptyCollection.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/EmptyCollection.java similarity index 64% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/service/EmptyCollection.java rename to bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/EmptyCollection.java index 30842c41..92bf8d20 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/service/EmptyCollection.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/EmptyCollection.java @@ -1,9 +1,9 @@ -package org.palladiosimulator.somox.analyzer.rules.service; +package org.palladiosimulator.retriever.core.service; import java.util.Collections; import java.util.Set; -import org.palladiosimulator.somox.analyzer.rules.engine.ServiceCollection; +import org.palladiosimulator.retriever.extraction.engine.ServiceCollection; public class EmptyCollection implements ServiceCollection { diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/service/PerformanceAnalyst.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/PerformanceAnalyst.java similarity index 78% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/service/PerformanceAnalyst.java rename to bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/PerformanceAnalyst.java index 9a8ddc4c..dcf84c4f 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/service/PerformanceAnalyst.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/PerformanceAnalyst.java @@ -1,11 +1,11 @@ -package org.palladiosimulator.somox.analyzer.rules.service; +package org.palladiosimulator.retriever.core.service; import java.util.Collections; import java.util.Set; import org.eclipse.core.runtime.IProgressMonitor; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; import de.uka.ipd.sdq.workflow.jobs.AbstractBlackboardInteractingJob; import de.uka.ipd.sdq.workflow.jobs.CleanupFailedException; @@ -19,11 +19,11 @@ * @author Florian Bossert */ public class PerformanceAnalyst implements Analyst { - private static final String ANALYST_ID = "org.palladiosimulator.somox.analyzer.rules.service.performance_analyst"; + private static final String ANALYST_ID = "org.palladiosimulator.retriever.core.service.performance_analyst"; @Override - public IBlackboardInteractingJob create(RuleEngineConfiguration configuration, - RuleEngineBlackboard blackboard) { + public IBlackboardInteractingJob create(final RetrieverConfiguration configuration, + final RetrieverBlackboard blackboard) { return new AbstractBlackboardInteractingJob<>() { @Override public void cleanup(final IProgressMonitor monitor) throws CleanupFailedException { diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/service/RuleCollection.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/RuleCollection.java similarity index 60% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/service/RuleCollection.java rename to bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/RuleCollection.java index 8964adc2..a32164f7 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/service/RuleCollection.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/service/RuleCollection.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.service; +package org.palladiosimulator.retriever.core.service; import java.util.HashSet; import java.util.Set; @@ -6,25 +6,25 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.Platform; -import org.palladiosimulator.somox.analyzer.rules.engine.Rule; -import org.palladiosimulator.somox.analyzer.rules.engine.ServiceCollection; +import org.palladiosimulator.retriever.extraction.engine.Rule; +import org.palladiosimulator.retriever.extraction.engine.ServiceCollection; public class RuleCollection implements ServiceCollection { - public static final String EXTENSION_POINT = "org.palladiosimulator.somox.analyzer.rule"; - private Set rules = new HashSet<>(); + public static final String EXTENSION_POINT = "org.palladiosimulator.retriever.extraction.rule"; + private final Set rules = new HashSet<>(); public RuleCollection() throws CoreException { - for (IConfigurationElement extension : Platform.getExtensionRegistry() + for (final IConfigurationElement extension : Platform.getExtensionRegistry() .getConfigurationElementsFor(EXTENSION_POINT)) { final Object o = extension.createExecutableExtension("class"); if (o instanceof Rule) { - rules.add((Rule) o); + this.rules.add((Rule) o); } } } @Override public Set getServices() { - return rules; + return this.rules; } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/PersistenceJob.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/PersistenceJob.java similarity index 66% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/PersistenceJob.java rename to bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/PersistenceJob.java index 3a617a55..528b7232 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/PersistenceJob.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/PersistenceJob.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.workflow; +package org.palladiosimulator.retriever.core.workflow; import java.util.Objects; @@ -28,8 +28,9 @@ public class PersistenceJob implements IBlackboardInteractingJob blackboard, URI inputFolder, URI outputFolder, String repositoryKey, - String systemKey, String allocationKey, String resourceEnvironmentKey) { + public PersistenceJob(final Blackboard blackboard, final URI inputFolder, final URI outputFolder, + final String repositoryKey, final String systemKey, final String allocationKey, + final String resourceEnvironmentKey) { this.blackboard = Objects.requireNonNull(blackboard); this.repositoryKey = Objects.requireNonNull(repositoryKey); @@ -50,26 +51,26 @@ public PersistenceJob(Blackboard blackboard, URI inputFolder, URI output } @Override - public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { // Fetch input from blackboard monitor.subTask("Retrieving job input from blackboard"); - Repository repository = (Repository) this.blackboard.getPartition(repositoryKey); - System system = (System) this.blackboard.getPartition(systemKey); - ResourceEnvironment resourceEnvironment = (ResourceEnvironment) this.blackboard - .getPartition(resourceEnvironmentKey); - Allocation allocation = (Allocation) this.blackboard.getPartition(allocationKey); + final Repository repository = (Repository) this.blackboard.getPartition(this.repositoryKey); + final System system = (System) this.blackboard.getPartition(this.systemKey); + final ResourceEnvironment resourceEnvironment = (ResourceEnvironment) this.blackboard + .getPartition(this.resourceEnvironmentKey); + final Allocation allocation = (Allocation) this.blackboard.getPartition(this.allocationKey); // Make blackboard models persistent by saving them as files monitor.subTask("Persisting models"); - ModelSaver.saveRepository(repository, outputFolder, projectName); - ModelSaver.saveSystem(system, outputFolder, projectName); - ModelSaver.saveResourceEnvironment(resourceEnvironment, outputFolder, projectName); - ModelSaver.saveAllocation(allocation, outputFolder, projectName); + ModelSaver.saveRepository(repository, this.outputFolder, this.projectName); + ModelSaver.saveSystem(system, this.outputFolder, this.projectName); + ModelSaver.saveResourceEnvironment(resourceEnvironment, this.outputFolder, this.projectName); + ModelSaver.saveAllocation(allocation, this.outputFolder, this.projectName); monitor.done(); } @Override - public void cleanup(IProgressMonitor monitor) throws CleanupFailedException { + public void cleanup(final IProgressMonitor monitor) throws CleanupFailedException { // No cleanup required for the job } @@ -79,7 +80,7 @@ public String getName() { } @Override - public void setBlackboard(Blackboard blackboard) { + public void setBlackboard(final Blackboard blackboard) { this.blackboard = Objects.requireNonNull(blackboard); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/PlantUmlJob.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/PlantUmlJob.java similarity index 56% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/PlantUmlJob.java rename to bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/PlantUmlJob.java index f87c5e18..f48b37e1 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/PlantUmlJob.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/PlantUmlJob.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.workflow; +package org.palladiosimulator.retriever.core.workflow; import java.io.ByteArrayInputStream; import java.io.FileWriter; @@ -7,14 +7,15 @@ import org.apache.log4j.Logger; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; import org.palladiosimulator.pcm.repository.Repository; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; import org.palladiosimulator.view.plantuml.generator.PcmComponentDiagramGenerator; import de.uka.ipd.sdq.workflow.jobs.AbstractBlackboardInteractingJob; @@ -22,52 +23,53 @@ import de.uka.ipd.sdq.workflow.jobs.JobFailedException; import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; -public class PlantUmlJob extends AbstractBlackboardInteractingJob { +public class PlantUmlJob extends AbstractBlackboardInteractingJob { private static final Logger LOG = Logger.getLogger(PlantUmlJob.class); - private static final String NAME = "Rule Engine PlantUML Generation"; + private static final String NAME = "Retriever PlantUML Generation"; - private final RuleEngineConfiguration configuration; + private final RetrieverConfiguration configuration; - public PlantUmlJob(RuleEngineConfiguration configuration, RuleEngineBlackboard blackboard) { + public PlantUmlJob(final RetrieverConfiguration configuration, final RetrieverBlackboard blackboard) { super.setBlackboard(blackboard); this.configuration = Objects.requireNonNull(configuration); } @Override - public void cleanup(IProgressMonitor arg0) throws CleanupFailedException { + public void cleanup(final IProgressMonitor arg0) throws CleanupFailedException { } @Override - public void execute(IProgressMonitor arg0) throws JobFailedException, UserCanceledException { - PcmComponentDiagramGenerator generator = new PcmComponentDiagramGenerator( - (Repository) getBlackboard().getPartition(RuleEngineBlackboard.KEY_REPOSITORY)); - String plantUmlSource = "@startuml\n" + generator.getDiagramText() + "\n@enduml\n"; + public void execute(final IProgressMonitor arg0) throws JobFailedException, UserCanceledException { + final PcmComponentDiagramGenerator generator = new PcmComponentDiagramGenerator( + (Repository) this.getBlackboard() + .getPartition(RetrieverBlackboard.KEY_REPOSITORY)); + final String plantUmlSource = "@startuml\n" + generator.getDiagramText() + "\n@enduml\n"; - if (configuration.getOutputFolder() + if (this.configuration.getOutputFolder() .isPlatformResource()) { - IWorkspaceRoot root = ResourcesPlugin.getWorkspace() + final IWorkspaceRoot root = ResourcesPlugin.getWorkspace() .getRoot(); - IFile file = root.getFile(new Path(configuration.getOutputFolder() + final IFile file = root.getFile(new Path(this.configuration.getOutputFolder() .appendSegment("componentDiagram.puml") .toPlatformString(true))); try { if (!file.exists()) { - file.create(new ByteArrayInputStream(new byte[0]), IFile.FORCE, null); + file.create(new ByteArrayInputStream(new byte[0]), IResource.FORCE, null); } - file.setContents(new ByteArrayInputStream(plantUmlSource.getBytes()), IFile.FORCE, null); - } catch (CoreException e) { + file.setContents(new ByteArrayInputStream(plantUmlSource.getBytes()), IResource.FORCE, null); + } catch (final CoreException e) { LOG.error(e); } } else { - String path = configuration.getOutputFolder() + final String path = this.configuration.getOutputFolder() .appendSegment("componentDiagram.puml") .devicePath(); try (FileWriter writer = new FileWriter(path)) { writer.append(plantUmlSource); - } catch (IOException e) { + } catch (final IOException e) { LOG.error(e); } } diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/RetrieverBlackboardInteractingJob.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/RetrieverBlackboardInteractingJob.java new file mode 100644 index 00000000..6b077463 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/RetrieverBlackboardInteractingJob.java @@ -0,0 +1,45 @@ +package org.palladiosimulator.retriever.core.workflow; + +import java.util.Objects; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.palladiosimulator.retriever.core.main.Retriever; +import org.palladiosimulator.retriever.core.main.RetrieverException; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; + +import de.uka.ipd.sdq.workflow.jobs.AbstractBlackboardInteractingJob; +import de.uka.ipd.sdq.workflow.jobs.CleanupFailedException; +import de.uka.ipd.sdq.workflow.jobs.JobFailedException; +import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; + +public class RetrieverBlackboardInteractingJob extends AbstractBlackboardInteractingJob { + + private static final String NAME = "Retriever Blackboard Interacting Job"; + + private final RetrieverConfiguration configuration; + + public RetrieverBlackboardInteractingJob(final RetrieverConfiguration configuration, + final RetrieverBlackboard blackboard) { + super.setBlackboard(blackboard); + this.configuration = Objects.requireNonNull(configuration); + } + + @Override + public void cleanup(final IProgressMonitor monitor) throws CleanupFailedException { + } + + @Override + public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + try { + new Retriever(this.getBlackboard()).analyze(this.configuration, monitor); + } catch (final RetrieverException e) { + throw new JobFailedException(NAME + " Failed", e); + } + } + + @Override + public String getName() { + return NAME; + } +} diff --git a/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/RetrieverJob.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/RetrieverJob.java new file mode 100644 index 00000000..9c02a1f1 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/RetrieverJob.java @@ -0,0 +1,143 @@ +package org.palladiosimulator.retriever.core.workflow; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.palladiosimulator.retriever.core.configuration.RetrieverBlackboardKeys; +import org.palladiosimulator.retriever.core.service.Analyst; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; +import org.palladiosimulator.retriever.extraction.engine.Discoverer; +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; +import org.palladiosimulator.retriever.extraction.engine.Rule; +import org.palladiosimulator.retriever.mocore.workflow.MoCoReJob; +import org.palladiosimulator.somox.ast2seff.jobs.Ast2SeffJob; + +import de.uka.ipd.sdq.workflow.extension.AbstractExtendableJob; +import de.uka.ipd.sdq.workflow.jobs.IBlackboardInteractingJob; +import de.uka.ipd.sdq.workflow.jobs.ParallelJob; + +public class RetrieverJob extends AbstractExtendableJob { + + public RetrieverJob(final RetrieverConfiguration configuration) { + super.setBlackboard(new RetrieverBlackboard()); + + super.addAll(this.createDiscovererJobs(configuration)); + + super.addAll(this.createRuleJobs(configuration)); + + super.addAll(this.createBuildRulesJob(configuration)); + + super.add(new RetrieverBlackboardInteractingJob(configuration, this.getBlackboard())); + + super.addAll(this.createAnalystJobs(configuration)); + + // Generate service effect specifications based on AST nodes and merge them into repository + super.add(new Ast2SeffJob(this.getBlackboard(), + RetrieverBlackboardKeys.RULE_ENGINE_BLACKBOARD_KEY_SEFF_ASSOCIATIONS, + RetrieverBlackboardKeys.RULE_ENGINE_AST2SEFF_OUTPUT_REPOSITORY)); + super.add(new SeffMergerJob(this.myBlackboard, RetrieverBlackboardKeys.RULE_ENGINE_AST2SEFF_OUTPUT_REPOSITORY, + RetrieverBlackboardKeys.RULE_ENGINE_BLACKBOARD_KEY_REPOSITORY)); + + // Refine model and create final repository, system, allocation, & resource environment + super.add(new MoCoReJob(this.getBlackboard(), RetrieverBlackboardKeys.RULE_ENGINE_BLACKBOARD_KEY_REPOSITORY, + RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_REPOSITORY, + RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_SYSTEM, + RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_ALLOCATION, + RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_RESOURCE_ENVIRONMENT)); + + // Merge data & failure types into output repository + super.add(new TypeMergerJob(this.getBlackboard(), RetrieverBlackboardKeys.RULE_ENGINE_BLACKBOARD_KEY_REPOSITORY, + RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_REPOSITORY)); + + // Persist repository, system, allocation, & resource environment model from blackboard into + // file system + super.add(new PersistenceJob(this.getBlackboard(), configuration.getInputFolder(), + configuration.getOutputFolder(), RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_REPOSITORY, + RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_SYSTEM, + RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_ALLOCATION, + RetrieverBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_RESOURCE_ENVIRONMENT)); + + super.add(new PlantUmlJob(configuration, this.getBlackboard())); + } + + private List createRuleJobs(final RetrieverConfiguration configuration) { + final List jobs = new ArrayList<>(); + + for (final Collection step : configuration.getConfig(Rule.class) + .getExecutionOrder()) { + final ParallelJob parentJob = new ParallelJob(); + for (final Rule rule : step) { + // Assume only build rules depend on build rules. + if (rule.isBuildRule()) { + continue; + } + final IBlackboardInteractingJob ruleJob = rule.create(configuration, + this.myBlackboard); + parentJob.add(ruleJob); + this.logger.info("Adding rule job \"" + ruleJob.getName() + "\""); + } + jobs.add(parentJob); + } + + return jobs; + } + + private List createBuildRulesJob(final RetrieverConfiguration configuration) { + final List jobs = new ArrayList<>(); + + for (final Collection step : configuration.getConfig(Rule.class) + .getExecutionOrder()) { + final ParallelJob parentJob = new ParallelJob(); + for (final Rule rule : step) { + // Assume only build rules depend on build rules. + if (!rule.isBuildRule()) { + continue; + } + final IBlackboardInteractingJob ruleJob = rule.create(configuration, + this.myBlackboard); + parentJob.add(ruleJob); + this.logger.info("Adding build rule job \"" + ruleJob.getName() + "\""); + } + jobs.add(parentJob); + } + + return jobs; + } + + private List createDiscovererJobs(final RetrieverConfiguration configuration) { + final List jobs = new ArrayList<>(); + + for (final Collection step : configuration.getConfig(Discoverer.class) + .getExecutionOrder()) { + final ParallelJob parentJob = new ParallelJob(); + for (final Discoverer discoverer : step) { + final IBlackboardInteractingJob discovererJob = discoverer.create(configuration, + this.myBlackboard); + parentJob.add(discovererJob); + this.logger.info("Adding discoverer job \"" + discovererJob.getName() + "\""); + } + jobs.add(parentJob); + } + + return jobs; + } + + private List createAnalystJobs(final RetrieverConfiguration configuration) { + final List jobs = new ArrayList<>(); + + for (final Collection step : configuration.getConfig(Analyst.class) + .getExecutionOrder()) { + final ParallelJob parentJob = new ParallelJob(); + for (final Analyst analyst : step) { + final IBlackboardInteractingJob analystJob = analyst.create(configuration, + this.myBlackboard); + parentJob.add(analystJob); + this.logger.info("Adding analyst job \"" + analystJob.getName() + "\""); + } + jobs.add(parentJob); + } + + return jobs; + } +} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/SeffMergerJob.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/SeffMergerJob.java similarity index 76% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/SeffMergerJob.java rename to bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/SeffMergerJob.java index 6440a8b0..3601dffa 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/SeffMergerJob.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/SeffMergerJob.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.workflow; +package org.palladiosimulator.retriever.core.workflow; import java.util.List; import java.util.Objects; @@ -35,23 +35,24 @@ public class SeffMergerJob implements IBlackboardInteractingJob blackboard, String sourceSeffRepositoryKey, - String destinationSeffRepositoryKey) { + public SeffMergerJob(final Blackboard blackboard, final String sourceSeffRepositoryKey, + final String destinationSeffRepositoryKey) { this.blackboard = Objects.requireNonNull(blackboard); this.sourceSeffRepositoryKey = sourceSeffRepositoryKey; this.destinationSeffRepositoryKey = destinationSeffRepositoryKey; } @Override - public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { // Fetch input from blackboard monitor.subTask("Retrieving source and destination repository from blackboard"); - Repository sourceRepository = (Repository) this.blackboard.getPartition(this.sourceSeffRepositoryKey); - Repository destinationRepository = (Repository) this.blackboard.getPartition(this.destinationSeffRepositoryKey); + final Repository sourceRepository = (Repository) this.blackboard.getPartition(this.sourceSeffRepositoryKey); + final Repository destinationRepository = (Repository) this.blackboard + .getPartition(this.destinationSeffRepositoryKey); // Move seffs from source to destination repository monitor.subTask("Merging ServiceEffectSpecificications from source with destination repository"); - for (RepositoryComponent component : sourceRepository.getComponents__Repository()) { + for (final RepositoryComponent component : sourceRepository.getComponents__Repository()) { if (!(component instanceof BasicComponent)) { continue; } @@ -59,8 +60,9 @@ public void execute(IProgressMonitor monitor) throws JobFailedException, UserCan // Assumes that each component from source repository has a counterpart with the same // name in destination // repository. Otherwise, exception is thrown. - BasicComponent sourceComponent = (BasicComponent) component; - Optional destinationComponentOption = destinationRepository.getComponents__Repository() + final BasicComponent sourceComponent = (BasicComponent) component; + final Optional destinationComponentOption = destinationRepository + .getComponents__Repository() .stream() .filter(otherComponent -> otherComponent.getEntityName() .equals(sourceComponent.getEntityName())) @@ -72,15 +74,15 @@ public void execute(IProgressMonitor monitor) throws JobFailedException, UserCan LOG.warn("Failed to find destination component " + sourceComponent.getEntityName() + "!"); continue; } - BasicComponent destinationComponent = destinationComponentOption.get(); + final BasicComponent destinationComponent = destinationComponentOption.get(); // Overwrite seffs within destination component - List sourceSeffs = List + final List sourceSeffs = List .copyOf(sourceComponent.getServiceEffectSpecifications__BasicComponent()); - for (ServiceEffectSpecification sourceSeff : sourceSeffs) { + for (final ServiceEffectSpecification sourceSeff : sourceSeffs) { // Retrieve destination signature for seff, throw if signature is not provided by // destination component - Optional destinationSignatureOption = destinationComponent + final Optional destinationSignatureOption = destinationComponent .getProvidedRoles_InterfaceProvidingEntity() .stream() .filter(role -> role instanceof OperationProvidedRole) @@ -98,7 +100,7 @@ public void execute(IProgressMonitor monitor) throws JobFailedException, UserCan .getEntityName() + " in component " + destinationComponent.getEntityName() + "!"); continue; } - OperationSignature destinationSignature = destinationSignatureOption.get(); + final OperationSignature destinationSignature = destinationSignatureOption.get(); // Set component and signature of source seff to destination elements sourceSeff.setBasicComponent_ServiceEffectSpecification(destinationComponent); @@ -106,17 +108,17 @@ public void execute(IProgressMonitor monitor) throws JobFailedException, UserCan // Adapt external call actions to new repository -> Swap signatures and required // roles - EList behaviorSteps = ((ResourceDemandingSEFF) sourceSeff).getSteps_Behaviour(); - for (AbstractAction action : behaviorSteps) { + final EList behaviorSteps = ((ResourceDemandingSEFF) sourceSeff).getSteps_Behaviour(); + for (final AbstractAction action : behaviorSteps) { if (!(action instanceof ExternalCallAction)) { continue; } - ExternalCallAction externalCallAction = (ExternalCallAction) action; - String calledSignatureEntityName = externalCallAction.getCalledService_ExternalService() + final ExternalCallAction externalCallAction = (ExternalCallAction) action; + final String calledSignatureEntityName = externalCallAction.getCalledService_ExternalService() .getEntityName(); // Fetch called signature from destination repository - Optional calledSignatureOption = destinationRepository + final Optional calledSignatureOption = destinationRepository .getInterfaces__Repository() .stream() .filter(interFace -> interFace instanceof OperationInterface) @@ -130,10 +132,10 @@ public void execute(IProgressMonitor monitor) throws JobFailedException, UserCan LOG.warn("Failed to find called signature for " + calledSignatureEntityName + "!"); continue; } - OperationSignature calledSignature = calledSignatureOption.get(); + final OperationSignature calledSignature = calledSignatureOption.get(); // Fetch required role from destination repository - Optional requiredRoleOption = destinationComponent + final Optional requiredRoleOption = destinationComponent .getRequiredRoles_InterfaceRequiringEntity() .stream() .filter(role -> role instanceof OperationRequiredRole) @@ -149,14 +151,14 @@ public void execute(IProgressMonitor monitor) throws JobFailedException, UserCan .getEntityName() + "#" + calledSignature.getEntityName() + "!"); continue; } - OperationRequiredRole requiredRole = requiredRoleOption.get(); + final OperationRequiredRole requiredRole = requiredRoleOption.get(); externalCallAction.setCalledService_ExternalService(calledSignature); externalCallAction.setRole_ExternalService(requiredRole); } // Find optional already existing and conflicting seff in destination component - Optional optionalDestinationSeff = destinationComponent + final Optional optionalDestinationSeff = destinationComponent .getServiceEffectSpecifications__BasicComponent() .stream() .filter(destinationSeff -> destinationSeff.getDescribedService__SEFF() @@ -176,7 +178,7 @@ public void execute(IProgressMonitor monitor) throws JobFailedException, UserCan } @Override - public void cleanup(IProgressMonitor monitor) throws CleanupFailedException { + public void cleanup(final IProgressMonitor monitor) throws CleanupFailedException { // No cleanup required for the job } @@ -186,7 +188,7 @@ public String getName() { } @Override - public void setBlackboard(Blackboard blackboard) { + public void setBlackboard(final Blackboard blackboard) { this.blackboard = Objects.requireNonNull(blackboard); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/TypeMergerJob.java b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/TypeMergerJob.java similarity index 70% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/TypeMergerJob.java rename to bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/TypeMergerJob.java index f7181a6a..5fe2ae1d 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/TypeMergerJob.java +++ b/bundles/org.palladiosimulator.retriever.core/src/org/palladiosimulator/retriever/core/workflow/TypeMergerJob.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.workflow; +package org.palladiosimulator.retriever.core.workflow; import java.util.Objects; @@ -19,19 +19,20 @@ public class TypeMergerJob implements IBlackboardInteractingJob blackboard, String sourceTypeRepositoryKey, - String destinationTypeRepositoryKey) { + public TypeMergerJob(final Blackboard blackboard, final String sourceTypeRepositoryKey, + final String destinationTypeRepositoryKey) { this.blackboard = Objects.requireNonNull(blackboard); this.sourceTypeRepositoryKey = sourceTypeRepositoryKey; this.destinationTypeRepositoryKey = destinationTypeRepositoryKey; } @Override - public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { // Fetch input from blackboard monitor.subTask("Retrieving source and destination repository from blackboard"); - Repository sourceRepository = (Repository) this.blackboard.getPartition(this.sourceTypeRepositoryKey); - Repository destinationRepository = (Repository) this.blackboard.getPartition(this.destinationTypeRepositoryKey); + final Repository sourceRepository = (Repository) this.blackboard.getPartition(this.sourceTypeRepositoryKey); + final Repository destinationRepository = (Repository) this.blackboard + .getPartition(this.destinationTypeRepositoryKey); // Move types from source to destination repository monitor.subTask("Merging types from source into destination repository"); @@ -43,7 +44,7 @@ public void execute(IProgressMonitor monitor) throws JobFailedException, UserCan } @Override - public void cleanup(IProgressMonitor monitor) throws CleanupFailedException { + public void cleanup(final IProgressMonitor monitor) throws CleanupFailedException { // No cleanup required for the job } @@ -53,7 +54,7 @@ public String getName() { } @Override - public void setBlackboard(Blackboard blackboard) { + public void setBlackboard(final Blackboard blackboard) { this.blackboard = Objects.requireNonNull(blackboard); } } diff --git a/bundles/org.palladiosimulator.retriever.extraction.discoverers/.classpath b/bundles/org.palladiosimulator.retriever.extraction.discoverers/.classpath new file mode 100644 index 00000000..9c8192c2 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/bundles/org.palladiosimulator.retriever.extraction.discoverers/.project b/bundles/org.palladiosimulator.retriever.extraction.discoverers/.project new file mode 100644 index 00000000..9ea5a784 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/.project @@ -0,0 +1,34 @@ + + + org.palladiosimulator.retriever.extraction.discoverers + + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.xtext.ui.shared.xtextNature + + diff --git a/bundles/org.palladiosimulator.retriever.extraction.discoverers/META-INF/MANIFEST.MF b/bundles/org.palladiosimulator.retriever.extraction.discoverers/META-INF/MANIFEST.MF new file mode 100644 index 00000000..c82d4148 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/META-INF/MANIFEST.MF @@ -0,0 +1,20 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Retriever Discoverers +Bundle-SymbolicName: org.palladiosimulator.retriever.extraction.discoverers;singleton:=true +Bundle-Version: 5.2.0.qualifier +Bundle-Vendor: palladiosimulator.org +Automatic-Module-Name: org.palladiosimulator.retriever.extraction.rules +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Export-Package: org.palladiosimulator.retriever.extraction.discoverers +Require-Bundle: org.palladiosimulator.pcm, + org.palladiosimulator.retriever.extraction, + org.eclipse.jdt.core, + de.uka.ipd.sdq.workflow, + org.jdom2, + org.openjdk.nashorn.core;bundle-version="15.4.0", + com.github.jsqlparser, + org.yaml.snakeyaml, + org.json, + org.apache.commons.csv, + org.palladiosimulator.retriever.core diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/build.properties b/bundles/org.palladiosimulator.retriever.extraction.discoverers/build.properties similarity index 100% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/build.properties rename to bundles/org.palladiosimulator.retriever.extraction.discoverers/build.properties diff --git a/bundles/org.palladiosimulator.retriever.extraction.discoverers/plugin.xml b/bundles/org.palladiosimulator.retriever.extraction.discoverers/plugin.xml new file mode 100644 index 00000000..c3dce3d0 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/plugin.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/CsvDiscoverer.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/CsvDiscoverer.java similarity index 73% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/CsvDiscoverer.java rename to bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/CsvDiscoverer.java index 80bfca39..170253df 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/CsvDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/CsvDiscoverer.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.discoverer; +package org.palladiosimulator.retriever.extraction.discoverers; import static org.apache.commons.csv.CSVFormat.DEFAULT; @@ -18,8 +18,9 @@ import org.apache.commons.csv.CSVRecord; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.emf.common.CommonPlugin; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; +import org.palladiosimulator.retriever.extraction.engine.Discoverer; +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; import de.uka.ipd.sdq.workflow.jobs.AbstractBlackboardInteractingJob; import de.uka.ipd.sdq.workflow.jobs.CleanupFailedException; @@ -29,11 +30,11 @@ public class CsvDiscoverer implements Discoverer { - private static final String DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.csv"; + private static final String DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.csv"; @Override - public IBlackboardInteractingJob create(final RuleEngineConfiguration configuration, - final RuleEngineBlackboard blackboard) { + public IBlackboardInteractingJob create(final RetrieverConfiguration configuration, + final RetrieverBlackboard blackboard) { return new AbstractBlackboardInteractingJob<>() { @Override @@ -44,20 +45,21 @@ public void cleanup(final IProgressMonitor monitor) throws CleanupFailedExceptio public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { final Path root = Paths.get(CommonPlugin.asLocalURI(configuration.getInputFolder()) .devicePath()); - setBlackboard(Objects.requireNonNull(blackboard)); + this.setBlackboard(Objects.requireNonNull(blackboard)); final Map> csvs = new HashMap<>(); - Discoverer.find(root, ".csv", logger) + Discoverer.find(root, ".csv", this.logger) .forEach(p -> { final List records = new LinkedList<>(); try (Reader reader = new FileReader(p.toFile())) { DEFAULT.parse(reader) .forEach(records::add); } catch (final IllegalStateException | IOException e) { - logger.error(String.format("%s could not be read correctly.", p), e); + this.logger.error(String.format("%s could not be read correctly.", p), e); } csvs.put(p, records); }); - getBlackboard().putDiscoveredFiles(DISCOVERER_ID, csvs); + this.getBlackboard() + .putDiscoveredFiles(DISCOVERER_ID, csvs); } @Override diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/EcmaScriptDiscoverer.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/EcmaScriptDiscoverer.java similarity index 72% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/EcmaScriptDiscoverer.java rename to bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/EcmaScriptDiscoverer.java index 9b17d5b0..d7ffa8ae 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/EcmaScriptDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/EcmaScriptDiscoverer.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.discoverer; +package org.palladiosimulator.retriever.extraction.discoverers; import java.io.IOException; import java.nio.file.Path; @@ -15,8 +15,9 @@ import org.openjdk.nashorn.api.scripting.NashornException; import org.openjdk.nashorn.api.tree.CompilationUnitTree; import org.openjdk.nashorn.api.tree.Parser; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; +import org.palladiosimulator.retriever.extraction.engine.Discoverer; +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; import de.uka.ipd.sdq.workflow.jobs.AbstractBlackboardInteractingJob; import de.uka.ipd.sdq.workflow.jobs.CleanupFailedException; @@ -26,11 +27,11 @@ public class EcmaScriptDiscoverer implements Discoverer { - private static final String DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.ecmascript"; + private static final String DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.ecmascript"; @Override - public IBlackboardInteractingJob create(final RuleEngineConfiguration configuration, - final RuleEngineBlackboard blackboard) { + public IBlackboardInteractingJob create(final RetrieverConfiguration configuration, + final RetrieverBlackboard blackboard) { return new AbstractBlackboardInteractingJob<>() { @Override @@ -41,9 +42,9 @@ public void cleanup(final IProgressMonitor monitor) throws CleanupFailedExceptio public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { final Path root = Paths.get(CommonPlugin.asLocalURI(configuration.getInputFolder()) .devicePath()); - setBlackboard(Objects.requireNonNull(blackboard)); + this.setBlackboard(Objects.requireNonNull(blackboard)); final Map compilationUnits = new HashMap<>(); - Stream.concat(Discoverer.find(root, ".js", logger), Discoverer.find(root, ".ts", logger)) + Stream.concat(Discoverer.find(root, ".js", this.logger), Discoverer.find(root, ".ts", this.logger)) .forEach(p -> { try { final CompilationUnitTree compilationUnit = Parser.create() @@ -52,10 +53,11 @@ public void execute(final IProgressMonitor monitor) throws JobFailedException, U }); compilationUnits.put(p, compilationUnit); } catch (NashornException | IOException e) { - logger.error(String.format("%s could not be read correctly.", p), e); + this.logger.error(String.format("%s could not be read correctly.", p), e); } }); - getBlackboard().putDiscoveredFiles(DISCOVERER_ID, compilationUnits); + this.getBlackboard() + .putDiscoveredFiles(DISCOVERER_ID, compilationUnits); } @Override diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/JavaDiscoverer.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/JavaDiscoverer.java similarity index 80% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/JavaDiscoverer.java rename to bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/JavaDiscoverer.java index f62fda56..61795b1a 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/JavaDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/JavaDiscoverer.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.discoverer; +package org.palladiosimulator.retriever.extraction.discoverers; import java.nio.file.Path; import java.nio.file.Paths; @@ -15,8 +15,9 @@ import org.eclipse.jdt.core.dom.ASTParser; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.FileASTRequestor; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; +import org.palladiosimulator.retriever.extraction.engine.Discoverer; +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; import de.uka.ipd.sdq.workflow.jobs.AbstractBlackboardInteractingJob; import de.uka.ipd.sdq.workflow.jobs.CleanupFailedException; @@ -26,11 +27,11 @@ public class JavaDiscoverer implements Discoverer { - public static final String DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.java"; + public static final String DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.java"; @Override - public IBlackboardInteractingJob create(final RuleEngineConfiguration configuration, - final RuleEngineBlackboard blackboard) { + public IBlackboardInteractingJob create(final RetrieverConfiguration configuration, + final RetrieverBlackboard blackboard) { return new AbstractBlackboardInteractingJob<>() { @Override @@ -41,7 +42,7 @@ public void cleanup(final IProgressMonitor monitor) throws CleanupFailedExceptio public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { final Path root = Paths.get(CommonPlugin.asLocalURI(configuration.getInputFolder()) .devicePath()); - setBlackboard(Objects.requireNonNull(blackboard)); + this.setBlackboard(Objects.requireNonNull(blackboard)); final Map compilationUnits = new HashMap<>(); final ASTParser parser = ASTParser.newParser(AST.getJLSLatest()); parser.setKind(ASTParser.K_COMPILATION_UNIT); @@ -52,10 +53,10 @@ public void execute(final IProgressMonitor monitor) throws JobFailedException, U parser.setCompilerOptions( Map.of(JavaCore.COMPILER_SOURCE, latestJavaVersion, JavaCore.COMPILER_COMPLIANCE, latestJavaVersion, JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, latestJavaVersion)); - final String[] classpathEntries = Discoverer.find(root, ".jar", logger) + final String[] classpathEntries = Discoverer.find(root, ".jar", this.logger) .map(Path::toString) .toArray(String[]::new); - final String[] sourceFilePaths = Discoverer.find(root, ".java", logger) + final String[] sourceFilePaths = Discoverer.find(root, ".java", this.logger) .map(Path::toString) .toArray(String[]::new); try { @@ -68,9 +69,10 @@ public void acceptAST(final String sourceFilePath, final CompilationUnit ast) { } }, monitor); } catch (IllegalArgumentException | IllegalStateException e) { - logger.error(String.format("No Java files in %s could be transposed.", root), e); + this.logger.error(String.format("No Java files in %s could be transposed.", root), e); } - getBlackboard().putDiscoveredFiles(DISCOVERER_ID, compilationUnits); + this.getBlackboard() + .putDiscoveredFiles(DISCOVERER_ID, compilationUnits); } @Override diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/JsonDiscoverer.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/JsonDiscoverer.java similarity index 71% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/JsonDiscoverer.java rename to bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/JsonDiscoverer.java index 97f75aea..8cdcae88 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/JsonDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/JsonDiscoverer.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.discoverer; +package org.palladiosimulator.retriever.extraction.discoverers; import java.io.BufferedReader; import java.io.FileReader; @@ -16,8 +16,9 @@ import org.eclipse.emf.common.CommonPlugin; import org.json.JSONException; import org.json.JSONObject; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; +import org.palladiosimulator.retriever.extraction.engine.Discoverer; +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; import de.uka.ipd.sdq.workflow.jobs.AbstractBlackboardInteractingJob; import de.uka.ipd.sdq.workflow.jobs.CleanupFailedException; @@ -27,11 +28,11 @@ public class JsonDiscoverer implements Discoverer { - public static final String DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.json"; + public static final String DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.json"; @Override - public IBlackboardInteractingJob create(final RuleEngineConfiguration configuration, - final RuleEngineBlackboard blackboard) { + public IBlackboardInteractingJob create(final RetrieverConfiguration configuration, + final RetrieverBlackboard blackboard) { return new AbstractBlackboardInteractingJob<>() { @Override @@ -42,19 +43,20 @@ public void cleanup(final IProgressMonitor monitor) throws CleanupFailedExceptio public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { final Path root = Paths.get(CommonPlugin.asLocalURI(configuration.getInputFolder()) .devicePath()); - setBlackboard(Objects.requireNonNull(blackboard)); + this.setBlackboard(Objects.requireNonNull(blackboard)); final Map jsons = new HashMap<>(); - Discoverer.find(root, ".json", logger) + Discoverer.find(root, ".json", this.logger) .forEach(p -> { try (BufferedReader reader = new BufferedReader(new FileReader(p.toFile()))) { - String jsonSource = reader.lines() + final String jsonSource = reader.lines() .collect(Collectors.joining(System.lineSeparator())); jsons.put(p, new JSONObject(jsonSource)); } catch (ClassCastException | IOException | JSONException e) { - logger.error(String.format("%s could not be read correctly.", p), e); + this.logger.error(String.format("%s could not be read correctly.", p), e); } }); - getBlackboard().putDiscoveredFiles(DISCOVERER_ID, jsons); + this.getBlackboard() + .putDiscoveredFiles(DISCOVERER_ID, jsons); } @Override diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/PropertiesDiscoverer.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/PropertiesDiscoverer.java similarity index 69% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/PropertiesDiscoverer.java rename to bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/PropertiesDiscoverer.java index b84d30f8..77eb49c4 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/PropertiesDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/PropertiesDiscoverer.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.discoverer; +package org.palladiosimulator.retriever.extraction.discoverers; import java.io.FileReader; import java.io.IOException; @@ -14,8 +14,9 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.emf.common.CommonPlugin; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; +import org.palladiosimulator.retriever.extraction.engine.Discoverer; +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; import de.uka.ipd.sdq.workflow.jobs.AbstractBlackboardInteractingJob; import de.uka.ipd.sdq.workflow.jobs.CleanupFailedException; @@ -25,11 +26,11 @@ public class PropertiesDiscoverer implements Discoverer { - public static final String DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.properties"; + public static final String DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.properties"; @Override - public IBlackboardInteractingJob create(final RuleEngineConfiguration configuration, - final RuleEngineBlackboard blackboard) { + public IBlackboardInteractingJob create(final RetrieverConfiguration configuration, + final RetrieverBlackboard blackboard) { return new AbstractBlackboardInteractingJob<>() { @Override @@ -40,19 +41,20 @@ public void cleanup(final IProgressMonitor monitor) throws CleanupFailedExceptio public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { final Path root = Paths.get(CommonPlugin.asLocalURI(configuration.getInputFolder()) .devicePath()); - setBlackboard(Objects.requireNonNull(blackboard)); + this.setBlackboard(Objects.requireNonNull(blackboard)); final Map propertyFiles = new HashMap<>(); - Discoverer.find(root, ".properties", logger) + Discoverer.find(root, ".properties", this.logger) .forEach(p -> { try (Reader reader = new FileReader(p.toFile())) { - Properties properties = new Properties(); + final Properties properties = new Properties(); properties.load(reader); propertyFiles.put(p, properties); } catch (final IOException | IllegalArgumentException e) { - logger.error(String.format("%s could not be read correctly.", p), e); + this.logger.error(String.format("%s could not be read correctly.", p), e); } }); - getBlackboard().putDiscoveredFiles(DISCOVERER_ID, propertyFiles); + this.getBlackboard() + .putDiscoveredFiles(DISCOVERER_ID, propertyFiles); } @Override diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/SqlDiscoverer.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/SqlDiscoverer.java similarity index 72% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/SqlDiscoverer.java rename to bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/SqlDiscoverer.java index ac0d1c11..b5216efb 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/SqlDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/SqlDiscoverer.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.discoverer; +package org.palladiosimulator.retriever.extraction.discoverers; import java.io.FileReader; import java.io.IOException; @@ -13,8 +13,9 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.emf.common.CommonPlugin; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; +import org.palladiosimulator.retriever.extraction.engine.Discoverer; +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; import de.uka.ipd.sdq.workflow.jobs.AbstractBlackboardInteractingJob; import de.uka.ipd.sdq.workflow.jobs.CleanupFailedException; @@ -27,11 +28,11 @@ public class SqlDiscoverer implements Discoverer { - public static final String DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.sql"; + public static final String DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.sql"; @Override - public IBlackboardInteractingJob create(final RuleEngineConfiguration configuration, - final RuleEngineBlackboard blackboard) { + public IBlackboardInteractingJob create(final RetrieverConfiguration configuration, + final RetrieverBlackboard blackboard) { return new AbstractBlackboardInteractingJob<>() { @Override @@ -42,17 +43,18 @@ public void cleanup(final IProgressMonitor monitor) throws CleanupFailedExceptio public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { final Path root = Paths.get(CommonPlugin.asLocalURI(configuration.getInputFolder()) .devicePath()); - setBlackboard(Objects.requireNonNull(blackboard)); + this.setBlackboard(Objects.requireNonNull(blackboard)); final Map sqls = new HashMap<>(); - Discoverer.find(root, ".sql", logger) + Discoverer.find(root, ".sql", this.logger) .forEach(p -> { try (Reader reader = new FileReader(p.toFile())) { sqls.put(p, CCJSqlParserUtil.parse(reader)); } catch (final IOException | JSQLParserException e) { - logger.error(String.format("%s could not be read correctly.", p), e); + this.logger.error(String.format("%s could not be read correctly.", p), e); } }); - getBlackboard().putDiscoveredFiles(DISCOVERER_ID, sqls); + this.getBlackboard() + .putDiscoveredFiles(DISCOVERER_ID, sqls); } @Override diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/XmlDiscoverer.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/XmlDiscoverer.java similarity index 74% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/XmlDiscoverer.java rename to bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/XmlDiscoverer.java index ac33e716..26fec6f0 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/XmlDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/XmlDiscoverer.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.discoverer; +package org.palladiosimulator.retriever.extraction.discoverers; import java.io.FileReader; import java.io.IOException; @@ -16,8 +16,9 @@ import org.jdom2.Document; import org.jdom2.JDOMException; import org.jdom2.input.SAXBuilder; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; +import org.palladiosimulator.retriever.extraction.engine.Discoverer; +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; import de.uka.ipd.sdq.workflow.jobs.AbstractBlackboardInteractingJob; import de.uka.ipd.sdq.workflow.jobs.CleanupFailedException; @@ -27,11 +28,11 @@ public class XmlDiscoverer implements Discoverer { - public static final String DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.xml"; + public static final String DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.xml"; @Override - public IBlackboardInteractingJob create(final RuleEngineConfiguration configuration, - final RuleEngineBlackboard blackboard) { + public IBlackboardInteractingJob create(final RetrieverConfiguration configuration, + final RetrieverBlackboard blackboard) { return new AbstractBlackboardInteractingJob<>() { @Override @@ -42,14 +43,14 @@ public void cleanup(final IProgressMonitor monitor) throws CleanupFailedExceptio public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { final Path root = Paths.get(CommonPlugin.asLocalURI(configuration.getInputFolder()) .devicePath()); - setBlackboard(Objects.requireNonNull(blackboard)); + this.setBlackboard(Objects.requireNonNull(blackboard)); final Map xmls = new HashMap<>(); - Discoverer.find(root, ".xml", logger) + Discoverer.find(root, ".xml", this.logger) .forEach(p -> { try (Reader reader = new FileReader(p.toFile())) { xmls.put(p, new SAXBuilder().build(reader)); } catch (IOException | JDOMException e) { - logger.error(String.format("%s could not be read correctly.", p), e); + this.logger.error(String.format("%s could not be read correctly.", p), e); } }); @@ -60,7 +61,8 @@ public void execute(final IProgressMonitor monitor) throws JobFailedException, U .toString() .equalsIgnoreCase("pom.xml")) .forEach(p -> poms.put(p, xmls.get(p))); - getBlackboard().putDiscoveredFiles(DISCOVERER_ID, poms); + this.getBlackboard() + .putDiscoveredFiles(DISCOVERER_ID, poms); } @Override diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/YamlDiscoverer.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/YamlDiscoverer.java similarity index 68% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/YamlDiscoverer.java rename to bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/YamlDiscoverer.java index 64f727d5..d2606633 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/YamlDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/YamlDiscoverer.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.discoverer; +package org.palladiosimulator.retriever.extraction.discoverers; import java.io.FileReader; import java.io.IOException; @@ -16,9 +16,10 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.emf.common.CommonPlugin; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; -import org.palladiosimulator.somox.discoverer.wrapper.YamlMapper; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; +import org.palladiosimulator.retriever.extraction.discoverers.wrappers.YamlMapper; +import org.palladiosimulator.retriever.extraction.engine.Discoverer; +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.error.YAMLException; @@ -30,12 +31,12 @@ public class YamlDiscoverer implements Discoverer { - public static final String DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.yaml"; + public static final String DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.yaml"; public static final String MAPPER_PARTITION_KEY = DISCOVERER_ID + ".mappers"; @Override - public IBlackboardInteractingJob create(final RuleEngineConfiguration configuration, - final RuleEngineBlackboard blackboard) { + public IBlackboardInteractingJob create(final RetrieverConfiguration configuration, + final RetrieverBlackboard blackboard) { return new AbstractBlackboardInteractingJob<>() { @Override @@ -46,23 +47,25 @@ public void cleanup(final IProgressMonitor monitor) throws CleanupFailedExceptio public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { final Path root = Paths.get(CommonPlugin.asLocalURI(configuration.getInputFolder()) .devicePath()); - setBlackboard(Objects.requireNonNull(blackboard)); + this.setBlackboard(Objects.requireNonNull(blackboard)); final Map yamls = new HashMap<>(); final Map mappers = new HashMap<>(); - Stream.concat(Discoverer.find(root, ".yml", logger), Discoverer.find(root, ".yaml", logger)) + Stream.concat(Discoverer.find(root, ".yml", this.logger), Discoverer.find(root, ".yaml", this.logger)) .forEach(p -> { try (Reader reader = new FileReader(p.toFile())) { - List yamlContents = new ArrayList<>(); + final List yamlContents = new ArrayList<>(); new Yaml().loadAll(reader) .forEach(yamlContents::add); yamls.put(p, yamlContents); mappers.put(p, new YamlMapper(yamlContents)); } catch (final IOException | YAMLException e) { - logger.error(String.format("%s could not be read correctly.", p), e); + this.logger.error(String.format("%s could not be read correctly.", p), e); } }); - getBlackboard().putDiscoveredFiles(DISCOVERER_ID, yamls); - getBlackboard().putDiscoveredFiles(MAPPER_PARTITION_KEY, mappers); + this.getBlackboard() + .putDiscoveredFiles(DISCOVERER_ID, yamls); + this.getBlackboard() + .putDiscoveredFiles(MAPPER_PARTITION_KEY, mappers); } @Override diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/wrapper/YamlMapper.java b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/wrappers/YamlMapper.java similarity index 55% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/wrapper/YamlMapper.java rename to bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/wrappers/YamlMapper.java index b0c13c95..eb281742 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/wrapper/YamlMapper.java +++ b/bundles/org.palladiosimulator.retriever.extraction.discoverers/src/org/palladiosimulator/retriever/extraction/discoverers/wrappers/YamlMapper.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.discoverer.wrapper; +package org.palladiosimulator.retriever.extraction.discoverers.wrappers; import java.util.Map; import java.util.Optional; @@ -7,20 +7,20 @@ public class YamlMapper implements Function> { private final Iterable subfiles; - public YamlMapper(Iterable content) { + public YamlMapper(final Iterable content) { this.subfiles = content; } @Override - public Optional apply(String fullKey) { - String[] segments = fullKey.split("\\."); + public Optional apply(final String fullKey) { + final String[] segments = fullKey.split("\\."); - for (Object subfile : subfiles) { + for (final Object subfile : this.subfiles) { boolean failed = false; Object currentNode = subfile; - for (String segment : segments) { - Optional nextNode = load(segment, currentNode); + for (final String segment : segments) { + final Optional nextNode = this.load(segment, currentNode); if (nextNode.isEmpty()) { failed = true; break; @@ -36,9 +36,9 @@ public Optional apply(String fullKey) { return Optional.empty(); } - private Optional load(String key, Object yamlObject) { - if (yamlObject instanceof Map map) { - Object value = map.get(key); + private Optional load(final String key, final Object yamlObject) { + if (yamlObject instanceof final Map map) { + final Object value = map.get(key); return Optional.ofNullable(value); } return Optional.empty(); diff --git a/bundles/org.palladiosimulator.retriever.extraction.rules/.classpath b/bundles/org.palladiosimulator.retriever.extraction.rules/.classpath new file mode 100644 index 00000000..e835399e --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction.rules/.classpath @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/.project b/bundles/org.palladiosimulator.retriever.extraction.rules/.project similarity index 92% rename from bundles/org.palladiosimulator.somox.analyzer.rules.impl/.project rename to bundles/org.palladiosimulator.retriever.extraction.rules/.project index cab1c84e..de1ea183 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/.project +++ b/bundles/org.palladiosimulator.retriever.extraction.rules/.project @@ -1,6 +1,6 @@ - org.palladiosimulator.somox.analyzer.rules.impl + org.palladiosimulator.retriever.extraction.rules diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/META-INF/MANIFEST.MF b/bundles/org.palladiosimulator.retriever.extraction.rules/META-INF/MANIFEST.MF similarity index 54% rename from bundles/org.palladiosimulator.somox.analyzer.rules.impl/META-INF/MANIFEST.MF rename to bundles/org.palladiosimulator.retriever.extraction.rules/META-INF/MANIFEST.MF index 1ce9e9a5..d08e08d6 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/META-INF/MANIFEST.MF +++ b/bundles/org.palladiosimulator.retriever.extraction.rules/META-INF/MANIFEST.MF @@ -1,17 +1,17 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: SoMoX Rule Implementations -Bundle-SymbolicName: org.palladiosimulator.somox.analyzer.rules.impl;singleton:=true +Bundle-Name: Retriever Rules +Bundle-SymbolicName: org.palladiosimulator.retriever.extraction.rules;singleton:=true Bundle-Version: 5.2.0.qualifier Bundle-Vendor: palladiosimulator.org -Automatic-Module-Name: org.palladiosimulator.somox.analyzer.rules.impl +Automatic-Module-Name: org.palladiosimulator.retriever.extraction.rules Bundle-RequiredExecutionEnvironment: JavaSE-17 -Export-Package: org.palladiosimulator.somox.analyzer.rules.impl Require-Bundle: org.eclipse.core.resources, org.eclipse.xtend.lib, org.palladiosimulator.pcm, - org.palladiosimulator.somox.analyzer.rules.engine, + org.palladiosimulator.retriever.extraction, org.eclipse.jdt.core, de.uka.ipd.sdq.workflow, org.jdom2, org.openjdk.nashorn.core;bundle-version="15.4.0" +Export-Package: org.palladiosimulator.retriever.extraction.rules diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/build.properties b/bundles/org.palladiosimulator.retriever.extraction.rules/build.properties similarity index 100% rename from bundles/org.palladiosimulator.somox.analyzer.rules.impl/build.properties rename to bundles/org.palladiosimulator.retriever.extraction.rules/build.properties diff --git a/bundles/org.palladiosimulator.retriever.extraction.rules/plugin.xml b/bundles/org.palladiosimulator.retriever.extraction.rules/plugin.xml new file mode 100644 index 00000000..48efefff --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction.rules/plugin.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/DockerRules.xtend b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/DockerRules.xtend similarity index 72% rename from bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/DockerRules.xtend rename to bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/DockerRules.xtend index ce133eaa..696e6cbe 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/DockerRules.xtend +++ b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/DockerRules.xtend @@ -1,19 +1,19 @@ -package org.palladiosimulator.somox.analyzer.rules.impl +package org.palladiosimulator.retriever.extraction.rules -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard import java.nio.file.Path; import java.util.HashSet import org.eclipse.jdt.core.dom.CompilationUnit import java.util.Set -import org.palladiosimulator.somox.analyzer.rules.engine.Rule +import org.palladiosimulator.retriever.extraction.engine.Rule +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard class DockerRules implements Rule { - static final String RULE_ID = "org.palladiosimulator.somox.analyzer.rules.impl.docker" - static final String JAVA_DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.java" + static final String RULE_ID = "org.palladiosimulator.retriever.extraction.rules.docker" + static final String JAVA_DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.java" static final String DOCKER_FILE_NAME = "Dockerfile"; - override processRules(RuleEngineBlackboard blackboard, Path path) { + override processRules(RetrieverBlackboard blackboard, Path path) { if (path !== null && path.fileName.toString().equals(DOCKER_FILE_NAME)) { // Add all file system children as associated compilation units diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/EcmaScriptRules.xtend b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/EcmaScriptRules.xtend similarity index 91% rename from bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/EcmaScriptRules.xtend rename to bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/EcmaScriptRules.xtend index c9f15463..c1ee6141 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/EcmaScriptRules.xtend +++ b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/EcmaScriptRules.xtend @@ -1,8 +1,7 @@ -package org.palladiosimulator.somox.analyzer.rules.impl +package org.palladiosimulator.retriever.extraction.rules import org.openjdk.nashorn.api.tree.CompilationUnitTree import java.nio.file.Path -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard import java.util.Map import java.util.HashSet import java.util.Set @@ -20,19 +19,20 @@ import org.openjdk.nashorn.api.tree.BinaryTree import org.openjdk.nashorn.api.tree.ObjectLiteralTree import java.util.List import org.openjdk.nashorn.api.tree.VariableTree -import org.palladiosimulator.somox.analyzer.rules.model.RESTName +import org.palladiosimulator.retriever.extraction.commonalities.RESTName import java.util.Optional -import org.palladiosimulator.somox.analyzer.rules.model.CompUnitOrName -import org.palladiosimulator.somox.analyzer.rules.engine.Rule -import org.palladiosimulator.somox.analyzer.rules.impl.data.GatewayRoute +import org.palladiosimulator.retriever.extraction.commonalities.CompUnitOrName +import org.palladiosimulator.retriever.extraction.engine.Rule +import org.palladiosimulator.retriever.extraction.rules.data.GatewayRoute +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard class EcmaScriptRules implements Rule { - public static final String RULE_ID = "org.palladiosimulator.somox.analyzer.rules.impl.ecmascript" + public static final String RULE_ID = "org.palladiosimulator.retriever.extraction.rules.ecmascript" - public static final String ECMASCRIPT_DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.ecmascript" - public static final String HOSTNAMES_ID = "org.palladiosimulator.somox.analyzer.rules.impl.ecmascript.hostnames" - public static final String GATEWAY_ROUTES_ID = "org.palladiosimulator.somox.analyzer.rules.impl.ecmascript.routes" + public static final String ECMASCRIPT_DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.ecmascript" + public static final String HOSTNAMES_ID = "org.palladiosimulator.retriever.extraction.rules.ecmascript.hostnames" + public static final String GATEWAY_ROUTES_ID = "org.palladiosimulator.retriever.extraction.rules.ecmascript.routes" static final CompUnitOrName GATEWAY_NAME = new CompUnitOrName("Gateway") static final String START_NONWORD_CHARS = "^[\\W]+" @@ -44,7 +44,7 @@ class EcmaScriptRules implements Rule { static final String VARIABLE_PREFIX = ":" static final String BLANK = "" - override processRules(RuleEngineBlackboard blackboard, Path path) { + override processRules(RetrieverBlackboard blackboard, Path path) { val compilationUnits = blackboard.getDiscoveredFiles(ECMASCRIPT_DISCOVERER_ID, typeof(CompilationUnitTree)) val compilationUnit = compilationUnits.get(path) if(compilationUnit === null) return @@ -77,7 +77,7 @@ class EcmaScriptRules implements Rule { } } - val pcmDetector = blackboard.PCMDetector + val pcmDetector = blackboard.getPCMDetector val httpRequests = findAllHttpRequests(blackboard, compilationUnit) for (key : httpRequests.keySet) { for (url : httpRequests.get(key)) { @@ -91,7 +91,7 @@ class EcmaScriptRules implements Rule { } } - def findAllHttpRequests(RuleEngineBlackboard blackboard, CompilationUnitTree unit) { + def findAllHttpRequests(RetrieverBlackboard blackboard, CompilationUnitTree unit) { val source = unit.getSourceName().substring(0, unit.getSourceName().lastIndexOf(SEPARATOR) + 1) val assignments = findVariableAssignments(unit) val requests = join(findFunctionCallsWithUrls(unit), findFunctionDeclarationsWithUrls(unit), diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/GradleRules.xtend b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/GradleRules.xtend similarity index 73% rename from bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/GradleRules.xtend rename to bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/GradleRules.xtend index 4fe7e311..a7513868 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/GradleRules.xtend +++ b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/GradleRules.xtend @@ -1,19 +1,19 @@ -package org.palladiosimulator.somox.analyzer.rules.impl +package org.palladiosimulator.retriever.extraction.rules -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard import java.nio.file.Path; import java.util.HashSet import org.eclipse.jdt.core.dom.CompilationUnit import java.util.Set -import org.palladiosimulator.somox.analyzer.rules.engine.Rule +import org.palladiosimulator.retriever.extraction.engine.Rule +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard class GradleRules implements Rule { - static final String RULE_ID = "org.palladiosimulator.somox.analyzer.rules.impl.gradle"; - static final String JAVA_DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.java"; + static final String RULE_ID = "org.palladiosimulator.retriever.extraction.rules.gradle"; + static final String JAVA_DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.java"; static final String GRADLE_FILE_NAME = "build.gradle"; - override processRules(RuleEngineBlackboard blackboard, Path path) { + override processRules(RetrieverBlackboard blackboard, Path path) { if (path !== null && path.fileName.toString().equals(GRADLE_FILE_NAME)) { // Add all file system children as associated compilation units diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/JaxRSRules.xtend b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/JaxRSRules.xtend similarity index 80% rename from bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/JaxRSRules.xtend rename to bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/JaxRSRules.xtend index 87fe35f3..8fe065a5 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/JaxRSRules.xtend +++ b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/JaxRSRules.xtend @@ -1,29 +1,29 @@ -package org.palladiosimulator.somox.analyzer.rules.impl +package org.palladiosimulator.retriever.extraction.rules -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard -import java.nio.file.Path; +import java.nio.file.Path import org.eclipse.jdt.core.dom.CompilationUnit -import static org.palladiosimulator.somox.analyzer.rules.engine.RuleHelper.* -import org.palladiosimulator.somox.analyzer.rules.model.CompUnitOrName +import static org.palladiosimulator.retriever.extraction.engine.RuleHelper.* +import org.palladiosimulator.retriever.extraction.commonalities.CompUnitOrName import java.util.Set -import org.palladiosimulator.somox.analyzer.rules.engine.Rule -import org.palladiosimulator.somox.analyzer.rules.model.RESTName +import org.palladiosimulator.retriever.extraction.engine.Rule +import org.palladiosimulator.retriever.extraction.commonalities.RESTName import java.util.Optional -import org.palladiosimulator.somox.analyzer.rules.impl.util.RESTHelper +import org.palladiosimulator.retriever.extraction.rules.util.RESTHelper import java.util.Map -import org.palladiosimulator.somox.analyzer.rules.model.HTTPMethod +import org.palladiosimulator.retriever.extraction.commonalities.HTTPMethod +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard class JaxRSRules implements Rule { - public static final String RULE_ID = "org.palladiosimulator.somox.analyzer.rules.impl.jax_rs" + public static final String RULE_ID = "org.palladiosimulator.retriever.extraction.rules.jax_rs" - public static final String JAVA_DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.java" + public static final String JAVA_DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.java" static final Map SERVLET_METHODS = Map.of("doGet", HTTPMethod.GET, "doPost", HTTPMethod.POST, "doDelete", HTTPMethod.DELETE, "doPut", HTTPMethod.PUT, "handleGETRequest", HTTPMethod.GET, "handlePOSTRequest", HTTPMethod.POST, "handleDELETERequest", HTTPMethod.DELETE, "handlePUTRequest", HTTPMethod.PUT); - override processRules(RuleEngineBlackboard blackboard, Path path) { + override processRules(RetrieverBlackboard blackboard, Path path) { val unit = blackboard.getDiscoveredFiles(JAVA_DISCOVERER_ID, typeof(CompilationUnit)).get(path) if(unit === null) return; @@ -31,7 +31,7 @@ class JaxRSRules implements Rule { processRuleForCompUnit(blackboard, unit) } - def processRuleForCompUnit(RuleEngineBlackboard blackboard, CompilationUnit unit) { + def processRuleForCompUnit(RetrieverBlackboard blackboard, CompilationUnit unit) { val pcmDetector = blackboard.getPCMDetector() if (pcmDetector === null) { return @@ -98,7 +98,7 @@ class JaxRSRules implements Rule { } } - def detectDefault(RuleEngineBlackboard blackboard, CompilationUnit unit) { + def detectDefault(RetrieverBlackboard blackboard, CompilationUnit unit) { val pcmDetector = blackboard.getPCMDetector() val identifier = new CompUnitOrName(unit) diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/MavenRules.xtend b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/MavenRules.xtend similarity index 73% rename from bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/MavenRules.xtend rename to bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/MavenRules.xtend index e4326982..a33350f0 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/MavenRules.xtend +++ b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/MavenRules.xtend @@ -1,19 +1,19 @@ -package org.palladiosimulator.somox.analyzer.rules.impl +package org.palladiosimulator.retriever.extraction.rules -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard import java.nio.file.Path; import java.util.HashSet import org.eclipse.jdt.core.dom.CompilationUnit import java.util.Set -import org.palladiosimulator.somox.analyzer.rules.engine.Rule +import org.palladiosimulator.retriever.extraction.engine.Rule +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard class MavenRules implements Rule { - static final String RULE_ID = "org.palladiosimulator.somox.analyzer.rules.impl.maven" - static final String JAVA_DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.java"; + static final String RULE_ID = "org.palladiosimulator.retriever.extraction.rules.maven" + static final String JAVA_DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.java"; static final String MAVEN_FILE_NAME = "pom.xml"; - override processRules(RuleEngineBlackboard blackboard, Path path) { + override processRules(RetrieverBlackboard blackboard, Path path) { if (path !== null && path.fileName.toString().equals(MAVEN_FILE_NAME)) { // Add all file system children as associated compilation units diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringGatewayRules.xtend b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/SpringGatewayRules.xtend similarity index 89% rename from bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringGatewayRules.xtend rename to bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/SpringGatewayRules.xtend index 2c7b0958..a8812423 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringGatewayRules.xtend +++ b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/SpringGatewayRules.xtend @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.impl +package org.palladiosimulator.retriever.extraction.rules import java.nio.file.Path import java.util.ArrayList @@ -11,24 +11,24 @@ import java.util.Set import java.util.function.Function import org.apache.log4j.Logger import org.jdom2.Document -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard -import org.palladiosimulator.somox.analyzer.rules.engine.Rule -import org.palladiosimulator.somox.analyzer.rules.impl.util.SpringHelper -import org.palladiosimulator.somox.analyzer.rules.impl.data.GatewayRoute +import org.palladiosimulator.retriever.extraction.engine.Rule +import org.palladiosimulator.retriever.extraction.rules.util.SpringHelper +import org.palladiosimulator.retriever.extraction.rules.data.GatewayRoute +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard class SpringGatewayRules implements Rule { static final Logger LOG = Logger.getLogger(SpringGatewayRules) - public static final String RULE_ID = "org.palladiosimulator.somox.analyzer.rules.impl.spring.cloudgateway" - public static final String YAML_DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.yaml" + public static final String RULE_ID = "org.palladiosimulator.retriever.extraction.rules.spring.cloudgateway" + public static final String YAML_DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.yaml" public static final String YAML_MAPPERS_KEY = YAML_DISCOVERER_ID + ".mappers" - public static final String XML_DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.xml" - public static final String PROPERTIES_DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.properties" - public static final String ECMASCRIPT_RULE_ID = "org.palladiosimulator.somox.analyzer.rules.impl.ecmascript" - public static final String ECMASCRIPT_ROUTES_ID = "org.palladiosimulator.somox.analyzer.rules.impl.ecmascript.routes" - public static final String ECMASCRIPT_HOSTNAMES_ID = "org.palladiosimulator.somox.analyzer.rules.impl.ecmascript.hostnames" + public static final String XML_DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.xml" + public static final String PROPERTIES_DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.properties" + public static final String ECMASCRIPT_RULE_ID = "org.palladiosimulator.retriever.extraction.rules.ecmascript" + public static final String ECMASCRIPT_ROUTES_ID = "org.palladiosimulator.retriever.extraction.rules.ecmascript.routes" + public static final String ECMASCRIPT_HOSTNAMES_ID = "org.palladiosimulator.retriever.extraction.rules.ecmascript.hostnames" - override processRules(RuleEngineBlackboard blackboard, Path path) { + override processRules(RetrieverBlackboard blackboard, Path path) { val rawYamls = blackboard.getPartition(YAML_DISCOVERER_ID) as Map>> val yamlMappers = blackboard.getPartition(YAML_MAPPERS_KEY) as Map>> val poms = blackboard.getDiscoveredFiles(XML_DISCOVERER_ID, typeof(Document)) diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringRules.xtend b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/SpringRules.xtend similarity index 91% rename from bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringRules.xtend rename to bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/SpringRules.xtend index 19994be1..f0fad214 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringRules.xtend +++ b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/SpringRules.xtend @@ -1,7 +1,6 @@ -package org.palladiosimulator.somox.analyzer.rules.impl +package org.palladiosimulator.retriever.extraction.rules -import static org.palladiosimulator.somox.analyzer.rules.engine.RuleHelper.* -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard +import static org.palladiosimulator.retriever.extraction.engine.RuleHelper.* import java.nio.file.Path import org.eclipse.jdt.core.dom.CompilationUnit import java.util.Map; @@ -12,29 +11,30 @@ import org.eclipse.jdt.core.dom.ITypeBinding import java.util.HashMap import java.util.List import java.util.Properties -import org.palladiosimulator.somox.analyzer.rules.model.RESTName -import org.palladiosimulator.somox.analyzer.rules.model.HTTPMethod +import org.palladiosimulator.retriever.extraction.commonalities.RESTName +import org.palladiosimulator.retriever.extraction.commonalities.HTTPMethod import java.util.Optional -import org.palladiosimulator.somox.analyzer.rules.model.CompUnitOrName +import org.palladiosimulator.retriever.extraction.commonalities.CompUnitOrName import java.util.function.Function import java.util.Set -import org.palladiosimulator.somox.analyzer.rules.engine.Rule -import org.palladiosimulator.somox.analyzer.rules.impl.util.SpringHelper -import org.palladiosimulator.somox.analyzer.rules.impl.util.RESTHelper +import org.palladiosimulator.retriever.extraction.engine.Rule +import org.palladiosimulator.retriever.extraction.rules.util.SpringHelper +import org.palladiosimulator.retriever.extraction.rules.util.RESTHelper +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard class SpringRules implements Rule { static final Logger LOG = Logger.getLogger(SpringRules) - public static final String RULE_ID = "org.palladiosimulator.somox.analyzer.rules.impl.spring" - public static final String JAVA_DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.java" - public static final String YAML_DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.yaml" + public static final String RULE_ID = "org.palladiosimulator.retriever.extraction.rules.spring" + public static final String JAVA_DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.java" + public static final String YAML_DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.yaml" public static final String YAML_MAPPERS_KEY = YAML_DISCOVERER_ID + ".mappers" - public static final String XML_DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.xml" - public static final String PROPERTIES_DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.properties" - public static final String ZUUL_RULE_ID = "org.palladiosimulator.somox.analyzer.rules.impl.spring.zuul"; - public static final String CLOUD_GATEWAY_RULE_ID = "org.palladiosimulator.somox.analyzer.rules.impl.spring.cloudgateway"; + public static final String XML_DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.xml" + public static final String PROPERTIES_DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.properties" + public static final String ZUUL_RULE_ID = "org.palladiosimulator.retriever.extraction.rules.spring.zuul"; + public static final String CLOUD_GATEWAY_RULE_ID = "org.palladiosimulator.retriever.extraction.rules.spring.cloudgateway"; - override processRules(RuleEngineBlackboard blackboard, Path path) { + override processRules(RetrieverBlackboard blackboard, Path path) { val unit = blackboard.getDiscoveredFiles(JAVA_DISCOVERER_ID, typeof(CompilationUnit)).get(path) if(unit === null) return; @@ -129,7 +129,7 @@ class SpringRules implements Rule { return result; } - def processRuleForCompUnit(RuleEngineBlackboard blackboard, CompilationUnit unit, String applicationName, + def processRuleForCompUnit(RetrieverBlackboard blackboard, CompilationUnit unit, String applicationName, String contextPath, Map contextVariables) { val pcmDetector = blackboard.getPCMDetector if(pcmDetector === null) return; diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringZuulRules.xtend b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/SpringZuulRules.xtend similarity index 88% rename from bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringZuulRules.xtend rename to bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/SpringZuulRules.xtend index 33428da7..599c7b05 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringZuulRules.xtend +++ b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/SpringZuulRules.xtend @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.impl +package org.palladiosimulator.retriever.extraction.rules import java.nio.file.Path import java.util.ArrayList @@ -11,24 +11,24 @@ import java.util.Set import java.util.function.Function import org.apache.log4j.Logger import org.jdom2.Document -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard -import org.palladiosimulator.somox.analyzer.rules.engine.Rule -import org.palladiosimulator.somox.analyzer.rules.impl.util.SpringHelper -import org.palladiosimulator.somox.analyzer.rules.impl.data.GatewayRoute +import org.palladiosimulator.retriever.extraction.engine.Rule +import org.palladiosimulator.retriever.extraction.rules.util.SpringHelper +import org.palladiosimulator.retriever.extraction.rules.data.GatewayRoute +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard class SpringZuulRules implements Rule { static final Logger LOG = Logger.getLogger(SpringZuulRules) - public static final String RULE_ID = "org.palladiosimulator.somox.analyzer.rules.impl.spring.zuul" - public static final String YAML_DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.yaml" + public static final String RULE_ID = "org.palladiosimulator.retriever.extraction.rules.spring.zuul" + public static final String YAML_DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.yaml" public static final String YAML_MAPPERS_KEY = YAML_DISCOVERER_ID + ".mappers" - public static final String XML_DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.xml" - public static final String PROPERTIES_DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.properties" - public static final String ECMASCRIPT_RULE_ID = "org.palladiosimulator.somox.analyzer.rules.impl.ecmascript" - public static final String ECMASCRIPT_ROUTES_ID = "org.palladiosimulator.somox.analyzer.rules.impl.ecmascript.routes" - public static final String ECMASCRIPT_HOSTNAMES_ID = "org.palladiosimulator.somox.analyzer.rules.impl.ecmascript.hostnames" + public static final String XML_DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.xml" + public static final String PROPERTIES_DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.properties" + public static final String ECMASCRIPT_RULE_ID = "org.palladiosimulator.retriever.extraction.rules.ecmascript" + public static final String ECMASCRIPT_ROUTES_ID = "org.palladiosimulator.retriever.extraction.rules.ecmascript.routes" + public static final String ECMASCRIPT_HOSTNAMES_ID = "org.palladiosimulator.retriever.extraction.rules.ecmascript.hostnames" - override processRules(RuleEngineBlackboard blackboard, Path path) { + override processRules(RetrieverBlackboard blackboard, Path path) { val rawYamls = blackboard.getPartition(YAML_DISCOVERER_ID) as Map>> val yamlMappers = blackboard.getPartition(YAML_MAPPERS_KEY) as Map>> val poms = blackboard.getDiscoveredFiles(XML_DISCOVERER_ID, typeof(Document)) diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/data/GatewayRoute.xtend b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/data/GatewayRoute.xtend similarity index 92% rename from bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/data/GatewayRoute.xtend rename to bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/data/GatewayRoute.xtend index 90b2671b..8a4a4650 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/data/GatewayRoute.xtend +++ b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/data/GatewayRoute.xtend @@ -1,6 +1,6 @@ -package org.palladiosimulator.somox.analyzer.rules.impl.data +package org.palladiosimulator.retriever.extraction.rules.data -import org.palladiosimulator.somox.analyzer.rules.model.RESTName +import org.palladiosimulator.retriever.extraction.commonalities.RESTName import java.util.Optional class GatewayRoute { diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/util/RESTHelper.xtend b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/util/RESTHelper.xtend similarity index 82% rename from bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/util/RESTHelper.xtend rename to bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/util/RESTHelper.xtend index 6383d58f..6a8d37a1 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/util/RESTHelper.xtend +++ b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/util/RESTHelper.xtend @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.impl.util +package org.palladiosimulator.retriever.extraction.rules.util class RESTHelper { def static replaceArgumentsWithWildcards(String methodName) { diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/util/SpringHelper.xtend b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/util/SpringHelper.xtend similarity index 97% rename from bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/util/SpringHelper.xtend rename to bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/util/SpringHelper.xtend index 315ed4a2..a6448b80 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/util/SpringHelper.xtend +++ b/bundles/org.palladiosimulator.retriever.extraction.rules/src/org/palladiosimulator/retriever/extraction/rules/util/SpringHelper.xtend @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.impl.util +package org.palladiosimulator.retriever.extraction.rules.util import java.nio.file.Path import java.util.Map diff --git a/bundles/org.palladiosimulator.retriever.extraction/.classpath b/bundles/org.palladiosimulator.retriever.extraction/.classpath new file mode 100644 index 00000000..9c8192c2 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/.project b/bundles/org.palladiosimulator.retriever.extraction/.project similarity index 93% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/.project rename to bundles/org.palladiosimulator.retriever.extraction/.project index bd65cac8..e6487205 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/.project +++ b/bundles/org.palladiosimulator.retriever.extraction/.project @@ -1,6 +1,6 @@ - org.palladiosimulator.somox.analyzer.rules.engine + org.palladiosimulator.retriever.extraction diff --git a/bundles/org.palladiosimulator.retriever.extraction/META-INF/MANIFEST.MF b/bundles/org.palladiosimulator.retriever.extraction/META-INF/MANIFEST.MF new file mode 100644 index 00000000..091f4602 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction/META-INF/MANIFEST.MF @@ -0,0 +1,14 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Retriever Extraction +Bundle-SymbolicName: org.palladiosimulator.retriever.extraction;singleton:=true +Bundle-Version: 5.2.0.qualifier +Bundle-Vendor: palladiosimulator.org +Automatic-Module-Name: org.palladiosimulator.retriever.extraction.engine +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Export-Package: org.palladiosimulator.retriever.extraction.blackboard, + org.palladiosimulator.retriever.extraction.commonalities, + org.palladiosimulator.retriever.extraction.engine +Require-Bundle: org.eclipse.jdt.core, + org.palladiosimulator.generator.fluent, + de.uka.ipd.sdq.workflow diff --git a/bundles/org.palladiosimulator.retriever.extraction/build.properties b/bundles/org.palladiosimulator.retriever.extraction/build.properties new file mode 100644 index 00000000..e9863e28 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml diff --git a/bundles/org.palladiosimulator.retriever.extraction/plugin.xml b/bundles/org.palladiosimulator.retriever.extraction/plugin.xml new file mode 100644 index 00000000..4b69b08d --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction/plugin.xml @@ -0,0 +1,13 @@ + + + + + + + diff --git a/bundles/org.palladiosimulator.retriever.extraction/schema/org.palladiosimulator.retriever.extraction.analyst.exsd b/bundles/org.palladiosimulator.retriever.extraction/schema/org.palladiosimulator.retriever.extraction.analyst.exsd new file mode 100644 index 00000000..68152c6a --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction/schema/org.palladiosimulator.retriever.extraction.analyst.exsd @@ -0,0 +1,107 @@ + + + + + + + + + [Enter description of this extension point.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension + point.] + + + + + diff --git a/bundles/org.palladiosimulator.retriever.extraction/schema/org.palladiosimulator.retriever.extraction.discoverer.exsd b/bundles/org.palladiosimulator.retriever.extraction/schema/org.palladiosimulator.retriever.extraction.discoverer.exsd new file mode 100644 index 00000000..a8a04416 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction/schema/org.palladiosimulator.retriever.extraction.discoverer.exsd @@ -0,0 +1,107 @@ + + + + + + + + + [Enter description of this extension point.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension + point.] + + + + + diff --git a/bundles/org.palladiosimulator.retriever.extraction/schema/org.palladiosimulator.retriever.extraction.rule.exsd b/bundles/org.palladiosimulator.retriever.extraction/schema/org.palladiosimulator.retriever.extraction.rule.exsd new file mode 100644 index 00000000..40cf7b4c --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction/schema/org.palladiosimulator.retriever.extraction.rule.exsd @@ -0,0 +1,107 @@ + + + + + + + + + [Enter description of this extension point.] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + [Enter extension point usage example here.] + + + + + + + + + [Enter API information here.] + + + + + + + + + [Enter information about supplied implementation of this extension + point.] + + + + + diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/blackboard/RetrieverBlackboard.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/blackboard/RetrieverBlackboard.java new file mode 100644 index 00000000..4ce42184 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/blackboard/RetrieverBlackboard.java @@ -0,0 +1,126 @@ +package org.palladiosimulator.retriever.extraction.blackboard; + +import java.nio.file.Path; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import org.eclipse.jdt.core.dom.ASTNode; +import org.eclipse.jdt.core.dom.CompilationUnit; +import org.palladiosimulator.pcm.repository.RepositoryComponent; +import org.palladiosimulator.pcm.seff.ServiceEffectSpecification; +import org.palladiosimulator.pcm.system.System; +import org.palladiosimulator.retriever.extraction.engine.PCMDetector; + +import de.uka.ipd.sdq.workflow.blackboard.Blackboard; + +public class RetrieverBlackboard extends Blackboard { + + public static final String KEY_REPOSITORY = "org.palladiosimulator.retriever.repository"; + public static final String KEY_SEFF_ASSOCIATIONS = "org.palladiosimulator.retriever.seff_associations"; + + private final Map repositoryComponentLocations; + private final Map> systemAssociations; + private final Map systemPaths; + private final Set discovererIDs; + private PCMDetector pcmDetector; + + public RetrieverBlackboard() { + super(); + this.repositoryComponentLocations = new HashMap<>(); + this.systemAssociations = new HashMap<>(); + this.systemPaths = new HashMap<>(); + this.discovererIDs = new HashSet<>(); + this.pcmDetector = new PCMDetector(); + this.addPartition(KEY_SEFF_ASSOCIATIONS, new HashMap<>()); + } + + public CompilationUnit putRepositoryComponentLocation(final RepositoryComponent repoComp, + final CompilationUnit compilationUnit) { + return this.repositoryComponentLocations.put(repoComp, compilationUnit); + } + + public Map getRepositoryComponentLocations() { + return Collections.unmodifiableMap(this.repositoryComponentLocations); + } + + public void setPCMDetector(final PCMDetector pcmDetector) { + this.pcmDetector = pcmDetector; + } + + public PCMDetector getPCMDetector() { + return this.pcmDetector; + } + + public void addSystemAssociations(final Path path, final Set compilationUnits) { + this.systemAssociations.put(path, Collections.unmodifiableSet(compilationUnits)); + } + + public Map> getSystemAssociations() { + return Collections.unmodifiableMap(this.systemAssociations); + } + + public void putSystemPath(final System system, final Path path) { + this.systemPaths.put(system, path); + } + + public void putSeffAssociation(final ASTNode astNode, final ServiceEffectSpecification seff) { + @SuppressWarnings("unchecked") + final Map seffAssociations = (Map) this + .getPartition(KEY_SEFF_ASSOCIATIONS); + seffAssociations.put(astNode, seff); + } + + public ServiceEffectSpecification getSeffAssociation(final ASTNode astNode) { + @SuppressWarnings("unchecked") + final Map seffAssociations = (Map) this + .getPartition(KEY_SEFF_ASSOCIATIONS); + return seffAssociations.get(astNode); + } + + public Map getSeffAssociations() { + @SuppressWarnings("unchecked") + final Map seffAssociations = (Map) this + .getPartition(KEY_SEFF_ASSOCIATIONS); + return Collections.unmodifiableMap(seffAssociations); + } + + public void putDiscoveredFiles(final String discovererID, final Map pathsToFiles) { + this.discovererIDs.add(discovererID); + this.addPartition(discovererID, pathsToFiles); + } + + public Map getDiscoveredFiles(final String discovererID, final Class fileClass) { + final Object partition = this.getPartition(discovererID); + if (!(partition instanceof Map)) { + return new HashMap<>(); + } + @SuppressWarnings("unchecked") // Not unchecked. + final Map map = (Map) partition; + if (map.isEmpty()) { + return new HashMap<>(); + } + final boolean allEntriesHaveCorrectType = map.entrySet() + .stream() + .allMatch(entry -> entry.getKey() instanceof Path && fileClass.isInstance(entry.getValue())); + if (!allEntriesHaveCorrectType) { + return new HashMap<>(); + } + return map.entrySet() + .stream() + .collect(Collectors.toMap(entry -> (Path) entry.getKey(), entry -> fileClass.cast(entry.getValue()))); + } + + public Set getDiscoveredPaths() { + final Set discoveredPaths = new HashSet<>(); + for (final String discovererID : this.discovererIDs) { + @SuppressWarnings("unchecked") // Local data structure, this assumption is an invariant. + final Map partition = (Map) this.getPartition(discovererID); + discoveredPaths.addAll(partition.keySet()); + } + return discoveredPaths; + } +} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/CompUnitOrName.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/CompUnitOrName.java similarity index 55% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/CompUnitOrName.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/CompUnitOrName.java index 1c368832..3a73739a 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/CompUnitOrName.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/CompUnitOrName.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.model; +package org.palladiosimulator.retriever.extraction.commonalities; import java.util.List; import java.util.Objects; @@ -13,36 +13,36 @@ public class CompUnitOrName { private final Optional compilationUnit; private final String name; - public CompUnitOrName(String name) { + public CompUnitOrName(final String name) { this.compilationUnit = Optional.empty(); this.name = name; } - public CompUnitOrName(CompilationUnit compilationUnit) { + public CompUnitOrName(final CompilationUnit compilationUnit) { this.compilationUnit = Optional.of(compilationUnit); this.name = toName(compilationUnit); } public boolean isUnit() { - return compilationUnit.isPresent(); + return this.compilationUnit.isPresent(); } public Optional compilationUnit() { - return compilationUnit; + return this.compilationUnit; } public String name() { - return name; + return this.name; } - private static String toName(CompilationUnit compilationUnit) { + private static String toName(final CompilationUnit compilationUnit) { @SuppressWarnings("unchecked") - List types = (List) compilationUnit.types(); + final List types = compilationUnit.types(); if (types.isEmpty()) { return "void"; } - AbstractTypeDeclaration firstTypeDecl = types.get(0); - ITypeBinding binding = firstTypeDecl.resolveBinding(); + final AbstractTypeDeclaration firstTypeDecl = types.get(0); + final ITypeBinding binding = firstTypeDecl.resolveBinding(); if (binding == null) { return firstTypeDecl.getName() .getFullyQualifiedName(); @@ -52,21 +52,18 @@ private static String toName(CompilationUnit compilationUnit) { @Override public int hashCode() { - return Objects.hash(compilationUnit, name); + return Objects.hash(this.compilationUnit, this.name); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - CompUnitOrName other = (CompUnitOrName) obj; - return Objects.equals(compilationUnit, other.compilationUnit) && Objects.equals(name, other.name); + final CompUnitOrName other = (CompUnitOrName) obj; + return Objects.equals(this.compilationUnit, other.compilationUnit) && Objects.equals(this.name, other.name); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Component.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Component.java similarity index 53% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Component.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Component.java index 51245643..a45035f8 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Component.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Component.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.model; +package org.palladiosimulator.retriever.extraction.commonalities; import java.util.Objects; import java.util.Optional; @@ -7,7 +7,7 @@ /** * Components are {@code CompilationUnits}. They provide and require interfaces. - * + * * @see CompilationUnit * @author Florian Bossert */ @@ -16,63 +16,62 @@ public class Component { private final Requirements requirements; private final Provisions provisions; - public Component(CompUnitOrName compUnitOrName, Requirements requirements, Provisions provisions) { + public Component(final CompUnitOrName compUnitOrName, final Requirements requirements, + final Provisions provisions) { this.compUnitOrName = compUnitOrName; this.requirements = requirements; this.provisions = provisions; } public Requirements requirements() { - return requirements; + return this.requirements; } public Provisions provisions() { - return provisions; + return this.provisions; } public Optional compilationUnit() { - return compUnitOrName.compilationUnit(); + return this.compUnitOrName.compilationUnit(); } public String name() { - return compUnitOrName.name(); + return this.compUnitOrName.name(); } public CompUnitOrName identifier() { - return compUnitOrName; + return this.compUnitOrName; } @Override public int hashCode() { - return Objects.hash(compUnitOrName, provisions, requirements); + return Objects.hash(this.compUnitOrName, this.provisions, this.requirements); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - Component other = (Component) obj; - return Objects.equals(compUnitOrName, other.compUnitOrName) && Objects.equals(provisions, other.provisions) - && Objects.equals(requirements, other.requirements); + final Component other = (Component) obj; + return Objects.equals(this.compUnitOrName, other.compUnitOrName) + && Objects.equals(this.provisions, other.provisions) + && Objects.equals(this.requirements, other.requirements); } @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("Name: "); - builder.append(name()); + builder.append(this.name()); builder.append("\nRequirements:\n\t"); - builder.append(requirements.toString() + builder.append(this.requirements.toString() .replace("\n", "\n\t")); builder.append("\nProvisions:\n\t"); - builder.append(provisions.toString() + builder.append(this.provisions.toString() .replace("\n", "\n\t")); return builder.toString(); diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ComponentBuilder.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ComponentBuilder.java new file mode 100644 index 00000000..41fa93d9 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ComponentBuilder.java @@ -0,0 +1,59 @@ +package org.palladiosimulator.retriever.extraction.commonalities; + +import java.util.Collection; +import java.util.Objects; + +/** + * Used to build {@code Component}s. + * + * @see Component + * @author Florian Bossert + */ +public class ComponentBuilder { + private final CompUnitOrName compUnitOrName; + private final RequirementsBuilder requirements; + private final ProvisionsBuilder provisions; + + public ComponentBuilder(final CompUnitOrName compUnitOrName) { + this.compUnitOrName = compUnitOrName; + this.requirements = new RequirementsBuilder(); + this.provisions = new ProvisionsBuilder(); + } + + public CompUnitOrName identifier() { + return this.compUnitOrName; + } + + public RequirementsBuilder requirements() { + return this.requirements; + } + + public ProvisionsBuilder provisions() { + return this.provisions; + } + + public Component create(final Collection allDependencies, + final Collection visibleProvisions) { + return new Component(this.compUnitOrName, this.requirements.create(allDependencies, visibleProvisions), + this.provisions.create(allDependencies)); + } + + @Override + public int hashCode() { + return Objects.hash(this.compUnitOrName, this.provisions, this.requirements); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if ((obj == null) || (this.getClass() != obj.getClass())) { + return false; + } + final ComponentBuilder other = (ComponentBuilder) obj; + return Objects.equals(this.compUnitOrName, other.compUnitOrName) + && Objects.equals(this.provisions, other.provisions) + && Objects.equals(this.requirements, other.requirements); + } +} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Composite.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Composite.java similarity index 53% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Composite.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Composite.java index bfd04402..1acb87eb 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Composite.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Composite.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.model; +package org.palladiosimulator.retriever.extraction.commonalities; import java.util.Collections; import java.util.Objects; @@ -12,8 +12,8 @@ public class Composite { private final Set requirements; private final Set provisions; - public Composite(String name, Set parts, Set requirements, - Set provisions, Set internalInterfaces) { + public Composite(final String name, final Set parts, final Set requirements, + final Set provisions, final Set internalInterfaces) { this.name = name; this.parts = parts; this.internalInterfaces = internalInterfaces; @@ -22,70 +22,68 @@ public Composite(String name, Set parts, Set requ } public String name() { - return name; + return this.name; } public Set requirements() { - return requirements; + return this.requirements; } public Set provisions() { - return provisions; + return this.provisions; } public Set parts() { - return Collections.unmodifiableSet(parts); + return Collections.unmodifiableSet(this.parts); } public Set internalInterfaces() { - return Collections.unmodifiableSet(internalInterfaces); + return Collections.unmodifiableSet(this.internalInterfaces); } public boolean isSubsetOf(final Composite other) { return other.parts() - .containsAll(parts); + .containsAll(this.parts); } @Override public int hashCode() { - return Objects.hash(internalInterfaces, name, parts, provisions, requirements); + return Objects.hash(this.internalInterfaces, this.name, this.parts, this.provisions, this.requirements); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - Composite other = (Composite) obj; - return Objects.equals(internalInterfaces, other.internalInterfaces) && Objects.equals(name, other.name) - && Objects.equals(parts, other.parts) && Objects.equals(provisions, other.provisions) - && Objects.equals(requirements, other.requirements); + final Composite other = (Composite) obj; + return Objects.equals(this.internalInterfaces, other.internalInterfaces) + && Objects.equals(this.name, other.name) && Objects.equals(this.parts, other.parts) + && Objects.equals(this.provisions, other.provisions) + && Objects.equals(this.requirements, other.requirements); } @Override public String toString() { - StringBuilder builder = new StringBuilder(); + final StringBuilder builder = new StringBuilder(); builder.append("Name: "); - builder.append(name); + builder.append(this.name); builder.append("\nRequirements:\n\t"); - builder.append(requirements.toString() + builder.append(this.requirements.toString() .replace("\n", "\n\t")); builder.append("\nProvisions:\n\t"); - builder.append(provisions.toString() + builder.append(this.provisions.toString() .replace("\n", "\n\t")); builder.append("\nInternal interfaces:\n"); - internalInterfaces.forEach(x -> builder.append('\t') + this.internalInterfaces.forEach(x -> builder.append('\t') .append(x.toString() .replace("\n", "\n\t")) .append('\n')); builder.append("\nParts:\n"); - parts.forEach(x -> builder.append('\t') + this.parts.forEach(x -> builder.append('\t') .append(x.toString() .replace("\n", "\n\t")) .append('\n')); diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/CompositeBuilder.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/CompositeBuilder.java similarity index 58% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/CompositeBuilder.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/CompositeBuilder.java index 5131d2a2..224c5dc6 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/CompositeBuilder.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/CompositeBuilder.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.model; +package org.palladiosimulator.retriever.extraction.commonalities; import java.util.ArrayList; import java.util.Collection; @@ -14,52 +14,52 @@ import java.util.stream.Collectors; import org.apache.log4j.Logger; -import org.palladiosimulator.somox.analyzer.rules.engine.MapMerger; +import org.palladiosimulator.retriever.extraction.engine.MapMerger; public class CompositeBuilder { - private String name; - private Set explicitParts = new HashSet<>(); + private final String name; + private final Set explicitParts = new HashSet<>(); - public CompositeBuilder(String name) { + public CompositeBuilder(final String name) { this.name = name; } - public void addPart(ComponentBuilder componentBuilder) { - explicitParts.add(componentBuilder); + public void addPart(final ComponentBuilder componentBuilder) { + this.explicitParts.add(componentBuilder); } - public boolean hasPart(CompUnitOrName identifier) { - return explicitParts.stream() + public boolean hasPart(final CompUnitOrName identifier) { + return this.explicitParts.stream() .anyMatch(part -> part.identifier() .equals(identifier)); } public Collection getParts() { - return Set.copyOf(explicitParts); + return Set.copyOf(this.explicitParts); } - public Composite construct(Collection allComponents, Requirements compositeRequirements, - Provisions compositeProvisions, Collection visibleProvisions) { - Logger.getLogger(getClass()) - .warn("Constructing composite component " + name); + public Composite construct(final Collection allComponents, final Requirements compositeRequirements, + final Provisions compositeProvisions, final Collection visibleProvisions) { + Logger.getLogger(this.getClass()) + .warn("Constructing composite component " + this.name); - List allDependencies = new LinkedList<>(); - for (OperationInterface requirement : compositeRequirements) { + final List allDependencies = new LinkedList<>(); + for (final OperationInterface requirement : compositeRequirements) { allDependencies.add(requirement); } - for (OperationInterface provision : compositeProvisions) { + for (final OperationInterface provision : compositeProvisions) { allDependencies.add(provision); } // Create and add all explicit parts. - Set parts = explicitParts.stream() + final Set parts = this.explicitParts.stream() .map(x -> x.create(allDependencies, visibleProvisions)) .collect(Collectors.toSet()); - Set remainingComponents = new HashSet<>(allComponents); + final Set remainingComponents = new HashSet<>(allComponents); remainingComponents.removeAll(parts); - Set internalInterfaces = new HashSet<>(); + final Set internalInterfaces = new HashSet<>(); int previousPartCount = 0; int previousInternalInterfaceCount = 0; @@ -73,21 +73,21 @@ public Composite construct(Collection allComponents, Requirements com internalInterfaces); } while (parts.size() > previousPartCount && internalInterfaces.size() > previousInternalInterfaceCount); - List requirements = new ArrayList<>(); - List>> provisions = new ArrayList<>(); + final List requirements = new ArrayList<>(); + final List>> provisions = new ArrayList<>(); - for (Component part : parts) { + for (final Component part : parts) { requirements.addAll(part.requirements() .get()); provisions.add(part.provisions() .getGrouped()); } - Set externalRequirements = requirements.stream() + final Set externalRequirements = requirements.stream() .filter(x -> compositeRequirements.containsEntire(x)) .collect(Collectors.toSet()); - Set externalProvisions = MapMerger.merge(provisions) + final Set externalProvisions = MapMerger.merge(provisions) .entrySet() .stream() .filter(entry -> entry.getValue() @@ -96,24 +96,24 @@ public Composite construct(Collection allComponents, Requirements com .map(entry -> entry.getKey()) .collect(Collectors.toSet()); - return new Composite(name, parts, externalRequirements, externalProvisions, internalInterfaces); + return new Composite(this.name, parts, externalRequirements, externalProvisions, internalInterfaces); } // Writes to remainingComopnents, parts, and internalInterfaces. - private static void propagateProvisions(Set remainingComponents, - final Requirements compositeRequirements, final Provisions compositeProvisions, Set parts, - Set internalInterfaces) { + private static void propagateProvisions(final Set remainingComponents, + final Requirements compositeRequirements, final Provisions compositeProvisions, final Set parts, + final Set internalInterfaces) { - List newParts = new LinkedList<>(); - for (Component providingPart : parts) { - List traversedInterfaces = findRequiringComponents(remainingComponents, + final List newParts = new LinkedList<>(); + for (final Component providingPart : parts) { + final List traversedInterfaces = findRequiringComponents(remainingComponents, compositeRequirements, compositeProvisions, newParts, providingPart); - Queue sortedInterfaces = new PriorityQueue<>(traversedInterfaces); + final Queue sortedInterfaces = new PriorityQueue<>(traversedInterfaces); while (!sortedInterfaces.isEmpty()) { - OperationInterface iface = sortedInterfaces.poll(); + final OperationInterface iface = sortedInterfaces.poll(); boolean isRoot = true; - for (OperationInterface rootInterface : internalInterfaces) { + for (final OperationInterface rootInterface : internalInterfaces) { if (iface.isPartOf(rootInterface)) { isRoot = false; break; @@ -133,20 +133,20 @@ private static void propagateProvisions(Set remainingComponents, } // Writes to remainingComopnents, parts, and internalInterfaces. - private static void propagateRequirements(Set remainingComponents, - final Requirements compositeRequirements, final Provisions compositeProvisions, Set parts, - Set internalInterfaces) { + private static void propagateRequirements(final Set remainingComponents, + final Requirements compositeRequirements, final Provisions compositeProvisions, final Set parts, + final Set internalInterfaces) { - List newParts = new LinkedList<>(); - for (Component requiringPart : parts) { - List traversedInterfaces = findProvidingComponents(remainingComponents, + final List newParts = new LinkedList<>(); + for (final Component requiringPart : parts) { + final List traversedInterfaces = findProvidingComponents(remainingComponents, compositeRequirements, compositeProvisions, newParts, requiringPart); - Queue sortedInterfaces = new PriorityQueue<>(traversedInterfaces); + final Queue sortedInterfaces = new PriorityQueue<>(traversedInterfaces); while (!sortedInterfaces.isEmpty()) { - OperationInterface iface = sortedInterfaces.poll(); + final OperationInterface iface = sortedInterfaces.poll(); boolean isRoot = true; - for (OperationInterface rootInterface : internalInterfaces) { + for (final OperationInterface rootInterface : internalInterfaces) { if (iface.isPartOf(rootInterface)) { isRoot = false; break; @@ -166,11 +166,11 @@ private static void propagateRequirements(Set remainingComponents, } // May remove components from remainingComponents. - private static List findRequiringComponents(Set remainingComponents, - final Requirements compositeRequirements, final Provisions compositeProvisions, List newParts, - final Component providingComponent) { + private static List findRequiringComponents(final Set remainingComponents, + final Requirements compositeRequirements, final Provisions compositeProvisions, + final List newParts, final Component providingComponent) { - Stack provisions = new Stack<>(); + final Stack provisions = new Stack<>(); providingComponent.provisions() .get() .stream() @@ -180,10 +180,10 @@ private static List findRequiringComponents(Set r .filter(x -> !compositeProvisions.containsEntire(x)) .forEach(provisions::add); - List traversedOperations = new ArrayList<>(); + final List traversedOperations = new ArrayList<>(); while (!provisions.isEmpty()) { - OperationInterface provision = provisions.pop(); - Set requiringComponents = remainingComponents.stream() + final OperationInterface provision = provisions.pop(); + final Set requiringComponents = remainingComponents.stream() .filter(x -> x.requirements() .containsPartOf(provision)) .filter(x -> !providingComponent.equals(x)) @@ -201,11 +201,11 @@ private static List findRequiringComponents(Set r } // May remove components from remainingComponents. - private static List findProvidingComponents(Set remainingComponents, - final Requirements compositeRequirements, final Provisions compositeProvisions, List newParts, - final Component requiringComponent) { + private static List findProvidingComponents(final Set remainingComponents, + final Requirements compositeRequirements, final Provisions compositeProvisions, + final List newParts, final Component requiringComponent) { - Stack requirements = new Stack<>(); + final Stack requirements = new Stack<>(); requiringComponent.requirements() .get() .stream() @@ -215,10 +215,10 @@ private static List findProvidingComponents(Set r .filter(x -> !compositeProvisions.containsEntire(x)) .forEach(requirements::add); - List traversedOperations = new ArrayList<>(); + final List traversedOperations = new ArrayList<>(); while (!requirements.isEmpty()) { - OperationInterface requirement = requirements.pop(); - Set providingComponents = remainingComponents.stream() + final OperationInterface requirement = requirements.pop(); + final Set providingComponents = remainingComponents.stream() .filter(x -> x.provisions() .containsPartOf(requirement)) .filter(x -> !requiringComponent.equals(x)) @@ -237,21 +237,18 @@ private static List findProvidingComponents(Set r @Override public int hashCode() { - return Objects.hash(explicitParts, name); + return Objects.hash(this.explicitParts, this.name); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - CompositeBuilder other = (CompositeBuilder) obj; - return Objects.equals(explicitParts, other.explicitParts) && Objects.equals(name, other.name); + final CompositeBuilder other = (CompositeBuilder) obj; + return Objects.equals(this.explicitParts, other.explicitParts) && Objects.equals(this.name, other.name); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/DependencyUtils.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/DependencyUtils.java similarity index 71% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/DependencyUtils.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/DependencyUtils.java index f9b44710..6ce2941a 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/DependencyUtils.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/DependencyUtils.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.model; +package org.palladiosimulator.retriever.extraction.commonalities; import java.util.ArrayList; import java.util.Collection; @@ -22,19 +22,19 @@ private DependencyUtils() throws IllegalAccessException { * Group all dependencies in {@code dependencies} by finding their common ancestors. Ensure that * no other dependency (not in {@code dependencies}, but in {@code allDependencies}) is included * into a group by accident. - * + * * @param * only for ease of calling */ public static Map> groupDependencies( - Collection dependencies, Collection allDependencies) { - Map> groupedDependencies = new HashMap<>(); - Queue sortedDependencies = new PriorityQueue<>(dependencies); + final Collection dependencies, final Collection allDependencies) { + final Map> groupedDependencies = new HashMap<>(); + final Queue sortedDependencies = new PriorityQueue<>(dependencies); while (!sortedDependencies.isEmpty()) { - OperationInterface grouplessDependency = sortedDependencies.poll(); + final OperationInterface grouplessDependency = sortedDependencies.poll(); boolean isRoot = true; - for (OperationInterface rootInterface : groupedDependencies.keySet()) { + for (final OperationInterface rootInterface : groupedDependencies.keySet()) { if (grouplessDependency.isPartOf(rootInterface)) { groupedDependencies.get(rootInterface) .add(grouplessDependency); @@ -43,8 +43,8 @@ public static Map commonInterfaceName = grouplessDependency.getName() + for (final OperationInterface rootInterface : groupedDependencies.keySet()) { + final Optional commonInterfaceName = grouplessDependency.getName() .getCommonInterface(rootInterface.getName()); boolean containsOtherDependency = false; @@ -52,10 +52,10 @@ public static Map Map interfaces = new HashSet<>(groupedDependencies.remove(rootInterface)); + final Set interfaces = new HashSet<>( + groupedDependencies.remove(rootInterface)); interfaces.add(commonInterface); interfaces.add(rootInterface); interfaces.add(grouplessDependency); diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/EntireInterface.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/EntireInterface.java similarity index 58% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/EntireInterface.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/EntireInterface.java index 1f8b17f9..d4590246 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/EntireInterface.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/EntireInterface.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.model; +package org.palladiosimulator.retriever.extraction.commonalities; import java.util.List; import java.util.Map; @@ -11,22 +11,23 @@ public class EntireInterface implements OperationInterface { private final Optional binding; private final InterfaceName name; - public EntireInterface(InterfaceName name) { + public EntireInterface(final InterfaceName name) { this.binding = Optional.empty(); this.name = name; } - public EntireInterface(ITypeBinding binding, InterfaceName name) { + public EntireInterface(final ITypeBinding binding, final InterfaceName name) { this.binding = Optional.of(binding); this.name = name; } public Optional getBinding() { - return binding; + return this.binding; } + @Override public Name getName() { - return name; + return this.name; } @Override @@ -36,32 +37,29 @@ public Map> simplified() { @Override public String getInterface() { - return name.getInterfaces() + return this.name.getInterfaces() .get(0); } @Override public int hashCode() { - return Objects.hash(binding, name); + return Objects.hash(this.binding, this.name); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - EntireInterface other = (EntireInterface) obj; - return Objects.equals(binding, other.binding) && Objects.equals(name, other.name); + final EntireInterface other = (EntireInterface) obj; + return Objects.equals(this.binding, other.binding) && Objects.equals(this.name, other.name); } @Override public String toString() { - return name.toString(); + return this.name.toString(); } } diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/HTTPMethod.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/HTTPMethod.java new file mode 100644 index 00000000..ab59ce92 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/HTTPMethod.java @@ -0,0 +1,5 @@ +package org.palladiosimulator.retriever.extraction.commonalities; + +public enum HTTPMethod { + GET, POST, PUT, DELETE, PATCH +} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/InterfaceName.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/InterfaceName.java similarity index 51% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/InterfaceName.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/InterfaceName.java index 2a9df842..f6ec04b2 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/InterfaceName.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/InterfaceName.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.model; +package org.palladiosimulator.retriever.extraction.commonalities; public interface InterfaceName extends Name { String getName(); diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/JavaInterfaceName.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/JavaInterfaceName.java similarity index 51% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/JavaInterfaceName.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/JavaInterfaceName.java index 0bd251fa..5f661674 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/JavaInterfaceName.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/JavaInterfaceName.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.model; +package org.palladiosimulator.retriever.extraction.commonalities; import java.util.List; import java.util.Objects; @@ -6,47 +6,44 @@ public class JavaInterfaceName implements InterfaceName { private final String name; - public JavaInterfaceName(String name) { + public JavaInterfaceName(final String name) { this.name = name; } @Override public String getName() { - return name; + return this.name; } @Override public List getInterfaces() { - return List.of(name); + return List.of(this.name); } @Override - public InterfaceName createInterface(String name) { + public InterfaceName createInterface(final String name) { return new JavaInterfaceName(name); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(this.name); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - JavaInterfaceName other = (JavaInterfaceName) obj; - return Objects.equals(name, other.name); + final JavaInterfaceName other = (JavaInterfaceName) obj; + return Objects.equals(this.name, other.name); } @Override public String toString() { - return name; + return this.name; } } \ No newline at end of file diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/JavaOperationName.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/JavaOperationName.java new file mode 100644 index 00000000..6b0f35be --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/JavaOperationName.java @@ -0,0 +1,60 @@ +package org.palladiosimulator.retriever.extraction.commonalities; + +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +public class JavaOperationName implements OperationName { + private final String iface; + private final String method; + + public JavaOperationName(final String iface, final String method) { + this.iface = iface; + this.method = method; + } + + @Override + public Optional forInterface(final String baseInterface) { + if (!this.iface.equals(baseInterface) && !baseInterface.startsWith(this.iface + "#")) { + return Optional.empty(); + } + return Optional.of(this.method); + } + + @Override + public List getInterfaces() { + return List.of(this.toString(), this.iface); + } + + @Override + public String getInterface() { + return this.iface; + } + + @Override + public InterfaceName createInterface(final String name) { + return new JavaInterfaceName(name); + } + + @Override + public int hashCode() { + return Objects.hash(this.iface, this.method); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if ((obj == null) || (this.getClass() != obj.getClass())) { + return false; + } + final JavaOperationName other = (JavaOperationName) obj; + return Objects.equals(this.iface, other.iface) && Objects.equals(this.method, other.method); + } + + @Override + public String toString() { + return this.iface + "#" + this.method; + } +} \ No newline at end of file diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Name.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Name.java similarity index 58% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Name.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Name.java index 0571c866..b87002e7 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Name.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Name.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.model; +package org.palladiosimulator.retriever.extraction.commonalities; import java.util.HashSet; import java.util.List; @@ -16,9 +16,9 @@ public interface Name { /** * @returns the most specific common interface */ - default Optional getCommonInterface(Name other) { - Set interfaces = new HashSet<>(getInterfaces()); - for (String iface : other.getInterfaces()) { + default Optional getCommonInterface(final Name other) { + final Set interfaces = new HashSet<>(this.getInterfaces()); + for (final String iface : other.getInterfaces()) { if (interfaces.contains(iface)) { return Optional.of(iface); } @@ -26,7 +26,8 @@ default Optional getCommonInterface(Name other) { return Optional.empty(); } - default boolean isPartOf(String iface) { - return getInterfaces().contains(iface); + default boolean isPartOf(final String iface) { + return this.getInterfaces() + .contains(iface); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Operation.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Operation.java similarity index 56% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Operation.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Operation.java index 1af05d09..a966ddf7 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Operation.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Operation.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.model; +package org.palladiosimulator.retriever.extraction.commonalities; import java.util.List; import java.util.Map; @@ -10,17 +10,18 @@ public class Operation implements OperationInterface { private final IMethodBinding binding; private final OperationName name; - public Operation(IMethodBinding binding, OperationName name) { + public Operation(final IMethodBinding binding, final OperationName name) { this.binding = binding; this.name = name; } public IMethodBinding getBinding() { - return binding; + return this.binding; } + @Override public OperationName getName() { - return name; + return this.name; } @Override @@ -30,31 +31,29 @@ public Map> simplified() { @Override public int hashCode() { - return Objects.hash(binding, name); + return Objects.hash(this.binding, this.name); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - Operation other = (Operation) obj; - return Objects.equals(binding, other.binding) && Objects.equals(name, other.name); + final Operation other = (Operation) obj; + return Objects.equals(this.binding, other.binding) && Objects.equals(this.name, other.name); } @Override public String getInterface() { - return name.getInterface(); + return this.name.getInterface(); } @Override public String toString() { - return getName().toString(); + return this.getName() + .toString(); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/OperationInterface.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/OperationInterface.java similarity index 58% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/OperationInterface.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/OperationInterface.java index 9c3133e5..8d9775a4 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/OperationInterface.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/OperationInterface.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.model; +package org.palladiosimulator.retriever.extraction.commonalities; import java.util.List; import java.util.Map; @@ -13,15 +13,16 @@ public interface OperationInterface extends Comparable { */ String getInterface(); - default boolean isPartOf(OperationInterface other) { - return getName().isPartOf(other.getName() - .toString()); + default boolean isPartOf(final OperationInterface other) { + return this.getName() + .isPartOf(other.getName() + .toString()); } @Override - default int compareTo(OperationInterface other) { - boolean isSubset = this.isPartOf(other); - boolean isSuperset = other.isPartOf(this); + default int compareTo(final OperationInterface other) { + final boolean isSubset = this.isPartOf(other); + final boolean isSuperset = other.isPartOf(this); if (isSubset && isSuperset) { return 0; // equal } else if (isSubset) { @@ -30,7 +31,8 @@ default int compareTo(OperationInterface other) { return -1; } - return getName().toString() + return this.getName() + .toString() .compareTo(other.getName() .toString()); // disjoint } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/OperationName.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/OperationName.java similarity index 76% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/OperationName.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/OperationName.java index 6a458429..a437f275 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/OperationName.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/OperationName.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.model; +package org.palladiosimulator.retriever.extraction.commonalities; import java.util.Optional; diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/PCMDetectionResult.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/PCMDetectionResult.java similarity index 60% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/PCMDetectionResult.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/PCMDetectionResult.java index 79b03069..4f62ef68 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/PCMDetectionResult.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/PCMDetectionResult.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.model; +package org.palladiosimulator.retriever.extraction.commonalities; import java.util.HashSet; import java.util.LinkedList; @@ -7,31 +7,31 @@ import java.util.Set; import java.util.stream.Collectors; -import org.palladiosimulator.somox.analyzer.rules.engine.MapMerger; +import org.palladiosimulator.retriever.extraction.engine.MapMerger; public class PCMDetectionResult { private final Set components; private final Set composites; private final Map> operationInterfaces; - public PCMDetectionResult(Map components, - Map composites, ProvisionsBuilder compositeProvisions, - RequirementsBuilder compositeRequirements) { + public PCMDetectionResult(final Map components, + final Map composites, final ProvisionsBuilder compositeProvisions, + final RequirementsBuilder compositeRequirements) { // Collect globally visible provisions - Set temporaryComponents = PCMDetectionResult.createComponents(components, compositeProvisions, + final Set temporaryComponents = PCMDetectionResult.createComponents(components, compositeProvisions, compositeRequirements, Set.of()); - Set connectedComponents = PCMDetectionResult.collectConnectedComponents(temporaryComponents, + final Set connectedComponents = PCMDetectionResult.collectConnectedComponents(temporaryComponents, composites, compositeProvisions, compositeRequirements); - Set temporaryComposites = PCMDetectionResult.createCompositeComponents(connectedComponents, + final Set temporaryComposites = PCMDetectionResult.createCompositeComponents(connectedComponents, composites, compositeProvisions, compositeRequirements, Set.of()); - Set visibleProvisions = PCMDetectionResult.collectVisibleProvisions(connectedComponents, - temporaryComposites); + final Set visibleProvisions = PCMDetectionResult + .collectVisibleProvisions(connectedComponents, temporaryComposites); // TODO: Do not rebuild everything, that is theoretically not necessary since provisions do // not change. - Map connectedComponentBuilders = connectedComponents.stream() + final Map connectedComponentBuilders = connectedComponents.stream() .map(Component::identifier) .map(components::get) .collect(Collectors.toMap(ComponentBuilder::identifier, x -> x)); @@ -41,28 +41,28 @@ public PCMDetectionResult(Map components, compositeRequirements, visibleProvisions); this.composites = PCMDetectionResult.createCompositeComponents(this.components, composites, compositeProvisions, compositeRequirements, visibleProvisions); - this.operationInterfaces = createOperationInterfaces(); + this.operationInterfaces = this.createOperationInterfaces(); } - private static Set collectConnectedComponents(Set temporaryComponents, - Map composites, ProvisionsBuilder compositeProvisions, - RequirementsBuilder compositeRequirements) { - CompositeBuilder metaCompositeBuilder = new CompositeBuilder("Meta Composite"); - for (CompositeBuilder composite : composites.values()) { - for (ComponentBuilder part : composite.getParts()) { + private static Set collectConnectedComponents(final Set temporaryComponents, + final Map composites, final ProvisionsBuilder compositeProvisions, + final RequirementsBuilder compositeRequirements) { + final CompositeBuilder metaCompositeBuilder = new CompositeBuilder("Meta Composite"); + for (final CompositeBuilder composite : composites.values()) { + for (final ComponentBuilder part : composite.getParts()) { metaCompositeBuilder.addPart(part); } } - Composite metaComposite = metaCompositeBuilder.construct(temporaryComponents, + final Composite metaComposite = metaCompositeBuilder.construct(temporaryComponents, new RequirementsBuilder().create(Set.of(), Set.of()), new ProvisionsBuilder().create(Set.of()), Set.of()); return metaComposite.parts(); } - private static Set createComponents(Map components, - ProvisionsBuilder compositeProvisions, RequirementsBuilder compositeRequirements, - Set visibleProvisions) { - List allDependencies = new LinkedList<>(); + private static Set createComponents(final Map components, + final ProvisionsBuilder compositeProvisions, final RequirementsBuilder compositeRequirements, + final Set visibleProvisions) { + final List allDependencies = new LinkedList<>(); // TODO: Aren't the dependencies of free components missing here? Is that alright? allDependencies.addAll(compositeRequirements.toList()); allDependencies.addAll(compositeProvisions.toList()); @@ -73,23 +73,23 @@ private static Set createComponents(Map createCompositeComponents(Set freeComponents, - Map composites, ProvisionsBuilder compositeProvisions, - RequirementsBuilder compositeRequirements, Set visibleProvisions) { + private static Set createCompositeComponents(final Set freeComponents, + final Map composites, final ProvisionsBuilder compositeProvisions, + final RequirementsBuilder compositeRequirements, final Set visibleProvisions) { // Construct composites. Set constructedComposites = new HashSet<>(); - List allComposites = composites.values() + final List allComposites = composites.values() .stream() .map(x -> x.construct(freeComponents, compositeRequirements.create(visibleProvisions, visibleProvisions), compositeProvisions.create(visibleProvisions), visibleProvisions)) .collect(Collectors.toList()); // Remove redundant composites. - Set redundantComposites = new HashSet<>(); + final Set redundantComposites = new HashSet<>(); for (int i = 0; i < allComposites.size(); ++i) { - Composite subject = allComposites.get(i); - long subsetCount = allComposites.subList(i + 1, allComposites.size()) + final Composite subject = allComposites.get(i); + final long subsetCount = allComposites.subList(i + 1, allComposites.size()) .stream() .filter(x -> subject.isSubsetOf(x) || x.isSubsetOf(subject)) .count(); @@ -112,21 +112,21 @@ private static Set createCompositeComponents(Set freeCompo return constructedComposites; } - private static Set collectVisibleProvisions(Set components, - Set composites) { + private static Set collectVisibleProvisions(final Set components, + final Set composites) { // Collect globally visible provisions - Set provisions = new HashSet<>(); + final Set provisions = new HashSet<>(); // 1. Collect composite provisions composites.stream() .flatMap(x -> x.provisions() .stream()) .forEach(provisions::add); // 2. Collect bare components - Set containedComponents = composites.stream() + final Set containedComponents = composites.stream() .flatMap(x -> x.parts() .stream()) .collect(Collectors.toSet()); - Set bareComponents = components.stream() + final Set bareComponents = components.stream() .filter(x -> !containedComponents.contains(x)) .collect(Collectors.toSet()); // 3. Collect bare component provisions @@ -142,19 +142,23 @@ private static Set collectVisibleProvisions(Set c private Map> createOperationInterfaces() { // TODO: This has to include composite interfaces as well - List>> constructedOperationInterfaces = getComponents().stream() + final List>> constructedOperationInterfaces = this.getComponents() + .stream() .map(x -> x.provisions() .simplified()) .collect(Collectors.toList()); - getComponents().stream() + this.getComponents() + .stream() .map(x -> x.requirements() .simplified()) .forEach(x -> constructedOperationInterfaces.add(x)); - getCompositeComponents().stream() + this.getCompositeComponents() + .stream() .flatMap(x -> x.provisions() .stream()) .forEach(x -> constructedOperationInterfaces.add(x.simplified())); - getCompositeComponents().stream() + this.getCompositeComponents() + .stream() .flatMap(x -> x.requirements() .stream()) .forEach(x -> constructedOperationInterfaces.add(x.simplified())); @@ -162,14 +166,14 @@ private Map> createOperationInterfaces() { } public Set getComponents() { - return components; + return this.components; } public Set getCompositeComponents() { - return composites; + return this.composites; } public Map> getOperationInterfaces() { - return operationInterfaces; + return this.operationInterfaces; } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Provisions.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Provisions.java similarity index 61% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Provisions.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Provisions.java index 07fe5979..68f2c430 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Provisions.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Provisions.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.model; +package org.palladiosimulator.retriever.extraction.commonalities; import java.util.ArrayList; import java.util.Collection; @@ -12,49 +12,50 @@ import java.util.Set; import java.util.stream.Collectors; -import org.palladiosimulator.somox.analyzer.rules.engine.MapMerger; +import org.palladiosimulator.retriever.extraction.engine.MapMerger; public class Provisions implements Iterable { private final Set provisions; private final Map> groupedProvisions; - public Provisions(Collection provisions, Collection allDependencies) { + public Provisions(final Collection provisions, + final Collection allDependencies) { this.provisions = Collections.unmodifiableSet(new HashSet<>(provisions)); this.groupedProvisions = DependencyUtils.groupDependencies(provisions, allDependencies); } public Set get() { - return provisions; + return this.provisions; } public Map> getGrouped() { - return groupedProvisions; + return this.groupedProvisions; } - public boolean containsPartOf(OperationInterface iface) { - return provisions.stream() + public boolean containsPartOf(final OperationInterface iface) { + return this.provisions.stream() .anyMatch(x -> x.isPartOf(iface)); } - public boolean containsEntire(OperationInterface iface) { - return provisions.stream() + public boolean containsEntire(final OperationInterface iface) { + return this.provisions.stream() .anyMatch(x -> iface.isPartOf(x)); } @Override public Iterator iterator() { - return provisions.iterator(); + return this.provisions.iterator(); } public Map> simplified() { - List>> simplifiedInterfaces = new LinkedList<>(); - for (OperationInterface root : groupedProvisions.keySet()) { - List simplifiedRoot = new ArrayList<>(root.simplified() + final List>> simplifiedInterfaces = new LinkedList<>(); + for (final OperationInterface root : this.groupedProvisions.keySet()) { + final List simplifiedRoot = new ArrayList<>(root.simplified() .values() .stream() .flatMap(x -> x.stream()) .collect(Collectors.toList())); - for (OperationInterface member : groupedProvisions.get(root)) { + for (final OperationInterface member : this.groupedProvisions.get(root)) { simplifiedRoot.addAll(member.simplified() .values() .stream() @@ -70,30 +71,27 @@ public Map> simplified() { @Override public int hashCode() { - return Objects.hash(provisions); + return Objects.hash(this.provisions); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - Provisions other = (Provisions) obj; - return Objects.equals(provisions, other.provisions); + final Provisions other = (Provisions) obj; + return Objects.equals(this.provisions, other.provisions); } @Override public String toString() { - StringBuilder builder = new StringBuilder(); - Map> simplified = simplified(); + final StringBuilder builder = new StringBuilder(); + final Map> simplified = this.simplified(); - for (OperationInterface iface : simplified.keySet()) { + for (final OperationInterface iface : simplified.keySet()) { builder.append(iface.getName()); simplified.get(iface) .forEach(x -> builder.append("\n\t") diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ProvisionsBuilder.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ProvisionsBuilder.java new file mode 100644 index 00000000..442e194c --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/ProvisionsBuilder.java @@ -0,0 +1,44 @@ +package org.palladiosimulator.retriever.extraction.commonalities; + +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; + +public class ProvisionsBuilder { + private final List provisions = new LinkedList<>(); + + public void add(final OperationInterface... provisions) { + this.add(List.of(provisions)); + } + + public void add(final Collection provisions) { + this.provisions.addAll(provisions); + } + + public Provisions create(final Collection allDependencies) { + return new Provisions(this.provisions, allDependencies); + } + + public List toList() { + return Collections.unmodifiableList(this.provisions); + } + + @Override + public int hashCode() { + return Objects.hash(this.provisions); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if ((obj == null) || (this.getClass() != obj.getClass())) { + return false; + } + final ProvisionsBuilder other = (ProvisionsBuilder) obj; + return Objects.equals(this.provisions, other.provisions); + } +} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/RESTName.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/RESTName.java similarity index 51% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/RESTName.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/RESTName.java index 3fd1ac0b..e89e7ff1 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/RESTName.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/RESTName.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.model; +package org.palladiosimulator.retriever.extraction.commonalities; import java.util.ArrayList; import java.util.List; @@ -12,10 +12,11 @@ public class RESTName implements InterfaceName, OperationName { private final List path; private final Optional httpMethod; - public RESTName(String host, String path, Optional httpMethod) throws IllegalArgumentException { + public RESTName(final String host, final String path, final Optional httpMethod) + throws IllegalArgumentException { this.host = host; this.httpMethod = httpMethod; - Optional> parsedPath = parsePath(host + path); + final Optional> parsedPath = this.parsePath(host + path); if (parsedPath.isEmpty()) { throw new IllegalArgumentException("Could not parse path due to illegal format: \"" + path + "\""); } @@ -27,60 +28,60 @@ public RESTName(String host, String path, Optional httpMethod) throw @Override public String getName() { - return getInterface(); + return this.getInterface(); } @Override public String getInterface() { - return toString(); + return this.toString(); } @Override - public Optional forInterface(String baseInterface) { - if (!isPartOf(baseInterface)) { + public Optional forInterface(final String baseInterface) { + if (!this.isPartOf(baseInterface)) { return Optional.empty(); } - return Optional.of(getInterface()); + return Optional.of(this.getInterface()); } @Override public List getInterfaces() { - Stack> prefixes = new Stack<>(); + final Stack> prefixes = new Stack<>(); - if (path.size() > 0) { - prefixes.push(List.of(path.get(0))); - for (int i = 1; i < path.size(); i++) { - List prefix = new ArrayList<>(prefixes.peek()); - prefix.add(path.get(i)); + if (this.path.size() > 0) { + prefixes.push(List.of(this.path.get(0))); + for (int i = 1; i < this.path.size(); i++) { + final List prefix = new ArrayList<>(prefixes.peek()); + prefix.add(this.path.get(i)); prefixes.push(prefix); } } - List interfaces = new ArrayList<>(prefixes.size()); + final List interfaces = new ArrayList<>(prefixes.size()); - if (httpMethod.isPresent()) { - interfaces.add(getInterface()); + if (this.httpMethod.isPresent()) { + interfaces.add(this.getInterface()); } // Insert the prefixes in reverse since the most specific element is at index 0 there. while (!prefixes.empty()) { - interfaces.add(toName(prefixes.pop())); + interfaces.add(this.toName(prefixes.pop())); } // Always add root interface - interfaces.add(toName(List.of())); + interfaces.add(this.toName(List.of())); return interfaces; } @Override - public InterfaceName createInterface(String name) { - return new RESTName(host, name, Optional.empty()); + public InterfaceName createInterface(final String name) { + return new RESTName(this.host, name, Optional.empty()); } - private String toName(List path) { - StringBuilder name = new StringBuilder(); + private String toName(final List path) { + final StringBuilder name = new StringBuilder(); name.append("/"); for (int i = 0; i < path.size(); i++) { name.append(path.get(i)); @@ -88,22 +89,22 @@ private String toName(List path) { name.append("/"); } } - return host + name.toString(); + return this.host + name.toString(); } @Override public String toString() { - String pathString = toName(path); + final String pathString = this.toName(this.path); String methodString = ""; - if (httpMethod.isPresent()) { - methodString = "[" + httpMethod.get() + if (this.httpMethod.isPresent()) { + methodString = "[" + this.httpMethod.get() .toString() + "]"; } return pathString + methodString; } - private Optional> parsePath(String string) { - String[] segments = string.split("/"); + private Optional> parsePath(final String string) { + final String[] segments = string.split("/"); // Require at least a "/" after the host name if (segments.length == 1 && !string.endsWith("/")) { @@ -119,45 +120,38 @@ private Optional> parsePath(String string) { @Override public int hashCode() { - return Objects.hash(host, path, httpMethod); + return Objects.hash(this.host, this.path, this.httpMethod); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - RESTName other = (RESTName) obj; - return Objects.equals(host, other.host) && Objects.equals(path, other.path) - && Objects.equals(httpMethod, other.httpMethod); + final RESTName other = (RESTName) obj; + return Objects.equals(this.host, other.host) && Objects.equals(this.path, other.path) + && Objects.equals(this.httpMethod, other.httpMethod); } @Override - public boolean isPartOf(String iface) { - String[] parts = iface.split("\\["); - Optional> interfacePathOption = parsePath(parts[0]); + public boolean isPartOf(final String iface) { + final String[] parts = iface.split("\\["); + final Optional> interfacePathOption = this.parsePath(parts[0]); if (interfacePathOption.isEmpty()) { return false; } - List interfacePath = interfacePathOption.get(); - String otherHost = interfacePath.remove(0); - - if (!otherHost.equals(host)) { - return false; - } + final List interfacePath = interfacePathOption.get(); + final String otherHost = interfacePath.remove(0); - if (interfacePath.size() > path.size()) { + if (!otherHost.equals(this.host) || (interfacePath.size() > this.path.size())) { return false; } for (int i = 0; i < interfacePath.size(); i++) { - if (!path.get(i) + if (!this.path.get(i) .equals(interfacePath.get(i))) { return false; } @@ -166,14 +160,14 @@ public boolean isPartOf(String iface) { Optional ifaceHttpMethod = Optional.empty(); if (parts.length > 1) { // Assume that a '[' implies a ']'. - int end = parts[1].lastIndexOf(']'); - String httpMethodName = parts[1].substring(0, end); + final int end = parts[1].lastIndexOf(']'); + final String httpMethodName = parts[1].substring(0, end); ifaceHttpMethod = Optional.of(HTTPMethod.valueOf(httpMethodName)); } // TODO: If this.httpMethod.isEmpty(), see it as part of the other interface anyway. // This allows some imprecision from ECMAScript detection - if (interfacePath.size() == path.size() && ifaceHttpMethod.isPresent() && this.httpMethod.isPresent() + if (interfacePath.size() == this.path.size() && ifaceHttpMethod.isPresent() && this.httpMethod.isPresent() && !ifaceHttpMethod.equals(this.httpMethod)) { return false; } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Requirements.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Requirements.java similarity index 56% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Requirements.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Requirements.java index 770586fe..1b1621d4 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/Requirements.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/Requirements.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.model; +package org.palladiosimulator.retriever.extraction.commonalities; import java.util.ArrayList; import java.util.Collection; @@ -12,62 +12,63 @@ import java.util.Set; import java.util.stream.Collectors; -import org.palladiosimulator.somox.analyzer.rules.engine.MapMerger; +import org.palladiosimulator.retriever.extraction.engine.MapMerger; public class Requirements implements Iterable { private final Set requirements; private final Map> groupedRequirements; - public Requirements(Collection requiredInterfaces, - Collection allDependencies, Collection visibleProvisions) { + public Requirements(final Collection requiredInterfaces, + final Collection allDependencies, + final Collection visibleProvisions) { this.requirements = new HashSet<>(); - List sortedProvisions = new ArrayList<>(visibleProvisions); + final List sortedProvisions = new ArrayList<>(visibleProvisions); Collections.sort(sortedProvisions); Collections.reverse(sortedProvisions); - for (OperationInterface requirement : requiredInterfaces) { + for (final OperationInterface requirement : requiredInterfaces) { OperationInterface generalizedRequirement = requirement; - for (OperationInterface provision : sortedProvisions) { + for (final OperationInterface provision : sortedProvisions) { if (requirement.isPartOf(provision)) { generalizedRequirement = provision; break; } } - requirements.add(generalizedRequirement); + this.requirements.add(generalizedRequirement); } - this.groupedRequirements = DependencyUtils.groupDependencies(requirements, allDependencies); + this.groupedRequirements = DependencyUtils.groupDependencies(this.requirements, allDependencies); } public Set get() { - return Collections.unmodifiableSet(requirements); + return Collections.unmodifiableSet(this.requirements); } - public boolean containsPartOf(OperationInterface iface) { - return requirements.stream() + public boolean containsPartOf(final OperationInterface iface) { + return this.requirements.stream() .anyMatch(x -> x.isPartOf(iface)); } - public boolean containsEntire(OperationInterface iface) { - return requirements.stream() + public boolean containsEntire(final OperationInterface iface) { + return this.requirements.stream() .anyMatch(x -> iface.isPartOf(x)); } @Override public Iterator iterator() { - return Collections.unmodifiableCollection(requirements) + return Collections.unmodifiableCollection(this.requirements) .iterator(); } public Map> simplified() { - List>> simplifiedInterfaces = new LinkedList<>(); - for (OperationInterface root : groupedRequirements.keySet()) { - List simplifiedRoot = new ArrayList<>(root.simplified() + final List>> simplifiedInterfaces = new LinkedList<>(); + for (final OperationInterface root : this.groupedRequirements.keySet()) { + final List simplifiedRoot = new ArrayList<>(root.simplified() .values() .stream() .flatMap(x -> x.stream()) .collect(Collectors.toList())); - for (OperationInterface member : groupedRequirements.get(root)) { + for (final OperationInterface member : this.groupedRequirements.get(root)) { simplifiedRoot.addAll(member.simplified() .values() .stream() @@ -83,30 +84,27 @@ public Map> simplified() { @Override public int hashCode() { - return Objects.hash(requirements); + return Objects.hash(this.requirements); } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } - if (obj == null) { + if ((obj == null) || (this.getClass() != obj.getClass())) { return false; } - if (getClass() != obj.getClass()) { - return false; - } - Requirements other = (Requirements) obj; - return Objects.equals(requirements, other.requirements); + final Requirements other = (Requirements) obj; + return Objects.equals(this.requirements, other.requirements); } @Override public String toString() { - StringBuilder builder = new StringBuilder(); - Map> simplified = simplified(); + final StringBuilder builder = new StringBuilder(); + final Map> simplified = this.simplified(); - for (OperationInterface iface : simplified.keySet()) { + for (final OperationInterface iface : simplified.keySet()) { builder.append(iface.getName()); simplified.get(iface) .forEach(x -> builder.append("\n\t") diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/RequirementsBuilder.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/RequirementsBuilder.java new file mode 100644 index 00000000..f33f35f6 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/commonalities/RequirementsBuilder.java @@ -0,0 +1,60 @@ +package org.palladiosimulator.retriever.extraction.commonalities; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; +import java.util.Set; + +public class RequirementsBuilder { + private final List requirements = new LinkedList<>(); + private final Set weakRequirements = new HashSet<>(); + + public void add(final OperationInterface... interfaces) { + this.add(List.of(interfaces)); + } + + public void add(final Collection interfaces) { + this.requirements.addAll(interfaces); + } + + public void addWeakly(final OperationInterface iface) { + this.weakRequirements.add(iface); + } + + public void strengthenIfPresent(final OperationInterface iface) { + if (this.weakRequirements.contains(iface)) { + this.weakRequirements.remove(iface); + this.requirements.add(iface); + } + } + + public Requirements create(final Collection allDependencies, + final Collection visibleProvisions) { + return new Requirements(this.requirements, allDependencies, visibleProvisions); + } + + public List toList() { + return Collections.unmodifiableList(this.requirements); + } + + @Override + public int hashCode() { + return Objects.hash(this.requirements, this.weakRequirements); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if ((obj == null) || (this.getClass() != obj.getClass())) { + return false; + } + final RequirementsBuilder other = (RequirementsBuilder) obj; + return Objects.equals(this.requirements, other.requirements) + && Objects.equals(this.weakRequirements, other.weakRequirements); + } +} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/Discoverer.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/Discoverer.java similarity index 92% rename from bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/Discoverer.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/Discoverer.java index c671d205..449095cc 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/discoverer/Discoverer.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/Discoverer.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.discoverer; +package org.palladiosimulator.retriever.extraction.engine; import java.io.IOException; import java.nio.file.Files; @@ -9,7 +9,6 @@ import java.util.stream.Stream; import org.apache.log4j.Logger; -import org.palladiosimulator.somox.analyzer.rules.engine.Service; public interface Discoverer extends Service { static Stream find(final Path root, final String suffix, final Logger logger) { diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/DockerParser.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/DockerParser.java similarity index 86% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/DockerParser.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/DockerParser.java index 5922c7a8..cb03e20f 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/DockerParser.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/DockerParser.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.engine; +package org.palladiosimulator.retriever.extraction.engine; import java.io.File; import java.io.FileInputStream; @@ -19,7 +19,7 @@ import org.apache.log4j.Logger; import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.palladiosimulator.somox.analyzer.rules.model.CompUnitOrName; +import org.palladiosimulator.retriever.extraction.commonalities.CompUnitOrName; /** * The DockerParser parses a docker-compose file to extract a mapping between service names @@ -35,15 +35,15 @@ public class DockerParser { private static final Logger LOG = Logger.getLogger(DockerParser.class); - public DockerParser(Path path, PCMDetector pcmDetector) { + public DockerParser(final Path path, final PCMDetector pcmDetector) { LOG.info("starting docker process"); this.path = path; this.pcmDetector = pcmDetector; - final InputStream input = getDockerFile(); + final InputStream input = this.getDockerFile(); final List services = extractServiceNames(input); - mapping = createServiceComponentMapping(services); + this.mapping = this.createServiceComponentMapping(services); } /** @@ -55,7 +55,7 @@ public DockerParser(Path path, PCMDetector pcmDetector) { private InputStream getDockerFile() { List paths = new ArrayList<>(); - try (Stream files = Files.walk(path)) { + try (Stream files = Files.walk(this.path)) { paths = files.filter(f -> f.getFileName() .toString() .contains(FILE_NAME)) @@ -86,7 +86,7 @@ private InputStream getDockerFile() { * @return the list of all service names found in the docker-compose file */ @SuppressWarnings("unchecked") - private static List extractServiceNames(InputStream stream) { + private static List extractServiceNames(final InputStream stream) { // final Yaml yaml = new Yaml(); final Map object = new HashMap<>(); // (Map) // yaml.load(stream); @@ -107,9 +107,9 @@ private static List extractServiceNames(InputStream stream) { * a list of all service names from a docker-compose file * @return the mapping between service names and Java model instances */ - private Map> createServiceComponentMapping(List serviceNames) { + private Map> createServiceComponentMapping(final List serviceNames) { - final Set components = pcmDetector.getCompilationUnits(); + final Set components = this.pcmDetector.getCompilationUnits(); final Map> serviceToCompMapping = new HashMap<>(); @@ -117,9 +117,9 @@ private Map> createServiceComponentMapping(List files = Files.walk(path)) { + try (Stream files = Files.walk(this.path)) { // TODO try to find a more robust heuristic final List foundPaths = files.filter(f -> f.toString() .contains(((AbstractTypeDeclaration) comp.types() @@ -149,7 +149,7 @@ private Map> createServiceComponentMapping(List> getMapping() { - return mapping; + return this.mapping; } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/MapMerger.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/MapMerger.java similarity index 60% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/MapMerger.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/MapMerger.java index 1db2613f..bc4126e8 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/MapMerger.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/MapMerger.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.engine; +package org.palladiosimulator.retriever.extraction.engine; import java.util.Collection; import java.util.HashMap; @@ -13,11 +13,11 @@ private MapMerger() { throw new IllegalStateException(); } - public static Map> merge(Collection>> maps) { - Map> mergedMap = new HashMap<>(); + public static Map> merge(final Collection>> maps) { + final Map> mergedMap = new HashMap<>(); - for (Map> map : maps) { - for (Map.Entry> entry : map.entrySet()) { + for (final Map> map : maps) { + for (final Map.Entry> entry : map.entrySet()) { mergedMap.merge(entry.getKey(), entry.getValue(), (a, b) -> Stream.concat(a.stream(), b.stream()) .collect(Collectors.toList())); } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/NameConverter.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/NameConverter.java similarity index 70% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/NameConverter.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/NameConverter.java index e20707ca..d696533b 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/NameConverter.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/NameConverter.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.engine; +package org.palladiosimulator.retriever.extraction.engine; import org.eclipse.jdt.core.dom.ITypeBinding; @@ -7,8 +7,8 @@ private NameConverter() { throw new IllegalStateException(); } - public static String toPCMIdentifier(ITypeBinding name) { - String fullName = name.getQualifiedName() + public static String toPCMIdentifier(final ITypeBinding name) { + final String fullName = name.getQualifiedName() .replace(".", "_"); // Erase type parameters in identifiers // TODO is this the right solution? diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/PCMDetector.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/PCMDetector.java new file mode 100644 index 00000000..dd972466 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/PCMDetector.java @@ -0,0 +1,314 @@ +package org.palladiosimulator.retriever.extraction.engine; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import org.apache.log4j.Logger; +import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; +import org.eclipse.jdt.core.dom.FieldDeclaration; +import org.eclipse.jdt.core.dom.IMethodBinding; +import org.eclipse.jdt.core.dom.ITypeBinding; +import org.eclipse.jdt.core.dom.IVariableBinding; +import org.eclipse.jdt.core.dom.SingleVariableDeclaration; +import org.eclipse.jdt.core.dom.TypeDeclaration; +import org.eclipse.jdt.core.dom.VariableDeclaration; +import org.palladiosimulator.retriever.extraction.commonalities.CompUnitOrName; +import org.palladiosimulator.retriever.extraction.commonalities.ComponentBuilder; +import org.palladiosimulator.retriever.extraction.commonalities.CompositeBuilder; +import org.palladiosimulator.retriever.extraction.commonalities.EntireInterface; +import org.palladiosimulator.retriever.extraction.commonalities.InterfaceName; +import org.palladiosimulator.retriever.extraction.commonalities.JavaInterfaceName; +import org.palladiosimulator.retriever.extraction.commonalities.JavaOperationName; +import org.palladiosimulator.retriever.extraction.commonalities.Operation; +import org.palladiosimulator.retriever.extraction.commonalities.OperationInterface; +import org.palladiosimulator.retriever.extraction.commonalities.OperationName; +import org.palladiosimulator.retriever.extraction.commonalities.PCMDetectionResult; +import org.palladiosimulator.retriever.extraction.commonalities.ProvisionsBuilder; +import org.palladiosimulator.retriever.extraction.commonalities.RequirementsBuilder; + +/** + * This class is used to detect and hold all relevant elements found during the processing of rules. + * It provides methods to detect and retrieve PCM elements. After all rules are parsed, this class + * holds the results as "simple" java objects not yet transformed to real PCM objects like PCM Basic + * Components. + */ +public class PCMDetector { + private static final Logger LOG = Logger.getLogger(PCMDetector.class); + + private final Map components = new HashMap<>(); + private final Map composites = new HashMap<>(); + private final ProvisionsBuilder compositeProvisions = new ProvisionsBuilder(); + private final RequirementsBuilder compositeRequirements = new RequirementsBuilder(); + private final Set providedInterfaces = new HashSet<>(); + + private static String getFullUnitName(final CompUnitOrName unit) { + // TODO this is potentially problematic, maybe restructure + // On the other hand, it is still fit as a unique identifier, + // since types cannot be declared multiple times. + + final List names = getFullUnitNames(unit); + if (!names.isEmpty()) { + return names.get(0); + } + return null; + } + + private static List getFullUnitNames(final CompUnitOrName unit) { + if (!unit.isUnit()) { + return List.of(unit.name()); + } + + final List names = new ArrayList<>(); + for (final Object type : unit.compilationUnit() + .get() + .types()) { + if (type instanceof AbstractTypeDeclaration) { + names.add(getFullTypeName((AbstractTypeDeclaration) type)); + } + } + + return names; + } + + private static String getFullTypeName(final AbstractTypeDeclaration type) { + return type.getName() + .getFullyQualifiedName(); + } + + public void detectComponent(final CompUnitOrName unit) { + if (!unit.isUnit()) { + this.components.put(unit, new ComponentBuilder(unit)); + return; + } + for (final Object type : unit.compilationUnit() + .get() + .types()) { + if (type instanceof TypeDeclaration) { + this.components.put(unit, new ComponentBuilder(unit)); + final ITypeBinding binding = ((TypeDeclaration) type).resolveBinding(); + this.detectProvidedInterface(unit, binding); + } + } + } + + public void detectRequiredInterface(final CompUnitOrName unit, final InterfaceName interfaceName) { + this.detectRequiredInterface(unit, interfaceName, false); + } + + public void detectRequiredInterface(final CompUnitOrName unit, final InterfaceName interfaceName, + final boolean compositeRequired) { + if (this.components.get(unit) == null) { + this.components.put(unit, new ComponentBuilder(unit)); + } + final EntireInterface iface = new EntireInterface(interfaceName); + this.detectRequiredInterface(unit, compositeRequired, false, iface); + } + + public void detectRequiredInterface(final CompUnitOrName unit, final FieldDeclaration field) { + this.detectRequiredInterface(unit, field, false, false); + } + + public void detectRequiredInterfaceWeakly(final CompUnitOrName unit, final FieldDeclaration field) { + this.detectRequiredInterface(unit, field, false, true); + } + + private void detectRequiredInterface(final CompUnitOrName unit, final FieldDeclaration field, + final boolean compositeRequired, final boolean detectWeakly) { + if (this.components.get(unit) == null) { + this.components.put(unit, new ComponentBuilder(unit)); + } + @SuppressWarnings("unchecked") + final List ifaces = ((List) field.fragments()).stream() + .map(x -> x.resolveBinding()) + .filter(x -> x != null) + .map(x -> x.getType()) + .map(x -> new EntireInterface(x, new JavaInterfaceName(NameConverter.toPCMIdentifier(x)))) + .collect(Collectors.toList()); + this.detectRequiredInterface(unit, compositeRequired, detectWeakly, ifaces); + } + + public void detectRequiredInterface(final CompUnitOrName unit, final SingleVariableDeclaration parameter) { + this.detectRequiredInterface(unit, parameter, false); + } + + private void detectRequiredInterface(final CompUnitOrName unit, final SingleVariableDeclaration parameter, + final boolean compositeRequired) { + if (this.components.get(unit) == null) { + this.components.put(unit, new ComponentBuilder(unit)); + } + final IVariableBinding parameterBinding = parameter.resolveBinding(); + if (parameterBinding == null) { + LOG.warn("Unresolved parameter binding " + parameter.getName() + " detected in " + getFullUnitName(unit) + + "!"); + return; + } + final ITypeBinding type = parameterBinding.getType(); + final EntireInterface iface = new EntireInterface(type, + new JavaInterfaceName(NameConverter.toPCMIdentifier(type))); + this.detectRequiredInterface(unit, compositeRequired, false, iface); + } + + private void detectRequiredInterface(final CompUnitOrName unit, final boolean compositeRequired, + final boolean detectWeakly, final OperationInterface iface) { + this.detectRequiredInterface(unit, compositeRequired, detectWeakly, List.of(iface)); + } + + private void detectRequiredInterface(final CompUnitOrName unit, final boolean compositeRequired, + final boolean detectWeakly, final Collection ifaces) { + for (final OperationInterface iface : ifaces) { + if (detectWeakly && !this.providedInterfaces.contains(iface)) { + this.components.get(unit) + .requirements() + .addWeakly(iface); + if (compositeRequired) { + this.compositeRequirements.addWeakly(iface); + } + } else { + this.components.get(unit) + .requirements() + .add(iface); + if (compositeRequired) { + this.compositeRequirements.add(iface); + } + } + } + } + + public void detectProvidedInterface(final CompUnitOrName unit, final ITypeBinding iface) { + if (iface == null) { + LOG.warn("Unresolved type binding detected in " + getFullUnitName(unit) + "!"); + return; + } + final OperationInterface provision = new EntireInterface(iface, + new JavaInterfaceName(NameConverter.toPCMIdentifier(iface))); + this.detectProvidedInterface(unit, provision); + } + + public void detectProvidedOperation(final CompUnitOrName unit, final IMethodBinding method) { + if (method == null) { + LOG.warn("Unresolved method binding detected in " + getFullUnitName(unit) + "!"); + return; + } + this.detectProvidedOperation(unit, method.getDeclaringClass(), method); + } + + public void detectProvidedOperation(final CompUnitOrName unit, final ITypeBinding declaringIface, + final IMethodBinding method) { + if (declaringIface == null) { + LOG.warn("Unresolved type binding detected in " + getFullUnitName(unit) + "!"); + return; + } + this.detectProvidedOperation(unit, NameConverter.toPCMIdentifier(declaringIface), method); + } + + public void detectProvidedOperation(final CompUnitOrName unit, final String declaringIface, + final IMethodBinding method) { + String operationName; + if (method == null) { + LOG.warn("Unresolved method binding detected in " + getFullUnitName(unit) + "!"); + operationName = "[unresolved]"; + } else { + operationName = method.getName(); + } + + this.detectProvidedOperation(unit, method, new JavaOperationName(declaringIface, operationName)); + } + + public void detectProvidedOperation(final CompUnitOrName unit, final IMethodBinding method, + final OperationName name) { + if (this.components.get(unit) == null) { + this.components.put(unit, new ComponentBuilder(unit)); + } + final OperationInterface provision = new Operation(method, name); + this.detectProvidedInterface(unit, provision); + } + + public void detectProvidedInterface(final CompUnitOrName unit, final OperationInterface provision) { + this.components.get(unit) + .provisions() + .add(provision); + this.providedInterfaces.add(provision); + this.components.values() + .stream() + .forEach(component -> component.requirements() + .strengthenIfPresent(provision)); + } + + public void detectPartOfComposite(final CompUnitOrName unit, final String compositeName) { + if (this.components.get(unit) == null) { + this.components.put(unit, new ComponentBuilder(unit)); + } + this.getComposite(compositeName) + .addPart(this.components.get(unit)); + } + + public void detectCompositeRequiredInterface(final CompUnitOrName unit, final InterfaceName interfaceName) { + this.detectRequiredInterface(unit, interfaceName, true); + } + + public void detectCompositeRequiredInterface(final CompUnitOrName unit, final FieldDeclaration field) { + this.detectRequiredInterface(unit, field, true, false); + } + + public void detectCompositeRequiredInterface(final CompUnitOrName unit, final SingleVariableDeclaration parameter) { + this.detectRequiredInterface(unit, parameter, true); + } + + public void detectCompositeProvidedOperation(final CompUnitOrName unit, final IMethodBinding method) { + this.detectCompositeProvidedOperation(unit, method.getDeclaringClass(), method); + } + + public void detectCompositeProvidedOperation(final CompUnitOrName unit, final ITypeBinding declaringIface, + final IMethodBinding method) { + this.detectCompositeProvidedOperation(unit, NameConverter.toPCMIdentifier(declaringIface), method); + } + + public void detectCompositeProvidedOperation(final CompUnitOrName unit, final String declaringIface, + final IMethodBinding method) { + this.compositeProvisions.add(new Operation(method, new JavaOperationName(declaringIface, method.getName()))); + this.detectProvidedOperation(unit, declaringIface, method); + } + + public void detectCompositeProvidedOperation(final CompUnitOrName unit, final IMethodBinding method, + final OperationName name) { + this.compositeProvisions.add(new Operation(method, name)); + this.detectProvidedOperation(unit, method, name); + } + + private CompositeBuilder getComposite(final String name) { + if (!this.composites.containsKey(name)) { + this.composites.put(name, new CompositeBuilder(name)); + } + return this.composites.get(name); + } + + public Set getCompilationUnits() { + return this.components.keySet(); + } + + public PCMDetectionResult getResult() { + return new PCMDetectionResult(this.components, this.composites, this.compositeProvisions, + this.compositeRequirements); + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(142); + sb.append("[PCMDetector] {\n\tcomponents: {\n"); + this.components.entrySet() + .forEach(entry -> { + sb.append("\t\t\""); + sb.append(entry.getKey()); + sb.append("\" -> {"); + sb.append(entry.getValue()); + sb.append("\t\t}\n"); + }); + return sb.toString(); + } +} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/PCMInstanceCreator.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/PCMInstanceCreator.java similarity index 58% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/PCMInstanceCreator.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/PCMInstanceCreator.java index b3be9569..d5210c02 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/PCMInstanceCreator.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/PCMInstanceCreator.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.engine; +package org.palladiosimulator.retriever.extraction.engine; import java.util.ArrayList; import java.util.HashMap; @@ -31,24 +31,24 @@ import org.palladiosimulator.pcm.repository.ParameterModifier; import org.palladiosimulator.pcm.repository.Repository; import org.palladiosimulator.pcm.seff.ResourceDemandingSEFF; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; -import org.palladiosimulator.somox.analyzer.rules.model.Component; -import org.palladiosimulator.somox.analyzer.rules.model.Composite; -import org.palladiosimulator.somox.analyzer.rules.model.Operation; -import org.palladiosimulator.somox.analyzer.rules.model.OperationInterface; -import org.palladiosimulator.somox.analyzer.rules.model.PCMDetectionResult; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; +import org.palladiosimulator.retriever.extraction.commonalities.Component; +import org.palladiosimulator.retriever.extraction.commonalities.Composite; +import org.palladiosimulator.retriever.extraction.commonalities.Operation; +import org.palladiosimulator.retriever.extraction.commonalities.OperationInterface; +import org.palladiosimulator.retriever.extraction.commonalities.PCMDetectionResult; // TODO Bug-fix, probably // Class to create a pcm instance out of all results from the detector class public class PCMInstanceCreator { private static final Logger LOG = Logger.getLogger(PCMInstanceCreator.class); - private static final String JAVA_DISCOVERER_ID = "org.palladiosimulator.somox.discoverer.java"; + private static final String JAVA_DISCOVERER_ID = "org.palladiosimulator.retriever.extraction.discoverers.java"; private static final String REPO_NAME = "Software Architecture Repository"; private final FluentRepositoryFactory create; private final Repo repository; - private final RuleEngineBlackboard blackboard; + private final RetrieverBlackboard blackboard; private final Map existingDataTypesMap; private final Map existingCollectionDataTypes; private final Map componentCompositeCreators; @@ -56,15 +56,15 @@ public class PCMInstanceCreator { private final Map compositeCreators; private final Map pcmInterfaces; - public PCMInstanceCreator(RuleEngineBlackboard blackboard) { - existingDataTypesMap = new HashMap<>(); - existingCollectionDataTypes = new HashMap<>(); + public PCMInstanceCreator(final RetrieverBlackboard blackboard) { + this.existingDataTypesMap = new HashMap<>(); + this.existingCollectionDataTypes = new HashMap<>(); this.componentCompositeCreators = new HashMap<>(); this.ifaceCompositeCreators = new HashMap<>(); this.compositeCreators = new HashMap<>(); this.pcmInterfaces = new HashMap<>(); - create = new FluentRepositoryFactory(); - repository = create.newRepository() + this.create = new FluentRepositoryFactory(); + this.repository = this.create.newRepository() .withName(REPO_NAME); this.blackboard = blackboard; } @@ -73,23 +73,23 @@ private class Pair { private final T1 t1; private final T2 t2; - public Pair(T1 t1, T2 t2) { + public Pair(final T1 t1, final T2 t2) { this.t1 = t1; this.t2 = t2; } public T1 getT1() { - return t1; + return this.t1; } public T2 getT2() { - return t2; + return this.t2; } } - private void put(Map> map, K key, V value) { + private void put(final Map> map, final K key, final V value) { if (!map.containsKey(key)) { - map.put(key, new ArrayList()); + map.put(key, new ArrayList<>()); } map.get(key) .add(value); @@ -102,27 +102,27 @@ private void put(Map> map, K key, V value) { * a mapping between microservice names and java model instances * @return the PCM repository model */ - public Repository createPCM(Map> mapping) { - PCMDetectionResult detectionResult = blackboard.getPCMDetector() + public Repository createPCM(final Map> mapping) { + final PCMDetectionResult detectionResult = this.blackboard.getPCMDetector() .getResult(); final Set components = detectionResult.getComponents(); final Map> interfaces = detectionResult.getOperationInterfaces(); final Set composites = detectionResult.getCompositeComponents(); - createPCMInterfaces(interfaces); + this.createPCMInterfaces(interfaces); - for (Composite composite : composites) { - CompositeComponentCreator c = create.newCompositeComponent() + for (final Composite composite : composites) { + final CompositeComponentCreator c = this.create.newCompositeComponent() .withName(composite.name()); composite.parts() - .forEach(x -> componentCompositeCreators.put(x, c)); + .forEach(x -> this.componentCompositeCreators.put(x, c)); composite.internalInterfaces() - .forEach(x -> ifaceCompositeCreators.put(x.getInterface(), c)); - compositeCreators.put(composite, c); + .forEach(x -> this.ifaceCompositeCreators.put(x.getInterface(), c)); + this.compositeCreators.put(composite, c); - Set distinctInterfaces = new HashSet<>(); - for (OperationInterface compRequirement : composite.requirements()) { - org.palladiosimulator.pcm.repository.OperationInterface requiredInterface = pcmInterfaces + final Set distinctInterfaces = new HashSet<>(); + for (final OperationInterface compRequirement : composite.requirements()) { + final org.palladiosimulator.pcm.repository.OperationInterface requiredInterface = this.pcmInterfaces .get(compRequirement); if (distinctInterfaces.contains(requiredInterface)) { continue; @@ -132,8 +132,8 @@ public Repository createPCM(Map> mapping) { } distinctInterfaces.clear(); - for (OperationInterface compProvision : composite.provisions()) { - org.palladiosimulator.pcm.repository.OperationInterface providedInterface = pcmInterfaces + for (final OperationInterface compProvision : composite.provisions()) { + final org.palladiosimulator.pcm.repository.OperationInterface providedInterface = this.pcmInterfaces .get(compProvision); if (distinctInterfaces.contains(providedInterface)) { continue; @@ -143,15 +143,15 @@ public Repository createPCM(Map> mapping) { } } - createPCMComponents(components); + this.createPCMComponents(components); // Add assemblyConnections to composite component. - for (Composite composite : composites) { - CompositeComponentCreator c = compositeCreators.get(composite); - CompositeComponent builtComp = (CompositeComponent) c.build(); + for (final Composite composite : composites) { + final CompositeComponentCreator c = this.compositeCreators.get(composite); + final CompositeComponent builtComp = (CompositeComponent) c.build(); - Map>> innerRequirements = new HashMap<>(); - Map>> innerProvisions = new HashMap<>(); + final Map>> innerRequirements = new HashMap<>(); + final Map>> innerProvisions = new HashMap<>(); // Find requiredRoles builtComp.getAssemblyContexts__ComposedStructure() @@ -160,8 +160,8 @@ public Repository createPCM(Map> mapping) { .getRequiredRoles_InterfaceRequiringEntity() .stream() .map(OperationRequiredRole.class::cast) - .forEach(y -> put(innerRequirements, y.getRequiredInterface__OperationRequiredRole() - .getEntityName(), new Pair(y, x)))); + .forEach(y -> this.put(innerRequirements, y.getRequiredInterface__OperationRequiredRole() + .getEntityName(), new Pair<>(y, x)))); // Find providedRoles builtComp.getAssemblyContexts__ComposedStructure() @@ -170,15 +170,15 @@ public Repository createPCM(Map> mapping) { .getProvidedRoles_InterfaceProvidingEntity() .stream() .map(OperationProvidedRole.class::cast) - .forEach(y -> put(innerProvisions, y.getProvidedInterface__OperationProvidedRole() - .getEntityName(), new Pair(y, x)))); + .forEach(y -> this.put(innerProvisions, y.getProvidedInterface__OperationProvidedRole() + .getEntityName(), new Pair<>(y, x)))); // Match them up - for (OperationInterface internalInterface : composite.internalInterfaces()) { - String ifaceName = internalInterface.getInterface(); - for (Pair r : innerRequirements.getOrDefault(ifaceName, + for (final OperationInterface internalInterface : composite.internalInterfaces()) { + final String ifaceName = internalInterface.getInterface(); + for (final Pair r : innerRequirements.getOrDefault(ifaceName, List.of())) { - for (Pair p : innerProvisions.getOrDefault(ifaceName, + for (final Pair p : innerProvisions.getOrDefault(ifaceName, List.of())) { if (!r.getT2() .equals(p.getT2())) { @@ -188,57 +188,57 @@ public Repository createPCM(Map> mapping) { } } - Map outerRequirements = new HashMap<>(); + final Map outerRequirements = new HashMap<>(); builtComp.getRequiredRoles_InterfaceRequiringEntity() .stream() .map(OperationRequiredRole.class::cast) .forEach(x -> outerRequirements.put(x.getRequiredInterface__OperationRequiredRole() .getEntityName(), x)); - for (OperationInterface requiredInterface : composite.requirements()) { - String requiredInterfaceName = requiredInterface.getName() + for (final OperationInterface requiredInterface : composite.requirements()) { + final String requiredInterfaceName = requiredInterface.getName() .toString() .replace(".", "_"); - for (Pair r : innerRequirements + for (final Pair r : innerRequirements .getOrDefault(requiredInterfaceName, List.of())) { c.withRequiredDelegationConnection(r.getT2(), r.getT1(), outerRequirements.get(requiredInterfaceName)); } } - Map outerProvisions = new HashMap<>(); + final Map outerProvisions = new HashMap<>(); builtComp.getProvidedRoles_InterfaceProvidingEntity() .stream() .map(OperationProvidedRole.class::cast) .forEach(x -> outerProvisions.put(x.getProvidedInterface__OperationProvidedRole() .getEntityName(), x)); - for (OperationInterface providedInterface : composite.provisions()) { - String providedInterfaceName = providedInterface.getName() + for (final OperationInterface providedInterface : composite.provisions()) { + final String providedInterfaceName = providedInterface.getName() .toString() .replace(".", "_"); - for (Pair r : innerProvisions + for (final Pair r : innerProvisions .getOrDefault(providedInterfaceName, List.of())) { c.withProvidedDelegationConnection(r.getT2(), r.getT1(), outerProvisions.get(providedInterfaceName)); } } - repository.addToRepository(c); + this.repository.addToRepository(c); } - return repository.createRepositoryNow(); + return this.repository.createRepositoryNow(); } - private void createPCMInterfaces(Map> interfaces) { - Map signatureNameCount = new HashMap<>(); + private void createPCMInterfaces(final Map> interfaces) { + final Map signatureNameCount = new HashMap<>(); interfaces.forEach((inter, operations) -> { - String interName = inter.getName() + final String interName = inter.getName() .toString(); LOG.info("Current PCM Interface: " + interName); - String pcmInterfaceName = interName.replace(".", "_"); - OperationInterfaceCreator pcmInterface = create.newOperationInterface() + final String pcmInterfaceName = interName.replace(".", "_"); + final OperationInterfaceCreator pcmInterface = this.create.newOperationInterface() .withName(pcmInterfaceName); for (final Operation operation : operations) { @@ -246,48 +246,48 @@ private void createPCMInterfaces(Map> interf .forInterface(interName) .orElseThrow(); name = name.replace(".", "_"); - Integer oldCount = signatureNameCount.getOrDefault(name, 0); + final Integer oldCount = signatureNameCount.getOrDefault(name, 0); signatureNameCount.put(name, oldCount + 1); // Omit suffix for first occurrence. if (oldCount > 0) { name = name + "$" + signatureNameCount.get(name); } - OperationSignatureCreator signature = create.newOperationSignature() + OperationSignatureCreator signature = this.create.newOperationSignature() .withName(name); - IMethodBinding method = operation.getBinding(); + final IMethodBinding method = operation.getBinding(); if (method != null) { // parameter type for (final ITypeBinding parameter : method.getParameterTypes()) { - signature = handleSignatureDataType(signature, parameter.getName(), parameter, + signature = this.handleSignatureDataType(signature, parameter.getName(), parameter, parameter.getDimensions(), false); } // Return type: Cast Method Return Type to Variable // OrdinaryParameterImpl is sufficient since return types cannot be varargs. - ITypeBinding returned = method.getReturnType(); - signature = handleSignatureDataType(signature, "", returned, returned.getDimensions(), true); + final ITypeBinding returned = method.getReturnType(); + signature = this.handleSignatureDataType(signature, "", returned, returned.getDimensions(), true); } pcmInterface.withOperationSignature(signature); - Optional astNode = getDeclaration(method); - if (astNode.isPresent() && blackboard.getSeffAssociation(astNode.get()) == null) { - ResourceDemandingSEFF seff = create.newSeff() - .onSignature(create.fetchOfSignature(name)) + final Optional astNode = this.getDeclaration(method); + if (astNode.isPresent() && this.blackboard.getSeffAssociation(astNode.get()) == null) { + final ResourceDemandingSEFF seff = this.create.newSeff() + .onSignature(this.create.fetchOfSignature(name)) .buildRDSeff(); - blackboard.putSeffAssociation(astNode.get(), seff); + this.blackboard.putSeffAssociation(astNode.get(), seff); } } - repository.addToRepository(pcmInterface); - pcmInterfaces.put(inter, create.fetchOfOperationInterface(pcmInterfaceName)); + this.repository.addToRepository(pcmInterface); + this.pcmInterfaces.put(inter, this.create.fetchOfOperationInterface(pcmInterfaceName)); }); } - private Optional getDeclaration(IMethodBinding binding) { - return blackboard.getDiscoveredFiles(JAVA_DISCOVERER_ID, CompilationUnit.class) + private Optional getDeclaration(final IMethodBinding binding) { + return this.blackboard.getDiscoveredFiles(JAVA_DISCOVERER_ID, CompilationUnit.class) .values() .stream() .map(unit -> unit.findDeclaringNode(binding)) @@ -295,16 +295,16 @@ private Optional getDeclaration(IMethodBinding binding) { .findAny(); } - private void createPCMComponents(Set components) { + private void createPCMComponents(final Set components) { for (final Component comp : components) { - BasicComponentCreator pcmComp = create.newBasicComponent() + final BasicComponentCreator pcmComp = this.create.newBasicComponent() .withName(wrapName(comp.name())); - Set distinctInterfaces = new HashSet<>(); - for (OperationInterface provision : comp.provisions() + final Set distinctInterfaces = new HashSet<>(); + for (final OperationInterface provision : comp.provisions() .getGrouped() .keySet()) { - org.palladiosimulator.pcm.repository.OperationInterface providedInterface = pcmInterfaces + final org.palladiosimulator.pcm.repository.OperationInterface providedInterface = this.pcmInterfaces .get(provision); if (distinctInterfaces.contains(providedInterface)) { continue; @@ -319,16 +319,17 @@ private void createPCMComponents(Set components) { .stream() .flatMap(List::stream) .forEach(operation -> { - IMethodBinding method = operation.getBinding(); - Optional declaration = getDeclaration(method); + final IMethodBinding method = operation.getBinding(); + final Optional declaration = this.getDeclaration(method); if (declaration.isPresent()) { - pcmComp.withServiceEffectSpecification(blackboard.getSeffAssociation(declaration.get())); + pcmComp.withServiceEffectSpecification(this.blackboard.getSeffAssociation(declaration.get())); } }); distinctInterfaces.clear(); - for (OperationInterface requirement : comp.requirements()) { - org.palladiosimulator.pcm.repository.OperationInterface requiredInterface = fetchInterface(requirement); + for (final OperationInterface requirement : comp.requirements()) { + final org.palladiosimulator.pcm.repository.OperationInterface requiredInterface = this + .fetchInterface(requirement); if (distinctInterfaces.contains(requiredInterface)) { continue; } @@ -337,37 +338,37 @@ private void createPCMComponents(Set components) { .toString()); } - BasicComponent builtComp = pcmComp.build(); + final BasicComponent builtComp = pcmComp.build(); // Add component to its composite, if it is part of one. - CompositeComponentCreator c = componentCompositeCreators.get(comp); + final CompositeComponentCreator c = this.componentCompositeCreators.get(comp); if (c != null) { c.withAssemblyContext(builtComp); } if (!comp.compilationUnit() .isEmpty()) { - blackboard.putRepositoryComponentLocation(builtComp, comp.compilationUnit() + this.blackboard.putRepositoryComponentLocation(builtComp, comp.compilationUnit() .get()); } - repository.addToRepository(builtComp); + this.repository.addToRepository(builtComp); } } - private org.palladiosimulator.pcm.repository.OperationInterface fetchInterface(OperationInterface iface) { - if (pcmInterfaces.containsKey(iface)) { - return pcmInterfaces.get(iface); + private org.palladiosimulator.pcm.repository.OperationInterface fetchInterface(final OperationInterface iface) { + if (this.pcmInterfaces.containsKey(iface)) { + return this.pcmInterfaces.get(iface); } - for (OperationInterface registeredInterface : pcmInterfaces.keySet()) { + for (final OperationInterface registeredInterface : this.pcmInterfaces.keySet()) { if (iface.isPartOf(registeredInterface)) { - return pcmInterfaces.get(registeredInterface); + return this.pcmInterfaces.get(registeredInterface); } } throw new IllegalArgumentException(); } - private static Primitive convertPrimitive(ITypeBinding primT) { + private static Primitive convertPrimitive(final ITypeBinding primT) { switch (primT.getQualifiedName()) { case "boolean": return Primitive.BOOLEAN; @@ -392,11 +393,11 @@ private static Primitive convertPrimitive(ITypeBinding primT) { } } - private OperationSignatureCreator handleSignatureDataType(OperationSignatureCreator signature, String varName, - ITypeBinding variable, int varDimensions, boolean asReturnType) { + private OperationSignatureCreator handleSignatureDataType(final OperationSignatureCreator signature, + final String varName, final ITypeBinding variable, final int varDimensions, final boolean asReturnType) { // Parameter is a collection (extends Collection, is an array or a vararg) - DataType collectionType = handleCollectionType(variable, varDimensions); + final DataType collectionType = this.handleCollectionType(variable, varDimensions); if (collectionType != null) { if (asReturnType) { return signature.withReturnType(collectionType); @@ -405,7 +406,7 @@ private OperationSignatureCreator handleSignatureDataType(OperationSignatureCrea } // Check if type is a primitive type - Primitive prim = handlePrimitive(variable); + final Primitive prim = handlePrimitive(variable); if (prim != null) { if (asReturnType) { return signature.withReturnType(prim); @@ -415,15 +416,15 @@ private OperationSignatureCreator handleSignatureDataType(OperationSignatureCrea // Check if type is void (not part of pcm primitives) if ("void".equals(variable.getQualifiedName()) && asReturnType) { - if (!create.containsDataType("Void")) { - repository.addToRepository(create.newCompositeDataType() + if (!this.create.containsDataType("Void")) { + this.repository.addToRepository(this.create.newCompositeDataType() .withName("Void")); } - return signature.withReturnType(create.fetchOfDataType("Void")); + return signature.withReturnType(this.create.fetchOfDataType("Void")); } // Parameter is Composite Type - DataType compositeType = handleCompositeType(variable); + final DataType compositeType = this.handleCompositeType(variable); if (compositeType != null) { if (asReturnType) { return signature.withReturnType(compositeType); @@ -434,7 +435,7 @@ private OperationSignatureCreator handleSignatureDataType(OperationSignatureCrea return null; } - private DataType handleCollectionType(ITypeBinding ref, int dimensions) { + private DataType handleCollectionType(final ITypeBinding ref, final int dimensions) { // Base for the name of the collection data type String typeName = wrapName(ref); @@ -447,51 +448,51 @@ private DataType handleCollectionType(ITypeBinding ref, int dimensions) { } collectionTypeName = typeName; - if (existingCollectionDataTypes.containsKey(collectionTypeName)) { - return existingCollectionDataTypes.get(collectionTypeName); + if (this.existingCollectionDataTypes.containsKey(collectionTypeName)) { + return this.existingCollectionDataTypes.get(collectionTypeName); } - collectionType = createCollectionWithTypeArg(collectionTypeName, ref, dimensions - 1); + collectionType = this.createCollectionWithTypeArg(collectionTypeName, ref, dimensions - 1); } else if (isCollectionType(ref) && (ref.getTypeArguments().length > 0)) { // TODO: I do not think this works properly for deeper collection types (e.g. // List[]), especially the naming. typeName = wrapName(ref); - ITypeBinding typeArg = ref.getTypeArguments()[0]; - String argumentTypeName = wrapName(typeArg); + final ITypeBinding typeArg = ref.getTypeArguments()[0]; + final String argumentTypeName = wrapName(typeArg); collectionTypeName = typeName + "<" + argumentTypeName + ">"; LOG.info("Current Argument type name: " + argumentTypeName); - if (existingCollectionDataTypes.containsKey(collectionTypeName)) { - return existingCollectionDataTypes.get(collectionTypeName); + if (this.existingCollectionDataTypes.containsKey(collectionTypeName)) { + return this.existingCollectionDataTypes.get(collectionTypeName); } - collectionType = createCollectionWithTypeArg(collectionTypeName, typeArg, typeArg.getDimensions()); + collectionType = this.createCollectionWithTypeArg(collectionTypeName, typeArg, typeArg.getDimensions()); } if (collectionType != null) { - existingCollectionDataTypes.put(collectionTypeName, collectionType); - repository.addToRepository(collectionType); + this.existingCollectionDataTypes.put(collectionTypeName, collectionType); + this.repository.addToRepository(collectionType); } return collectionType; } - private CollectionDataType createCollectionWithTypeArg(String collectionTypeName, ITypeBinding typeArg, - int typeArgDimensions) { + private CollectionDataType createCollectionWithTypeArg(final String collectionTypeName, final ITypeBinding typeArg, + final int typeArgDimensions) { // Type argument is primitive - Primitive primitiveArg = handlePrimitive(typeArg); + final Primitive primitiveArg = handlePrimitive(typeArg); if (primitiveArg != null) { - return create.newCollectionDataType(collectionTypeName, primitiveArg); + return this.create.newCollectionDataType(collectionTypeName, primitiveArg); } // Type argument is a collection again // A type argument cannot be a vararg, therefore it is "ordinary" - DataType collectionArg = handleCollectionType(typeArg, typeArgDimensions); + final DataType collectionArg = this.handleCollectionType(typeArg, typeArgDimensions); if (collectionArg != null) { return FluentRepositoryFactory.newCollectionDataType(collectionTypeName, collectionArg); } // Type argument is a composite data type - DataType compositeArg = handleCompositeType(typeArg); + final DataType compositeArg = this.handleCompositeType(typeArg); if (compositeArg != null) { return FluentRepositoryFactory.newCollectionDataType(collectionTypeName, compositeArg); } @@ -499,9 +500,9 @@ private CollectionDataType createCollectionWithTypeArg(String collectionTypeName return null; } - private static boolean isCollectionType(ITypeBinding varClassifier) { + private static boolean isCollectionType(final ITypeBinding varClassifier) { - List refs = new ArrayList<>(); + final List refs = new ArrayList<>(); if (varClassifier.isClass()) { refs.addAll(List.of(varClassifier.getInterfaces())); @@ -512,7 +513,7 @@ private static boolean isCollectionType(ITypeBinding varClassifier) { refs.addAll(List.of(varClassifier.getInterfaces())); } - for (ITypeBinding ref : refs) { + for (final ITypeBinding ref : refs) { if ("java.util.Collection".equals(ref.getQualifiedName())) { return true; } @@ -521,7 +522,7 @@ private static boolean isCollectionType(ITypeBinding varClassifier) { return false; } - private static Primitive handlePrimitive(ITypeBinding variable) { + private static Primitive handlePrimitive(final ITypeBinding variable) { if (variable.isPrimitive()) { return convertPrimitive(variable); } @@ -532,26 +533,26 @@ private static Primitive handlePrimitive(ITypeBinding variable) { return null; } - private DataType handleCompositeType(ITypeBinding ref) { - String classifierName = wrapName(ref); + private DataType handleCompositeType(final ITypeBinding ref) { + final String classifierName = wrapName(ref); - if (!existingDataTypesMap.containsKey(classifierName)) { + if (!this.existingDataTypesMap.containsKey(classifierName)) { // TODO why is this commented out? // existingDataTypesMap.put(classifierName, createTypesRecursively(ref)); - existingDataTypesMap.put(classifierName, create.newCompositeDataType() + this.existingDataTypesMap.put(classifierName, this.create.newCompositeDataType() .withName(classifierName)); - repository.addToRepository(existingDataTypesMap.get(classifierName)); + this.repository.addToRepository(this.existingDataTypesMap.get(classifierName)); } - return create.fetchOfCompositeDataType(classifierName); + return this.create.fetchOfCompositeDataType(classifierName); } - private static String wrapName(ITypeBinding name) { + private static String wrapName(final ITypeBinding name) { return wrapName(name.getQualifiedName()); } - private static String wrapName(String name) { - String fullName = name.replace(".", "_"); + private static String wrapName(final String name) { + final String fullName = name.replace(".", "_"); // Erase type parameters in identifiers // TODO is this the right solution? if (fullName.contains("<")) { diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/RuleEngineConfiguration.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RetrieverConfiguration.java similarity index 71% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/RuleEngineConfiguration.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RetrieverConfiguration.java index 43f8e03e..b61a4a0a 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/RuleEngineConfiguration.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RetrieverConfiguration.java @@ -1,10 +1,10 @@ -package org.palladiosimulator.somox.analyzer.rules.engine; +package org.palladiosimulator.retriever.extraction.engine; import org.eclipse.emf.common.util.URI; import de.uka.ipd.sdq.workflow.extension.ExtendableJobConfiguration; -public interface RuleEngineConfiguration extends ExtendableJobConfiguration { +public interface RetrieverConfiguration extends ExtendableJobConfiguration { URI getInputFolder(); diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/Rule.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/Rule.java new file mode 100644 index 00000000..cc0b9e4f --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/Rule.java @@ -0,0 +1,44 @@ +package org.palladiosimulator.retriever.extraction.engine; + +import java.nio.file.Path; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; + +import de.uka.ipd.sdq.workflow.jobs.AbstractBlackboardInteractingJob; +import de.uka.ipd.sdq.workflow.jobs.CleanupFailedException; +import de.uka.ipd.sdq.workflow.jobs.IBlackboardInteractingJob; +import de.uka.ipd.sdq.workflow.jobs.JobFailedException; +import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; + +/** + * This interface has to be implemented in order to write rules. + */ +public interface Rule extends Service { + public abstract void processRules(RetrieverBlackboard blackboard, Path path); + + public abstract boolean isBuildRule(); + + @Override + default IBlackboardInteractingJob create(final RetrieverConfiguration configuration, + final RetrieverBlackboard blackboard) { + final Rule rule = this; + return new AbstractBlackboardInteractingJob<>() { + @Override + public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + for (final Path path : blackboard.getDiscoveredPaths()) { + rule.processRules(blackboard, path); + } + } + + @Override + public void cleanup(final IProgressMonitor monitor) throws CleanupFailedException { + } + + @Override + public String getName() { + return rule.getName() + " Job"; + } + }; + } +} \ No newline at end of file diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/RuleHelper.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RuleHelper.java similarity index 57% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/RuleHelper.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RuleHelper.java index 697f80e6..03bb65a0 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/RuleHelper.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/RuleHelper.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.engine; +package org.palladiosimulator.retriever.extraction.engine; import java.util.ArrayList; import java.util.List; @@ -34,10 +34,10 @@ import org.eclipse.jdt.core.dom.VariableDeclarationStatement; /** - * This class is used as a supporting library for writing rules for the rule engine. It contains - * numerous methods to query a certain state of a java model instance. For example, is a class is - * annotated with a specific annotation name. Also the helper contains methods for retrieving - * aspects of a class like the interfaces it is implementing. + * This class is used as a supporting library for writing rules for Retriever. It contains numerous + * methods to query a certain state of a java model instance. For example, is a class is annotated + * with a specific annotation name. Also the helper contains methods for retrieving aspects of a + * class like the interfaces it is implementing. * * @author Florian Bossert */ @@ -45,8 +45,8 @@ public class RuleHelper { private static final Logger LOG = Logger.getLogger(RuleHelper.class); - public static String getUnitName(CompilationUnit unit) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static String getUnitName(final CompilationUnit unit) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); String name = "NO NAME"; for (final AbstractTypeDeclaration abstType : types) { @@ -57,8 +57,8 @@ public static String getUnitName(CompilationUnit unit) { return name; } - public static boolean isAbstraction(CompilationUnit unit) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static boolean isAbstraction(final CompilationUnit unit) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); for (final AbstractTypeDeclaration abstType : types) { if ((abstType instanceof TypeDeclaration) && ((TypeDeclaration) abstType).isInterface()) { @@ -68,8 +68,8 @@ public static boolean isAbstraction(CompilationUnit unit) { return false; } - public static boolean isUnitAnnotatedWithName(CompilationUnit unit, String... names) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static boolean isUnitAnnotatedWithName(final CompilationUnit unit, final String... names) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); for (final String name : names) { for (final AbstractTypeDeclaration abstType : types) { @@ -81,31 +81,31 @@ public static boolean isUnitAnnotatedWithName(CompilationUnit unit, String... na return false; } - public static boolean isObjectAnnotatedWithName(BodyDeclaration body, String name) { + public static boolean isObjectAnnotatedWithName(final BodyDeclaration body, final String name) { return containsAnnotationWithName(cast(body.modifiers(), IExtendedModifier.class), name); } - public static boolean isObjectAnnotatedWithName(SingleVariableDeclaration parameter, String name) { + public static boolean isObjectAnnotatedWithName(final SingleVariableDeclaration parameter, final String name) { return containsAnnotationWithName(cast(parameter.modifiers(), IExtendedModifier.class), name); } - public static boolean isObjectAnnotatedWithName(TypeParameter parameter, String name) { + public static boolean isObjectAnnotatedWithName(final TypeParameter parameter, final String name) { return containsAnnotationWithName(cast(parameter.modifiers(), IExtendedModifier.class), name); } - public static boolean isObjectAnnotatedWithName(VariableDeclarationExpression expression, String name) { + public static boolean isObjectAnnotatedWithName(final VariableDeclarationExpression expression, final String name) { return containsAnnotationWithName(cast(expression.modifiers(), IExtendedModifier.class), name); } - public static boolean isObjectAnnotatedWithName(VariableDeclarationStatement statement, String name) { + public static boolean isObjectAnnotatedWithName(final VariableDeclarationStatement statement, final String name) { return containsAnnotationWithName(cast(statement.modifiers(), IExtendedModifier.class), name); } - public static boolean isClassifierAnnotatedWithName(BodyDeclaration abstTypeDecl, String name) { + public static boolean isClassifierAnnotatedWithName(final BodyDeclaration abstTypeDecl, final String name) { return containsAnnotationWithName(cast(abstTypeDecl.modifiers(), IExtendedModifier.class), name); } - private static boolean containsAnnotationWithName(List modifiers, String name) { + private static boolean containsAnnotationWithName(final List modifiers, final String name) { for (final IExtendedModifier mod : modifiers) { if (mod.isAnnotation()) { final Annotation anno = (Annotation) mod; @@ -120,33 +120,33 @@ private static boolean containsAnnotationWithName(List modifi return false; } - public static List getMethods(CompilationUnit unit) { + public static List getMethods(final CompilationUnit unit) { final List methods = new ArrayList<>(); // TODO: Methods of sub-classes are not returned - List types = cast(unit.types(), AbstractTypeDeclaration.class); + final List types = cast(unit.types(), AbstractTypeDeclaration.class); for (final AbstractTypeDeclaration abstType : types) { if (abstType instanceof TypeDeclaration) { methods.addAll(getMethods((TypeDeclaration) abstType)); } else if (abstType instanceof EnumDeclaration) { - EnumDeclaration enumDecl = (EnumDeclaration) abstType; + final EnumDeclaration enumDecl = (EnumDeclaration) abstType; - List bodies = cast(enumDecl.bodyDeclarations(), BodyDeclaration.class); + final List bodies = cast(enumDecl.bodyDeclarations(), BodyDeclaration.class); - for (BodyDeclaration body : bodies) { + for (final BodyDeclaration body : bodies) { if (body instanceof MethodDeclaration) { methods.add((MethodDeclaration) body); } } } else if (abstType instanceof AnnotationTypeDeclaration) { - AnnotationTypeDeclaration anno = (AnnotationTypeDeclaration) abstType; + final AnnotationTypeDeclaration anno = (AnnotationTypeDeclaration) abstType; - List bodies = cast(anno.bodyDeclarations(), BodyDeclaration.class); + final List bodies = cast(anno.bodyDeclarations(), BodyDeclaration.class); - for (BodyDeclaration body : bodies) { + for (final BodyDeclaration body : bodies) { if (body instanceof MethodDeclaration) { methods.add((MethodDeclaration) body); } @@ -157,12 +157,12 @@ public static List getMethods(CompilationUnit unit) { return methods; } - public static List getMethods(TypeDeclaration type) { + public static List getMethods(final TypeDeclaration type) { return List.of(type.getMethods()); } - public static List getMethods(Type type) { - ITypeBinding binding = type.resolveBinding(); + public static List getMethods(final Type type) { + final ITypeBinding binding = type.resolveBinding(); if (binding == null) { LOG.warn("Could not resolve type binding for \"" + type + "\". Returning empty list for getMethods"); return List.of(); @@ -171,33 +171,33 @@ public static List getMethods(Type type) { } } - public static List getFields(CompilationUnit unit) { + public static List getFields(final CompilationUnit unit) { final List fields = new ArrayList<>(); - List types = cast(unit.types(), AbstractTypeDeclaration.class); + final List types = cast(unit.types(), AbstractTypeDeclaration.class); for (final AbstractTypeDeclaration abstType : types) { if (abstType instanceof TypeDeclaration) { - TypeDeclaration type = (TypeDeclaration) abstType; + final TypeDeclaration type = (TypeDeclaration) abstType; fields.addAll(List.of(type.getFields())); } else if (abstType instanceof EnumDeclaration) { - EnumDeclaration enumDecl = (EnumDeclaration) abstType; + final EnumDeclaration enumDecl = (EnumDeclaration) abstType; - List bodies = cast(enumDecl.bodyDeclarations(), BodyDeclaration.class); + final List bodies = cast(enumDecl.bodyDeclarations(), BodyDeclaration.class); - for (BodyDeclaration body : bodies) { + for (final BodyDeclaration body : bodies) { if (body instanceof FieldDeclaration) { fields.add((FieldDeclaration) body); } } } else if (abstType instanceof AnnotationTypeDeclaration) { - AnnotationTypeDeclaration anno = (AnnotationTypeDeclaration) abstType; + final AnnotationTypeDeclaration anno = (AnnotationTypeDeclaration) abstType; - List bodies = cast(anno.bodyDeclarations(), BodyDeclaration.class); + final List bodies = cast(anno.bodyDeclarations(), BodyDeclaration.class); - for (BodyDeclaration body : bodies) { + for (final BodyDeclaration body : bodies) { if (body instanceof FieldDeclaration) { fields.add((FieldDeclaration) body); } @@ -208,12 +208,12 @@ public static List getFields(CompilationUnit unit) { return fields; } - public static List getParameters(MethodDeclaration method) { + public static List getParameters(final MethodDeclaration method) { return cast(method.parameters(), SingleVariableDeclaration.class); } - public static boolean isMethodAnnotatedWithName(MethodDeclaration method, String... names) { - for (String name : names) { + public static boolean isMethodAnnotatedWithName(final MethodDeclaration method, final String... names) { + for (final String name : names) { if (isObjectAnnotatedWithName(method, name)) { return true; } @@ -221,9 +221,9 @@ public static boolean isMethodAnnotatedWithName(MethodDeclaration method, String return false; } - public static boolean isFieldAbstract(FieldDeclaration field) { - Type type = field.getType(); - ITypeBinding binding = type.resolveBinding(); + public static boolean isFieldAbstract(final FieldDeclaration field) { + final Type type = field.getType(); + final ITypeBinding binding = type.resolveBinding(); if (binding == null) { LOG.warn("field: \"" + field + "\", has type binding null => returning false for isFieldAbstract"); @@ -233,9 +233,9 @@ public static boolean isFieldAbstract(FieldDeclaration field) { return binding.isInterface(); } - public static boolean isParameterAbstract(SingleVariableDeclaration parameter) { - Type type = parameter.getType(); - ITypeBinding binding = type.resolveBinding(); + public static boolean isParameterAbstract(final SingleVariableDeclaration parameter) { + final Type type = parameter.getType(); + final ITypeBinding binding = type.resolveBinding(); if (binding == null) { LOG.warn("parameter: \"" + parameter + "\", has type binding null " @@ -246,9 +246,10 @@ public static boolean isParameterAbstract(SingleVariableDeclaration parameter) { return binding.isInterface(); } - public static boolean isParameterAClassAnnotatedWith(SingleVariableDeclaration parameter, String... names) { - Type type = parameter.getType(); - ITypeBinding binding = type.resolveBinding(); + public static boolean isParameterAClassAnnotatedWith(final SingleVariableDeclaration parameter, + final String... names) { + final Type type = parameter.getType(); + final ITypeBinding binding = type.resolveBinding(); if (binding == null) { LOG.warn("parameter: \"" + parameter + "\", has type binding null " @@ -257,7 +258,7 @@ public static boolean isParameterAClassAnnotatedWith(SingleVariableDeclaration p } for (final String name : names) { - for (IAnnotationBinding anno : binding.getAnnotations()) { + for (final IAnnotationBinding anno : binding.getAnnotations()) { if (anno.getName() .equals(name)) { return true; @@ -268,17 +269,17 @@ public static boolean isParameterAClassAnnotatedWith(SingleVariableDeclaration p return false; } - public static boolean isFieldModifiedExactlyWith(BodyDeclaration field, String... names) { + public static boolean isFieldModifiedExactlyWith(final BodyDeclaration field, final String... names) { return areModifiersExactly(cast(field.modifiers(), IExtendedModifier.class), names); } - private static boolean areModifiersExactly(List modifiers, String... names) { - Set nameSet = Set.of(names) + private static boolean areModifiersExactly(final List modifiers, final String... names) { + final Set nameSet = Set.of(names) .stream() .map(x -> x.toLowerCase(Locale.US)) .collect(Collectors.toSet()); - long exactModifierCount = modifiers.stream() + final long exactModifierCount = modifiers.stream() .filter(IExtendedModifier::isModifier) .map(Modifier.class::cast) .map(x -> x.getKeyword() @@ -290,14 +291,14 @@ private static boolean areModifiersExactly(List modifiers, St return exactModifierCount == names.length; } - public static boolean isParameterAnnotatedWith(SingleVariableDeclaration parameter, String name) { + public static boolean isParameterAnnotatedWith(final SingleVariableDeclaration parameter, final String name) { return isObjectAnnotatedWithName(parameter, name); } - public static boolean isUnitNamedWith(CompilationUnit unit, String name) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static boolean isUnitNamedWith(final CompilationUnit unit, final String name) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - for (AbstractTypeDeclaration type : types) { + for (final AbstractTypeDeclaration type : types) { if (type.getName() .getFullyQualifiedName() .equals(name)) { @@ -308,10 +309,10 @@ public static boolean isUnitNamedWith(CompilationUnit unit, String name) { return false; } - public static boolean isUnitAnEnum(CompilationUnit unit) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static boolean isUnitAnEnum(final CompilationUnit unit) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - for (AbstractTypeDeclaration type : types) { + for (final AbstractTypeDeclaration type : types) { if (type instanceof EnumDeclaration) { return true; } @@ -319,16 +320,16 @@ public static boolean isUnitAnEnum(CompilationUnit unit) { return false; } - public static List getAllInterfaces(CompilationUnit unit) { - List interfaces = new ArrayList<>(); + public static List getAllInterfaces(final CompilationUnit unit) { + final List interfaces = new ArrayList<>(); - List types = cast(unit.types(), AbstractTypeDeclaration.class); + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - for (AbstractTypeDeclaration abstType : types) { + for (final AbstractTypeDeclaration abstType : types) { if (abstType instanceof TypeDeclaration) { - TypeDeclaration type = (TypeDeclaration) abstType; + final TypeDeclaration type = (TypeDeclaration) abstType; - List interfaceTypes = cast(type.superInterfaceTypes(), Type.class); + final List interfaceTypes = cast(type.superInterfaceTypes(), Type.class); interfaces.addAll(interfaceTypes); } } @@ -336,16 +337,16 @@ public static List getAllInterfaces(CompilationUnit unit) { return interfaces; } - public static boolean isFieldAnnotatedWithName(BodyDeclaration field, String name) { + public static boolean isFieldAnnotatedWithName(final BodyDeclaration field, final String name) { return containsAnnotationWithName(cast(field.modifiers(), IExtendedModifier.class), name); } - public static boolean isClassImplementing(CompilationUnit unit) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static boolean isClassImplementing(final CompilationUnit unit) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - for (AbstractTypeDeclaration abstType : types) { + for (final AbstractTypeDeclaration abstType : types) { if (abstType instanceof TypeDeclaration) { - TypeDeclaration type = (TypeDeclaration) abstType; + final TypeDeclaration type = (TypeDeclaration) abstType; if (!type.isInterface() && (!type.superInterfaceTypes() .isEmpty())) { return true; @@ -355,12 +356,12 @@ public static boolean isClassImplementing(CompilationUnit unit) { return false; } - public static boolean isImplementingOrExtending(CompilationUnit unit, String ifaceName) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static boolean isImplementingOrExtending(final CompilationUnit unit, final String ifaceName) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - for (AbstractTypeDeclaration abstType : types) { + for (final AbstractTypeDeclaration abstType : types) { if (abstType instanceof TypeDeclaration) { - TypeDeclaration type = (TypeDeclaration) abstType; + final TypeDeclaration type = (TypeDeclaration) abstType; if (isImplementingOrExtending(type.resolveBinding(), ifaceName)) { return true; } @@ -369,7 +370,7 @@ public static boolean isImplementingOrExtending(CompilationUnit unit, String ifa return false; } - public static boolean isImplementingOrExtending(ITypeBinding binding, String ifaceName) { + public static boolean isImplementingOrExtending(final ITypeBinding binding, final String ifaceName) { if (binding == null) { LOG.warn( "binding is null => returning false for isImplementingOrExtending(binding, \"" + ifaceName + "\")"); @@ -379,38 +380,35 @@ public static boolean isImplementingOrExtending(ITypeBinding binding, String ifa if (equalsWithGeneric(binding.getName(), ifaceName)) { return true; } - ITypeBinding superClass = binding.getSuperclass(); + final ITypeBinding superClass = binding.getSuperclass(); if (superClass != null && isImplementingOrExtending(superClass, ifaceName)) { return true; } - for (ITypeBinding type : binding.getInterfaces()) { - if (equalsWithGeneric(type.getName(), ifaceName)) { - return true; - } - if (isImplementingOrExtending(type, ifaceName)) { + for (final ITypeBinding type : binding.getInterfaces()) { + if (equalsWithGeneric(type.getName(), ifaceName) || isImplementingOrExtending(type, ifaceName)) { return true; } } return false; } - private static boolean equalsWithGeneric(String withGeneric, String withoutGeneric) { + private static boolean equalsWithGeneric(final String withGeneric, final String withoutGeneric) { if (!withGeneric.startsWith(withoutGeneric)) { return false; } - String rest = withGeneric.substring(withoutGeneric.length()); + final String rest = withGeneric.substring(withoutGeneric.length()); if (!rest.isEmpty() && (!rest.startsWith("<") || !rest.endsWith(">"))) { return false; } return true; } - public static boolean isClassExtending(CompilationUnit unit) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static boolean isClassExtending(final CompilationUnit unit) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - for (AbstractTypeDeclaration abstType : types) { + for (final AbstractTypeDeclaration abstType : types) { if (abstType instanceof TypeDeclaration) { - TypeDeclaration type = (TypeDeclaration) abstType; + final TypeDeclaration type = (TypeDeclaration) abstType; if (!type.isInterface() && (type.getSuperclassType() != null)) { return true; } @@ -419,14 +417,14 @@ public static boolean isClassExtending(CompilationUnit unit) { return false; } - public static Type getExtends(CompilationUnit unit) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static Type getExtends(final CompilationUnit unit) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - for (AbstractTypeDeclaration abstType : types) { + for (final AbstractTypeDeclaration abstType : types) { if (abstType instanceof TypeDeclaration) { - TypeDeclaration type = (TypeDeclaration) abstType; + final TypeDeclaration type = (TypeDeclaration) abstType; if (!type.isInterface()) { - Type superclass = type.getSuperclassType(); + final Type superclass = type.getSuperclassType(); if (superclass != null) { return superclass; } @@ -437,12 +435,12 @@ public static Type getExtends(CompilationUnit unit) { return null; } - public static boolean isClassModifiedExactlyWith(CompilationUnit unit, String... names) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static boolean isClassModifiedExactlyWith(final CompilationUnit unit, final String... names) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - for (AbstractTypeDeclaration abstType : types) { + for (final AbstractTypeDeclaration abstType : types) { if (abstType instanceof TypeDeclaration) { - TypeDeclaration type = (TypeDeclaration) abstType; + final TypeDeclaration type = (TypeDeclaration) abstType; if (!type.isInterface()) { return areModifiersExactly(cast(type.modifiers(), IExtendedModifier.class), names); } @@ -451,11 +449,11 @@ public static boolean isClassModifiedExactlyWith(CompilationUnit unit, String... return false; } - public static boolean isMethodModifiedExactlyWith(BodyDeclaration method, String... names) { + public static boolean isMethodModifiedExactlyWith(final BodyDeclaration method, final String... names) { return areModifiersExactly(cast(method.modifiers(), IExtendedModifier.class), names); } - public static List getAllPublicMethods(CompilationUnit unit) { + public static List getAllPublicMethods(final CompilationUnit unit) { return getMethods(unit).stream() .filter(MethodDeclaration::isConstructor) .filter(x -> cast(x.modifiers(), IExtendedModifier.class).stream() @@ -465,29 +463,29 @@ public static List getAllPublicMethods(CompilationUnit unit) .collect(Collectors.toList()); } - public static List getConstructors(CompilationUnit unit) { + public static List getConstructors(final CompilationUnit unit) { return getMethods(unit).stream() .filter(MethodDeclaration::isConstructor) .collect(Collectors.toList()); } - public static boolean isConstructorAnnotatedWithName(MethodDeclaration constructor, String name) { + public static boolean isConstructorAnnotatedWithName(final MethodDeclaration constructor, final String name) { if (!constructor.isConstructor()) { return false; } return isMethodAnnotatedWithName(constructor, name); } - public static boolean isClassOfFieldAnnotatedWithName(FieldDeclaration field, String... names) { - ITypeBinding binding = field.getType() + public static boolean isClassOfFieldAnnotatedWithName(final FieldDeclaration field, final String... names) { + final ITypeBinding binding = field.getType() .resolveBinding(); if (binding == null) { LOG.warn("field: could not resolve type binding for \"" + field.getType() + "\" => returning false from isClassOfFieldAnnotatedWithName"); return false; } - IAnnotationBinding[] annotations = binding.getAnnotations(); - Set uniqueNames = Set.of(names); + final IAnnotationBinding[] annotations = binding.getAnnotations(); + final Set uniqueNames = Set.of(names); return List.of(annotations) .stream() @@ -495,13 +493,13 @@ public static boolean isClassOfFieldAnnotatedWithName(FieldDeclaration field, St .anyMatch(uniqueNames::contains); } - public static String getMethodAnnotationStringValue(MethodDeclaration method, String annotation) { + public static String getMethodAnnotationStringValue(final MethodDeclaration method, final String annotation) { return getMethodAnnotationStringValue(method, annotation, "value"); } - public static String getMethodAnnotationStringValue(MethodDeclaration method, String annotationName, - String memberName) { - List annotations = cast(method.modifiers(), IExtendedModifier.class).stream() + public static String getMethodAnnotationStringValue(final MethodDeclaration method, final String annotationName, + final String memberName) { + final List annotations = cast(method.modifiers(), IExtendedModifier.class).stream() .filter(x -> x.isAnnotation()) .map(Annotation.class::cast) .filter(x -> x.getTypeName() @@ -509,14 +507,14 @@ public static String getMethodAnnotationStringValue(MethodDeclaration method, St .endsWith(annotationName)) .collect(Collectors.toList()); - for (Annotation annotation : annotations) { + for (final Annotation annotation : annotations) { Expression expression = null; if (annotation.isSingleMemberAnnotation()) { - SingleMemberAnnotation smAnnotation = (SingleMemberAnnotation) annotation; + final SingleMemberAnnotation smAnnotation = (SingleMemberAnnotation) annotation; expression = smAnnotation.getValue(); } else if (annotation.isNormalAnnotation()) { - NormalAnnotation nAnnotation = (NormalAnnotation) annotation; + final NormalAnnotation nAnnotation = (NormalAnnotation) annotation; expression = cast(nAnnotation.values(), MemberValuePair.class).stream() .filter(x -> x.getName() .getIdentifier() @@ -536,7 +534,7 @@ public static String getMethodAnnotationStringValue(MethodDeclaration method, St return ((StringLiteral) expression).getLiteralValue(); } - Object compiledValue = expression.resolveConstantExpressionValue(); + final Object compiledValue = expression.resolveConstantExpressionValue(); if (compiledValue != null) { return compiledValue.toString(); } @@ -546,14 +544,15 @@ public static String getMethodAnnotationStringValue(MethodDeclaration method, St return null; } - public static String getUnitAnnotationStringValue(CompilationUnit unit, String annotation) { + public static String getUnitAnnotationStringValue(final CompilationUnit unit, final String annotation) { return getUnitAnnotationStringValue(unit, annotation, "value"); } - public static String getUnitAnnotationStringValue(CompilationUnit unit, String annotationName, String memberName) { - List types = cast(unit.types(), AbstractTypeDeclaration.class); + public static String getUnitAnnotationStringValue(final CompilationUnit unit, final String annotationName, + final String memberName) { + final List types = cast(unit.types(), AbstractTypeDeclaration.class); - List annotations = types.stream() + final List annotations = types.stream() .map(y -> cast(y.modifiers(), IExtendedModifier.class).stream() .filter(x -> x.isAnnotation()) .map(Annotation.class::cast) @@ -561,16 +560,16 @@ public static String getUnitAnnotationStringValue(CompilationUnit unit, String a .getFullyQualifiedName() .endsWith(annotationName)) .collect(Collectors.toList())) - .collect(() -> new ArrayList(), (acc, x) -> acc.addAll(x), (acc1, acc2) -> acc1.addAll(acc2)); + .collect(() -> new ArrayList<>(), (acc, x) -> acc.addAll(x), (acc1, acc2) -> acc1.addAll(acc2)); - for (Annotation annotation : annotations) { + for (final Annotation annotation : annotations) { Expression expression = null; if (annotation.isSingleMemberAnnotation()) { - SingleMemberAnnotation smAnnotation = (SingleMemberAnnotation) annotation; + final SingleMemberAnnotation smAnnotation = (SingleMemberAnnotation) annotation; expression = smAnnotation.getValue(); } else if (annotation.isNormalAnnotation()) { - NormalAnnotation nAnnotation = (NormalAnnotation) annotation; + final NormalAnnotation nAnnotation = (NormalAnnotation) annotation; expression = cast(nAnnotation.values(), MemberValuePair.class).stream() .filter(x -> x.getName() .getIdentifier() @@ -595,7 +594,7 @@ public static String getUnitAnnotationStringValue(CompilationUnit unit, String a // Concentrate the warnings to this single method. It is necessary due to the // Eclipse JDT DOM API. @SuppressWarnings({ "unchecked", "rawtypes" }) - private static List cast(List list, Class clazz) { + private static List cast(final List list, final Class clazz) { if (!list.isEmpty() && !clazz.isInstance(list.get(0))) { throw new ClassCastException("Illegal cast in EclipseRuleHelper!" + "\n" + list.get(0) .getClass() + " -> " + clazz); diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/Service.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/Service.java similarity index 56% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/Service.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/Service.java index e69067ee..9a45e11a 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/Service.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/Service.java @@ -1,19 +1,19 @@ -package org.palladiosimulator.somox.analyzer.rules.engine; +package org.palladiosimulator.retriever.extraction.engine; import java.util.Set; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; import de.uka.ipd.sdq.workflow.jobs.IBlackboardInteractingJob; /** - * The defining interface for any plug-in style service for the rule engine. + * The defining interface for any plug-in style service for Retriever. * * @author Florian Bossert */ public interface Service { - IBlackboardInteractingJob create(RuleEngineConfiguration configuration, - RuleEngineBlackboard blackboard); + IBlackboardInteractingJob create(RetrieverConfiguration configuration, + RetrieverBlackboard blackboard); Set getConfigurationKeys(); diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/ServiceCollection.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/ServiceCollection.java similarity index 60% rename from bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/ServiceCollection.java rename to bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/ServiceCollection.java index cab42e2c..c245a203 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/ServiceCollection.java +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/ServiceCollection.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.engine; +package org.palladiosimulator.retriever.extraction.engine; import java.util.Set; diff --git a/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/ServiceConfiguration.java b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/ServiceConfiguration.java new file mode 100644 index 00000000..04797dff --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.extraction/src/org/palladiosimulator/retriever/extraction/engine/ServiceConfiguration.java @@ -0,0 +1,244 @@ +package org.palladiosimulator.retriever.extraction.engine; + +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Queue; +import java.util.Set; + +public class ServiceConfiguration { + private final String selectedServicesKey; + private final String serviceConfigKeyPrefix; + private final Map> serviceConfigs; + private final Map services; + private final Set manuallySelectedServices; + private final Map> selectedDependencies; + private final Set> dependencyProviders; + + public ServiceConfiguration(final ServiceCollection serviceCollection, final String selectedServicesKey, + final String serviceConfigKeyPrefix) { + this.selectedServicesKey = selectedServicesKey; + this.serviceConfigKeyPrefix = serviceConfigKeyPrefix; + this.serviceConfigs = new HashMap<>(); + this.services = new HashMap<>(); + for (final T service : serviceCollection.getServices()) { + this.services.put(service.getID(), service); + final Map initializedConfig = new HashMap<>(); + for (final String key : service.getConfigurationKeys()) { + initializedConfig.put(key, ""); + } + this.serviceConfigs.put(service.getID(), initializedConfig); + } + this.manuallySelectedServices = new HashSet<>(); + this.selectedDependencies = new HashMap<>(); + this.dependencyProviders = new HashSet<>(); + this.dependencyProviders.add(this); + } + + public void addDependencyProvider(final ServiceConfiguration dependencyProvider) { + this.dependencyProviders.add(dependencyProvider); + } + + @SuppressWarnings("unchecked") + public void applyAttributeMap(final Map attributeMap) { + final Set serviceIds = (Set) attributeMap.get(this.selectedServicesKey); + for (final Map.Entry serviceEntry : this.services.entrySet()) { + final String serviceId = serviceEntry.getKey(); + final T service = serviceEntry.getValue(); + if (attributeMap.get(this.serviceConfigKeyPrefix + serviceId) != null) { + this.serviceConfigs.put(serviceId, + (Map) attributeMap.get(this.serviceConfigKeyPrefix + serviceId)); + } + if ((serviceIds != null) && serviceIds.contains(service.getID())) { + this.select(service); + } + } + + } + + public String getConfig(final String serviceId, final String key) { + final Map config = this.serviceConfigs.get(serviceId); + if (config == null) { + return null; + } + return config.get(key); + } + + public Map getWholeConfig(final String serviceId) { + return Collections.unmodifiableMap(this.serviceConfigs.get(serviceId)); + } + + public void setConfig(final String serviceId, final String key, final String value) { + Map config = this.serviceConfigs.get(serviceId); + if (config == null) { + config = new HashMap<>(); + this.serviceConfigs.put(serviceId, config); + } + config.put(key, value); + } + + public void select(final T service) { + this.manuallySelectedServices.add(service); + for (final ServiceConfiguration dependencyProvider : this.dependencyProviders) { + dependencyProvider.selectDependenciesOf(service); + } + } + + public void deselect(final T service) { + this.manuallySelectedServices.remove(service); + for (final ServiceConfiguration dependencyProvider : this.dependencyProviders) { + dependencyProvider.deselectDependenciesOf(service); + } + } + + public boolean isManuallySelected(final T service) { + return this.manuallySelectedServices.contains(service); + } + + public Set getSelected() { + final Set selectedServices = new HashSet<>(this.manuallySelectedServices); + selectedServices.addAll(this.selectedDependencies.keySet()); + return Collections.unmodifiableSet(selectedServices); + } + + public Queue> getExecutionOrder() { + final List> executionOrder = new ArrayList<>(); + final Queue remainingServices = new ArrayDeque<>(this.getSelected()); + final List requiringServices = new LinkedList<>(); + final Map> extendedRequirements = new HashMap<>(); + + for (final T service : remainingServices) { + extendedRequirements.put(service.getID(), new HashSet<>(service.getRequiredServices())); + } + + // Rephrase all dependencies into requirements + for (final T providingService : remainingServices) { + for (final String dependentID : providingService.getDependentServices()) { + if (!extendedRequirements.containsKey(dependentID)) { + continue; + } + extendedRequirements.get(dependentID) + .add(providingService.getID()); + } + } + + while (!remainingServices.isEmpty()) { + final T candidate = remainingServices.poll(); + final String candidateID = candidate.getID(); + final Set candidateRequirements = extendedRequirements.get(candidateID); + if (this.isRequiringAny(candidateRequirements, remainingServices) + || this.isRequiringAny(candidateRequirements, requiringServices)) { + requiringServices.add(candidate); + } else { + this.addAfterRequirements(candidate, candidateRequirements, executionOrder); + + remainingServices.addAll(requiringServices); + requiringServices.clear(); + } + } + if (!requiringServices.isEmpty()) { + throw new IllegalStateException("Dependency cycle in services, no possible execution order."); + } + return new ArrayDeque<>(executionOrder); + } + + private void addAfterRequirements(final T service, final Set serviceRequirements, + final List> executionOrder) { + if (executionOrder.isEmpty() + || this.isRequiringAny(serviceRequirements, executionOrder.get(executionOrder.size() - 1))) { + final Collection newStep = new ArrayList<>(); + newStep.add(service); + executionOrder.add(newStep); + return; + } + + Collection earliestCandidate = executionOrder.get(executionOrder.size() - 1); + for (int i = executionOrder.size() - 2; i >= 0; i--) { + final Collection currentStep = executionOrder.get(i); + if (this.isRequiringAny(serviceRequirements, currentStep)) { + break; + } + earliestCandidate = currentStep; + } + earliestCandidate.add(service); + } + + private boolean isRequiringAny(final Set requirements, final Collection services) { + return services.stream() + .map(Service::getID) + .anyMatch(requirements::contains); + } + + public Collection getAvailable() { + return Collections.unmodifiableCollection(this.services.values()); + } + + public void selectDependenciesOf(final Service service) { + for (final String dependencyID : service.getRequiredServices()) { + if (!this.services.containsKey(dependencyID)) { + continue; + } + final T dependency = this.services.get(dependencyID); + this.addDependingService(dependency, service); + } + } + + private void addDependingService(final T dependency, final Service service) { + if (this.selectedDependencies.containsKey(dependency)) { + final Set dependingServices = this.selectedDependencies.get(dependency); + dependingServices.add(service); + } else { + final Set dependingServices = new HashSet<>(); + dependingServices.add(service); + this.selectedDependencies.put(dependency, dependingServices); + for (final ServiceConfiguration dependencyProvider : this.dependencyProviders) { + dependencyProvider.selectDependenciesOf(dependency); + } + } + } + + public void deselectDependenciesOf(final Service service) { + for (final String dependencyID : service.getRequiredServices()) { + if (!this.services.containsKey(dependencyID)) { + continue; + } + final T dependency = this.services.get(dependencyID); + this.removeDependingService(dependency, service); + } + } + + private void removeDependingService(final T dependency, final Service service) { + if (!this.selectedDependencies.containsKey(dependency)) { + return; + } + final Set dependingServices = this.selectedDependencies.get(dependency); + dependingServices.remove(service); + // Remove not needed dependencies. + if (dependingServices.isEmpty()) { + this.selectedDependencies.remove(dependency); + } + } + + public Map toMap() { + final Map result = new HashMap<>(); + for (final String serviceId : this.serviceConfigs.keySet()) { + result.put(this.serviceConfigKeyPrefix + serviceId, this.serviceConfigs.get(serviceId)); + } + result.put(this.selectedServicesKey, serializeServices(this.manuallySelectedServices)); + return result; + } + + private static Set serializeServices(final Iterable services) { + final Set serviceIds = new HashSet<>(); + for (final Service service : services) { + serviceIds.add(service.getID()); + } + return serviceIds; + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/.classpath b/bundles/org.palladiosimulator.retriever.mocore/.classpath new file mode 100644 index 00000000..2b79293e --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/.project b/bundles/org.palladiosimulator.retriever.mocore/.project similarity index 90% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/.project rename to bundles/org.palladiosimulator.retriever.mocore/.project index 067891ae..6cfbb089 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/.project +++ b/bundles/org.palladiosimulator.retriever.mocore/.project @@ -1,6 +1,6 @@ - org.palladiosimulator.somox.analyzer.rules.test + org.palladiosimulator.retriever.mocore diff --git a/bundles/org.palladiosimulator.retriever.mocore/META-INF/MANIFEST.MF b/bundles/org.palladiosimulator.retriever.mocore/META-INF/MANIFEST.MF new file mode 100644 index 00000000..ec777257 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/META-INF/MANIFEST.MF @@ -0,0 +1,23 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.palladiosimulator.retriever.mocore +Bundle-SymbolicName: org.palladiosimulator.retriever.mocore;singleton:=true +Bundle-Version: 1.0.0.qualifier +Automatic-Module-Name: org.palladiosimulator.retriever.mocore +Bundle-Vendor: palladiosimulator.org +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Bundle-ActivationPolicy: lazy +Export-Package: org.palladiosimulator.retriever.mocore.discovery, + org.palladiosimulator.retriever.mocore.orchestration, + org.palladiosimulator.retriever.mocore.processor.element, + org.palladiosimulator.retriever.mocore.processor.relation, + org.palladiosimulator.retriever.mocore.surrogate, + org.palladiosimulator.retriever.mocore.surrogate.element, + org.palladiosimulator.retriever.mocore.surrogate.relation, + org.palladiosimulator.retriever.mocore.transformation, + org.palladiosimulator.retriever.mocore.workflow +Require-Bundle: tools.mdsd.mocore.framework, + org.palladiosimulator.pcm, + org.palladiosimulator.pcm.resources, + org.palladiosimulator.generator.fluent, + de.uka.ipd.sdq.workflow diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/build.properties b/bundles/org.palladiosimulator.retriever.mocore/build.properties similarity index 100% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/build.properties rename to bundles/org.palladiosimulator.retriever.mocore/build.properties diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/discovery/Decompositor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/discovery/Decompositor.java similarity index 60% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/discovery/Decompositor.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/discovery/Decompositor.java index 9fdb6c85..0027188d 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/discovery/Decompositor.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/discovery/Decompositor.java @@ -1,20 +1,22 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.discovery; +package org.palladiosimulator.retriever.mocore.discovery; import java.util.Collection; import tools.mdsd.mocore.framework.discovery.Discoverer; /** - * Represents an entity able to deconstruct a source of model-based information like existing models or configuration - * files into model-elements and model-relations. + * Represents an entity able to deconstruct a source of model-based information like existing models + * or configuration files into model-elements and model-relations. * - * @param the type of model or information source deconstructed by the decompositor + * @param + * the type of model or information source deconstructed by the decompositor */ public interface Decompositor { /** * Extracts model-elements and model-relations from a source of model-based information. * - * @param source the source of model-based information + * @param source + * the source of model-based information * @return a collection of discoverers containing the extracted elements and relations */ Collection> decompose(T source); diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/discovery/RepositoryDecompositor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/discovery/RepositoryDecompositor.java new file mode 100644 index 00000000..283ab923 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/discovery/RepositoryDecompositor.java @@ -0,0 +1,283 @@ +package org.palladiosimulator.retriever.mocore.discovery; + +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.palladiosimulator.pcm.core.composition.AssemblyConnector; +import org.palladiosimulator.pcm.core.composition.AssemblyContext; +import org.palladiosimulator.pcm.core.composition.Connector; +import org.palladiosimulator.pcm.core.composition.ProvidedDelegationConnector; +import org.palladiosimulator.pcm.core.composition.RequiredDelegationConnector; +import org.palladiosimulator.pcm.repository.BasicComponent; +import org.palladiosimulator.pcm.repository.CompositeComponent; +import org.palladiosimulator.pcm.repository.OperationProvidedRole; +import org.palladiosimulator.pcm.repository.OperationRequiredRole; +import org.palladiosimulator.pcm.repository.OperationSignature; +import org.palladiosimulator.pcm.repository.ProvidedRole; +import org.palladiosimulator.pcm.repository.Repository; +import org.palladiosimulator.pcm.repository.RepositoryComponent; +import org.palladiosimulator.pcm.repository.RequiredRole; +import org.palladiosimulator.pcm.seff.ResourceDemandingSEFF; +import org.palladiosimulator.retriever.mocore.surrogate.element.AtomicComponent; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.ServiceEffectSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.element.Signature; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAssemblyRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentSignatureProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositeProvisionDelegationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositeRequirementDelegationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceRequirementRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ServiceEffectSpecificationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.SignatureProvisionRelation; + +import tools.mdsd.mocore.framework.discovery.Discoverer; + +/** + * A decompositor able to extract model-elements and model-relations from a {@link Repository PCM + * repository}. + */ +public class RepositoryDecompositor implements Decompositor { + @Override + public Collection> decompose(final Repository repository) { + // Fetch components, interface provisions and requirements, signatures, and service effect + // specifications + final Set atomicComponents = new HashSet<>(); + final Set composites = new HashSet<>(); + final Set compositions = new HashSet<>(); + final Set interfaceProvisions = new HashSet<>(); + final Set interfaceRequirements = new HashSet<>(); + final Set signatureProvisions = new HashSet<>(); + final Set seffProvisions = new HashSet<>(); + final Set componentAssemblies = new HashSet<>(); + final Set provisionDelegations = new HashSet<>(); + final Set requirementDelegations = new HashSet<>(); + + for (final RepositoryComponent repositoryComponent : repository.getComponents__Repository()) { + Component component; + if (repositoryComponent instanceof BasicComponent) { + final AtomicComponent atomicComponent = new AtomicComponent((BasicComponent) repositoryComponent, + false); + atomicComponents.add(atomicComponent); + component = atomicComponent; + + // Basic component specific behavior + // Fetch service effect specifications from basic component + for (final org.palladiosimulator.pcm.seff.ServiceEffectSpecification seff : atomicComponent.getValue() + .getServiceEffectSpecifications__BasicComponent()) { + if (seff instanceof ResourceDemandingSEFF) { + if (seff.getDescribedService__SEFF() instanceof OperationSignature) { + final ServiceEffectSpecification seffWrapper = new ServiceEffectSpecification( + (ResourceDemandingSEFF) seff, false); + final OperationSignature operationSignature = (OperationSignature) seff + .getDescribedService__SEFF(); + final Signature signature = new Signature(operationSignature, false); + final Interface interFace = new Interface( + operationSignature.getInterface__OperationSignature(), false); + final SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation( + signature, interFace, false); + final InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation( + component, interFace, false); + final ComponentSignatureProvisionRelation componentSignatureProvision = new ComponentSignatureProvisionRelation( + interfaceProvision, signatureProvision, false); + seffProvisions.add(new ServiceEffectSpecificationRelation(componentSignatureProvision, + seffWrapper, false)); + } + } + } + } else if (repositoryComponent instanceof CompositeComponent) { + final Composite composite = new Composite((CompositeComponent) repositoryComponent, false); + composites.add(composite); + component = composite; + + // Composite specific behavior + // Create composition relations for each composite + for (final AssemblyContext assemblyContext : composite.getValue() + .getAssemblyContexts__ComposedStructure()) { + final RepositoryComponent encapsulatedComponent = assemblyContext + .getEncapsulatedComponent__AssemblyContext(); + + // Create appropriate wrapper for child component + final Component childWrapper = this.getGenericWrapperFor(encapsulatedComponent); + if (childWrapper == null) { + // Ignore child that cannot be wrapped + continue; + } + + // Create composition for composite & child + final CompositionRelation composition = new CompositionRelation(composite, childWrapper, false); + compositions.add(composition); + } + + // Process connectors of composite component + for (final Connector connector : composite.getValue() + .getConnectors__ComposedStructure()) { + if (connector instanceof AssemblyConnector) { + final AssemblyConnector assemblyConnector = (AssemblyConnector) connector; + + // Wrap provider and consumer component + final Component provider = this + .getGenericWrapperFor(assemblyConnector.getProvidingAssemblyContext_AssemblyConnector() + .getEncapsulatedComponent__AssemblyContext()); + final Component consumer = this + .getGenericWrapperFor(assemblyConnector.getRequiringAssemblyContext_AssemblyConnector() + .getEncapsulatedComponent__AssemblyContext()); + + // Wrap role interfaces + final Interface providedInterface = new Interface( + assemblyConnector.getProvidedRole_AssemblyConnector() + .getProvidedInterface__OperationProvidedRole(), + false); + final Interface requiredInterface = new Interface( + assemblyConnector.getRequiredRole_AssemblyConnector() + .getRequiredInterface__OperationRequiredRole(), + false); + + // Create interface relations & component assembly relation + final InterfaceProvisionRelation provisionRelation = new InterfaceProvisionRelation(provider, + providedInterface, false); + final InterfaceRequirementRelation requirementRelation = new InterfaceRequirementRelation( + consumer, requiredInterface, false); + final ComponentAssemblyRelation assemblyRelation = new ComponentAssemblyRelation( + provisionRelation, requirementRelation, false); + + // Add assembly to discoverer + componentAssemblies.add(assemblyRelation); + } else if (connector instanceof ProvidedDelegationConnector) { + final ProvidedDelegationConnector providedDelegationConnector = (ProvidedDelegationConnector) connector; + + // Wrap the providing component & the inner and outer role's interfaces + final Component connectorComponent = this.getGenericWrapperFor( + providedDelegationConnector.getAssemblyContext_ProvidedDelegationConnector() + .getEncapsulatedComponent__AssemblyContext()); + final Interface innerInterface = new Interface( + providedDelegationConnector.getInnerProvidedRole_ProvidedDelegationConnector() + .getProvidedInterface__OperationProvidedRole(), + false); + final Interface outerInterface = new Interface( + providedDelegationConnector.getOuterProvidedRole_ProvidedDelegationConnector() + .getProvidedInterface__OperationProvidedRole(), + false); + + // Create interface relations + final InterfaceProvisionRelation innerInterfaceRelation = new InterfaceProvisionRelation( + connectorComponent, innerInterface, false); + final InterfaceProvisionRelation outerInterfaceRelation = new InterfaceProvisionRelation( + composite, outerInterface, false); + final CompositeProvisionDelegationRelation delegationRelation = new CompositeProvisionDelegationRelation( + outerInterfaceRelation, innerInterfaceRelation, false); + + // Add delegation relation to discoverer + provisionDelegations.add(delegationRelation); + } else if (connector instanceof RequiredDelegationConnector) { + final RequiredDelegationConnector requiredDelegationConnector = (RequiredDelegationConnector) connector; + + // Wrap the requiring component & the inner and outer role's interfaces + final Component connectorComponent = this.getGenericWrapperFor( + requiredDelegationConnector.getAssemblyContext_RequiredDelegationConnector() + .getEncapsulatedComponent__AssemblyContext()); + final Interface innerInterface = new Interface( + requiredDelegationConnector.getInnerRequiredRole_RequiredDelegationConnector() + .getRequiredInterface__OperationRequiredRole(), + false); + final Interface outerInterface = new Interface( + requiredDelegationConnector.getOuterRequiredRole_RequiredDelegationConnector() + .getRequiredInterface__OperationRequiredRole(), + false); + + // Create interface relations & delegation relation + final InterfaceRequirementRelation innerInterfaceRelation = new InterfaceRequirementRelation( + connectorComponent, innerInterface, false); + final InterfaceRequirementRelation outerInterfaceRelation = new InterfaceRequirementRelation( + composite, outerInterface, false); + final CompositeRequirementDelegationRelation delegationRelation = new CompositeRequirementDelegationRelation( + outerInterfaceRelation, innerInterfaceRelation, false); + + // Add delegation relation to discoverer + requirementDelegations.add(delegationRelation); + } + } + } else { + // Ignore repository components that are neither basic nor composite + continue; + } + + // Behavior for generic repository components + // Transform provided roles into interface provision relations + for (final ProvidedRole providedRole : repositoryComponent.getProvidedRoles_InterfaceProvidingEntity()) { + if (providedRole instanceof OperationProvidedRole) { + final OperationProvidedRole operationProvidedRole = (OperationProvidedRole) providedRole; + final Interface providerInterface = new Interface( + operationProvidedRole.getProvidedInterface__OperationProvidedRole(), false); + interfaceProvisions.add(new InterfaceProvisionRelation(component, providerInterface, false)); + + // Create signature provisions for provider interface + for (final OperationSignature operationSignature : providerInterface.getValue() + .getSignatures__OperationInterface()) { + final Signature signatureWrapper = new Signature(operationSignature, false); + signatureProvisions + .add(new SignatureProvisionRelation(signatureWrapper, providerInterface, false)); + } + } + } + + // Transform required roles into interface requirement relations + for (final RequiredRole requiredRole : repositoryComponent.getRequiredRoles_InterfaceRequiringEntity()) { + if (requiredRole instanceof OperationRequiredRole) { + final OperationRequiredRole operationRequiredRole = (OperationRequiredRole) requiredRole; + final Interface consumerInterface = new Interface( + operationRequiredRole.getRequiredInterface__OperationRequiredRole(), false); + interfaceRequirements.add(new InterfaceRequirementRelation(component, consumerInterface, false)); + + // Create signature provisions for consumer interface + for (final OperationSignature operationSignature : consumerInterface.getValue() + .getSignatures__OperationInterface()) { + final Signature signatureWrapper = new Signature(operationSignature, false); + signatureProvisions + .add(new SignatureProvisionRelation(signatureWrapper, consumerInterface, false)); + } + } + } + } + + final SimpleDiscoverer atomicComponentDiscoverer = new SimpleDiscoverer<>(atomicComponents, + AtomicComponent.class); + final SimpleDiscoverer compositeDiscoverer = new SimpleDiscoverer<>(composites, Composite.class); + final SimpleDiscoverer compositionDiscoverer = new SimpleDiscoverer<>(compositions, + CompositionRelation.class); + final SimpleDiscoverer signatureProvisionDiscoverer = new SimpleDiscoverer<>( + signatureProvisions, SignatureProvisionRelation.class); + final SimpleDiscoverer interfaceProvisionDiscoverer = new SimpleDiscoverer<>( + interfaceProvisions, InterfaceProvisionRelation.class); + final SimpleDiscoverer interfaceRequirementDiscoverer = new SimpleDiscoverer<>( + interfaceRequirements, InterfaceRequirementRelation.class); + final SimpleDiscoverer seffProvisionDiscoverer = new SimpleDiscoverer<>( + seffProvisions, ServiceEffectSpecificationRelation.class); + final SimpleDiscoverer assemblyDiscoverer = new SimpleDiscoverer<>( + componentAssemblies, ComponentAssemblyRelation.class); + final SimpleDiscoverer provisionDelegationDiscoverer = new SimpleDiscoverer<>( + provisionDelegations, CompositeProvisionDelegationRelation.class); + final SimpleDiscoverer requirementDelegationDiscoverer = new SimpleDiscoverer<>( + requirementDelegations, CompositeRequirementDelegationRelation.class); + return List.of(atomicComponentDiscoverer, compositeDiscoverer, compositionDiscoverer, + signatureProvisionDiscoverer, interfaceProvisionDiscoverer, interfaceRequirementDiscoverer, + seffProvisionDiscoverer, assemblyDiscoverer, provisionDelegationDiscoverer, + requirementDelegationDiscoverer); + } + + private Component getGenericWrapperFor(final RepositoryComponent repositoryComponent) { + // Ignore components that are neither basic nor composite + Component wrapper = null; + if (repositoryComponent instanceof BasicComponent) { + wrapper = new AtomicComponent((BasicComponent) repositoryComponent, false); + } else if (repositoryComponent instanceof CompositeComponent) { + wrapper = new Composite((CompositeComponent) repositoryComponent, false); + } + return wrapper; + } +} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/discovery/SimpleDiscoverer.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/discovery/SimpleDiscoverer.java similarity index 55% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/discovery/SimpleDiscoverer.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/discovery/SimpleDiscoverer.java index a2c50f36..d621b1dc 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/discovery/SimpleDiscoverer.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/discovery/SimpleDiscoverer.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.discovery; +package org.palladiosimulator.retriever.mocore.discovery; import java.util.Set; @@ -6,12 +6,14 @@ import tools.mdsd.mocore.framework.surrogate.Replaceable; /** - * Realization of the {@link Discoverer abstract framework discoverer} without changes or adaptations in behavior. + * Realization of the {@link Discoverer abstract framework discoverer} without changes or + * adaptations in behavior. * - * @param the type of {@link Replaceable} the discoverer provides + * @param + * the type of {@link Replaceable} the discoverer provides */ public class SimpleDiscoverer extends Discoverer { - public SimpleDiscoverer(Set discoveries, Class discoveryType) { + public SimpleDiscoverer(final Set discoveries, final Class discoveryType) { super(discoveries, discoveryType); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/orchestration/PcmOrchestrator.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/orchestration/PcmOrchestrator.java new file mode 100644 index 00000000..6b98b78e --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/orchestration/PcmOrchestrator.java @@ -0,0 +1,44 @@ +package org.palladiosimulator.retriever.mocore.orchestration; + +import org.palladiosimulator.retriever.mocore.processor.element.AtomicComponentProcessor; +import org.palladiosimulator.retriever.mocore.processor.element.CompositeProcessor; +import org.palladiosimulator.retriever.mocore.processor.element.DeploymentProcessor; +import org.palladiosimulator.retriever.mocore.processor.element.InterfaceProcessor; +import org.palladiosimulator.retriever.mocore.processor.element.LinkResourceSpecificationProcessor; +import org.palladiosimulator.retriever.mocore.processor.element.ServiceEffectSpecificationProcessor; +import org.palladiosimulator.retriever.mocore.processor.element.SignatureProcessor; +import org.palladiosimulator.retriever.mocore.processor.relation.ComponentAllocationRelationProcessor; +import org.palladiosimulator.retriever.mocore.processor.relation.ComponentAssemblyRelationProcessor; +import org.palladiosimulator.retriever.mocore.processor.relation.ComponentSignatureProvisionRelationProcessor; +import org.palladiosimulator.retriever.mocore.processor.relation.CompositeProvisionDelegationRelationProcessor; +import org.palladiosimulator.retriever.mocore.processor.relation.CompositeRequirementDelegationRelationProcessor; +import org.palladiosimulator.retriever.mocore.processor.relation.CompositionRelationProcessor; +import org.palladiosimulator.retriever.mocore.processor.relation.DeploymentDeploymentRelationProcessor; +import org.palladiosimulator.retriever.mocore.processor.relation.InterfaceProvisionRelationProcessor; +import org.palladiosimulator.retriever.mocore.processor.relation.InterfaceRequirementRelationProcessor; +import org.palladiosimulator.retriever.mocore.processor.relation.LinkResourceSpecificationRelationProcessor; +import org.palladiosimulator.retriever.mocore.processor.relation.ServiceEffectSpecificationRelationProcessor; +import org.palladiosimulator.retriever.mocore.processor.relation.SignatureProvisionRelationProcessor; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; + +import tools.mdsd.mocore.framework.orchestration.Orchestrator; + +public class PcmOrchestrator extends Orchestrator { + @SuppressWarnings("unchecked") + public PcmOrchestrator(final PcmSurrogate model) { + super(model, new SignatureProcessor(model), new InterfaceProcessor(model), new DeploymentProcessor(model), + new LinkResourceSpecificationProcessor(model), new ServiceEffectSpecificationProcessor(model), + new SignatureProvisionRelationProcessor(model), new InterfaceProvisionRelationProcessor(model), + new InterfaceRequirementRelationProcessor(model), new ComponentAssemblyRelationProcessor(model), + new ComponentAllocationRelationProcessor(model), new DeploymentDeploymentRelationProcessor(model), + new LinkResourceSpecificationRelationProcessor(model), + new ServiceEffectSpecificationRelationProcessor(model), new AtomicComponentProcessor(model), + new ComponentSignatureProvisionRelationProcessor(model), new CompositeProcessor(model), + new CompositionRelationProcessor(model), new CompositeRequirementDelegationRelationProcessor(model), + new CompositeProvisionDelegationRelationProcessor(model)); + } + + public PcmOrchestrator() { + this(new PcmSurrogate()); + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/AtomicComponentProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/AtomicComponentProcessor.java new file mode 100644 index 00000000..a2103708 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/AtomicComponentProcessor.java @@ -0,0 +1,10 @@ +package org.palladiosimulator.retriever.mocore.processor.element; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.AtomicComponent; + +public class AtomicComponentProcessor extends ComponentProcessor { + public AtomicComponentProcessor(final PcmSurrogate model) { + super(model, AtomicComponent.class); + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/ComponentProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/ComponentProcessor.java new file mode 100644 index 00000000..138be4bf --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/ComponentProcessor.java @@ -0,0 +1,30 @@ +package org.palladiosimulator.retriever.mocore.processor.element; + +import java.util.List; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAllocationRelation; + +import tools.mdsd.mocore.framework.processor.Processor; + +public abstract class ComponentProcessor> extends Processor { + public ComponentProcessor(final PcmSurrogate model, final Class processableType) { + super(model, processableType); + } + + @Override + protected void refine(final T discovery) { + final List deploymentRelations = this.getModel() + .getByType(ComponentAllocationRelation.class); + deploymentRelations.removeIf(relation -> !relation.getSource() + .equals(discovery)); + + if (deploymentRelations.isEmpty()) { + final Deployment deployment = Deployment.getUniquePlaceholder(); + final ComponentAllocationRelation relation = new ComponentAllocationRelation(discovery, deployment, true); + this.addImplication(relation); + } + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/CompositeProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/CompositeProcessor.java new file mode 100644 index 00000000..fbbfe1ff --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/CompositeProcessor.java @@ -0,0 +1,10 @@ +package org.palladiosimulator.retriever.mocore.processor.element; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; + +public class CompositeProcessor extends ComponentProcessor { + public CompositeProcessor(final PcmSurrogate model) { + super(model, Composite.class); + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/DeploymentProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/DeploymentProcessor.java new file mode 100644 index 00000000..021f199f --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/DeploymentProcessor.java @@ -0,0 +1,17 @@ +package org.palladiosimulator.retriever.mocore.processor.element; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; + +import tools.mdsd.mocore.framework.processor.Processor; + +public class DeploymentProcessor extends Processor { + public DeploymentProcessor(final PcmSurrogate model) { + super(model, Deployment.class); + } + + @Override + protected void refine(final Deployment discovery) { + // No refinement needed when adding a deployment element + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/InterfaceProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/InterfaceProcessor.java new file mode 100644 index 00000000..52eae7ed --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/InterfaceProcessor.java @@ -0,0 +1,39 @@ +package org.palladiosimulator.retriever.mocore.processor.element; + +import java.util.List; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceProvisionRelation; + +import tools.mdsd.mocore.framework.processor.Processor; + +public class InterfaceProcessor extends Processor { + private static final String PLACEHOLDER_COMPONENT_NAME_PATTERN = "%s Provider"; + + public InterfaceProcessor(final PcmSurrogate model) { + super(model, Interface.class); + } + + @Override + protected void refine(final Interface discovery) { + final List providesRelations = this.getModel() + .getByType(InterfaceProvisionRelation.class); + providesRelations.removeIf(relation -> !relation.getDestination() + .equals(discovery)); + + // Rule: Each interface has to be provided by a component. + // -> If no provision relation exists yet, add a placeholder provider and relation to the + // model. + if (providesRelations.isEmpty()) { + final String interfaceName = discovery.getValue() + .getEntityName(); + final String componentName = String.format(PLACEHOLDER_COMPONENT_NAME_PATTERN, interfaceName); + final Component component = Component.getNamedPlaceholder(componentName); + final InterfaceProvisionRelation relation = new InterfaceProvisionRelation(component, discovery, true); + this.addImplication(relation); + } + } + +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/LinkResourceSpecificationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/LinkResourceSpecificationProcessor.java new file mode 100644 index 00000000..cbec629a --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/LinkResourceSpecificationProcessor.java @@ -0,0 +1,35 @@ +package org.palladiosimulator.retriever.mocore.processor.element; + +import java.util.List; +import java.util.Objects; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.element.LinkResourceSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.relation.DeploymentDeploymentRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.LinkResourceSpecificationRelation; + +import tools.mdsd.mocore.framework.processor.Processor; + +public class LinkResourceSpecificationProcessor extends Processor { + public LinkResourceSpecificationProcessor(final PcmSurrogate model) { + super(model, LinkResourceSpecification.class); + } + + @Override + protected void refine(final LinkResourceSpecification discovery) { + final List relations = this.getModel() + .getByType(LinkResourceSpecificationRelation.class); + relations.removeIf(relation -> !Objects.equals(relation.getSource(), discovery)); + + if (relations.isEmpty()) { + final Deployment sourcePlaceholder = Deployment.getUniquePlaceholder(); + final Deployment destinationPlaceholder = Deployment.getUniquePlaceholder(); + final DeploymentDeploymentRelation deploymentRelation = new DeploymentDeploymentRelation(sourcePlaceholder, + destinationPlaceholder, true); + final LinkResourceSpecificationRelation implicitRelation = new LinkResourceSpecificationRelation(discovery, + deploymentRelation, true); + this.addImplication(implicitRelation); + } + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/ServiceEffectSpecificationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/ServiceEffectSpecificationProcessor.java new file mode 100644 index 00000000..50fd0151 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/ServiceEffectSpecificationProcessor.java @@ -0,0 +1,17 @@ +package org.palladiosimulator.retriever.mocore.processor.element; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.ServiceEffectSpecification; + +import tools.mdsd.mocore.framework.processor.Processor; + +public class ServiceEffectSpecificationProcessor extends Processor { + public ServiceEffectSpecificationProcessor(final PcmSurrogate model) { + super(model, ServiceEffectSpecification.class); + } + + @Override + protected void refine(final ServiceEffectSpecification discovery) { + // TODO Evaluate whether refinement should be done for a single specification element + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/SignatureProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/SignatureProcessor.java new file mode 100644 index 00000000..29941621 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/element/SignatureProcessor.java @@ -0,0 +1,31 @@ +package org.palladiosimulator.retriever.mocore.processor.element; + +import java.util.List; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.Signature; +import org.palladiosimulator.retriever.mocore.surrogate.relation.SignatureProvisionRelation; + +import tools.mdsd.mocore.framework.processor.Processor; + +public class SignatureProcessor extends Processor { + public SignatureProcessor(final PcmSurrogate model) { + super(model, Signature.class); + } + + @Override + protected void refine(final Signature discovery) { + // Add providing interface for signature if none exists + final List interfaceRelations = this.getModel() + .getByType(SignatureProvisionRelation.class); + interfaceRelations.removeIf(relation -> !relation.getSource() + .equals(discovery)); + if (interfaceRelations.isEmpty()) { + final Interface interfaceElement = Interface.getUniquePlaceholder(); + final SignatureProvisionRelation relation = new SignatureProvisionRelation(discovery, interfaceElement, + true); + this.addImplication(relation); + } + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAllocationRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAllocationRelationProcessor.java new file mode 100644 index 00000000..5750a751 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAllocationRelationProcessor.java @@ -0,0 +1,12 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAllocationRelation; + +import tools.mdsd.mocore.framework.processor.RelationProcessor; + +public class ComponentAllocationRelationProcessor extends RelationProcessor { + public ComponentAllocationRelationProcessor(final PcmSurrogate model) { + super(model, ComponentAllocationRelation.class); + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAssemblyRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAssemblyRelationProcessor.java new file mode 100644 index 00000000..6b4c617c --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAssemblyRelationProcessor.java @@ -0,0 +1,120 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAllocationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAssemblyRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.DeploymentDeploymentRelation; + +import tools.mdsd.mocore.framework.processor.RelationProcessor; + +public class ComponentAssemblyRelationProcessor extends RelationProcessor { + public ComponentAssemblyRelationProcessor(final PcmSurrogate model) { + super(model, ComponentAssemblyRelation.class); + } + + @Override + protected void refine(final ComponentAssemblyRelation discovery) { + // Identify all allocations of the providing and consuming component in the assembly + final Component provider = discovery.getSource() + .getSource(); + final Component consumer = discovery.getDestination() + .getSource(); + final Interface providerConsumerInterface = discovery.getSource() + .getDestination(); + final List providerAllocations = this.getAllocatedContainers(provider); + final List consumerAllocations = this.getAllocatedContainers(consumer); + + // Add link between allocation containers of assembled components if needed + if (providerAllocations.isEmpty()) { + final Deployment placeholderDeployment = Deployment.getUniquePlaceholder(); + final ComponentAllocationRelation allocation = new ComponentAllocationRelation(provider, + placeholderDeployment, true); + providerAllocations.add(placeholderDeployment); + this.addImplication(allocation); + } + if (consumerAllocations.isEmpty()) { + final Deployment placeholderDeployment = Deployment.getUniquePlaceholder(); + final ComponentAllocationRelation allocation = new ComponentAllocationRelation(consumer, + placeholderDeployment, true); + consumerAllocations.add(placeholderDeployment); + this.addImplication(allocation); + } + for (final Deployment providerContainer : providerAllocations) { + for (final Deployment consumerContainer : consumerAllocations) { + if (!providerContainer.equals(consumerContainer)) { + // Connect every providing container with each consuming one, except they are + // the same container + final DeploymentDeploymentRelation containerLink = new DeploymentDeploymentRelation( + providerContainer, consumerContainer, true); + this.addImplication(containerLink); + } + } + } + + // Remove component assembly fully-placeholder relation (non-direct & non-indirect) + final List assemblies = this.getModel() + .getByType(ComponentAssemblyRelation.class); + assemblies.removeIf(assembly -> !assembly.getSource() + .isPlaceholder() + || !assembly.getDestination() + .isPlaceholder()); + for (final ComponentAssemblyRelation placeholderAssembly : assemblies) { + if (discovery.equals(placeholderAssembly)) { + continue; + } + final Component source = placeholderAssembly.getSource() + .getSource(); + final Component destination = placeholderAssembly.getDestination() + .getSource(); + final Interface sourceDestinationInterface = placeholderAssembly.getSource() + .getDestination(); + // Placeholder are unique and can only be allocated to a single container + final Optional optionalSourceContainer = this.getAllocatedContainers(source) + .stream() + .findFirst(); + final Optional optionalDestinationContainer = this.getAllocatedContainers(destination) + .stream() + .findFirst(); + + if (optionalSourceContainer.isPresent() && optionalDestinationContainer.isPresent()) { + final Deployment sourceContainer = optionalSourceContainer.get(); + final Deployment destinationContainer = optionalDestinationContainer.get(); + + // Container links are bi-directional => Parallel or inverse assemblies are valid + final boolean isParallelAssembly = providerAllocations.contains(sourceContainer) + && consumerAllocations.contains(destinationContainer); + final boolean isInverseAssembly = providerAllocations.contains(destinationContainer) + && consumerAllocations.contains(sourceContainer); + if (isParallelAssembly || isInverseAssembly) { + this.addImplications(this.getModel() + .replace(placeholderAssembly, discovery)); + this.addImplications(this.getModel() + .replace(source, provider)); + this.addImplications(this.getModel() + .replace(destination, consumer)); + this.addImplications(this.getModel() + .replace(sourceDestinationInterface, providerConsumerInterface)); + } + } + } + + super.refine(discovery); + } + + private List getAllocatedContainers(final Component component) { + final List allocations = this.getModel() + .getByType(ComponentAllocationRelation.class); + return allocations.stream() + .filter(allocation -> allocation.getSource() + .equals(component)) + .map(ComponentAllocationRelation::getDestination) + .collect(Collectors.toList()); + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentSignatureProvisionRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentSignatureProvisionRelationProcessor.java new file mode 100644 index 00000000..36382b3a --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentSignatureProvisionRelationProcessor.java @@ -0,0 +1,13 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentSignatureProvisionRelation; + +import tools.mdsd.mocore.framework.processor.RelationProcessor; + +public class ComponentSignatureProvisionRelationProcessor + extends RelationProcessor { + public ComponentSignatureProvisionRelationProcessor(final PcmSurrogate model) { + super(model, ComponentSignatureProvisionRelation.class); + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeProvisionDelegationRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeProvisionDelegationRelationProcessor.java new file mode 100644 index 00000000..0bc6a4fd --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeProvisionDelegationRelationProcessor.java @@ -0,0 +1,38 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import java.util.List; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositeProvisionDelegationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositionRelation; + +import tools.mdsd.mocore.framework.processor.RelationProcessor; + +public class CompositeProvisionDelegationRelationProcessor + extends RelationProcessor { + public CompositeProvisionDelegationRelationProcessor(final PcmSurrogate model) { + super(model, CompositeProvisionDelegationRelation.class); + } + + @Override + protected void refine(final CompositeProvisionDelegationRelation discovery) { + final Composite discoveryComposite = (Composite) discovery.getSource() + .getSource(); + final Component discoveryChild = discovery.getDestination() + .getSource(); + + // Check if the sub-component is part of the composite already + final List compositions = this.getModel() + .getByType(CompositionRelation.class); + compositions.removeIf(relation -> !discoveryComposite.equals(relation.getSource())); + compositions.removeIf(relation -> !discoveryChild.equals(relation.getDestination())); + if (compositions.isEmpty()) { + final CompositionRelation composition = new CompositionRelation(discoveryComposite, discoveryChild, true); + this.addImplication(composition); + } + + super.refine(discovery); + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeRequirementDelegationRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeRequirementDelegationRelationProcessor.java new file mode 100644 index 00000000..6ed1b6a5 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeRequirementDelegationRelationProcessor.java @@ -0,0 +1,38 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import java.util.List; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositeRequirementDelegationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositionRelation; + +import tools.mdsd.mocore.framework.processor.RelationProcessor; + +public class CompositeRequirementDelegationRelationProcessor + extends RelationProcessor { + public CompositeRequirementDelegationRelationProcessor(final PcmSurrogate model) { + super(model, CompositeRequirementDelegationRelation.class); + } + + @Override + protected void refine(final CompositeRequirementDelegationRelation discovery) { + final Composite discoveryComposite = (Composite) discovery.getSource() + .getSource(); + final Component discoveryChild = discovery.getDestination() + .getSource(); + + // Check if the sub-component is part of the composite already + final List compositions = this.getModel() + .getByType(CompositionRelation.class); + compositions.removeIf(relation -> !discoveryComposite.equals(relation.getSource())); + compositions.removeIf(relation -> !discoveryChild.equals(relation.getDestination())); + if (compositions.isEmpty()) { + final CompositionRelation composition = new CompositionRelation(discoveryComposite, discoveryChild, true); + this.addImplication(composition); + } + + super.refine(discovery); + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositionRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositionRelationProcessor.java new file mode 100644 index 00000000..b581c240 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositionRelationProcessor.java @@ -0,0 +1,12 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositionRelation; + +import tools.mdsd.mocore.framework.processor.RelationProcessor; + +public class CompositionRelationProcessor extends RelationProcessor { + public CompositionRelationProcessor(final PcmSurrogate model) { + super(model, CompositionRelation.class); + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/DeploymentDeploymentRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/DeploymentDeploymentRelationProcessor.java new file mode 100644 index 00000000..90ed13ed --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/DeploymentDeploymentRelationProcessor.java @@ -0,0 +1,64 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import java.util.List; +import java.util.Objects; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.LinkResourceSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.relation.DeploymentDeploymentRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.LinkResourceSpecificationRelation; + +import tools.mdsd.mocore.framework.processor.RelationProcessor; + +public class DeploymentDeploymentRelationProcessor + extends RelationProcessor { + public DeploymentDeploymentRelationProcessor(final PcmSurrogate model) { + super(model, DeploymentDeploymentRelation.class); + } + + @Override + protected void refine(final DeploymentDeploymentRelation discovery) { + // Check whether a linking resource specification already exists for the link to be merged + final List specifications = this.getModel() + .getByType(LinkResourceSpecificationRelation.class); + specifications.removeIf(specification -> !Objects.equals(discovery, specification.getDestination())); + if (specifications.isEmpty()) { + // Add implicit placeholder specification, if no specification is found for this + // deployment link + final LinkResourceSpecification placeholderSpecification = LinkResourceSpecification.getUniquePlaceholder(); + final LinkResourceSpecificationRelation implicitRelation = new LinkResourceSpecificationRelation( + placeholderSpecification, discovery, true); + this.addImplication(implicitRelation); + } + + super.refine(discovery); + } + + @Override + protected void replaceIndirectPlaceholders(final DeploymentDeploymentRelation discovery) { + /* + * TL;DR Indirect refinement of depl->depl relations is disabled because it leads to + * information loss. + * + * In a real system each component has to be allocated to a minimum of one container. + * Otherwise, the component is not a working part of the running system. As a consequence, a + * placeholder container is created for each component without a real container. This + * placeholder cannot be replaced by any depl->depl relation with the same source or + * destination because the replacement would also imply that the component of the container + * is deployed on the new "replacement" container. This may be true but is false in general. + * Therefore, the replacement of the placeholder container has to be triggered from a lower + * architectural "layer". + * + * Example: Let's assume we have two components called A and B. When we add A and B to the + * model, we also add a placeholder container A_Cont for A and B_Cont for B. Moreover, a + * component assembly called A->B is added to the model leading to a A_Cont<->B_Cont + * deployment relation. The resulting model is in a hazard-state due to the following + * problem: If we now add another deployment relation, B_Cont<->C_Cont for example, the + * indirect refinement would assume that C_Cont and A_Cont are the same and initiate the + * replacement of A_Cont to C_Cont. The implication of this replacement is that A and the + * components of C_Cont are deployed on the same container. In general, this implication is + * not true. Consequently, a replacement of A_Cont may only be initiated by a lower-level + * relation. In the PCM case this relation is the component allocation relation. + */ + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceProvisionRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceProvisionRelationProcessor.java new file mode 100644 index 00000000..c05c3de9 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceProvisionRelationProcessor.java @@ -0,0 +1,37 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import java.util.List; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAssemblyRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceRequirementRelation; + +import tools.mdsd.mocore.framework.processor.RelationProcessor; + +public class InterfaceProvisionRelationProcessor extends RelationProcessor { + public InterfaceProvisionRelationProcessor(final PcmSurrogate model) { + super(model, InterfaceProvisionRelation.class); + } + + @Override + protected void refine(final InterfaceProvisionRelation discovery) { + final Interface commonInterface = discovery.getDestination(); + + // Get all requirements from model & filter for same interface as in discovery + final List requirementRelations = this.getModel() + .getByType(InterfaceRequirementRelation.class); + requirementRelations.removeIf(relation -> !relation.getDestination() + .equals(commonInterface)); + + // Create component assembly placeholder for pairs of provision & requirement relations + for (final InterfaceRequirementRelation requirementRelation : requirementRelations) { + final ComponentAssemblyRelation assemblyRelation = new ComponentAssemblyRelation(discovery, + requirementRelation, true); + this.addImplication(assemblyRelation); + } + + super.refine(discovery); + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceRequirementRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceRequirementRelationProcessor.java new file mode 100644 index 00000000..31f3d9b0 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceRequirementRelationProcessor.java @@ -0,0 +1,38 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import java.util.List; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAssemblyRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceRequirementRelation; + +import tools.mdsd.mocore.framework.processor.RelationProcessor; + +public class InterfaceRequirementRelationProcessor + extends RelationProcessor { + public InterfaceRequirementRelationProcessor(final PcmSurrogate model) { + super(model, InterfaceRequirementRelation.class); + } + + @Override + protected void refine(final InterfaceRequirementRelation discovery) { + final Interface commonInterface = discovery.getDestination(); + + // Get all requirements from model & filter for same interface as in discovery + final List provisionRelations = this.getModel() + .getByType(InterfaceProvisionRelation.class); + provisionRelations.removeIf(relation -> !relation.getDestination() + .equals(commonInterface)); + + // Create component assembly placeholder for pairs of provision & requirement relations + for (final InterfaceProvisionRelation provisionRelation : provisionRelations) { + final ComponentAssemblyRelation assemblyRelation = new ComponentAssemblyRelation(provisionRelation, + discovery, true); + this.addImplication(assemblyRelation); + } + + super.refine(discovery); + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/LinkResourceSpecificationRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/LinkResourceSpecificationRelationProcessor.java new file mode 100644 index 00000000..a72cdb33 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/LinkResourceSpecificationRelationProcessor.java @@ -0,0 +1,13 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.relation.LinkResourceSpecificationRelation; + +import tools.mdsd.mocore.framework.processor.RelationProcessor; + +public class LinkResourceSpecificationRelationProcessor + extends RelationProcessor { + public LinkResourceSpecificationRelationProcessor(final PcmSurrogate model) { + super(model, LinkResourceSpecificationRelation.class); + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ServiceEffectSpecificationRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ServiceEffectSpecificationRelationProcessor.java new file mode 100644 index 00000000..140637e8 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/ServiceEffectSpecificationRelationProcessor.java @@ -0,0 +1,13 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ServiceEffectSpecificationRelation; + +import tools.mdsd.mocore.framework.processor.RelationProcessor; + +public class ServiceEffectSpecificationRelationProcessor + extends RelationProcessor { + public ServiceEffectSpecificationRelationProcessor(final PcmSurrogate model) { + super(model, ServiceEffectSpecificationRelation.class); + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/SignatureProvisionRelationProcessor.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/SignatureProvisionRelationProcessor.java new file mode 100644 index 00000000..5e9a66e3 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/processor/relation/SignatureProvisionRelationProcessor.java @@ -0,0 +1,12 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.relation.SignatureProvisionRelation; + +import tools.mdsd.mocore.framework.processor.RelationProcessor; + +public class SignatureProvisionRelationProcessor extends RelationProcessor { + public SignatureProvisionRelationProcessor(final PcmSurrogate model) { + super(model, SignatureProvisionRelation.class); + } +} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/PcmSurrogate.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/PcmSurrogate.java similarity index 68% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/PcmSurrogate.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/PcmSurrogate.java index 0c125866..04c1be15 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/PcmSurrogate.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/PcmSurrogate.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate; +package org.palladiosimulator.retriever.mocore.surrogate; import tools.mdsd.mocore.framework.surrogate.Model; diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/AtomicComponent.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/AtomicComponent.java new file mode 100644 index 00000000..ab380d72 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/AtomicComponent.java @@ -0,0 +1,22 @@ +package org.palladiosimulator.retriever.mocore.surrogate.element; + +import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; +import org.palladiosimulator.pcm.repository.BasicComponent; + +public class AtomicComponent extends Component { + public AtomicComponent(final BasicComponent value, final boolean isPlaceholder) { + super(value, isPlaceholder); + } + + public static AtomicComponent getNamedPlaceholder(final String name) { + final BasicComponent value = new FluentRepositoryFactory().newBasicComponent() + .withName(name) + .build(); + return new AtomicComponent(value, true); + } + + public static AtomicComponent getUniquePlaceholder() { + final String identifier = "Placeholder_" + getUniqueValue(); + return getNamedPlaceholder(identifier); + } +} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/Component.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Component.java similarity index 64% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/Component.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Component.java index 207b3141..8cdf6087 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/Component.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Component.java @@ -1,13 +1,13 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element; +package org.palladiosimulator.retriever.mocore.surrogate.element; import org.palladiosimulator.pcm.repository.RepositoryComponent; public class Component extends PcmElement { - public Component(T value, boolean isPlaceholder) { + public Component(final T value, final boolean isPlaceholder) { super(value, isPlaceholder); } - public static Component getNamedPlaceholder(String name) { + public static Component getNamedPlaceholder(final String name) { return AtomicComponent.getNamedPlaceholder(name); } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/Composite.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Composite.java similarity index 54% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/Composite.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Composite.java index 3947dd74..d20fccf9 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/Composite.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Composite.java @@ -1,17 +1,19 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element; +package org.palladiosimulator.retriever.mocore.surrogate.element; import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; import org.palladiosimulator.pcm.repository.CompositeComponent; import org.palladiosimulator.pcm.repository.RepositoryComponent; public class Composite extends Component { - public Composite(CompositeComponent value, boolean isPlaceholder) { + public Composite(final CompositeComponent value, final boolean isPlaceholder) { super(value, isPlaceholder); } public static Composite getUniquePlaceholder() { - String identifier = "Placeholder_" + getUniqueValue(); - RepositoryComponent value = new FluentRepositoryFactory().newCompositeComponent().withName(identifier).build(); + final String identifier = "Placeholder_" + getUniqueValue(); + final RepositoryComponent value = new FluentRepositoryFactory().newCompositeComponent() + .withName(identifier) + .build(); return new Composite((CompositeComponent) value, true); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/Deployment.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Deployment.java similarity index 55% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/Deployment.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Deployment.java index dcb8adc9..37b94f43 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/Deployment.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Deployment.java @@ -1,16 +1,16 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element; +package org.palladiosimulator.retriever.mocore.surrogate.element; import org.palladiosimulator.pcm.resourceenvironment.ResourceContainer; import org.palladiosimulator.pcm.resourceenvironment.ResourceenvironmentFactory; public class Deployment extends PcmElement { - public Deployment(ResourceContainer value, boolean isPlaceholder) { + public Deployment(final ResourceContainer value, final boolean isPlaceholder) { super(value, isPlaceholder); } public static Deployment getUniquePlaceholder() { - String identifier = "Placeholder_" + getUniqueValue(); - ResourceContainer value = ResourceenvironmentFactory.eINSTANCE.createResourceContainer(); + final String identifier = "Placeholder_" + getUniqueValue(); + final ResourceContainer value = ResourceenvironmentFactory.eINSTANCE.createResourceContainer(); value.setEntityName(identifier); return new Deployment(value, true); } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Interface.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Interface.java new file mode 100644 index 00000000..b6e8889a --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Interface.java @@ -0,0 +1,18 @@ +package org.palladiosimulator.retriever.mocore.surrogate.element; + +import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; +import org.palladiosimulator.pcm.repository.OperationInterface; + +public class Interface extends PcmElement { + public Interface(final OperationInterface value, final boolean isPlaceholder) { + super(value, isPlaceholder); + } + + public static Interface getUniquePlaceholder() { + final String identifier = "Placeholder_" + getUniqueValue(); + final OperationInterface value = new FluentRepositoryFactory().newOperationInterface() + .withName(identifier) + .build(); + return new Interface(value, true); + } +} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/LinkResourceSpecification.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/LinkResourceSpecification.java similarity index 54% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/LinkResourceSpecification.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/LinkResourceSpecification.java index c74e5058..93e75a4e 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/LinkResourceSpecification.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/LinkResourceSpecification.java @@ -1,19 +1,19 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element; +package org.palladiosimulator.retriever.mocore.surrogate.element; import org.palladiosimulator.pcm.resourceenvironment.CommunicationLinkResourceSpecification; import org.palladiosimulator.pcm.resourceenvironment.ResourceenvironmentFactory; public class LinkResourceSpecification extends PcmElement { - public LinkResourceSpecification(CommunicationLinkResourceSpecification value, boolean isPlaceholder) { + public LinkResourceSpecification(final CommunicationLinkResourceSpecification value, final boolean isPlaceholder) { super(value, isPlaceholder); } public static LinkResourceSpecification getUniquePlaceholder() { - String identifier = "Placeholder_" + getUniqueValue(); - double failureProbability = 0D; + final String identifier = "Placeholder_" + getUniqueValue(); + final double failureProbability = 0D; - CommunicationLinkResourceSpecification value = ResourceenvironmentFactory.eINSTANCE - .createCommunicationLinkResourceSpecification(); + final CommunicationLinkResourceSpecification value = ResourceenvironmentFactory.eINSTANCE + .createCommunicationLinkResourceSpecification(); value.setId(identifier); value.setFailureProbability(failureProbability); return new LinkResourceSpecification(value, true); diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/PcmElement.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/PcmElement.java similarity index 66% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/PcmElement.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/PcmElement.java index 95f4de41..ba395a71 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/PcmElement.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/PcmElement.java @@ -1,35 +1,36 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element; +package org.palladiosimulator.retriever.mocore.surrogate.element; import java.util.Objects; -import tools.mdsd.mocore.framework.surrogate.Element; - import de.uka.ipd.sdq.identifier.Identifier; +import tools.mdsd.mocore.framework.surrogate.Element; public abstract class PcmElement extends Element { - protected PcmElement(T value, boolean isPlaceholder) { + protected PcmElement(final T value, final boolean isPlaceholder) { super(value, isPlaceholder); } public String getIdentifier() { - return getValue().getId(); + return this.getValue() + .getId(); } @Override public int hashCode() { - String wrappedIdentifier = getValue().getId(); + final String wrappedIdentifier = this.getValue() + .getId(); return Objects.hash(this.isPlaceholder(), wrappedIdentifier); } @Override - public boolean equals(Object object) { + public boolean equals(final Object object) { if (this == object) { return true; } if (object == null || this.getClass() != object.getClass()) { return false; } - PcmElement element = (PcmElement) object; + final PcmElement element = (PcmElement) object; return Objects.equals(this.getIdentifier(), element.getIdentifier()) && (this.isPlaceholder() == element.isPlaceholder()); } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/ServiceEffectSpecification.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/ServiceEffectSpecification.java new file mode 100644 index 00000000..90d60d4a --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/ServiceEffectSpecification.java @@ -0,0 +1,21 @@ +package org.palladiosimulator.retriever.mocore.surrogate.element; + +import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; +import org.palladiosimulator.pcm.seff.ResourceDemandingSEFF; + +public class ServiceEffectSpecification extends PcmElement { + public ServiceEffectSpecification(final ResourceDemandingSEFF value, final boolean isPlaceholder) { + super(value, isPlaceholder); + } + + public static ServiceEffectSpecification getUniquePlaceholder() { + final ResourceDemandingSEFF value = new FluentRepositoryFactory().newSeff() + .withSeffBehaviour() + .withStartAction() + .followedBy() + .stopAction() + .createBehaviourNow() + .buildRDSeff(); + return new ServiceEffectSpecification(value, true); + } +} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/Signature.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Signature.java similarity index 54% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/Signature.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Signature.java index 8ac8dfa1..30a8cba2 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/Signature.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/element/Signature.java @@ -1,16 +1,16 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element; +package org.palladiosimulator.retriever.mocore.surrogate.element; import org.palladiosimulator.pcm.repository.OperationSignature; import org.palladiosimulator.pcm.repository.RepositoryFactory; public class Signature extends PcmElement { - public Signature(OperationSignature value, boolean isPlaceholder) { + public Signature(final OperationSignature value, final boolean isPlaceholder) { super(value, isPlaceholder); } public static Signature getUniquePlaceholder() { - String identifier = "Placeholder_" + getUniqueValue(); - OperationSignature value = RepositoryFactory.eINSTANCE.createOperationSignature(); + final String identifier = "Placeholder_" + getUniqueValue(); + final OperationSignature value = RepositoryFactory.eINSTANCE.createOperationSignature(); value.setEntityName(identifier); return new Signature(value, true); } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentAllocationRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAllocationRelation.java similarity index 54% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentAllocationRelation.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAllocationRelation.java index 1fd96f06..504e3395 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentAllocationRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAllocationRelation.java @@ -1,18 +1,19 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; import tools.mdsd.mocore.framework.surrogate.Relation; import tools.mdsd.mocore.framework.surrogate.Replaceable; public class ComponentAllocationRelation extends Relation, Deployment> { - public ComponentAllocationRelation(Component source, Deployment destination, boolean isPlaceholder) { + public ComponentAllocationRelation(final Component source, final Deployment destination, + final boolean isPlaceholder) { super(source, destination, isPlaceholder); } @Override - public ComponentAllocationRelation replace(U original, U replacement) { + public ComponentAllocationRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -20,8 +21,8 @@ public ComponentAllocationRelation replace(U original, U if (this.equals(original)) { return (ComponentAllocationRelation) replacement; } - Component source = getSourceReplacement(original, replacement); - Deployment destination = getDestinationReplacement(original, replacement); + final Component source = this.getSourceReplacement(original, replacement); + final Deployment destination = this.getDestinationReplacement(original, replacement); return new ComponentAllocationRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentAssemblyRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAssemblyRelation.java similarity index 67% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentAssemblyRelation.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAssemblyRelation.java index 7f8c48b7..a40ede21 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentAssemblyRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAssemblyRelation.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; import java.util.Objects; @@ -8,8 +8,8 @@ public class ComponentAssemblyRelation extends Relation { private static final String ERROR_UNEQUAL_INTERFACE = "Interfaces of relations have to be equal."; - public ComponentAssemblyRelation(InterfaceProvisionRelation source, InterfaceRequirementRelation destination, - boolean isPlaceholder) { + public ComponentAssemblyRelation(final InterfaceProvisionRelation source, + final InterfaceRequirementRelation destination, final boolean isPlaceholder) { super(source, destination, isPlaceholder); if (!Objects.equals(source.getDestination(), destination.getDestination())) { throw new IllegalArgumentException(ERROR_UNEQUAL_INTERFACE); @@ -17,7 +17,7 @@ public ComponentAssemblyRelation(InterfaceProvisionRelation source, InterfaceReq } @Override - public ComponentAssemblyRelation replace(U original, U replacement) { + public ComponentAssemblyRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -25,8 +25,8 @@ public ComponentAssemblyRelation replace(U original, U r if (this.equals(original)) { return (ComponentAssemblyRelation) replacement; } - InterfaceProvisionRelation source = getSourceReplacement(original, replacement); - InterfaceRequirementRelation destination = getDestinationReplacement(original, replacement); + final InterfaceProvisionRelation source = this.getSourceReplacement(original, replacement); + final InterfaceRequirementRelation destination = this.getDestinationReplacement(original, replacement); return new ComponentAssemblyRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentSignatureProvisionRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentSignatureProvisionRelation.java similarity index 58% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentSignatureProvisionRelation.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentSignatureProvisionRelation.java index 19b53995..f6e32a8a 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentSignatureProvisionRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentSignatureProvisionRelation.java @@ -1,15 +1,16 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; import java.util.Objects; import tools.mdsd.mocore.framework.surrogate.Relation; import tools.mdsd.mocore.framework.surrogate.Replaceable; -public class ComponentSignatureProvisionRelation extends Relation { +public class ComponentSignatureProvisionRelation + extends Relation { private static final String ERROR_UNEQUAL_INTERFACE = "Interfaces of relations have to be equal."; - public ComponentSignatureProvisionRelation(InterfaceProvisionRelation source, SignatureProvisionRelation destination, - boolean isPlaceholder) { + public ComponentSignatureProvisionRelation(final InterfaceProvisionRelation source, + final SignatureProvisionRelation destination, final boolean isPlaceholder) { super(source, destination, isPlaceholder); if (!Objects.equals(source.getDestination(), destination.getDestination())) { throw new IllegalArgumentException(ERROR_UNEQUAL_INTERFACE); @@ -17,7 +18,7 @@ public ComponentSignatureProvisionRelation(InterfaceProvisionRelation source, Si } @Override - public ComponentSignatureProvisionRelation replace(U original, U replacement) { + public ComponentSignatureProvisionRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -25,8 +26,8 @@ public ComponentSignatureProvisionRelation replace(U ori if (this.equals(original)) { return (ComponentSignatureProvisionRelation) replacement; } - InterfaceProvisionRelation source = getSourceReplacement(original, replacement); - SignatureProvisionRelation destination = getDestinationReplacement(original, replacement); + final InterfaceProvisionRelation source = this.getSourceReplacement(original, replacement); + final SignatureProvisionRelation destination = this.getDestinationReplacement(original, replacement); return new ComponentSignatureProvisionRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositeProvisionDelegationRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeProvisionDelegationRelation.java similarity index 70% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositeProvisionDelegationRelation.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeProvisionDelegationRelation.java index 73720f14..da5fce14 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositeProvisionDelegationRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeProvisionDelegationRelation.java @@ -1,6 +1,6 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Composite; +import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; import tools.mdsd.mocore.framework.surrogate.Relation; import tools.mdsd.mocore.framework.surrogate.Replaceable; @@ -11,9 +11,8 @@ public class CompositeProvisionDelegationRelation private static final String ERROR_SAME_RELATION = "Delegations may not exist between equal source and destination."; private static final String ERROR_NON_EQUAL_INTERFACES = "Interfaces of the given relations must be equal."; - public CompositeProvisionDelegationRelation(InterfaceProvisionRelation source, - InterfaceProvisionRelation destination, - boolean isPlaceholder) { + public CompositeProvisionDelegationRelation(final InterfaceProvisionRelation source, + final InterfaceProvisionRelation destination, final boolean isPlaceholder) { super(source, destination, isPlaceholder); // Check whether relations are equal @@ -22,19 +21,21 @@ public CompositeProvisionDelegationRelation(InterfaceProvisionRelation source, } // Check whether the delegating component is a composite - if (!Composite.class.isAssignableFrom(source.getSource().getClass())) { + if (!Composite.class.isAssignableFrom(source.getSource() + .getClass())) { throw new IllegalArgumentException(ERROR_NOT_COMPOSITE); } // Check whether interfaces are equal - if (!source.getDestination().equals(destination.getDestination())) { + if (!source.getDestination() + .equals(destination.getDestination())) { // TODO Allow child/parent interfaces throw new IllegalArgumentException(ERROR_NON_EQUAL_INTERFACES); } } @Override - public CompositeProvisionDelegationRelation replace(T original, T replacement) { + public CompositeProvisionDelegationRelation replace(final T original, final T replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -42,8 +43,8 @@ public CompositeProvisionDelegationRelation replace(T or if (this.equals(original)) { return (CompositeProvisionDelegationRelation) replacement; } - InterfaceProvisionRelation source = getSourceReplacement(original, replacement); - InterfaceProvisionRelation destination = getDestinationReplacement(original, replacement); + final InterfaceProvisionRelation source = this.getSourceReplacement(original, replacement); + final InterfaceProvisionRelation destination = this.getDestinationReplacement(original, replacement); return new CompositeProvisionDelegationRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositeRequirementDelegationRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeRequirementDelegationRelation.java similarity index 69% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositeRequirementDelegationRelation.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeRequirementDelegationRelation.java index e434bbe5..63a2d7f7 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositeRequirementDelegationRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeRequirementDelegationRelation.java @@ -1,6 +1,6 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Composite; +import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; import tools.mdsd.mocore.framework.surrogate.Relation; import tools.mdsd.mocore.framework.surrogate.Replaceable; @@ -11,9 +11,8 @@ public class CompositeRequirementDelegationRelation private static final String ERROR_SAME_RELATION = "Delegations may not exist between equal source and destination."; private static final String ERROR_NON_EQUAL_INTERFACES = "Interfaces of the given relations must be equal."; - public CompositeRequirementDelegationRelation(InterfaceRequirementRelation source, - InterfaceRequirementRelation destination, - boolean isPlaceholder) { + public CompositeRequirementDelegationRelation(final InterfaceRequirementRelation source, + final InterfaceRequirementRelation destination, final boolean isPlaceholder) { super(source, destination, isPlaceholder); // Check whether relations are equal @@ -22,19 +21,22 @@ public CompositeRequirementDelegationRelation(InterfaceRequirementRelation sourc } // Check whether the delegating component is a composite - if (!Composite.class.isAssignableFrom(source.getSource().getClass())) { + if (!Composite.class.isAssignableFrom(source.getSource() + .getClass())) { throw new IllegalArgumentException(ERROR_NOT_COMPOSITE); } // Check whether interfaces are equal - if (!source.getDestination().equals(destination.getDestination())) { + if (!source.getDestination() + .equals(destination.getDestination())) { // TODO Allow child/parent interfaces throw new IllegalArgumentException(ERROR_NON_EQUAL_INTERFACES); } } @Override - public CompositeRequirementDelegationRelation replace(T original, T replacement) { + public CompositeRequirementDelegationRelation replace(final T original, + final T replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -42,8 +44,8 @@ public CompositeRequirementDelegationRelation replace(T if (this.equals(original)) { return (CompositeRequirementDelegationRelation) replacement; } - InterfaceRequirementRelation source = getSourceReplacement(original, replacement); - InterfaceRequirementRelation destination = getDestinationReplacement(original, replacement); + final InterfaceRequirementRelation source = this.getSourceReplacement(original, replacement); + final InterfaceRequirementRelation destination = this.getDestinationReplacement(original, replacement); return new CompositeRequirementDelegationRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositionRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositionRelation.java new file mode 100644 index 00000000..8c33e5c1 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositionRelation.java @@ -0,0 +1,27 @@ +package org.palladiosimulator.retriever.mocore.surrogate.relation; + +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; + +import tools.mdsd.mocore.framework.surrogate.Relation; +import tools.mdsd.mocore.framework.surrogate.Replaceable; + +public class CompositionRelation extends Relation> { + public CompositionRelation(final Composite source, final Component destination, final boolean isPlaceholder) { + super(source, destination, isPlaceholder); + } + + @Override + public CompositionRelation replace(final T original, final T replacement) { + if (!this.includes(original)) { + // TODO Add message to exception + throw new IllegalArgumentException(); + } + if (this.equals(original)) { + return (CompositionRelation) replacement; + } + final Composite source = this.getSourceReplacement(original, replacement); + final Component destination = this.getDestinationReplacement(original, replacement); + return new CompositionRelation(source, destination, this.isPlaceholder()); + } +} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/DeploymentDeploymentRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/DeploymentDeploymentRelation.java similarity index 57% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/DeploymentDeploymentRelation.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/DeploymentDeploymentRelation.java index e5c72342..f9fba80b 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/DeploymentDeploymentRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/DeploymentDeploymentRelation.java @@ -1,17 +1,18 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; import tools.mdsd.mocore.framework.surrogate.Relation; import tools.mdsd.mocore.framework.surrogate.Replaceable; public class DeploymentDeploymentRelation extends Relation { - public DeploymentDeploymentRelation(Deployment source, Deployment destination, boolean isPlaceholder) { + public DeploymentDeploymentRelation(final Deployment source, final Deployment destination, + final boolean isPlaceholder) { super(source, destination, isPlaceholder); } @Override - public DeploymentDeploymentRelation replace(U original, U replacement) { + public DeploymentDeploymentRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -19,8 +20,8 @@ public DeploymentDeploymentRelation replace(U original, if (this.equals(original)) { return (DeploymentDeploymentRelation) replacement; } - Deployment source = getSourceReplacement(original, replacement); - Deployment destination = getDestinationReplacement(original, replacement); + final Deployment source = this.getSourceReplacement(original, replacement); + final Deployment destination = this.getDestinationReplacement(original, replacement); return new DeploymentDeploymentRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/InterfaceProvisionRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceProvisionRelation.java similarity index 54% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/InterfaceProvisionRelation.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceProvisionRelation.java index 0d7d3129..44fc65f9 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/InterfaceProvisionRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceProvisionRelation.java @@ -1,18 +1,19 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; import tools.mdsd.mocore.framework.surrogate.Relation; import tools.mdsd.mocore.framework.surrogate.Replaceable; public class InterfaceProvisionRelation extends Relation, Interface> { - public InterfaceProvisionRelation(Component source, Interface destination, boolean isPlaceholder) { + public InterfaceProvisionRelation(final Component source, final Interface destination, + final boolean isPlaceholder) { super(source, destination, isPlaceholder); } @Override - public InterfaceProvisionRelation replace(U original, U replacement) { + public InterfaceProvisionRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -20,8 +21,8 @@ public InterfaceProvisionRelation replace(U original, U if (this.equals(original)) { return (InterfaceProvisionRelation) replacement; } - Component source = getSourceReplacement(original, replacement); - Interface destination = getDestinationReplacement(original, replacement); + final Component source = this.getSourceReplacement(original, replacement); + final Interface destination = this.getDestinationReplacement(original, replacement); return new InterfaceProvisionRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/InterfaceRequirementRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceRequirementRelation.java similarity index 54% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/InterfaceRequirementRelation.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceRequirementRelation.java index 9a09c5e3..41ea1845 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/InterfaceRequirementRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceRequirementRelation.java @@ -1,18 +1,19 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; import tools.mdsd.mocore.framework.surrogate.Relation; import tools.mdsd.mocore.framework.surrogate.Replaceable; public class InterfaceRequirementRelation extends Relation, Interface> { - public InterfaceRequirementRelation(Component source, Interface destination, boolean isPlaceholder) { + public InterfaceRequirementRelation(final Component source, final Interface destination, + final boolean isPlaceholder) { super(source, destination, isPlaceholder); } @Override - public InterfaceRequirementRelation replace(U original, U replacement) { + public InterfaceRequirementRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -20,8 +21,8 @@ public InterfaceRequirementRelation replace(U original, if (this.equals(original)) { return (InterfaceRequirementRelation) replacement; } - Component source = getSourceReplacement(original, replacement); - Interface destination = getDestinationReplacement(original, replacement); + final Component source = this.getSourceReplacement(original, replacement); + final Interface destination = this.getDestinationReplacement(original, replacement); return new InterfaceRequirementRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/LinkResourceSpecificationRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/LinkResourceSpecificationRelation.java similarity index 55% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/LinkResourceSpecificationRelation.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/LinkResourceSpecificationRelation.java index 3f0651b3..7ef0d41d 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/LinkResourceSpecificationRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/LinkResourceSpecificationRelation.java @@ -1,19 +1,19 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.LinkResourceSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.element.LinkResourceSpecification; import tools.mdsd.mocore.framework.surrogate.Relation; import tools.mdsd.mocore.framework.surrogate.Replaceable; public class LinkResourceSpecificationRelation extends Relation { - public LinkResourceSpecificationRelation(LinkResourceSpecification source, DeploymentDeploymentRelation destination, - boolean isPlaceholder) { + public LinkResourceSpecificationRelation(final LinkResourceSpecification source, + final DeploymentDeploymentRelation destination, final boolean isPlaceholder) { super(source, destination, isPlaceholder); } @Override - public LinkResourceSpecificationRelation replace(U original, U replacement) { + public LinkResourceSpecificationRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -21,8 +21,8 @@ public LinkResourceSpecificationRelation replace(U origi if (this.equals(original)) { return (LinkResourceSpecificationRelation) replacement; } - LinkResourceSpecification source = getSourceReplacement(original, replacement); - DeploymentDeploymentRelation destination = getDestinationReplacement(original, replacement); + final LinkResourceSpecification source = this.getSourceReplacement(original, replacement); + final DeploymentDeploymentRelation destination = this.getDestinationReplacement(original, replacement); return new LinkResourceSpecificationRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ServiceEffectSpecificationRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ServiceEffectSpecificationRelation.java similarity index 55% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ServiceEffectSpecificationRelation.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ServiceEffectSpecificationRelation.java index b11817e6..2300af9d 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ServiceEffectSpecificationRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ServiceEffectSpecificationRelation.java @@ -1,20 +1,19 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.ServiceEffectSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.element.ServiceEffectSpecification; import tools.mdsd.mocore.framework.surrogate.Relation; import tools.mdsd.mocore.framework.surrogate.Replaceable; public class ServiceEffectSpecificationRelation extends Relation { - public ServiceEffectSpecificationRelation(ComponentSignatureProvisionRelation source, - ServiceEffectSpecification destination, - boolean isPlaceholder) { + public ServiceEffectSpecificationRelation(final ComponentSignatureProvisionRelation source, + final ServiceEffectSpecification destination, final boolean isPlaceholder) { super(source, destination, isPlaceholder); } @Override - public ServiceEffectSpecificationRelation replace(U original, U replacement) { + public ServiceEffectSpecificationRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -22,8 +21,8 @@ public ServiceEffectSpecificationRelation replace(U orig if (this.equals(original)) { return (ServiceEffectSpecificationRelation) replacement; } - ComponentSignatureProvisionRelation source = getSourceReplacement(original, replacement); - ServiceEffectSpecification destination = getDestinationReplacement(original, replacement); + final ComponentSignatureProvisionRelation source = this.getSourceReplacement(original, replacement); + final ServiceEffectSpecification destination = this.getDestinationReplacement(original, replacement); return new ServiceEffectSpecificationRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/SignatureProvisionRelation.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/SignatureProvisionRelation.java similarity index 54% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/SignatureProvisionRelation.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/SignatureProvisionRelation.java index 16e3d652..adb8bc2a 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/SignatureProvisionRelation.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/surrogate/relation/SignatureProvisionRelation.java @@ -1,18 +1,19 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Signature; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.Signature; import tools.mdsd.mocore.framework.surrogate.Relation; import tools.mdsd.mocore.framework.surrogate.Replaceable; public class SignatureProvisionRelation extends Relation { - public SignatureProvisionRelation(Signature source, Interface destination, boolean isPlaceholder) { + public SignatureProvisionRelation(final Signature source, final Interface destination, + final boolean isPlaceholder) { super(source, destination, isPlaceholder); } @Override - public SignatureProvisionRelation replace(U original, U replacement) { + public SignatureProvisionRelation replace(final U original, final U replacement) { if (!this.includes(original)) { // TODO Add message to exception throw new IllegalArgumentException(); @@ -20,8 +21,8 @@ public SignatureProvisionRelation replace(U original, U if (this.equals(original)) { return (SignatureProvisionRelation) replacement; } - Signature source = getSourceReplacement(original, replacement); - Interface destination = getDestinationReplacement(original, replacement); + final Signature source = this.getSourceReplacement(original, replacement); + final Interface destination = this.getDestinationReplacement(original, replacement); return new SignatureProvisionRelation(source, destination, this.isPlaceholder()); } } diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/AllocationTransformer.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/AllocationTransformer.java new file mode 100644 index 00000000..908974b1 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/AllocationTransformer.java @@ -0,0 +1,56 @@ +package org.palladiosimulator.retriever.mocore.transformation; + +import java.util.List; + +import org.palladiosimulator.generator.fluent.allocation.api.IAllocationAddition; +import org.palladiosimulator.generator.fluent.allocation.factory.FluentAllocationFactory; +import org.palladiosimulator.generator.fluent.allocation.structure.AllocationContextCreator; +import org.palladiosimulator.pcm.allocation.Allocation; +import org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment; +import org.palladiosimulator.pcm.system.System; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAllocationRelation; + +import tools.mdsd.mocore.framework.transformation.Transformer; + +public class AllocationTransformer implements Transformer { + @Override + public Allocation transform(final PcmSurrogate model) { + final System system = new SystemTransformer().transform(model); + final ResourceEnvironment resourceEnvironment = new ResourceEnvironmentTransformer().transform(model); + return this.transform(model, system, resourceEnvironment); + } + + public Allocation transform(final PcmSurrogate model, final System system, + final ResourceEnvironment resourceEnvironment) { + final FluentAllocationFactory allocationFactory = new FluentAllocationFactory(); + final IAllocationAddition fluentAllocation = allocationFactory.newAllocation() + .withSystem(system) + .withResourceEnvironment(resourceEnvironment); + + // Add allocation contexts to allocation + final List relations = model.getByType(ComponentAllocationRelation.class); + for (final ComponentAllocationRelation relation : relations) { + // Get and add context (creator) for specific allocation relation + final AllocationContextCreator contextCreator = this.getCreator(allocationFactory, relation); + fluentAllocation.addToAllocation(contextCreator); + } + + return fluentAllocation.createAllocationNow(); + } + + private AllocationContextCreator getCreator(final FluentAllocationFactory fluentFactory, + final ComponentAllocationRelation relation) { + final AllocationContextCreator contextCreator = fluentFactory.newAllocationContext(); + + // Use name of entities to fetch up-to-date entities from system and resource environment + final String assemblyContextName = SystemTransformer.getAssemblyContextName(relation.getSource()); + final String deploymentEntityName = relation.getDestination() + .getValue() + .getEntityName(); + contextCreator.withAssemblyContext(assemblyContextName) + .withResourceContainer(deploymentEntityName); + + return contextCreator; + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/RepositoryTransformer.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/RepositoryTransformer.java new file mode 100644 index 00000000..7fde0d43 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/RepositoryTransformer.java @@ -0,0 +1,694 @@ +package org.palladiosimulator.retriever.mocore.transformation; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; +import org.palladiosimulator.generator.fluent.repository.api.Repo; +import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; +import org.palladiosimulator.generator.fluent.repository.structure.components.BasicComponentCreator; +import org.palladiosimulator.generator.fluent.repository.structure.components.CompositeComponentCreator; +import org.palladiosimulator.generator.fluent.repository.structure.interfaces.OperationInterfaceCreator; +import org.palladiosimulator.pcm.core.composition.AssemblyConnector; +import org.palladiosimulator.pcm.core.composition.AssemblyContext; +import org.palladiosimulator.pcm.core.composition.CompositionFactory; +import org.palladiosimulator.pcm.core.composition.ProvidedDelegationConnector; +import org.palladiosimulator.pcm.core.composition.RequiredDelegationConnector; +import org.palladiosimulator.pcm.repository.BasicComponent; +import org.palladiosimulator.pcm.repository.CompositeComponent; +import org.palladiosimulator.pcm.repository.OperationInterface; +import org.palladiosimulator.pcm.repository.OperationProvidedRole; +import org.palladiosimulator.pcm.repository.OperationRequiredRole; +import org.palladiosimulator.pcm.repository.OperationSignature; +import org.palladiosimulator.pcm.repository.Repository; +import org.palladiosimulator.pcm.repository.RepositoryComponent; +import org.palladiosimulator.pcm.seff.AbstractAction; +import org.palladiosimulator.pcm.seff.ExternalCallAction; +import org.palladiosimulator.pcm.seff.ResourceDemandingSEFF; +import org.palladiosimulator.pcm.seff.ServiceEffectSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.AtomicComponent; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.Signature; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAssemblyRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositeProvisionDelegationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositeRequirementDelegationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceRequirementRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ServiceEffectSpecificationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.SignatureProvisionRelation; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; + +import tools.mdsd.mocore.framework.transformation.Transformer; + +public class RepositoryTransformer implements Transformer { + private static final Logger LOG = Logger.getLogger(RepositoryTransformer.class); + + private static final String DELEGATION_EXCLUSION_NAME_PATTERN = "%s"; + private static final String ROLE_PROVIDES_NAME_PATTERN = "%s Provider"; + private static final String ROLE_REQUIRES_NAME_PATTERN = "%s Consumer"; + + @Override + public Repository transform(final PcmSurrogate model) { + final FluentRepositoryFactory repositoryFactory = new FluentRepositoryFactory(); + final Repo fluentRepository = repositoryFactory.newRepository(); + + final List seffRelations = model + .getByType(ServiceEffectSpecificationRelation.class); + List provisionRelations = model.getByType(InterfaceProvisionRelation.class); + final List requirementRelations = model + .getByType(InterfaceRequirementRelation.class); + final List signatureRelations = model.getByType(SignatureProvisionRelation.class); + final List interfaces = model.getByType(Interface.class); + + // Add interfaces to fluent repository + for (final Interface interfaceInstance : interfaces) { + final OperationInterfaceCreator interfaceCreator = this.getCreator(repositoryFactory, interfaceInstance); + + // Add interface to repository and fetch built interface + fluentRepository.addToRepository(interfaceCreator); + final OperationInterface repositoryInterface = repositoryFactory + .fetchOfOperationInterface(interfaceInstance.getValue() + .getEntityName()); + + // Add signatures to the added interface directly + // Avoids the creation of signature creator and tight coupling to fluentApi + for (final SignatureProvisionRelation relation : signatureRelations) { + if (relation.getDestination() + .equals(interfaceInstance)) { + final Signature signature = relation.getSource(); + signature.getValue() + .setInterface__OperationSignature(repositoryInterface); + } + } + } + + // Add basic components with their roles and seff to fluent repository + for (final AtomicComponent component : model.getByType(AtomicComponent.class)) { + final BasicComponentCreator componentCreator = this.getCreator(repositoryFactory, component); + + // Add provided interfaces + for (final InterfaceProvisionRelation relation : provisionRelations) { + final Interface interfaceInstance = relation.getDestination(); + if (relation.getSource() + .equals(component)) { + final String interfaceName = interfaceInstance.getValue() + .getEntityName(); + final OperationInterface operationInterface = repositoryFactory + .fetchOfOperationInterface(interfaceName); + componentCreator.provides(operationInterface, getProvidedRoleName(interfaceInstance)); + } + } + + // Add required interfaces + for (final InterfaceRequirementRelation relation : requirementRelations) { + final Interface interfaceInstance = relation.getDestination(); + if (relation.getSource() + .equals(component)) { + final String interfaceName = interfaceInstance.getValue() + .getEntityName(); + final OperationInterface operationInterface = repositoryFactory + .fetchOfOperationInterface(interfaceName); + componentCreator.requires(operationInterface, getRequiredRoleName(interfaceInstance)); + } + } + + // Build component to make changes that are unsupported by fluent api + final BasicComponent repositoryComponent = componentCreator.build(); + + // Add service effect specifications to component + // For each provided interface, iterate over each signature of interface and add seff if + // it exists + for (final InterfaceProvisionRelation interfaceProvision : provisionRelations) { + if (interfaceProvision.getSource() + .equals(component)) { + final OperationInterface operationInterface = repositoryFactory + .fetchOfOperationInterface(interfaceProvision.getDestination() + .getValue() + .getEntityName()); + for (final OperationSignature signature : operationInterface.getSignatures__OperationInterface()) { + // Get seff entity for specific signature in interface + final Predicate filter = relation -> { + final Signature wrappedSignature = relation.getSource() + .getDestination() + .getSource(); + final Interface wrappedInterface = relation.getSource() + .getSource() + .getDestination(); + return representSameSignature(signature, wrappedSignature.getValue()) + && representSameInterface(operationInterface, wrappedInterface.getValue()); + }; + final ServiceEffectSpecification seff = seffRelations.stream() + .filter(relation -> relation.getSource() + .getSource() + .getSource() + .equals(component)) + .filter(filter) + .map(relation -> relation.getDestination() + .getValue()) + .findFirst() + .orElse(org.palladiosimulator.retriever.mocore.surrogate.element.ServiceEffectSpecification + .getUniquePlaceholder() + .getValue()); + + // Reset component and signature within seff because they may be out-dated + seff.setBasicComponent_ServiceEffectSpecification(repositoryComponent); + seff.setDescribedService__SEFF(signature); + + // Fix changed identifier of required roles in external call actions + if (seff instanceof ResourceDemandingSEFF) { + final ResourceDemandingSEFF rdSeff = (ResourceDemandingSEFF) seff; + final EList behavior = rdSeff.getSteps_Behaviour(); + final List externalCallActions = behavior.stream() + .filter(action -> action instanceof ExternalCallAction) + .map(action -> (ExternalCallAction) action) + .collect(Collectors.toList()); + + for (final ExternalCallAction externalCallAction : externalCallActions) { + final OperationSignature externalSignature = externalCallAction + .getCalledService_ExternalService(); + + // Get required role containing called signature of + // externalCallAction from component + final Optional requiredRoleOption = repositoryComponent + .getRequiredRoles_InterfaceRequiringEntity() + .stream() + .filter(role -> role instanceof OperationRequiredRole) + .map(role -> (OperationRequiredRole) role) + .filter(role -> role.getRequiredInterface__OperationRequiredRole() + .getSignatures__OperationInterface() + .contains(externalSignature)) + .findFirst(); + if (requiredRoleOption.isEmpty()) { + LOG.warn( + "Failed to find required role for external call to " + + externalSignature.getInterface__OperationSignature() + .getEntityName() + + "#" + externalSignature.getEntityName() + "!"); + continue; + } + final OperationRequiredRole requiredRole = requiredRoleOption.get(); + + // Set role in external call action to fetched required role + externalCallAction.setRole_ExternalService(requiredRole); + } + } + } + } + } + + // Add created basic component with roles and seff to repository + fluentRepository.addToRepository(repositoryComponent); + } + + // Add implicitly provided interfaces of composites to model (non-required interface of + // child). + // Problem: This has to happen from innermost to outermost component. -> Sorted by + // dependency. + // First step: Get children of each composite + final List compositionRelations = model.getByType(CompositionRelation.class); + final List composites = model.getByType(Composite.class); + final Multimap> compositesChildren = HashMultimap.create(); + for (final Composite composite : composites) { + final List> children = compositionRelations.stream() + .filter(relation -> relation.getSource() + .equals(composite)) + .map(relation -> relation.getDestination()) + .collect(Collectors.toList()); + compositesChildren.putAll(composite, children); + } + // Second step: Sort composites + final List sortedComposites = new LinkedList<>(composites); + sortedComposites.sort((a, b) -> this.compareComposites(a, b, compositesChildren)); + // Third step: Get non-required interfaces & their providers + final List nonRequiredProvisionRelations = new LinkedList<>(provisionRelations); + nonRequiredProvisionRelations.removeIf(provisionRelation -> requirementRelations.stream() + .anyMatch(requirementRelation -> requirementRelation.getDestination() + .equals(provisionRelation.getDestination()))); + // Fourth step: Provide non-required interface of children & add delegation + for (final Composite composite : sortedComposites) { + for (int i = 0; i < nonRequiredProvisionRelations.size(); i++) { + // Access via index due to concurrent modification -> New last element might be + // added to list + final InterfaceProvisionRelation nonRequiredProvision = nonRequiredProvisionRelations.get(i); + final Component provider = nonRequiredProvision.getSource(); + final Interface providedInterface = nonRequiredProvision.getDestination(); + + // Only add if provider is direct child of composite + if (this.isDirectChild(provider, composite, compositesChildren)) { + // Check whether delegation already exists in model + boolean existsDelegation = false; + for (final CompositeProvisionDelegationRelation delegationRelation : model + .getByType(CompositeProvisionDelegationRelation.class)) { + if (delegationRelation.getDestination() + .equals(nonRequiredProvision) + && delegationRelation.getSource() + .getSource() + .equals(composite)) { + existsDelegation = true; + break; + } + } + + // Check whether interface should be excluded from recursive delegation + final boolean excludeDelegation = isExcludedFromDelegation(provider, providedInterface); + + if (!existsDelegation && !excludeDelegation) { + // Check whether interface provision already exists + InterfaceProvisionRelation provisionRelation = null; + for (final InterfaceProvisionRelation provision : provisionRelations) { + if (provision.getSource() + .equals(composite) + && provision.getDestination() + .equals(providedInterface)) { + provisionRelation = provision; + } + } + // Create new provision if it does not exist yet + if (Objects.isNull(provisionRelation)) { + provisionRelation = new InterfaceProvisionRelation(composite, providedInterface, true); + + // Add to model and refresh already fetched relations + model.add(provisionRelation); + nonRequiredProvisionRelations.add(provisionRelation); + provisionRelations = model.getByType(InterfaceProvisionRelation.class); + } + + // Add provided delegation connector + final CompositeProvisionDelegationRelation provisionDelegation = new CompositeProvisionDelegationRelation( + provisionRelation, nonRequiredProvision, true); + model.add(provisionDelegation); + } + } + } + } + + // Add composite components with their roles to fluent repository + for (final Composite composite : composites) { + final CompositeComponentCreator compositeCreator = this.getCreator(repositoryFactory, composite); + + // Add explicitly provided interfaces + for (final InterfaceProvisionRelation relation : provisionRelations) { + final Interface interfaceInstance = relation.getDestination(); + if (relation.getSource() + .equals(composite)) { + final String interfaceName = interfaceInstance.getValue() + .getEntityName(); + final OperationInterface operationInterface = repositoryFactory + .fetchOfOperationInterface(interfaceName); + compositeCreator.provides(operationInterface, getProvidedRoleName(interfaceInstance)); + } + } + + // Add required interfaces + for (final InterfaceRequirementRelation relation : requirementRelations) { + final Interface interfaceInstance = relation.getDestination(); + if (relation.getSource() + .equals(composite)) { + final String interfaceName = interfaceInstance.getValue() + .getEntityName(); + final OperationInterface operationInterface = repositoryFactory + .fetchOfOperationInterface(interfaceName); + compositeCreator.requires(operationInterface, getRequiredRoleName(interfaceInstance)); + } + } + + // Add composite to fluent repository + fluentRepository.addToRepository(compositeCreator); + } + + // Add compositions to repository -> All composites & composites have to be added beforehand + for (final CompositionRelation relation : compositionRelations) { + final Composite composite = relation.getSource(); + final Component destination = relation.getDestination(); + + // Fetch composite from repository + final CompositeComponent persistedCompositeComponent = repositoryFactory + .fetchOfCompositeComponent(composite.getValue() + .getEntityName()); + persistedCompositeComponent.getAssemblyContexts__ComposedStructure(); + + // Fetch composite child from repository & create temporary fluent creator + final CompositeComponentCreator temporaryCreator = repositoryFactory.newCompositeComponent(); + if (destination instanceof AtomicComponent) { + temporaryCreator.withAssemblyContext(repositoryFactory.fetchOfBasicComponent(destination.getValue() + .getEntityName())); + } else if (destination instanceof Composite) { + temporaryCreator.withAssemblyContext(repositoryFactory.fetchOfCompositeComponent(destination.getValue() + .getEntityName())); + } + + // Copy assembly contexts from temporary to persisted composite + final CompositeComponent temporaryComposite = (CompositeComponent) temporaryCreator.build(); + persistedCompositeComponent.getAssemblyContexts__ComposedStructure() + .addAll(temporaryComposite.getAssemblyContexts__ComposedStructure()); + } + + final Repository repository = fluentRepository.createRepositoryNow(); + + // Add assembly connectors for assembly relations of components within same composite + for (final ComponentAssemblyRelation assemblyRelation : model.getByType(ComponentAssemblyRelation.class)) { + final Component provider = assemblyRelation.getSource() + .getSource(); + final Component consumer = assemblyRelation.getDestination() + .getSource(); + final Interface interFace = assemblyRelation.getSource() + .getDestination(); + + // Get common composites of provider and consumer + final List providerComposites = compositionRelations.stream() + .filter(relation -> relation.getDestination() + .equals(provider)) + .map(CompositionRelation::getSource) + .collect(Collectors.toList()); + final List consumerComposites = compositionRelations.stream() + .filter(relation -> relation.getDestination() + .equals(consumer)) + .map(CompositionRelation::getSource) + .collect(Collectors.toList()); + final List commonComposites = providerComposites.stream() + .filter(composite -> consumerComposites.contains(composite)) + .collect(Collectors.toList()); + + // Get real composites of wrappers from repository + final List commonRepositoryComposites = new ArrayList<>(); + for (final RepositoryComponent repositoryComponent : repository.getComponents__Repository()) { + for (final Composite commonComposite : commonComposites) { + if (repositoryComponent.getEntityName() + .equals(commonComposite.getValue() + .getEntityName())) { + commonRepositoryComposites.add((CompositeComponent) repositoryComponent); + } + } + } + + // Add assembly connector to each common composite + for (final CompositeComponent repositoryComposite : commonRepositoryComposites) { + // Fetch assembly contexts from composite + final AssemblyContext providerContext = repositoryComposite.getAssemblyContexts__ComposedStructure() + .stream() + .filter(context -> context.getEncapsulatedComponent__AssemblyContext() + .getEntityName() + .equals(provider.getValue() + .getEntityName())) + .findFirst() + .orElseThrow(); + final AssemblyContext consumerContext = repositoryComposite.getAssemblyContexts__ComposedStructure() + .stream() + .filter(context -> context.getEncapsulatedComponent__AssemblyContext() + .getEntityName() + .equals(consumer.getValue() + .getEntityName())) + .findFirst() + .orElseThrow(); + + // Fetch roles from contexts + final OperationProvidedRole providerRole = (OperationProvidedRole) providerContext + .getEncapsulatedComponent__AssemblyContext() + .getProvidedRoles_InterfaceProvidingEntity() + .stream() + .filter(role -> role instanceof OperationProvidedRole + && ((OperationProvidedRole) role).getProvidedInterface__OperationProvidedRole() + .getEntityName() + .equals(interFace.getValue() + .getEntityName())) + .findFirst() + .orElseThrow(); + final OperationRequiredRole consumerRole = (OperationRequiredRole) consumerContext + .getEncapsulatedComponent__AssemblyContext() + .getRequiredRoles_InterfaceRequiringEntity() + .stream() + .filter(role -> role instanceof OperationRequiredRole + && ((OperationRequiredRole) role).getRequiredInterface__OperationRequiredRole() + .getEntityName() + .equals(interFace.getValue() + .getEntityName())) + .findFirst() + .orElseThrow(); + + // Construct assembly connector + final AssemblyConnector assemblyConnector = CompositionFactory.eINSTANCE.createAssemblyConnector(); + assemblyConnector.setProvidedRole_AssemblyConnector(providerRole); + assemblyConnector.setProvidingAssemblyContext_AssemblyConnector(providerContext); + assemblyConnector.setRequiredRole_AssemblyConnector(consumerRole); + assemblyConnector.setRequiringAssemblyContext_AssemblyConnector(consumerContext); + + // Add connector to composite + repositoryComposite.getConnectors__ComposedStructure() + .add(assemblyConnector); + } + } + + // Add provided delegation connectors to composite + for (final CompositeProvisionDelegationRelation delegationRelation : model + .getByType(CompositeProvisionDelegationRelation.class)) { + // Decompose delegation relation into components & interfaces + final Composite compositeWrapper = (Composite) delegationRelation.getSource() + .getSource(); + final Component childWrapper = delegationRelation.getDestination() + .getSource(); + final Interface outerInterfaceWrapper = delegationRelation.getSource() + .getDestination(); + final Interface innerInterfaceWrapper = delegationRelation.getDestination() + .getDestination(); + + // Fetch composite, assembly context, & roles from repository + final CompositeComponent repositoryComposite = (CompositeComponent) repository.getComponents__Repository() + .stream() + .filter(CompositeComponent.class::isInstance) + .filter(component -> component.getEntityName() + .equals(compositeWrapper.getValue() + .getEntityName())) + .findFirst() + .orElseThrow(); + final AssemblyContext childContext = repositoryComposite.getAssemblyContexts__ComposedStructure() + .stream() + .filter(context -> context.getEncapsulatedComponent__AssemblyContext() + .getEntityName() + .equals(childWrapper.getValue() + .getEntityName())) + .findFirst() + .orElseThrow(); + final OperationProvidedRole innerRole = (OperationProvidedRole) childContext + .getEncapsulatedComponent__AssemblyContext() + .getProvidedRoles_InterfaceProvidingEntity() + .stream() + .filter(role -> role instanceof OperationProvidedRole + && ((OperationProvidedRole) role).getProvidedInterface__OperationProvidedRole() + .getEntityName() + .equals(innerInterfaceWrapper.getValue() + .getEntityName())) + .findFirst() + .orElseThrow(); + final OperationProvidedRole outerRole = (OperationProvidedRole) repositoryComposite + .getProvidedRoles_InterfaceProvidingEntity() + .stream() + .filter(role -> role instanceof OperationProvidedRole + && ((OperationProvidedRole) role).getProvidedInterface__OperationProvidedRole() + .getEntityName() + .equals(outerInterfaceWrapper.getValue() + .getEntityName())) + .findFirst() + .orElseThrow(); + + // Create delegation connector + final ProvidedDelegationConnector delegationConnector = CompositionFactory.eINSTANCE + .createProvidedDelegationConnector(); + delegationConnector.setAssemblyContext_ProvidedDelegationConnector(childContext); + delegationConnector.setInnerProvidedRole_ProvidedDelegationConnector(innerRole); + delegationConnector.setOuterProvidedRole_ProvidedDelegationConnector(outerRole); + + // Add connector to composite component + repositoryComposite.getConnectors__ComposedStructure() + .add(delegationConnector); + } + + // Add required delegation connectors to composite + for (final CompositeRequirementDelegationRelation delegationRelation : model + .getByType(CompositeRequirementDelegationRelation.class)) { + // Decompose delegation relation into components & interfaces + final Composite compositeWrapper = (Composite) delegationRelation.getSource() + .getSource(); + final Component childWrapper = delegationRelation.getDestination() + .getSource(); + final Interface outerInterfaceWrapper = delegationRelation.getSource() + .getDestination(); + final Interface innerInterfaceWrapper = delegationRelation.getDestination() + .getDestination(); + + // Fetch composite, assembly context, & roles from repository + final CompositeComponent repositoryComposite = (CompositeComponent) repository.getComponents__Repository() + .stream() + .filter(component -> component.getEntityName() + .equals(compositeWrapper.getValue() + .getEntityName())) + .findFirst() + .orElseThrow(); + final AssemblyContext childContext = repositoryComposite.getAssemblyContexts__ComposedStructure() + .stream() + .filter(context -> context.getEncapsulatedComponent__AssemblyContext() + .getEntityName() + .equals(childWrapper.getValue() + .getEntityName())) + .findFirst() + .orElseThrow(); + final OperationRequiredRole innerRole = (OperationRequiredRole) childContext + .getEncapsulatedComponent__AssemblyContext() + .getRequiredRoles_InterfaceRequiringEntity() + .stream() + .filter(role -> role instanceof OperationRequiredRole + && ((OperationRequiredRole) role).getRequiredInterface__OperationRequiredRole() + .getEntityName() + .equals(innerInterfaceWrapper.getValue() + .getEntityName())) + .findFirst() + .orElseThrow(); + final OperationRequiredRole outerRole = (OperationRequiredRole) repositoryComposite + .getRequiredRoles_InterfaceRequiringEntity() + .stream() + .filter(role -> role instanceof OperationRequiredRole + && ((OperationRequiredRole) role).getRequiredInterface__OperationRequiredRole() + .getEntityName() + .equals(outerInterfaceWrapper.getValue() + .getEntityName())) + .findFirst() + .orElseThrow(); + + // Create delegation connector + final RequiredDelegationConnector delegationConnector = CompositionFactory.eINSTANCE + .createRequiredDelegationConnector(); + delegationConnector.setAssemblyContext_RequiredDelegationConnector(childContext); + delegationConnector.setInnerRequiredRole_RequiredDelegationConnector(innerRole); + delegationConnector.setOuterRequiredRole_RequiredDelegationConnector(outerRole); + + // Add connector to composite component + repositoryComposite.getConnectors__ComposedStructure() + .add(delegationConnector); + } + + return repository; + + } + + private boolean isDirectChild(final Component child, final Composite parent, + final Multimap> compositesChildren) { + return compositesChildren.get(parent) + .contains(child); + } + + private boolean isRecursiveChild(final Component child, final Composite parent, + final Multimap> compositesChildren) { + // Case 1: Direct child + if (this.isDirectChild(child, parent, compositesChildren)) { + return true; + } + + // Case 2: Indirect child + for (final Component childOfParent : compositesChildren.get(parent)) { + if (childOfParent instanceof Composite) { + return this.isRecursiveChild(child, (Composite) childOfParent, compositesChildren); + } + } + + // Case 3: Not child of parent + return false; + } + + protected static boolean isExcludedFromDelegation(final Component provider, final Interface providedInterface) { + final String providerName = provider.getValue() + .getEntityName(); + final String providedInterfaceName = providedInterface.getValue() + .getEntityName(); + return providedInterfaceName.equals(String.format(DELEGATION_EXCLUSION_NAME_PATTERN, providerName)); + } + + private int compareComposites(final Composite a, final Composite b, + final Multimap> compositesChildren) { + if (this.isRecursiveChild(a, b, compositesChildren)) { + return -1; + } else if (this.isRecursiveChild(b, a, compositesChildren)) { + return 1; + } + return 0; + } + + private BasicComponentCreator getCreator(final FluentRepositoryFactory fluentFactory, + final AtomicComponent component) { + final BasicComponentCreator componentCreator = fluentFactory.newBasicComponent(); + + // TODO Identify important information within wrapped component + // Copy information from wrapped component, dismiss deprecated information. + final BasicComponent wrappedComponent = component.getValue(); + componentCreator.withName(wrappedComponent.getEntityName()); + + return componentCreator; + } + + private CompositeComponentCreator getCreator(final FluentRepositoryFactory fluentFactory, + final Composite component) { + final CompositeComponentCreator compositeCreator = fluentFactory.newCompositeComponent(); + + // TODO Identify important information within wrapped component + // Copy information from wrapped component, dismiss deprecated information. + final RepositoryComponent wrappedComponent = component.getValue(); + compositeCreator.withName(wrappedComponent.getEntityName()); + + return compositeCreator; + } + + private OperationInterfaceCreator getCreator(final FluentRepositoryFactory fluentFactory, + final Interface interfaceInstance) { + final OperationInterfaceCreator interfaceCreator = fluentFactory.newOperationInterface(); + + // TODO Identify important information within wrapped interface + // Copy information from wrapped interface, dismiss deprecated information. + final OperationInterface wrappedInterface = interfaceInstance.getValue(); + interfaceCreator.withName(wrappedInterface.getEntityName()); + + return interfaceCreator; + } + + protected static String getProvidedRoleName(final Interface interfaceInstance) { + final String interfaceEntityName = interfaceInstance.getValue() + .getEntityName(); + return String.format(ROLE_PROVIDES_NAME_PATTERN, interfaceEntityName); + } + + protected static String getRequiredRoleName(final Interface interfaceInstance) { + final String interfaceEntityName = interfaceInstance.getValue() + .getEntityName(); + return String.format(ROLE_REQUIRES_NAME_PATTERN, interfaceEntityName); + } + + // TODO Test and move to evaluation helper + private static boolean representSameSignature(final OperationSignature signature, + final OperationSignature otherSignature) { + final boolean equalName = Objects.equals(signature.getEntityName(), otherSignature.getEntityName()); + final boolean equalReturn = Objects.equals(signature.getReturnType__OperationSignature(), + otherSignature.getReturnType__OperationSignature()); + final boolean equalParameters = signature.getParameters__OperationSignature() + .containsAll(otherSignature.getParameters__OperationSignature()) + && otherSignature.getParameters__OperationSignature() + .containsAll(signature.getParameters__OperationSignature()); + return equalName && equalReturn && equalParameters; + } + + // TODO Test and move to evaluation helper + private static boolean representSameInterface(final OperationInterface interFace, + final OperationInterface otherInterFace) { + final boolean equalName = Objects.equals(interFace.getEntityName(), otherInterFace.getEntityName()); + // TODO Check if signatures are equal via representSameSignature + return equalName; + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/ResourceEnvironmentTransformer.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/ResourceEnvironmentTransformer.java new file mode 100644 index 00000000..e56b89d0 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/ResourceEnvironmentTransformer.java @@ -0,0 +1,128 @@ +package org.palladiosimulator.retriever.mocore.transformation; + +import java.util.Collection; +import java.util.Objects; +import java.util.Set; + +import org.palladiosimulator.generator.fluent.resourceenvironment.api.IResourceEnvironment; +import org.palladiosimulator.generator.fluent.resourceenvironment.factory.FluentResourceEnvironmentFactory; +import org.palladiosimulator.generator.fluent.resourceenvironment.structure.LinkingResourceCreator; +import org.palladiosimulator.generator.fluent.resourceenvironment.structure.ResourceContainerCreator; +import org.palladiosimulator.pcm.resourceenvironment.LinkingResource; +import org.palladiosimulator.pcm.resourceenvironment.ResourceContainer; +import org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.element.LinkResourceSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.relation.LinkResourceSpecificationRelation; + +import com.google.common.collect.HashMultimap; + +import tools.mdsd.mocore.framework.transformation.Transformer; + +public class ResourceEnvironmentTransformer implements Transformer { + @Override + public ResourceEnvironment transform(final PcmSurrogate model) { + final FluentResourceEnvironmentFactory resourceEnvironmentFactory = new FluentResourceEnvironmentFactory(); + final IResourceEnvironment fluentResourceEnvironment = resourceEnvironmentFactory.newResourceEnvironment(); + + // Add resource containers to resource environment + for (final Deployment deployment : model.getByType(Deployment.class)) { + final ResourceContainerCreator containerCreator = this.getContainerCreator(resourceEnvironmentFactory, + deployment); + fluentResourceEnvironment.addToResourceEnvironment(containerCreator); + } + + final HashMultimap linkSpecificationMap = HashMultimap.create(); + for (final LinkResourceSpecificationRelation linkingRelation : model + .getByType(LinkResourceSpecificationRelation.class)) { + final Deployment source = linkingRelation.getDestination() + .getSource(); + final Deployment destination = linkingRelation.getDestination() + .getDestination(); + final LinkResourceSpecification specification = linkingRelation.getSource(); + + // The if clause filters non-wrong but trivial A->A container links + if (!source.equals(destination)) { + linkSpecificationMap.put(specification, source); + linkSpecificationMap.put(specification, destination); + } + } + + // Add linking resources (specification <-> [deployment <-> deployment]) to resource + // environment + for (final LinkResourceSpecification key : linkSpecificationMap.keySet()) { + final LinkingResourceCreator linkingResourceCreator = this + .getLinkingResourceCreator(resourceEnvironmentFactory, linkSpecificationMap.get(key)); + fluentResourceEnvironment.addToResourceEnvironment(linkingResourceCreator); + } + + // Create PCM resource environment + final ResourceEnvironment resourceEnvironment = fluentResourceEnvironment.createResourceEnvironmentNow(); + + // Copy resource specifications from old to new containers + for (final ResourceContainer container : resourceEnvironment.getResourceContainer_ResourceEnvironment()) { + for (final Deployment deployment : model.getByType(Deployment.class)) { + // TODO Use container wrapper.equals + final ResourceContainer wrappedContainer = deployment.getValue(); + if (container.getEntityName() + .equals(wrappedContainer.getEntityName())) { + container.getActiveResourceSpecifications_ResourceContainer() + .addAll(wrappedContainer.getActiveResourceSpecifications_ResourceContainer()); + container.getHddResourceSpecifications() + .addAll(wrappedContainer.getHddResourceSpecifications()); + } + } + } + + // Add linking resource specifications to PCM linking resources + for (final LinkResourceSpecification specification : linkSpecificationMap.keySet()) { + final Set deployments = linkSpecificationMap.get(specification); + for (final LinkingResource linkingResource : resourceEnvironment + .getLinkingResources__ResourceEnvironment()) { + if (Objects.equals(getLinkingResourceName(deployments), linkingResource.getEntityName())) { + linkingResource + .setCommunicationLinkResourceSpecifications_LinkingResource(specification.getValue()); + } + } + } + + return resourceEnvironment; + } + + protected static String getLinkingResourceName(final Collection deployments) { + final StringBuilder stringBuilder = new StringBuilder(); + for (final Deployment deployment : deployments) { + stringBuilder.append(" " + deployment.getValue() + .getEntityName()); + } + stringBuilder.append(" Link"); + return stringBuilder.toString(); + } + + private ResourceContainerCreator getContainerCreator(final FluentResourceEnvironmentFactory fluentFactory, + final Deployment deployment) { + final ResourceContainer wrappedContainer = deployment.getValue(); + + // Create a container creator instance w/o processing specifications due to missing + // fluentApi copy support + final ResourceContainerCreator containerCreator = fluentFactory.newResourceContainer() + .withName(wrappedContainer.getEntityName()); + return containerCreator; + } + + private LinkingResourceCreator getLinkingResourceCreator(final FluentResourceEnvironmentFactory fluentFactory, + final Collection deployments) { + // Create a linking resource creator w/o specifications due to missing fluentApi copy + // support + final String entityName = getLinkingResourceName(deployments); + final LinkingResourceCreator creator = fluentFactory.newLinkingResource() + .withName(entityName); + for (final Deployment deployment : deployments) { + final String containerName = deployment.getValue() + .getEntityName(); + creator.addLinkedResourceContainer(containerName); + } + return creator; + } +} diff --git a/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/SystemTransformer.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/SystemTransformer.java new file mode 100644 index 00000000..8af0e7c5 --- /dev/null +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/transformation/SystemTransformer.java @@ -0,0 +1,147 @@ +package org.palladiosimulator.retriever.mocore.transformation; + +import org.palladiosimulator.generator.fluent.system.api.ISystemAddition; +import org.palladiosimulator.generator.fluent.system.factory.FluentSystemFactory; +import org.palladiosimulator.generator.fluent.system.structure.AssemblyContextCreator; +import org.palladiosimulator.generator.fluent.system.structure.connector.operation.AssemblyConnectorCreator; +import org.palladiosimulator.generator.fluent.system.structure.connector.operation.ProvidedDelegationConnectorCreator; +import org.palladiosimulator.generator.fluent.system.structure.role.OperationProvidedRoleCreator; +import org.palladiosimulator.pcm.repository.Repository; +import org.palladiosimulator.pcm.system.System; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAssemblyRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceRequirementRelation; + +import tools.mdsd.mocore.framework.transformation.Transformer; + +public class SystemTransformer implements Transformer { + private static final String ASSEMBLY_CONTEXT_NAME_PATTERN = "%s Assembly Context"; + private static final String ASSEMBLY_CONNECTOR_NAME_PATTERN = "%s Connector"; + private static final String DELEGATION_ROLE_NAME_PATTERN = "%s Delegation-Provider"; + private static final String DELEGATION_CONNECTOR_NAME_PATTERN = "%s Delegation Connector"; + + @Override + public System transform(final PcmSurrogate model) { + final Repository repository = new RepositoryTransformer().transform(model); + return this.transform(model, repository); + } + + public System transform(final PcmSurrogate model, final Repository repository) { + final FluentSystemFactory systemFactory = new FluentSystemFactory(); + final ISystemAddition fluentSystem = systemFactory.newSystem() + .addRepository(repository); + + // Add repository components as assembly contexts to system + for (final Component component : model.getByType(Component.class)) { + final AssemblyContextCreator contextCreator = this.getAssemblyContextCreator(systemFactory, component); + fluentSystem.addToSystem(contextCreator); + } + + // Add assembly connectors (component assembly relations) + for (final ComponentAssemblyRelation relation : model.getByType(ComponentAssemblyRelation.class)) { + final AssemblyConnectorCreator connectorCreator = this.getAssemblyConnectorCreator(systemFactory, relation); + fluentSystem.addToSystem(connectorCreator); + } + + // Add provided delegation connectors for provided non-required interfaces + for (final InterfaceProvisionRelation relation : model.getByType(InterfaceProvisionRelation.class)) { + final Interface providedInteface = relation.getDestination(); + final String providedIntefaceName = providedInteface.getValue() + .getEntityName(); + final Component provider = relation.getSource(); + final boolean existsRequirement = model.getByType(InterfaceRequirementRelation.class) + .stream() + .anyMatch(requirementRelation -> requirementRelation.getDestination() + .equals(providedInteface)); + final boolean isCompositeChild = model.getByType(CompositionRelation.class) + .stream() + .anyMatch(composition -> composition.getDestination() + .equals(provider)); + // Check whether interface should be excluded from delegation + final boolean excludeDelegation = RepositoryTransformer.isExcludedFromDelegation(provider, + providedInteface); + + // Only add delegation if no other component requires interface and only add for most + // outer provider in case + // of composite structures + // + // Important: Asserts that repository transformer added provision delegation from + // innermost to outermost + // component in case of a composite structure. If not, no delegation to system is added. + if (!existsRequirement && !isCompositeChild && !excludeDelegation) { + // Create & add provided role to fluent system + final String delegationRoleName = String.format(DELEGATION_ROLE_NAME_PATTERN, providedIntefaceName); + final OperationProvidedRoleCreator systemProvidedRole = systemFactory.newOperationProvidedRole() + .withName(delegationRoleName) + .withProvidedInterface(providedIntefaceName); + fluentSystem.addToSystem(systemProvidedRole); + + // Create & add delegation between context provided role & system provided role + final String delegationConnectorName = String.format(DELEGATION_CONNECTOR_NAME_PATTERN, + providedIntefaceName); + final ProvidedDelegationConnectorCreator systemDelegation = systemFactory + .newProvidedDelegationConnectorCreator() + .withName(delegationConnectorName) + .withOuterProvidedRole(delegationRoleName) + .withProvidingContext(getAssemblyContextName(provider)) + .withOperationProvidedRole(RepositoryTransformer.getProvidedRoleName(providedInteface)); + fluentSystem.addToSystem(systemDelegation); + } + } + + return fluentSystem.createSystemNow(); + } + + protected static String getAssemblyContextName(final Component component) { + final String componentEntityName = component.getValue() + .getEntityName(); + return String.format(ASSEMBLY_CONTEXT_NAME_PATTERN, componentEntityName); + } + + protected static String getAssemblyConnectorName(final Interface interfaceInstance) { + final String interfaceEntityName = interfaceInstance.getValue() + .getEntityName(); + return String.format(ASSEMBLY_CONNECTOR_NAME_PATTERN, interfaceEntityName); + } + + private AssemblyContextCreator getAssemblyContextCreator(final FluentSystemFactory fluentFactory, + final Component component) { + final String componentEntityName = component.getValue() + .getEntityName(); + final String assemblyContextName = getAssemblyContextName(component); + final AssemblyContextCreator contextCreator = fluentFactory.newAssemblyContext() + .withName(assemblyContextName) + .withEncapsulatedComponent(componentEntityName); + return contextCreator; + } + + private AssemblyConnectorCreator getAssemblyConnectorCreator(final FluentSystemFactory fluentFactory, + final ComponentAssemblyRelation assemblyRelation) { + // Get wrapper from relation + final Component provider = assemblyRelation.getSource() + .getSource(); + final Component consumer = assemblyRelation.getDestination() + .getSource(); + final Interface interfaceInstance = assemblyRelation.getSource() + .getDestination(); + + // Get entity names of roles, components and connector + final String connectorName = getAssemblyConnectorName(interfaceInstance); + final String providerName = getAssemblyContextName(provider); + final String consumerName = getAssemblyContextName(consumer); + final String providedRoleName = RepositoryTransformer.getProvidedRoleName(interfaceInstance); + final String requiredRoleName = RepositoryTransformer.getRequiredRoleName(interfaceInstance); + + final AssemblyConnectorCreator connectorCreator = fluentFactory.newAssemblyConnector() + .withName(connectorName) + .withProvidingAssemblyContext(providerName) + .withOperationProvidedRole(providedRoleName) + .withRequiringAssemblyContext(consumerName) + .withOperationRequiredRole(requiredRoleName); + return connectorCreator; + } +} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/workflow/MoCoReJob.java b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/workflow/MoCoReJob.java similarity index 52% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/workflow/MoCoReJob.java rename to bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/workflow/MoCoReJob.java index 9890158f..f41b4075 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/workflow/MoCoReJob.java +++ b/bundles/org.palladiosimulator.retriever.mocore/src/org/palladiosimulator/retriever/mocore/workflow/MoCoReJob.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.workflow; +package org.palladiosimulator.retriever.mocore.workflow; import java.util.Collection; import java.util.Objects; @@ -8,13 +8,13 @@ import org.palladiosimulator.pcm.repository.Repository; import org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment; import org.palladiosimulator.pcm.system.System; -import org.palladiosimulator.somox.analyzer.rules.mocore.discovery.RepositoryDecompositor; -import org.palladiosimulator.somox.analyzer.rules.mocore.orchestration.PcmOrchestrator; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.transformation.AllocationTransformer; -import org.palladiosimulator.somox.analyzer.rules.mocore.transformation.RepositoryTransformer; -import org.palladiosimulator.somox.analyzer.rules.mocore.transformation.ResourceEnvironmentTransformer; -import org.palladiosimulator.somox.analyzer.rules.mocore.transformation.SystemTransformer; +import org.palladiosimulator.retriever.mocore.discovery.RepositoryDecompositor; +import org.palladiosimulator.retriever.mocore.orchestration.PcmOrchestrator; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.transformation.AllocationTransformer; +import org.palladiosimulator.retriever.mocore.transformation.RepositoryTransformer; +import org.palladiosimulator.retriever.mocore.transformation.ResourceEnvironmentTransformer; +import org.palladiosimulator.retriever.mocore.transformation.SystemTransformer; import de.uka.ipd.sdq.workflow.blackboard.Blackboard; import de.uka.ipd.sdq.workflow.jobs.CleanupFailedException; @@ -33,8 +33,9 @@ public class MoCoReJob implements IBlackboardInteractingJob> private final String allocationOutputKey; private final String resourceEnvironmentOutputKey; - public MoCoReJob(Blackboard blackboard, String repositoryInputKey, String repositoryOutputKey, - String systemOutputKey, String allocationOutputKey, String resourceEnvironmentOutputKey) { + public MoCoReJob(final Blackboard blackboard, final String repositoryInputKey, + final String repositoryOutputKey, final String systemOutputKey, final String allocationOutputKey, + final String resourceEnvironmentOutputKey) { this.blackboard = Objects.requireNonNull(blackboard); this.repositoryInputKey = Objects.requireNonNull(repositoryInputKey); this.repositoryOutputKey = Objects.requireNonNull(repositoryOutputKey); @@ -44,40 +45,40 @@ public MoCoReJob(Blackboard blackboard, String repositoryInputKey, Strin } @Override - public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { + public void execute(final IProgressMonitor monitor) throws JobFailedException, UserCanceledException { // Fetch input from blackboard monitor.subTask("Retrieving job input from blackboard"); - Repository inputRepository = (Repository) this.blackboard.getPartition(repositoryInputKey); + final Repository inputRepository = (Repository) this.blackboard.getPartition(this.repositoryInputKey); // Convert input into processable discoverers monitor.subTask("Converting input into processable discoveries"); - RepositoryDecompositor repositoryDecompositor = new RepositoryDecompositor(); - Collection> discoverers = repositoryDecompositor.decompose(inputRepository); + final RepositoryDecompositor repositoryDecompositor = new RepositoryDecompositor(); + final Collection> discoverers = repositoryDecompositor.decompose(inputRepository); // Composite & refine discoveries via PCM orchestrator monitor.subTask("Processing discoveries"); - PcmOrchestrator orchestrator = new PcmOrchestrator(); + final PcmOrchestrator orchestrator = new PcmOrchestrator(); discoverers.forEach(orchestrator::processDiscoverer); // Transform surrogate model into PCM models monitor.subTask("Transforming surrogate model into output models"); - PcmSurrogate surrogate = orchestrator.getModel(); - Repository repository = new RepositoryTransformer().transform(surrogate); - System system = new SystemTransformer().transform(surrogate, repository); - ResourceEnvironment resourceEnvironment = new ResourceEnvironmentTransformer().transform(surrogate); - Allocation allocation = new AllocationTransformer().transform(surrogate, system, resourceEnvironment); + final PcmSurrogate surrogate = orchestrator.getModel(); + final Repository repository = new RepositoryTransformer().transform(surrogate); + final System system = new SystemTransformer().transform(surrogate, repository); + final ResourceEnvironment resourceEnvironment = new ResourceEnvironmentTransformer().transform(surrogate); + final Allocation allocation = new AllocationTransformer().transform(surrogate, system, resourceEnvironment); // Add transformed models to blackboard monitor.subTask("Adding output models to blackboard"); - this.blackboard.addPartition(repositoryOutputKey, repository); - this.blackboard.addPartition(systemOutputKey, system); - this.blackboard.addPartition(allocationOutputKey, allocation); - this.blackboard.addPartition(resourceEnvironmentOutputKey, resourceEnvironment); + this.blackboard.addPartition(this.repositoryOutputKey, repository); + this.blackboard.addPartition(this.systemOutputKey, system); + this.blackboard.addPartition(this.allocationOutputKey, allocation); + this.blackboard.addPartition(this.resourceEnvironmentOutputKey, resourceEnvironment); monitor.done(); } @Override - public void cleanup(IProgressMonitor monitor) throws CleanupFailedException { + public void cleanup(final IProgressMonitor monitor) throws CleanupFailedException { // No cleanup required for the job } @@ -87,7 +88,7 @@ public String getName() { } @Override - public void setBlackboard(Blackboard blackboard) { + public void setBlackboard(final Blackboard blackboard) { this.blackboard = Objects.requireNonNull(blackboard); } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/.classpath b/bundles/org.palladiosimulator.somox.analyzer.rules.engine/.classpath deleted file mode 100644 index e3378d07..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/META-INF/MANIFEST.MF b/bundles/org.palladiosimulator.somox.analyzer.rules.engine/META-INF/MANIFEST.MF deleted file mode 100644 index 78ff5af6..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/META-INF/MANIFEST.MF +++ /dev/null @@ -1,17 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: SoMoX Rule Engine -Bundle-SymbolicName: org.palladiosimulator.somox.analyzer.rules.engine;singleton:=true -Bundle-Version: 5.2.0.qualifier -Bundle-Vendor: palladiosimulator.org -Automatic-Module-Name: org.palladiosimulator.somox.analyzer.rules.engine -Bundle-RequiredExecutionEnvironment: JavaSE-17 -Export-Package: org.palladiosimulator.somox.analyzer.rules.blackboard, - org.palladiosimulator.somox.analyzer.rules.engine, - org.palladiosimulator.somox.analyzer.rules.model -Require-Bundle: org.eclipse.core.resources, - org.eclipse.jdt.core, - org.palladiosimulator.pcm, - org.apache.log4j, - org.palladiosimulator.generator.fluent, - de.uka.ipd.sdq.workflow diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/plugin.xml b/bundles/org.palladiosimulator.somox.analyzer.rules.engine/plugin.xml deleted file mode 100644 index 936ac1d8..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/plugin.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/schema/org.palladiosimulator.somox.analyzer.rule.exsd b/bundles/org.palladiosimulator.somox.analyzer.rules.engine/schema/org.palladiosimulator.somox.analyzer.rule.exsd deleted file mode 100644 index c10040ea..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/schema/org.palladiosimulator.somox.analyzer.rule.exsd +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - [Enter description of this extension point.] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/blackboard/RuleEngineBlackboard.java b/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/blackboard/RuleEngineBlackboard.java deleted file mode 100644 index 0bd64653..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/blackboard/RuleEngineBlackboard.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.blackboard; - -import java.nio.file.Path; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import org.eclipse.jdt.core.dom.ASTNode; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.palladiosimulator.pcm.repository.RepositoryComponent; -import org.palladiosimulator.pcm.seff.ServiceEffectSpecification; -import org.palladiosimulator.pcm.system.System; -import org.palladiosimulator.somox.analyzer.rules.engine.PCMDetector; - -import de.uka.ipd.sdq.workflow.blackboard.Blackboard; - -public class RuleEngineBlackboard extends Blackboard { - - public static final String KEY_REPOSITORY = "org.palladiosimulator.somox.analyzer.repository"; - public static final String KEY_SEFF_ASSOCIATIONS = "org.palladiosimulator.somox.analyzer.seff_associations"; - - private final Map repositoryComponentLocations; - private final Map> systemAssociations; - private final Map systemPaths; - private final Set discovererIDs; - private PCMDetector pcmDetector; - - public RuleEngineBlackboard() { - super(); - repositoryComponentLocations = new HashMap<>(); - systemAssociations = new HashMap<>(); - systemPaths = new HashMap<>(); - discovererIDs = new HashSet<>(); - pcmDetector = new PCMDetector(); - addPartition(KEY_SEFF_ASSOCIATIONS, new HashMap<>()); - } - - public CompilationUnit putRepositoryComponentLocation(RepositoryComponent repoComp, - CompilationUnit compilationUnit) { - return repositoryComponentLocations.put(repoComp, compilationUnit); - } - - public Map getRepositoryComponentLocations() { - return Collections.unmodifiableMap(repositoryComponentLocations); - } - - public void setPCMDetector(PCMDetector pcmDetector) { - this.pcmDetector = pcmDetector; - } - - public PCMDetector getPCMDetector() { - return pcmDetector; - } - - public void addSystemAssociations(Path path, Set compilationUnits) { - systemAssociations.put(path, Collections.unmodifiableSet(compilationUnits)); - } - - public Map> getSystemAssociations() { - return Collections.unmodifiableMap(systemAssociations); - } - - public void putSystemPath(System system, Path path) { - systemPaths.put(system, path); - } - - public void putSeffAssociation(ASTNode astNode, ServiceEffectSpecification seff) { - @SuppressWarnings("unchecked") - Map seffAssociations = (Map) getPartition( - KEY_SEFF_ASSOCIATIONS); - seffAssociations.put(astNode, seff); - } - - public ServiceEffectSpecification getSeffAssociation(ASTNode astNode) { - @SuppressWarnings("unchecked") - Map seffAssociations = (Map) getPartition( - KEY_SEFF_ASSOCIATIONS); - return seffAssociations.get(astNode); - } - - public Map getSeffAssociations() { - @SuppressWarnings("unchecked") - Map seffAssociations = (Map) getPartition( - KEY_SEFF_ASSOCIATIONS); - return Collections.unmodifiableMap(seffAssociations); - } - - public void putDiscoveredFiles(String discovererID, Map pathsToFiles) { - discovererIDs.add(discovererID); - addPartition(discovererID, pathsToFiles); - } - - public Map getDiscoveredFiles(String discovererID, Class fileClass) { - Object partition = getPartition(discovererID); - if (!(partition instanceof Map)) { - return new HashMap<>(); - } - @SuppressWarnings("unchecked") // Not unchecked. - Map map = (Map) partition; - if (map.isEmpty()) { - return new HashMap<>(); - } - boolean allEntriesHaveCorrectType = map.entrySet() - .stream() - .allMatch(entry -> entry.getKey() instanceof Path && fileClass.isInstance(entry.getValue())); - if (!allEntriesHaveCorrectType) { - return new HashMap<>(); - } - return map.entrySet() - .stream() - .collect(Collectors.toMap(entry -> (Path) entry.getKey(), entry -> fileClass.cast(entry.getValue()))); - } - - public Set getDiscoveredPaths() { - Set discoveredPaths = new HashSet<>(); - for (String discovererID : discovererIDs) { - @SuppressWarnings("unchecked") // Local data structure, this assumption is an invariant. - Map partition = (Map) getPartition(discovererID); - discoveredPaths.addAll(partition.keySet()); - } - return discoveredPaths; - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/PCMDetector.java b/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/PCMDetector.java deleted file mode 100644 index 371bd361..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/PCMDetector.java +++ /dev/null @@ -1,305 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.engine; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import org.apache.log4j.Logger; -import org.eclipse.jdt.core.dom.AbstractTypeDeclaration; -import org.eclipse.jdt.core.dom.FieldDeclaration; -import org.eclipse.jdt.core.dom.IMethodBinding; -import org.eclipse.jdt.core.dom.ITypeBinding; -import org.eclipse.jdt.core.dom.IVariableBinding; -import org.eclipse.jdt.core.dom.SingleVariableDeclaration; -import org.eclipse.jdt.core.dom.TypeDeclaration; -import org.eclipse.jdt.core.dom.VariableDeclaration; -import org.palladiosimulator.somox.analyzer.rules.model.CompUnitOrName; -import org.palladiosimulator.somox.analyzer.rules.model.ComponentBuilder; -import org.palladiosimulator.somox.analyzer.rules.model.CompositeBuilder; -import org.palladiosimulator.somox.analyzer.rules.model.EntireInterface; -import org.palladiosimulator.somox.analyzer.rules.model.InterfaceName; -import org.palladiosimulator.somox.analyzer.rules.model.JavaInterfaceName; -import org.palladiosimulator.somox.analyzer.rules.model.JavaOperationName; -import org.palladiosimulator.somox.analyzer.rules.model.Operation; -import org.palladiosimulator.somox.analyzer.rules.model.OperationInterface; -import org.palladiosimulator.somox.analyzer.rules.model.OperationName; -import org.palladiosimulator.somox.analyzer.rules.model.PCMDetectionResult; -import org.palladiosimulator.somox.analyzer.rules.model.ProvisionsBuilder; -import org.palladiosimulator.somox.analyzer.rules.model.RequirementsBuilder; - -/** - * This class is used to detect and hold all relevant elements found during the processing of rules. - * It provides methods to detect and retrieve PCM elements. After all rules are parsed, this class - * holds the results as "simple" java objects not yet transformed to real PCM objects like PCM Basic - * Components. - */ -public class PCMDetector { - private static final Logger LOG = Logger.getLogger(PCMDetector.class); - - private Map components = new HashMap<>(); - private Map composites = new HashMap<>(); - private ProvisionsBuilder compositeProvisions = new ProvisionsBuilder(); - private RequirementsBuilder compositeRequirements = new RequirementsBuilder(); - private Set providedInterfaces = new HashSet<>(); - - private static String getFullUnitName(CompUnitOrName unit) { - // TODO this is potentially problematic, maybe restructure - // On the other hand, it is still fit as a unique identifier, - // since types cannot be declared multiple times. - - List names = getFullUnitNames(unit); - if (!names.isEmpty()) { - return names.get(0); - } - return null; - } - - private static List getFullUnitNames(CompUnitOrName unit) { - if (!unit.isUnit()) { - return List.of(unit.name()); - } - - List names = new ArrayList<>(); - for (Object type : unit.compilationUnit() - .get() - .types()) { - if (type instanceof AbstractTypeDeclaration) { - names.add(getFullTypeName((AbstractTypeDeclaration) type)); - } - } - - return names; - } - - private static String getFullTypeName(AbstractTypeDeclaration type) { - return type.getName() - .getFullyQualifiedName(); - } - - public void detectComponent(CompUnitOrName unit) { - if (!unit.isUnit()) { - components.put(unit, new ComponentBuilder(unit)); - return; - } - for (Object type : unit.compilationUnit() - .get() - .types()) { - if (type instanceof TypeDeclaration) { - components.put(unit, new ComponentBuilder(unit)); - ITypeBinding binding = ((TypeDeclaration) type).resolveBinding(); - detectProvidedInterface(unit, binding); - } - } - } - - public void detectRequiredInterface(CompUnitOrName unit, InterfaceName interfaceName) { - detectRequiredInterface(unit, interfaceName, false); - } - - public void detectRequiredInterface(CompUnitOrName unit, InterfaceName interfaceName, boolean compositeRequired) { - if (components.get(unit) == null) { - components.put(unit, new ComponentBuilder(unit)); - } - EntireInterface iface = new EntireInterface(interfaceName); - detectRequiredInterface(unit, compositeRequired, false, iface); - } - - public void detectRequiredInterface(CompUnitOrName unit, FieldDeclaration field) { - detectRequiredInterface(unit, field, false, false); - } - - public void detectRequiredInterfaceWeakly(CompUnitOrName unit, FieldDeclaration field) { - detectRequiredInterface(unit, field, false, true); - } - - private void detectRequiredInterface(CompUnitOrName unit, FieldDeclaration field, boolean compositeRequired, - boolean detectWeakly) { - if (components.get(unit) == null) { - components.put(unit, new ComponentBuilder(unit)); - } - @SuppressWarnings("unchecked") - List ifaces = ((List) field.fragments()).stream() - .map(x -> x.resolveBinding()) - .filter(x -> x != null) - .map(x -> x.getType()) - .map(x -> new EntireInterface(x, new JavaInterfaceName(NameConverter.toPCMIdentifier(x)))) - .collect(Collectors.toList()); - detectRequiredInterface(unit, compositeRequired, detectWeakly, ifaces); - } - - public void detectRequiredInterface(CompUnitOrName unit, SingleVariableDeclaration parameter) { - detectRequiredInterface(unit, parameter, false); - } - - private void detectRequiredInterface(CompUnitOrName unit, SingleVariableDeclaration parameter, - boolean compositeRequired) { - if (components.get(unit) == null) { - components.put(unit, new ComponentBuilder(unit)); - } - IVariableBinding parameterBinding = parameter.resolveBinding(); - if (parameterBinding == null) { - LOG.warn("Unresolved parameter binding " + parameter.getName() + " detected in " + getFullUnitName(unit) - + "!"); - return; - } - ITypeBinding type = parameterBinding.getType(); - EntireInterface iface = new EntireInterface(type, new JavaInterfaceName(NameConverter.toPCMIdentifier(type))); - detectRequiredInterface(unit, compositeRequired, false, iface); - } - - private void detectRequiredInterface(CompUnitOrName unit, boolean compositeRequired, boolean detectWeakly, - OperationInterface iface) { - detectRequiredInterface(unit, compositeRequired, detectWeakly, List.of(iface)); - } - - private void detectRequiredInterface(CompUnitOrName unit, boolean compositeRequired, boolean detectWeakly, - Collection ifaces) { - for (OperationInterface iface : ifaces) { - if (detectWeakly && !providedInterfaces.contains(iface)) { - components.get(unit) - .requirements() - .addWeakly(iface); - if (compositeRequired) { - compositeRequirements.addWeakly(iface); - } - } else { - components.get(unit) - .requirements() - .add(iface); - if (compositeRequired) { - compositeRequirements.add(iface); - } - } - } - } - - public void detectProvidedInterface(CompUnitOrName unit, ITypeBinding iface) { - if (iface == null) { - LOG.warn("Unresolved type binding detected in " + getFullUnitName(unit) + "!"); - return; - } - OperationInterface provision = new EntireInterface(iface, - new JavaInterfaceName(NameConverter.toPCMIdentifier(iface))); - detectProvidedInterface(unit, provision); - } - - public void detectProvidedOperation(CompUnitOrName unit, IMethodBinding method) { - if (method == null) { - LOG.warn("Unresolved method binding detected in " + getFullUnitName(unit) + "!"); - return; - } - detectProvidedOperation(unit, method.getDeclaringClass(), method); - } - - public void detectProvidedOperation(CompUnitOrName unit, ITypeBinding declaringIface, IMethodBinding method) { - if (declaringIface == null) { - LOG.warn("Unresolved type binding detected in " + getFullUnitName(unit) + "!"); - return; - } - detectProvidedOperation(unit, NameConverter.toPCMIdentifier(declaringIface), method); - } - - public void detectProvidedOperation(CompUnitOrName unit, String declaringIface, IMethodBinding method) { - String operationName; - if (method == null) { - LOG.warn("Unresolved method binding detected in " + getFullUnitName(unit) + "!"); - operationName = "[unresolved]"; - } else { - operationName = method.getName(); - } - - detectProvidedOperation(unit, method, new JavaOperationName(declaringIface, operationName)); - } - - public void detectProvidedOperation(CompUnitOrName unit, IMethodBinding method, OperationName name) { - if (components.get(unit) == null) { - components.put(unit, new ComponentBuilder(unit)); - } - OperationInterface provision = new Operation(method, name); - detectProvidedInterface(unit, provision); - } - - public void detectProvidedInterface(CompUnitOrName unit, OperationInterface provision) { - components.get(unit) - .provisions() - .add(provision); - providedInterfaces.add(provision); - components.values() - .stream() - .forEach(component -> component.requirements() - .strengthenIfPresent(provision)); - } - - public void detectPartOfComposite(CompUnitOrName unit, String compositeName) { - if (components.get(unit) == null) { - components.put(unit, new ComponentBuilder(unit)); - } - getComposite(compositeName).addPart(components.get(unit)); - } - - public void detectCompositeRequiredInterface(CompUnitOrName unit, InterfaceName interfaceName) { - detectRequiredInterface(unit, interfaceName, true); - } - - public void detectCompositeRequiredInterface(CompUnitOrName unit, FieldDeclaration field) { - detectRequiredInterface(unit, field, true, false); - } - - public void detectCompositeRequiredInterface(CompUnitOrName unit, SingleVariableDeclaration parameter) { - detectRequiredInterface(unit, parameter, true); - } - - public void detectCompositeProvidedOperation(CompUnitOrName unit, IMethodBinding method) { - detectCompositeProvidedOperation(unit, method.getDeclaringClass(), method); - } - - public void detectCompositeProvidedOperation(CompUnitOrName unit, ITypeBinding declaringIface, - IMethodBinding method) { - detectCompositeProvidedOperation(unit, NameConverter.toPCMIdentifier(declaringIface), method); - } - - public void detectCompositeProvidedOperation(CompUnitOrName unit, String declaringIface, IMethodBinding method) { - compositeProvisions.add(new Operation(method, new JavaOperationName(declaringIface, method.getName()))); - detectProvidedOperation(unit, declaringIface, method); - } - - public void detectCompositeProvidedOperation(CompUnitOrName unit, IMethodBinding method, OperationName name) { - compositeProvisions.add(new Operation(method, name)); - detectProvidedOperation(unit, method, name); - } - - private CompositeBuilder getComposite(String name) { - if (!composites.containsKey(name)) { - composites.put(name, new CompositeBuilder(name)); - } - return composites.get(name); - } - - public Set getCompilationUnits() { - return components.keySet(); - } - - public PCMDetectionResult getResult() { - return new PCMDetectionResult(components, composites, compositeProvisions, compositeRequirements); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(142); - sb.append("[PCMDetector] {\n\tcomponents: {\n"); - components.entrySet() - .forEach(entry -> { - sb.append("\t\t\""); - sb.append(entry.getKey()); - sb.append("\" -> {"); - sb.append(entry.getValue()); - sb.append("\t\t}\n"); - }); - return sb.toString(); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/Rule.java b/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/Rule.java deleted file mode 100644 index fe3d549b..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/Rule.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.engine; - -import java.nio.file.Path; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; - -import de.uka.ipd.sdq.workflow.jobs.AbstractBlackboardInteractingJob; -import de.uka.ipd.sdq.workflow.jobs.CleanupFailedException; -import de.uka.ipd.sdq.workflow.jobs.IBlackboardInteractingJob; -import de.uka.ipd.sdq.workflow.jobs.JobFailedException; -import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; - -/** - * This interface has to be implemented in order to write rules. The method will be used by the - * RuleEngine class to process all written rule lines which are inside the method. - */ -public interface Rule extends Service { - public abstract void processRules(RuleEngineBlackboard blackboard, Path path); - - public abstract boolean isBuildRule(); - - @Override - default IBlackboardInteractingJob create(RuleEngineConfiguration configuration, - RuleEngineBlackboard blackboard) { - Rule rule = this; - return new AbstractBlackboardInteractingJob() { - @Override - public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { - for (Path path : blackboard.getDiscoveredPaths()) { - rule.processRules(blackboard, path); - } - } - - @Override - public void cleanup(IProgressMonitor monitor) throws CleanupFailedException { - } - - @Override - public String getName() { - return rule.getName() + " Job"; - } - }; - } -} \ No newline at end of file diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/ServiceConfiguration.java b/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/ServiceConfiguration.java deleted file mode 100644 index 95d95f9e..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/ServiceConfiguration.java +++ /dev/null @@ -1,243 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.engine; - -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.Set; - -public class ServiceConfiguration { - private final String selectedServicesKey; - private final String serviceConfigKeyPrefix; - private final Map> serviceConfigs; - private final Map services; - private final Set manuallySelectedServices; - private final Map> selectedDependencies; - private final Set> dependencyProviders; - - public ServiceConfiguration(ServiceCollection serviceCollection, String selectedServicesKey, - String serviceConfigKeyPrefix) { - this.selectedServicesKey = selectedServicesKey; - this.serviceConfigKeyPrefix = serviceConfigKeyPrefix; - this.serviceConfigs = new HashMap<>(); - this.services = new HashMap<>(); - for (T service : serviceCollection.getServices()) { - this.services.put(service.getID(), service); - Map initializedConfig = new HashMap<>(); - for (String key : service.getConfigurationKeys()) { - initializedConfig.put(key, ""); - } - this.serviceConfigs.put(service.getID(), initializedConfig); - } - this.manuallySelectedServices = new HashSet<>(); - this.selectedDependencies = new HashMap<>(); - this.dependencyProviders = new HashSet<>(); - this.dependencyProviders.add(this); - } - - public void addDependencyProvider(ServiceConfiguration dependencyProvider) { - dependencyProviders.add(dependencyProvider); - } - - @SuppressWarnings("unchecked") - public void applyAttributeMap(Map attributeMap) { - Set serviceIds = (Set) attributeMap.get(selectedServicesKey); - for (Map.Entry serviceEntry : services.entrySet()) { - String serviceId = serviceEntry.getKey(); - T service = serviceEntry.getValue(); - if (attributeMap.get(serviceConfigKeyPrefix + serviceId) != null) { - serviceConfigs.put(serviceId, - (Map) attributeMap.get(serviceConfigKeyPrefix + serviceId)); - } - if ((serviceIds != null) && serviceIds.contains(service.getID())) { - this.select(service); - } - } - - } - - public String getConfig(String serviceId, String key) { - Map config = serviceConfigs.get(serviceId); - if (config == null) { - return null; - } - return config.get(key); - } - - public Map getWholeConfig(String serviceId) { - return Collections.unmodifiableMap(serviceConfigs.get(serviceId)); - } - - public void setConfig(String serviceId, String key, String value) { - Map config = serviceConfigs.get(serviceId); - if (config == null) { - config = new HashMap<>(); - serviceConfigs.put(serviceId, config); - } - config.put(key, value); - } - - public void select(T service) { - manuallySelectedServices.add(service); - for (ServiceConfiguration dependencyProvider : dependencyProviders) { - dependencyProvider.selectDependenciesOf(service); - } - } - - public void deselect(T service) { - manuallySelectedServices.remove(service); - for (ServiceConfiguration dependencyProvider : dependencyProviders) { - dependencyProvider.deselectDependenciesOf(service); - } - } - - public boolean isManuallySelected(T service) { - return manuallySelectedServices.contains(service); - } - - public Set getSelected() { - Set selectedServices = new HashSet<>(manuallySelectedServices); - selectedServices.addAll(selectedDependencies.keySet()); - return Collections.unmodifiableSet(selectedServices); - } - - public Queue> getExecutionOrder() { - List> executionOrder = new ArrayList<>(); - Queue remainingServices = new ArrayDeque<>(getSelected()); - List requiringServices = new LinkedList<>(); - Map> extendedRequirements = new HashMap<>(); - - for (T service : remainingServices) { - extendedRequirements.put(service.getID(), new HashSet<>(service.getRequiredServices())); - } - - // Rephrase all dependencies into requirements - for (T providingService : remainingServices) { - for (String dependentID : providingService.getDependentServices()) { - if (!extendedRequirements.containsKey(dependentID)) { - continue; - } - extendedRequirements.get(dependentID) - .add(providingService.getID()); - } - } - - while (!remainingServices.isEmpty()) { - T candidate = remainingServices.poll(); - String candidateID = candidate.getID(); - Set candidateRequirements = extendedRequirements.get(candidateID); - if (isRequiringAny(candidateRequirements, remainingServices) - || isRequiringAny(candidateRequirements, requiringServices)) { - requiringServices.add(candidate); - } else { - addAfterRequirements(candidate, candidateRequirements, executionOrder); - - remainingServices.addAll(requiringServices); - requiringServices.clear(); - } - } - if (!requiringServices.isEmpty()) { - throw new IllegalStateException("Dependency cycle in services, no possible execution order."); - } - return new ArrayDeque<>(executionOrder); - } - - private void addAfterRequirements(T service, Set serviceRequirements, List> executionOrder) { - if (executionOrder.isEmpty() - || isRequiringAny(serviceRequirements, executionOrder.get(executionOrder.size() - 1))) { - Collection newStep = new ArrayList<>(); - newStep.add(service); - executionOrder.add(newStep); - return; - } - - Collection earliestCandidate = executionOrder.get(executionOrder.size() - 1); - for (int i = executionOrder.size() - 2; i >= 0; i--) { - Collection currentStep = executionOrder.get(i); - if (isRequiringAny(serviceRequirements, currentStep)) { - break; - } - earliestCandidate = currentStep; - } - earliestCandidate.add(service); - } - - private boolean isRequiringAny(Set requirements, Collection services) { - return services.stream() - .map(Service::getID) - .anyMatch(requirements::contains); - } - - public Collection getAvailable() { - return Collections.unmodifiableCollection(services.values()); - } - - public void selectDependenciesOf(Service service) { - for (String dependencyID : service.getRequiredServices()) { - if (!services.containsKey(dependencyID)) { - continue; - } - T dependency = services.get(dependencyID); - addDependingService(dependency, service); - } - } - - private void addDependingService(T dependency, Service service) { - if (selectedDependencies.containsKey(dependency)) { - Set dependingServices = selectedDependencies.get(dependency); - dependingServices.add(service); - } else { - Set dependingServices = new HashSet<>(); - dependingServices.add(service); - selectedDependencies.put(dependency, dependingServices); - for (ServiceConfiguration dependencyProvider : dependencyProviders) { - dependencyProvider.selectDependenciesOf(dependency); - } - } - } - - public void deselectDependenciesOf(Service service) { - for (String dependencyID : service.getRequiredServices()) { - if (!services.containsKey(dependencyID)) { - continue; - } - T dependency = services.get(dependencyID); - removeDependingService(dependency, service); - } - } - - private void removeDependingService(T dependency, Service service) { - if (!selectedDependencies.containsKey(dependency)) { - return; - } - Set dependingServices = selectedDependencies.get(dependency); - dependingServices.remove(service); - // Remove not needed dependencies. - if (dependingServices.isEmpty()) { - selectedDependencies.remove(dependency); - } - } - - public Map toMap() { - final Map result = new HashMap<>(); - for (String serviceId : serviceConfigs.keySet()) { - result.put(serviceConfigKeyPrefix + serviceId, serviceConfigs.get(serviceId)); - } - result.put(selectedServicesKey, serializeServices(manuallySelectedServices)); - return result; - } - - private static Set serializeServices(Iterable services) { - Set serviceIds = new HashSet<>(); - for (Service service : services) { - serviceIds.add(service.getID()); - } - return serviceIds; - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/ComponentBuilder.java b/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/ComponentBuilder.java deleted file mode 100644 index 2553a1f6..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/ComponentBuilder.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.model; - -import java.util.Collection; -import java.util.Objects; - -/** - * Used to build {@code Component}s. - * - * @see Component - * @author Florian Bossert - */ -public class ComponentBuilder { - private final CompUnitOrName compUnitOrName; - private final RequirementsBuilder requirements; - private final ProvisionsBuilder provisions; - - public ComponentBuilder(CompUnitOrName compUnitOrName) { - this.compUnitOrName = compUnitOrName; - this.requirements = new RequirementsBuilder(); - this.provisions = new ProvisionsBuilder(); - } - - public CompUnitOrName identifier() { - return compUnitOrName; - } - - public RequirementsBuilder requirements() { - return requirements; - } - - public ProvisionsBuilder provisions() { - return provisions; - } - - public Component create(Collection allDependencies, - Collection visibleProvisions) { - return new Component(compUnitOrName, requirements.create(allDependencies, visibleProvisions), - provisions.create(allDependencies)); - } - - @Override - public int hashCode() { - return Objects.hash(compUnitOrName, provisions, requirements); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ComponentBuilder other = (ComponentBuilder) obj; - return Objects.equals(compUnitOrName, other.compUnitOrName) && Objects.equals(provisions, other.provisions) - && Objects.equals(requirements, other.requirements); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/HTTPMethod.java b/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/HTTPMethod.java deleted file mode 100644 index 6b23f051..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/HTTPMethod.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.model; - -public enum HTTPMethod { - GET, POST, PUT, DELETE, PATCH -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/JavaOperationName.java b/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/JavaOperationName.java deleted file mode 100644 index 4309445f..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/JavaOperationName.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.model; - -import java.util.List; -import java.util.Objects; -import java.util.Optional; - -public class JavaOperationName implements OperationName { - private final String iface; - private final String method; - - public JavaOperationName(String iface, String method) { - this.iface = iface; - this.method = method; - } - - @Override - public Optional forInterface(String baseInterface) { - if (!iface.equals(baseInterface) && !baseInterface.startsWith(iface + "#")) { - return Optional.empty(); - } - return Optional.of(method); - } - - @Override - public List getInterfaces() { - return List.of(toString(), iface); - } - - @Override - public String getInterface() { - return iface; - } - - @Override - public InterfaceName createInterface(String name) { - return new JavaInterfaceName(name); - } - - @Override - public int hashCode() { - return Objects.hash(iface, method); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - JavaOperationName other = (JavaOperationName) obj; - return Objects.equals(iface, other.iface) && Objects.equals(method, other.method); - } - - @Override - public String toString() { - return iface + "#" + method; - } -} \ No newline at end of file diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/ProvisionsBuilder.java b/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/ProvisionsBuilder.java deleted file mode 100644 index 77cfe25e..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/ProvisionsBuilder.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.model; - -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.Objects; - -public class ProvisionsBuilder { - private final List provisions = new LinkedList<>(); - - public void add(OperationInterface... provisions) { - this.add(List.of(provisions)); - } - - public void add(Collection provisions) { - this.provisions.addAll(provisions); - } - - public Provisions create(Collection allDependencies) { - return new Provisions(provisions, allDependencies); - } - - public List toList() { - return Collections.unmodifiableList(provisions); - } - - @Override - public int hashCode() { - return Objects.hash(provisions); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ProvisionsBuilder other = (ProvisionsBuilder) obj; - return Objects.equals(provisions, other.provisions); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/RequirementsBuilder.java b/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/RequirementsBuilder.java deleted file mode 100644 index e7601e8a..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/model/RequirementsBuilder.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.model; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Objects; -import java.util.Set; - -public class RequirementsBuilder { - private final List requirements = new LinkedList<>(); - private final Set weakRequirements = new HashSet<>(); - - public void add(OperationInterface... interfaces) { - this.add(List.of(interfaces)); - } - - public void add(Collection interfaces) { - requirements.addAll(interfaces); - } - - public void addWeakly(OperationInterface iface) { - weakRequirements.add(iface); - } - - public void strengthenIfPresent(OperationInterface iface) { - if (weakRequirements.contains(iface)) { - weakRequirements.remove(iface); - requirements.add(iface); - } - } - - public Requirements create(Collection allDependencies, - Collection visibleProvisions) { - return new Requirements(requirements, allDependencies, visibleProvisions); - } - - public List toList() { - return Collections.unmodifiableList(requirements); - } - - @Override - public int hashCode() { - return Objects.hash(requirements, weakRequirements); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - RequirementsBuilder other = (RequirementsBuilder) obj; - return Objects.equals(requirements, other.requirements) - && Objects.equals(weakRequirements, other.weakRequirements); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/.classpath b/bundles/org.palladiosimulator.somox.analyzer.rules.impl/.classpath deleted file mode 100644 index 14dd6eb2..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/.classpath +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/plugin.xml b/bundles/org.palladiosimulator.somox.analyzer.rules.impl/plugin.xml deleted file mode 100644 index ceb70709..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/plugin.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/.classpath b/bundles/org.palladiosimulator.somox.analyzer.rules.main/.classpath deleted file mode 100644 index e3378d07..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/META-INF/MANIFEST.MF b/bundles/org.palladiosimulator.somox.analyzer.rules.main/META-INF/MANIFEST.MF deleted file mode 100644 index b65e75b6..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/META-INF/MANIFEST.MF +++ /dev/null @@ -1,38 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: SoMoX Rule Main -Bundle-SymbolicName: org.palladiosimulator.somox.analyzer.rules.main;singleton:=true -Bundle-Version: 5.2.0.qualifier -Bundle-Vendor: palladiosimulator.org -Automatic-Module-Name: org.palladiosimulator.somox.analyzer.rules.main -Bundle-RequiredExecutionEnvironment: JavaSE-17 -Require-Bundle: org.eclipse.core.resources, - org.eclipse.jdt.core, - org.palladiosimulator.pcm, - org.palladiosimulator.somox.analyzer.rules.engine, - org.palladiosimulator.somox.analyzer.rules.impl, - org.apache.log4j, - de.uka.ipd.sdq.workflow, - de.uka.ipd.sdq.workflow.launchconfig, - org.eclipse.debug.ui, - org.eclipse.equinox.app, - org.eclipse.swt, - org.palladiosimulator.commons, - org.eclipse.emf.ecore, - org.palladiosimulator.generator.fluent, - org.apache.commons.csv, - org.jdom2, - org.yaml.snakeyaml, - org.json, - org.apache.commons.cli, - com.github.jsqlparser, - org.palladiosimulator.somox.ast2seff, - org.palladiosimulator.somox.analyzer.rules.mocore, - org.palladiosimulator.view.plantuml.generator, - org.openjdk.nashorn.core -Export-Package: org.palladiosimulator.somox.analyzer.rules.cli;uses:="org.eclipse.equinox.app", - org.palladiosimulator.somox.analyzer.rules.configuration, - org.palladiosimulator.somox.analyzer.rules.main, - org.palladiosimulator.somox.analyzer.rules.service, - org.palladiosimulator.somox.analyzer.rules.workflow, - org.palladiosimulator.somox.discoverer diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/plugin.xml b/bundles/org.palladiosimulator.somox.analyzer.rules.main/plugin.xml deleted file mode 100644 index 444ee6db..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/plugin.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/schema/org.palladiosimulator.somox.analyzer.rules.analyst.exsd b/bundles/org.palladiosimulator.somox.analyzer.rules.main/schema/org.palladiosimulator.somox.analyzer.rules.analyst.exsd deleted file mode 100644 index 9f6a9f19..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/schema/org.palladiosimulator.somox.analyzer.rules.analyst.exsd +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - [Enter description of this extension point.] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/schema/org.palladiosimulator.somox.discoverer.exsd b/bundles/org.palladiosimulator.somox.analyzer.rules.main/schema/org.palladiosimulator.somox.discoverer.exsd deleted file mode 100644 index 1927b682..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/schema/org.palladiosimulator.somox.discoverer.exsd +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - [Enter description of this extension point.] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/configuration/RuleEngineAnalyzerConfiguration.java b/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/configuration/RuleEngineAnalyzerConfiguration.java deleted file mode 100644 index 21bde074..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/configuration/RuleEngineAnalyzerConfiguration.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.configuration; - -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; - -import de.uka.ipd.sdq.workflow.launchconfig.AbstractWorkflowBasedRunConfiguration; - -/** - * An adapter for RuleEngineConfiguration, not more than a formality for use as a type parameter - * AbstractWorkflowBasedLaunchConfigurationDelegate - * - * @see de.uka.ipd.sdq.workflow.launchconfig.AbstractWorkflowBasedLaunchConfigurationDelegate - */ -public class RuleEngineAnalyzerConfiguration extends AbstractWorkflowBasedRunConfiguration { - - private RuleEngineConfiguration ruleEngineConfiguration; - - @Override - public void setDefaults() { - ruleEngineConfiguration = new RuleEngineConfigurationImpl(); - } - - public RuleEngineConfiguration getRuleEngineConfiguration() { - return ruleEngineConfiguration; - } - - public void setRuleEngineConfiguration(RuleEngineConfiguration ruleEngineConfiguration) { - this.ruleEngineConfiguration = ruleEngineConfiguration; - } - - @Override - public String getErrorMessage() { - return null; - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/RuleEngineConfigurationDelegate.java b/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/RuleEngineConfigurationDelegate.java deleted file mode 100644 index 54957dba..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/RuleEngineConfigurationDelegate.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.gui; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.palladiosimulator.somox.analyzer.rules.configuration.RuleEngineAnalyzerConfiguration; -import org.palladiosimulator.somox.analyzer.rules.configuration.RuleEngineConfigurationImpl; -import org.palladiosimulator.somox.analyzer.rules.workflow.RuleEngineJob; - -import de.uka.ipd.sdq.workflow.Workflow; -import de.uka.ipd.sdq.workflow.jobs.IJob; -import de.uka.ipd.sdq.workflow.launchconfig.AbstractWorkflowBasedLaunchConfigurationDelegate; - -public class RuleEngineConfigurationDelegate - extends AbstractWorkflowBasedLaunchConfigurationDelegate { - - @Override - protected IJob createWorkflowJob(RuleEngineAnalyzerConfiguration config, ILaunch launch) throws CoreException { - return new RuleEngineJob(config.getRuleEngineConfiguration()); - } - - @Override - protected RuleEngineAnalyzerConfiguration deriveConfiguration(ILaunchConfiguration configuration, String mode) - throws CoreException { - - final RuleEngineAnalyzerConfiguration analyzerConfiguration = new RuleEngineAnalyzerConfiguration(); - analyzerConfiguration - .setRuleEngineConfiguration(new RuleEngineConfigurationImpl(configuration.getAttributes())); - - return analyzerConfiguration; - } - -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/RuleEngineIoTab.java b/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/RuleEngineIoTab.java deleted file mode 100644 index 2de1a62f..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/RuleEngineIoTab.java +++ /dev/null @@ -1,246 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.gui; - -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.apache.log4j.Logger; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; -import org.eclipse.emf.common.CommonPlugin; -import org.eclipse.emf.common.util.URI; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Text; -import org.palladiosimulator.somox.analyzer.rules.configuration.RuleEngineConfigurationImpl; -import org.palladiosimulator.somox.analyzer.rules.engine.Rule; -import org.palladiosimulator.somox.analyzer.rules.engine.ServiceCollection; -import org.palladiosimulator.somox.analyzer.rules.engine.ServiceConfiguration; -import org.palladiosimulator.somox.analyzer.rules.service.Analyst; -import org.palladiosimulator.somox.analyzer.rules.service.AnalystCollection; -import org.palladiosimulator.somox.analyzer.rules.service.EmptyCollection; -import org.palladiosimulator.somox.analyzer.rules.service.RuleCollection; -import org.palladiosimulator.somox.discoverer.Discoverer; -import org.palladiosimulator.somox.discoverer.DiscovererCollection; - -import de.uka.ipd.sdq.workflow.launchconfig.ImageRegistryHelper; -import de.uka.ipd.sdq.workflow.launchconfig.LaunchConfigPlugin; -import de.uka.ipd.sdq.workflow.launchconfig.tabs.TabHelper; - -public class RuleEngineIoTab extends AbstractLaunchConfigurationTab { - - public static final String NAME = "Rule Engine IO"; - public static final String PLUGIN_ID = "org.palladiosimulator.somox.analyzer.rules.runconfig.LaunchRuleEngineAnalyzer"; - private static final String FILENAME_TAB_IMAGE_PATH = "icons/RuleEngine_16x16.gif"; - - private final String defaultPath; - private final ModifyListener modifyListener; - - private Text in; - private Text out; - private final ServiceConfigurationManager discovererConfigManager; - private final ServiceConfigurationView ruleConfigView; - private final ServiceConfigurationView analystConfigView; - - public RuleEngineIoTab() { - // Create the default path of this Eclipse application - defaultPath = Paths.get(".") - .toAbsolutePath() - .normalize() - .toString(); - - // Create a listener for GUI modification events - modifyListener = e -> { - // e may be null here! - setDirty(true); - updateLaunchConfigurationDialog(); - }; - - ServiceCollection discovererCollection = null; - try { - discovererCollection = new DiscovererCollection(); - } catch (CoreException e) { - Logger.getLogger(RuleEngineIoTab.class) - .error("Exception occurred while discovering discoverers!"); - discovererCollection = new EmptyCollection<>(); - } - ServiceConfiguration discovererConfig = new ServiceConfiguration<>(discovererCollection, - RuleEngineConfigurationImpl.RULE_ENGINE_SELECTED_DISCOVERERS, - RuleEngineConfigurationImpl.RULE_ENGINE_DISCOVERER_CONFIG_PREFIX); - discovererConfigManager = new ServiceConfigurationManager<>(discovererConfig); - - ServiceCollection ruleCollection = null; - try { - ruleCollection = new RuleCollection(); - } catch (CoreException e) { - Logger.getLogger(RuleEngineIoTab.class) - .error("Exception occurred while discovering rules!"); - ruleCollection = new EmptyCollection<>(); - } - ServiceConfiguration ruleConfig = new ServiceConfiguration<>(ruleCollection, - RuleEngineConfigurationImpl.RULE_ENGINE_SELECTED_RULES, - RuleEngineConfigurationImpl.RULE_ENGINE_RULE_CONFIG_PREFIX); - ruleConfig.addDependencyProvider(discovererConfig); - ruleConfigView = new ServiceConfigurationView<>(ruleConfig, modifyListener); - - ServiceCollection analystCollection = null; - try { - analystCollection = new AnalystCollection(); - } catch (CoreException e) { - Logger.getLogger(RuleEngineIoTab.class) - .error("Exception occurred while discovering analysts!"); - analystCollection = new EmptyCollection<>(); - } - ServiceConfiguration analystConfig = new ServiceConfiguration<>(analystCollection, - RuleEngineConfigurationImpl.RULE_ENGINE_SELECTED_ANALYSTS, - RuleEngineConfigurationImpl.RULE_ENGINE_ANALYST_CONFIG_PREFIX); - analystConfig.addDependencyProvider(discovererConfig); - analystConfig.addDependencyProvider(ruleConfig); - analystConfigView = new ServiceConfigurationView<>(analystConfig, modifyListener); - - } - - @Override - public Image getImage() { - // TODO create an image - return ImageRegistryHelper.getTabImage(PLUGIN_ID, FILENAME_TAB_IMAGE_PATH); - } - - @Override - public void createControl(Composite parent) { - // Create a new Composite to hold the page's controls - Composite container = new Composite(parent, SWT.NONE); - setControl(container); - container.setLayout(new GridLayout()); - - // Create file input area for input - in = new Text(container, SWT.SINGLE | SWT.BORDER); - TabHelper.createFolderInputSection(container, modifyListener, "File In", in, "File In", getShell(), - defaultPath); - - // Create file input area for output - out = new Text(container, SWT.SINGLE | SWT.BORDER); - TabHelper.createFolderInputSection(container, modifyListener, "File Out", out, "File Out", getShell(), - defaultPath); - - // Create tree view for rule and analyst configuration - // Do not create a view for discoverers, they can always be selected automatically. - // If a discoverer is added that requires configuration, this view has to be added back. - ruleConfigView.createControl(container); - analystConfigView.createControl(container); - } - - private boolean validateFolderInput(Text widget) { - if ((widget == null) || (widget.getText() == null) || widget.getText() - .isBlank()) { - return error("Blank input."); - } - - try { - URI uri = getURI(widget); - Path path = Paths.get(CommonPlugin.asLocalURI(uri) - .devicePath()); - - if (!Files.exists(path)) { - return error("The file located by '" + uri + "'does not exist."); - } - } catch (Exception e) { - return error(e.getLocalizedMessage()); - } - return error(null); - } - - private boolean error(final String message) { - setErrorMessage(message); - return message == null; - } - - private static URI getURI(Text widget) { - String text = URI.decode(widget.getText()); - URI uri = URI.createURI(text); - if (uri.isPlatform() || uri.isFile()) { - return uri; - } - // This is necessary since paths may start with e.g. "C:" which would - // then be interpreted as a URI scheme - return URI.createFileURI(text); - } - - @Override - public boolean isValid(ILaunchConfiguration launchConfig) { - return validateFolderInput(in) && validateFolderInput(out); - } - - @Override - public void initializeFrom(ILaunchConfiguration configuration) { - setText(configuration, in, RuleEngineConfigurationImpl.RULE_ENGINE_INPUT_PATH); - setText(configuration, out, RuleEngineConfigurationImpl.RULE_ENGINE_OUTPUT_PATH); - - discovererConfigManager.initializeFrom(configuration); - ruleConfigView.initializeFrom(configuration); - analystConfigView.initializeFrom(configuration); - } - - private void setText(ILaunchConfiguration configuration, Text textWidget, String attributeName) { - try { - textWidget.setText(configuration.getAttribute(attributeName, "")); - } catch (final Exception e) { - LaunchConfigPlugin.errorLogger(getName(), attributeName, e.getMessage()); - error(e.getLocalizedMessage()); - } - } - - @Override - public void performApply(ILaunchConfigurationWorkingCopy configuration) { - setAttribute(configuration, RuleEngineConfigurationImpl.RULE_ENGINE_INPUT_PATH, in); - setAttribute(configuration, RuleEngineConfigurationImpl.RULE_ENGINE_OUTPUT_PATH, out); - discovererConfigManager.performApply(configuration); - ruleConfigView.performApply(configuration); - analystConfigView.performApply(configuration); - } - - private void setAttribute(ILaunchConfigurationWorkingCopy configuration, String attributeName, Text textWidget) { - try { - if (textWidget.getText() - .isEmpty()) { - configuration.setAttribute(attributeName, ""); - } else { - configuration.setAttribute(attributeName, getURI(textWidget).toString()); - } - } catch (final Exception e) { - error(e.getLocalizedMessage()); - } - } - - @Override - public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { - setText(in, defaultPath); - setAttribute(configuration, RuleEngineConfigurationImpl.RULE_ENGINE_INPUT_PATH, in); - - setText(out, defaultPath); - setAttribute(configuration, RuleEngineConfigurationImpl.RULE_ENGINE_OUTPUT_PATH, out); - - discovererConfigManager.setDefaults(configuration); - ruleConfigView.setDefaults(configuration); - analystConfigView.setDefaults(configuration); - } - - private void setText(final Text textWidget, final String attributeName) { - try { - textWidget.setText(attributeName); - } catch (final Exception e) { - error(e.getMessage()); - } - } - - @Override - public String getName() { - return NAME; - } - -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/ServiceConfigurationManager.java b/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/ServiceConfigurationManager.java deleted file mode 100644 index 6878a877..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/ServiceConfigurationManager.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.gui; - -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.palladiosimulator.somox.analyzer.rules.engine.Service; -import org.palladiosimulator.somox.analyzer.rules.engine.ServiceConfiguration; - -import de.uka.ipd.sdq.workflow.launchconfig.LaunchConfigPlugin; - -public class ServiceConfigurationManager { - private final ServiceConfiguration serviceConfiguration; - - public ServiceConfigurationManager(ServiceConfiguration serviceConfiguration) { - this.serviceConfiguration = serviceConfiguration; - } - - public void initializeFrom(ILaunchConfiguration configuration) { - try { - serviceConfiguration.applyAttributeMap(configuration.getAttributes()); - } catch (CoreException e) { - LaunchConfigPlugin.log(IStatus.ERROR, e.getMessage()); - } - } - - public void performApply(ILaunchConfigurationWorkingCopy configuration) { - // Update the LaunchConfiguration - writeServiceConfigAttributes(configuration); - } - - /** - * Called when a new launch configuration is created, to set the values to sensible defaults. - * - * @param configuration - * the new launch configuration - */ - public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { - writeServiceConfigAttributes(configuration); - } - - private void writeServiceConfigAttributes(ILaunchConfigurationWorkingCopy configuration) { - Map attributes = serviceConfiguration.toMap(); - for (Map.Entry attribute : attributes.entrySet()) { - configuration.setAttribute(attribute.getKey(), attribute.getValue()); - } - } - - public ServiceConfiguration getServiceConfiguration() { - return serviceConfiguration; - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/ServiceConfigurationView.java b/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/ServiceConfigurationView.java deleted file mode 100644 index b7471209..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/gui/ServiceConfigurationView.java +++ /dev/null @@ -1,157 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.gui; - -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.stream.Collectors; - -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.TreeEditor; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeColumn; -import org.eclipse.swt.widgets.TreeItem; -import org.palladiosimulator.somox.analyzer.rules.engine.Service; -import org.palladiosimulator.somox.analyzer.rules.engine.ServiceConfiguration; - -public class ServiceConfigurationView extends ServiceConfigurationManager { - private static final int SERVICE_CONFIGURATION_VALUE_COLUMN = 1; - - private final Map> configTreeItems; - private final Map serviceCheckboxes; - - private final ModifyListener modifyListener; - - public ServiceConfigurationView(ServiceConfiguration serviceConfiguration, ModifyListener modifyListener) { - super(serviceConfiguration); - - configTreeItems = new HashMap<>(); - serviceCheckboxes = new HashMap<>(); - - this.modifyListener = modifyListener; - } - - public void createControl(Composite container) { - Tree tree = new Tree(container, SWT.BORDER | SWT.FULL_SELECTION); - TreeColumn nameColumn = new TreeColumn(tree, SWT.NONE); - nameColumn.setWidth(200); - TreeColumn valueColumn = new TreeColumn(tree, SWT.NONE); - valueColumn.setWidth(200); - - tree.addListener(SWT.Selection, new TreeEditListener(tree, modifyListener, SERVICE_CONFIGURATION_VALUE_COLUMN)); - - List sortedServices = getServiceConfiguration().getAvailable() - .stream() - .sorted(Comparator.comparing(T::getName)) - .collect(Collectors.toList()); - for (T service : sortedServices) { - TreeItem serviceItem = new TreeItem(tree, SWT.NONE); - serviceItem.setText(0, service.getClass() - .getSimpleName()); - addCheckboxTo(serviceItem, service); - if (service.getConfigurationKeys() != null) { - String serviceId = service.getID(); - configTreeItems.putIfAbsent(serviceId, new HashMap<>()); - for (String configKey : service.getConfigurationKeys()) { - TreeItem propertyItem = new TreeItem(serviceItem, SWT.NONE); - propertyItem.setText(0, configKey); - configTreeItems.get(serviceId) - .put(configKey, propertyItem); - } - } - } - } - - private void addCheckboxTo(TreeItem item, T service) { - Tree tree = item.getParent(); - TreeEditor editor = new TreeEditor(tree); - Button checkbox = new Button(tree, SWT.CHECK); - checkbox.addSelectionListener(new SelectionListener() { - @Override - public void widgetSelected(SelectionEvent e) { - if (((Button) e.getSource()).getSelection()) { - getServiceConfiguration().select(service); - } else { - getServiceConfiguration().deselect(service); - } - modifyListener.modifyText(null); - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - } - }); - checkbox.pack(); - serviceCheckboxes.put(service.getID(), checkbox); - editor.minimumWidth = checkbox.getSize().x; - editor.horizontalAlignment = SWT.LEFT; - editor.setEditor(checkbox, item, SERVICE_CONFIGURATION_VALUE_COLUMN); - } - - @Override - public void initializeFrom(ILaunchConfiguration configuration) { - super.initializeFrom(configuration); - for (T service : getServiceConfiguration().getAvailable()) { - String id = service.getID(); - initializeCheckbox(service, serviceCheckboxes.get(id)); - initializeTreeItems(service, configTreeItems.get(id)); - } - } - - private void initializeCheckbox(T service, Button checkbox) { - boolean selected = getServiceConfiguration().isManuallySelected(service); - checkbox.setSelection(selected); - } - - private void initializeTreeItems(T service, Map treeItems) { - Map strings = getServiceConfiguration().getWholeConfig(service.getID()); - for (Entry entry : treeItems.entrySet()) { - String value = strings.get(entry.getKey()); - if (value == null) { - value = ""; - } - entry.getValue() - .setText(SERVICE_CONFIGURATION_VALUE_COLUMN, value); - } - } - - @Override - public void performApply(ILaunchConfigurationWorkingCopy configuration) { - // Update the ServiceConfiguration with the values from the tree items - for (T service : getServiceConfiguration().getAvailable()) { - for (Entry entry : configTreeItems.get(service.getID()) - .entrySet()) { - TreeItem treeItem = entry.getValue(); - String configurationValue = treeItem.getText(SERVICE_CONFIGURATION_VALUE_COLUMN); - getServiceConfiguration().setConfig(service.getID(), entry.getKey(), configurationValue); - } - } - - super.performApply(configuration); - } - - /** - * Called when a new launch configuration is created, to set the values to sensible defaults. - * - * @param configuration - * the new launch configuration - */ - public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { - writeServiceConfigAttributes(configuration); - } - - private void writeServiceConfigAttributes(ILaunchConfigurationWorkingCopy configuration) { - Map attributes = getServiceConfiguration().toMap(); - for (Map.Entry attribute : attributes.entrySet()) { - configuration.setAttribute(attribute.getKey(), attribute.getValue()); - } - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/main/RuleEngineException.java b/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/main/RuleEngineException.java deleted file mode 100644 index b77d771e..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/main/RuleEngineException.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.main; - -/** - * A general exception for the rule engine. - * - * @author Florian Bossert - */ -public class RuleEngineException extends Exception { - - private static final long serialVersionUID = 8438995877350048404L; - - public RuleEngineException(String message) { - super(message); - } - - public RuleEngineException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/service/Analyst.java b/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/service/Analyst.java deleted file mode 100644 index 7c0611e0..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/service/Analyst.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.service; - -import java.util.Set; - -import org.palladiosimulator.somox.analyzer.rules.engine.Service; - -/** - * The defining interface of the org.palladiosimulator.somox.analyzer.rules.analyst extension point. - * Implement this interface to extend the rule engine by an additional analyst that can then process - * the generated model. - * - * @author Florian Bossert - */ -public interface Analyst extends Service { - @Override - default Set getDependentServices() { - return Set.of(); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/RuleEngineBlackboardInteractingJob.java b/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/RuleEngineBlackboardInteractingJob.java deleted file mode 100644 index 4852c29d..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/RuleEngineBlackboardInteractingJob.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.workflow; - -import java.util.Objects; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; -import org.palladiosimulator.somox.analyzer.rules.main.RuleEngineAnalyzer; -import org.palladiosimulator.somox.analyzer.rules.main.RuleEngineException; - -import de.uka.ipd.sdq.workflow.jobs.AbstractBlackboardInteractingJob; -import de.uka.ipd.sdq.workflow.jobs.CleanupFailedException; -import de.uka.ipd.sdq.workflow.jobs.JobFailedException; -import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; - -public class RuleEngineBlackboardInteractingJob extends AbstractBlackboardInteractingJob { - - private static final String NAME = "Rule Engine Blackboard Interacting"; - - private final RuleEngineConfiguration configuration; - - public RuleEngineBlackboardInteractingJob(RuleEngineConfiguration configuration, RuleEngineBlackboard blackboard) { - super.setBlackboard(blackboard); - this.configuration = Objects.requireNonNull(configuration); - } - - @Override - public void cleanup(IProgressMonitor monitor) throws CleanupFailedException { - } - - @Override - public void execute(IProgressMonitor monitor) throws JobFailedException, UserCanceledException { - try { - new RuleEngineAnalyzer(getBlackboard()).analyze(configuration, monitor); - } catch (final RuleEngineException e) { - throw new JobFailedException(NAME + " Failed", e); - } - } - - @Override - public String getName() { - return NAME; - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/RuleEngineJob.java b/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/RuleEngineJob.java deleted file mode 100644 index 7fb32485..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.main/src/org/palladiosimulator/somox/analyzer/rules/workflow/RuleEngineJob.java +++ /dev/null @@ -1,141 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.workflow; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; -import org.palladiosimulator.somox.analyzer.rules.configuration.RuleEngineBlackboardKeys; -import org.palladiosimulator.somox.analyzer.rules.engine.Rule; -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; -import org.palladiosimulator.somox.analyzer.rules.mocore.workflow.MoCoReJob; -import org.palladiosimulator.somox.analyzer.rules.service.Analyst; -import org.palladiosimulator.somox.ast2seff.jobs.Ast2SeffJob; -import org.palladiosimulator.somox.discoverer.Discoverer; - -import de.uka.ipd.sdq.workflow.extension.AbstractExtendableJob; -import de.uka.ipd.sdq.workflow.jobs.IBlackboardInteractingJob; -import de.uka.ipd.sdq.workflow.jobs.ParallelJob; - -public class RuleEngineJob extends AbstractExtendableJob { - - public RuleEngineJob(RuleEngineConfiguration configuration) { - super.setBlackboard(new RuleEngineBlackboard()); - - super.addAll(createDiscovererJobs(configuration)); - - super.addAll(createRuleJobs(configuration)); - - super.addAll(createBuildRulesJob(configuration)); - - super.add(new RuleEngineBlackboardInteractingJob(configuration, getBlackboard())); - - super.addAll(createAnalystJobs(configuration)); - - // Generate service effect specifications based on AST nodes and merge them into repository - super.add( - new Ast2SeffJob(getBlackboard(), RuleEngineBlackboardKeys.RULE_ENGINE_BLACKBOARD_KEY_SEFF_ASSOCIATIONS, - RuleEngineBlackboardKeys.RULE_ENGINE_AST2SEFF_OUTPUT_REPOSITORY)); - super.add(new SeffMergerJob(myBlackboard, RuleEngineBlackboardKeys.RULE_ENGINE_AST2SEFF_OUTPUT_REPOSITORY, - RuleEngineBlackboardKeys.RULE_ENGINE_BLACKBOARD_KEY_REPOSITORY)); - - // Refine model and create final repository, system, allocation, & resource environment - super.add(new MoCoReJob(getBlackboard(), RuleEngineBlackboardKeys.RULE_ENGINE_BLACKBOARD_KEY_REPOSITORY, - RuleEngineBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_REPOSITORY, - RuleEngineBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_SYSTEM, - RuleEngineBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_ALLOCATION, - RuleEngineBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_RESOURCE_ENVIRONMENT)); - - // Merge data & failure types into output repository - super.add(new TypeMergerJob(getBlackboard(), RuleEngineBlackboardKeys.RULE_ENGINE_BLACKBOARD_KEY_REPOSITORY, - RuleEngineBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_REPOSITORY)); - - // Persist repository, system, allocation, & resource environment model from blackboard into - // file system - super.add(new PersistenceJob(getBlackboard(), configuration.getInputFolder(), configuration.getOutputFolder(), - RuleEngineBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_REPOSITORY, - RuleEngineBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_SYSTEM, - RuleEngineBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_ALLOCATION, - RuleEngineBlackboardKeys.RULE_ENGINE_MOCORE_OUTPUT_RESOURCE_ENVIRONMENT)); - - super.add(new PlantUmlJob(configuration, getBlackboard())); - } - - private List createRuleJobs(RuleEngineConfiguration configuration) { - List jobs = new ArrayList<>(); - - for (Collection step : configuration.getConfig(Rule.class) - .getExecutionOrder()) { - ParallelJob parentJob = new ParallelJob(); - for (Rule rule : step) { - // Assume only build rules depend on build rules. - if (rule.isBuildRule()) { - continue; - } - IBlackboardInteractingJob ruleJob = rule.create(configuration, myBlackboard); - parentJob.add(ruleJob); - logger.info("Adding rule job \"" + ruleJob.getName() + "\""); - } - jobs.add(parentJob); - } - - return jobs; - } - - private List createBuildRulesJob(RuleEngineConfiguration configuration) { - List jobs = new ArrayList<>(); - - for (Collection step : configuration.getConfig(Rule.class) - .getExecutionOrder()) { - ParallelJob parentJob = new ParallelJob(); - for (Rule rule : step) { - // Assume only build rules depend on build rules. - if (!rule.isBuildRule()) { - continue; - } - IBlackboardInteractingJob ruleJob = rule.create(configuration, myBlackboard); - parentJob.add(ruleJob); - logger.info("Adding build rule job \"" + ruleJob.getName() + "\""); - } - jobs.add(parentJob); - } - - return jobs; - } - - private List createDiscovererJobs(RuleEngineConfiguration configuration) { - List jobs = new ArrayList<>(); - - for (Collection step : configuration.getConfig(Discoverer.class) - .getExecutionOrder()) { - ParallelJob parentJob = new ParallelJob(); - for (Discoverer discoverer : step) { - IBlackboardInteractingJob discovererJob = discoverer.create(configuration, - myBlackboard); - parentJob.add(discovererJob); - logger.info("Adding discoverer job \"" + discovererJob.getName() + "\""); - } - jobs.add(parentJob); - } - - return jobs; - } - - private List createAnalystJobs(RuleEngineConfiguration configuration) { - List jobs = new ArrayList<>(); - - for (Collection step : configuration.getConfig(Analyst.class) - .getExecutionOrder()) { - ParallelJob parentJob = new ParallelJob(); - for (Analyst analyst : step) { - IBlackboardInteractingJob analystJob = analyst.create(configuration, - myBlackboard); - parentJob.add(analystJob); - logger.info("Adding analyst job \"" + analystJob.getName() + "\""); - } - jobs.add(parentJob); - } - - return jobs; - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/.classpath b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/.classpath deleted file mode 100644 index 3628e336..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/META-INF/MANIFEST.MF b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/META-INF/MANIFEST.MF deleted file mode 100644 index fbe71be6..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/META-INF/MANIFEST.MF +++ /dev/null @@ -1,23 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: org.palladiosimulator.somox.analyzer.rules.mocore -Bundle-SymbolicName: org.palladiosimulator.somox.analyzer.rules.mocore;singleton:=true -Bundle-Version: 1.0.0.qualifier -Automatic-Module-Name: org.palladiosimulator.somox.analyzer.rules.mocore -Bundle-Vendor: palladiosimulator.org -Bundle-RequiredExecutionEnvironment: JavaSE-17 -Bundle-ActivationPolicy: lazy -Export-Package: org.palladiosimulator.somox.analyzer.rules.mocore.discovery, - org.palladiosimulator.somox.analyzer.rules.mocore.orchestration, - org.palladiosimulator.somox.analyzer.rules.mocore.processor.element, - org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation, - org.palladiosimulator.somox.analyzer.rules.mocore.surrogate, - org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element, - org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation, - org.palladiosimulator.somox.analyzer.rules.mocore.transformation, - org.palladiosimulator.somox.analyzer.rules.mocore.workflow -Require-Bundle: tools.mdsd.mocore.framework, - org.palladiosimulator.pcm, - org.palladiosimulator.pcm.resources, - org.palladiosimulator.generator.fluent, - de.uka.ipd.sdq.workflow diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/discovery/RepositoryDecompositor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/discovery/RepositoryDecompositor.java deleted file mode 100644 index 02072653..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/discovery/RepositoryDecompositor.java +++ /dev/null @@ -1,277 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.discovery; - -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.palladiosimulator.pcm.core.composition.AssemblyConnector; -import org.palladiosimulator.pcm.core.composition.AssemblyContext; -import org.palladiosimulator.pcm.core.composition.Connector; -import org.palladiosimulator.pcm.core.composition.ProvidedDelegationConnector; -import org.palladiosimulator.pcm.core.composition.RequiredDelegationConnector; -import org.palladiosimulator.pcm.repository.BasicComponent; -import org.palladiosimulator.pcm.repository.CompositeComponent; -import org.palladiosimulator.pcm.repository.OperationProvidedRole; -import org.palladiosimulator.pcm.repository.OperationRequiredRole; -import org.palladiosimulator.pcm.repository.OperationSignature; -import org.palladiosimulator.pcm.repository.ProvidedRole; -import org.palladiosimulator.pcm.repository.Repository; -import org.palladiosimulator.pcm.repository.RepositoryComponent; -import org.palladiosimulator.pcm.repository.RequiredRole; -import org.palladiosimulator.pcm.seff.ResourceDemandingSEFF; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.AtomicComponent; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Composite; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.ServiceEffectSpecification; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Signature; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAssemblyRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentSignatureProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositeProvisionDelegationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositeRequirementDelegationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceRequirementRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ServiceEffectSpecificationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.SignatureProvisionRelation; - -import tools.mdsd.mocore.framework.discovery.Discoverer; - -/** - * A decompositor able to extract model-elements and model-relations from a {@link Repository PCM repository}. - */ -public class RepositoryDecompositor implements Decompositor { - @Override - public Collection> decompose(Repository repository) { - // Fetch components, interface provisions and requirements, signatures, and service effect specifications - Set atomicComponents = new HashSet<>(); - Set composites = new HashSet<>(); - Set compositions = new HashSet<>(); - Set interfaceProvisions = new HashSet<>(); - Set interfaceRequirements = new HashSet<>(); - Set signatureProvisions = new HashSet<>(); - Set seffProvisions = new HashSet<>(); - Set componentAssemblies = new HashSet<>(); - Set provisionDelegations = new HashSet<>(); - Set requirementDelegations = new HashSet<>(); - - for (RepositoryComponent repositoryComponent : repository.getComponents__Repository()) { - Component component; - if (repositoryComponent instanceof BasicComponent) { - AtomicComponent atomicComponent = new AtomicComponent((BasicComponent) repositoryComponent, false); - atomicComponents.add(atomicComponent); - component = atomicComponent; - - // Basic component specific behavior - // Fetch service effect specifications from basic component - for (org.palladiosimulator.pcm.seff.ServiceEffectSpecification seff : atomicComponent.getValue() - .getServiceEffectSpecifications__BasicComponent()) { - if (seff instanceof ResourceDemandingSEFF) { - if (seff.getDescribedService__SEFF() instanceof OperationSignature) { - ServiceEffectSpecification seffWrapper = new ServiceEffectSpecification( - (ResourceDemandingSEFF) seff, false); - OperationSignature operationSignature = (OperationSignature) seff - .getDescribedService__SEFF(); - Signature signature = new Signature(operationSignature, false); - Interface interFace = new Interface(operationSignature.getInterface__OperationSignature(), - false); - SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, - interFace, false); - InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(component, - interFace, false); - ComponentSignatureProvisionRelation componentSignatureProvision = new ComponentSignatureProvisionRelation( - interfaceProvision, signatureProvision, false); - seffProvisions.add(new ServiceEffectSpecificationRelation(componentSignatureProvision, - seffWrapper, false)); - } - } - } - } else if (repositoryComponent instanceof CompositeComponent) { - Composite composite = new Composite((CompositeComponent) repositoryComponent, false); - composites.add(composite); - component = composite; - - // Composite specific behavior - // Create composition relations for each composite - for (AssemblyContext assemblyContext : composite.getValue().getAssemblyContexts__ComposedStructure()) { - RepositoryComponent encapsulatedComponent = assemblyContext - .getEncapsulatedComponent__AssemblyContext(); - - // Create appropriate wrapper for child component - Component childWrapper = getGenericWrapperFor(encapsulatedComponent); - if (childWrapper == null) { - // Ignore child that cannot be wrapped - continue; - } - - // Create composition for composite & child - CompositionRelation composition = new CompositionRelation(composite, childWrapper, false); - compositions.add(composition); - } - - // Process connectors of composite component - for (Connector connector : composite.getValue().getConnectors__ComposedStructure()) { - if (connector instanceof AssemblyConnector) { - AssemblyConnector assemblyConnector = (AssemblyConnector) connector; - - // Wrap provider and consumer component - Component provider = getGenericWrapperFor( - assemblyConnector.getProvidingAssemblyContext_AssemblyConnector() - .getEncapsulatedComponent__AssemblyContext()); - Component consumer = getGenericWrapperFor( - assemblyConnector.getRequiringAssemblyContext_AssemblyConnector() - .getEncapsulatedComponent__AssemblyContext()); - - // Wrap role interfaces - Interface providedInterface = new Interface(assemblyConnector - .getProvidedRole_AssemblyConnector().getProvidedInterface__OperationProvidedRole(), - false); - Interface requiredInterface = new Interface(assemblyConnector - .getRequiredRole_AssemblyConnector().getRequiredInterface__OperationRequiredRole(), - false); - - // Create interface relations & component assembly relation - InterfaceProvisionRelation provisionRelation = new InterfaceProvisionRelation(provider, - providedInterface, false); - InterfaceRequirementRelation requirementRelation = new InterfaceRequirementRelation(consumer, - requiredInterface, false); - ComponentAssemblyRelation assemblyRelation = new ComponentAssemblyRelation(provisionRelation, - requirementRelation, false); - - // Add assembly to discoverer - componentAssemblies.add(assemblyRelation); - } else if (connector instanceof ProvidedDelegationConnector) { - ProvidedDelegationConnector providedDelegationConnector = (ProvidedDelegationConnector) connector; - - // Wrap the providing component & the inner and outer role's interfaces - Component connectorComponent = getGenericWrapperFor( - providedDelegationConnector.getAssemblyContext_ProvidedDelegationConnector() - .getEncapsulatedComponent__AssemblyContext()); - Interface innerInterface = new Interface( - providedDelegationConnector.getInnerProvidedRole_ProvidedDelegationConnector() - .getProvidedInterface__OperationProvidedRole(), - false); - Interface outerInterface = new Interface( - providedDelegationConnector.getOuterProvidedRole_ProvidedDelegationConnector() - .getProvidedInterface__OperationProvidedRole(), - false); - - // Create interface relations - InterfaceProvisionRelation innerInterfaceRelation = new InterfaceProvisionRelation( - connectorComponent, innerInterface, false); - InterfaceProvisionRelation outerInterfaceRelation = new InterfaceProvisionRelation( - composite, outerInterface, false); - CompositeProvisionDelegationRelation delegationRelation = new CompositeProvisionDelegationRelation( - outerInterfaceRelation, innerInterfaceRelation, false); - - // Add delegation relation to discoverer - provisionDelegations.add(delegationRelation); - } else if (connector instanceof RequiredDelegationConnector) { - RequiredDelegationConnector requiredDelegationConnector = (RequiredDelegationConnector) connector; - - // Wrap the requiring component & the inner and outer role's interfaces - Component connectorComponent = getGenericWrapperFor( - requiredDelegationConnector.getAssemblyContext_RequiredDelegationConnector() - .getEncapsulatedComponent__AssemblyContext()); - Interface innerInterface = new Interface( - requiredDelegationConnector.getInnerRequiredRole_RequiredDelegationConnector() - .getRequiredInterface__OperationRequiredRole(), - false); - Interface outerInterface = new Interface( - requiredDelegationConnector.getOuterRequiredRole_RequiredDelegationConnector() - .getRequiredInterface__OperationRequiredRole(), - false); - - // Create interface relations & delegation relation - InterfaceRequirementRelation innerInterfaceRelation = new InterfaceRequirementRelation( - connectorComponent, innerInterface, false); - InterfaceRequirementRelation outerInterfaceRelation = new InterfaceRequirementRelation( - composite, outerInterface, false); - CompositeRequirementDelegationRelation delegationRelation = new CompositeRequirementDelegationRelation( - outerInterfaceRelation, innerInterfaceRelation, false); - - // Add delegation relation to discoverer - requirementDelegations.add(delegationRelation); - } - } - } else { - // Ignore repository components that are neither basic nor composite - continue; - } - - // Behavior for generic repository components - // Transform provided roles into interface provision relations - for (ProvidedRole providedRole : repositoryComponent.getProvidedRoles_InterfaceProvidingEntity()) { - if (providedRole instanceof OperationProvidedRole) { - OperationProvidedRole operationProvidedRole = (OperationProvidedRole) providedRole; - Interface providerInterface = new Interface( - operationProvidedRole.getProvidedInterface__OperationProvidedRole(), false); - interfaceProvisions.add(new InterfaceProvisionRelation(component, providerInterface, false)); - - // Create signature provisions for provider interface - for (OperationSignature operationSignature : providerInterface.getValue() - .getSignatures__OperationInterface()) { - Signature signatureWrapper = new Signature(operationSignature, false); - signatureProvisions.add(new SignatureProvisionRelation(signatureWrapper, - providerInterface, false)); - } - } - } - - // Transform required roles into interface requirement relations - for (RequiredRole requiredRole : repositoryComponent.getRequiredRoles_InterfaceRequiringEntity()) { - if (requiredRole instanceof OperationRequiredRole) { - OperationRequiredRole operationRequiredRole = (OperationRequiredRole) requiredRole; - Interface consumerInterface = new Interface( - operationRequiredRole.getRequiredInterface__OperationRequiredRole(), false); - interfaceRequirements.add(new InterfaceRequirementRelation(component, consumerInterface, false)); - - // Create signature provisions for consumer interface - for (OperationSignature operationSignature : consumerInterface.getValue() - .getSignatures__OperationInterface()) { - Signature signatureWrapper = new Signature(operationSignature, false); - signatureProvisions.add(new SignatureProvisionRelation(signatureWrapper, - consumerInterface, false)); - } - } - } - } - - SimpleDiscoverer atomicComponentDiscoverer = new SimpleDiscoverer<>(atomicComponents, - AtomicComponent.class); - SimpleDiscoverer compositeDiscoverer = new SimpleDiscoverer<>(composites, Composite.class); - SimpleDiscoverer compositionDiscoverer = new SimpleDiscoverer<>(compositions, - CompositionRelation.class); - SimpleDiscoverer signatureProvisionDiscoverer = new SimpleDiscoverer<>( - signatureProvisions, SignatureProvisionRelation.class); - SimpleDiscoverer interfaceProvisionDiscoverer = new SimpleDiscoverer<>( - interfaceProvisions, InterfaceProvisionRelation.class); - SimpleDiscoverer interfaceRequirementDiscoverer = new SimpleDiscoverer<>( - interfaceRequirements, InterfaceRequirementRelation.class); - SimpleDiscoverer seffProvisionDiscoverer = new SimpleDiscoverer<>( - seffProvisions, ServiceEffectSpecificationRelation.class); - SimpleDiscoverer assemblyDiscoverer = new SimpleDiscoverer<>(componentAssemblies, - ComponentAssemblyRelation.class); - SimpleDiscoverer provisionDelegationDiscoverer = new SimpleDiscoverer<>( - provisionDelegations, CompositeProvisionDelegationRelation.class); - SimpleDiscoverer< - CompositeRequirementDelegationRelation> requirementDelegationDiscoverer = new SimpleDiscoverer<>( - requirementDelegations, CompositeRequirementDelegationRelation.class); - return List.of(atomicComponentDiscoverer, compositeDiscoverer, compositionDiscoverer, - signatureProvisionDiscoverer, interfaceProvisionDiscoverer, interfaceRequirementDiscoverer, - seffProvisionDiscoverer, assemblyDiscoverer, provisionDelegationDiscoverer, - requirementDelegationDiscoverer); - } - - private Component getGenericWrapperFor(RepositoryComponent repositoryComponent) { - // Ignore components that are neither basic nor composite - Component wrapper = null; - if (repositoryComponent instanceof BasicComponent) { - wrapper = new AtomicComponent((BasicComponent) repositoryComponent, false); - } else if (repositoryComponent instanceof CompositeComponent) { - wrapper = new Composite((CompositeComponent) repositoryComponent, false); - } - return wrapper; - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/orchestration/PcmOrchestrator.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/orchestration/PcmOrchestrator.java deleted file mode 100644 index fdaf08a3..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/orchestration/PcmOrchestrator.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.orchestration; - -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.element.AtomicComponentProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.element.CompositeProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.element.DeploymentProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.element.InterfaceProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.element.LinkResourceSpecificationProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.element.ServiceEffectSpecificationProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.element.SignatureProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation.ComponentAllocationRelationProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation.ComponentAssemblyRelationProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation.ComponentSignatureProvisionRelationProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation.CompositeProvisionDelegationRelationProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation.CompositeRequirementDelegationRelationProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation.CompositionRelationProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation.DeploymentDeploymentRelationProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation.InterfaceProvisionRelationProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation.InterfaceRequirementRelationProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation.LinkResourceSpecificationRelationProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation.ServiceEffectSpecificationRelationProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation.SignatureProvisionRelationProcessor; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; - -import tools.mdsd.mocore.framework.orchestration.Orchestrator; - -public class PcmOrchestrator extends Orchestrator { - public PcmOrchestrator(PcmSurrogate model) { - super(model, new SignatureProcessor(model), new InterfaceProcessor(model), - new DeploymentProcessor(model), new LinkResourceSpecificationProcessor(model), - new ServiceEffectSpecificationProcessor(model), new SignatureProvisionRelationProcessor(model), - new InterfaceProvisionRelationProcessor(model), new InterfaceRequirementRelationProcessor(model), - new ComponentAssemblyRelationProcessor(model), new ComponentAllocationRelationProcessor(model), - new DeploymentDeploymentRelationProcessor(model), new LinkResourceSpecificationRelationProcessor(model), - new ServiceEffectSpecificationRelationProcessor(model), new AtomicComponentProcessor(model), - new ComponentSignatureProvisionRelationProcessor(model), new CompositeProcessor(model), - new CompositionRelationProcessor(model), new CompositeRequirementDelegationRelationProcessor(model), - new CompositeProvisionDelegationRelationProcessor(model)); - } - - public PcmOrchestrator() { - this(new PcmSurrogate()); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/AtomicComponentProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/AtomicComponentProcessor.java deleted file mode 100644 index 2c9260f3..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/AtomicComponentProcessor.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.element; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.AtomicComponent; - -public class AtomicComponentProcessor extends ComponentProcessor { - public AtomicComponentProcessor(PcmSurrogate model) { - super(model, AtomicComponent.class); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/ComponentProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/ComponentProcessor.java deleted file mode 100644 index 1e4925bf..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/ComponentProcessor.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.element; - -import java.util.List; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAllocationRelation; - -import tools.mdsd.mocore.framework.processor.Processor; - -public abstract class ComponentProcessor> extends Processor { - public ComponentProcessor(PcmSurrogate model, Class processableType) { - super(model, processableType); - } - - @Override - protected void refine(T discovery) { - List deploymentRelations = getModel().getByType(ComponentAllocationRelation.class); - deploymentRelations.removeIf(relation -> !relation.getSource().equals(discovery)); - - if (deploymentRelations.isEmpty()) { - Deployment deployment = Deployment.getUniquePlaceholder(); - ComponentAllocationRelation relation = new ComponentAllocationRelation(discovery, deployment, true); - addImplication(relation); - } - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/CompositeProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/CompositeProcessor.java deleted file mode 100644 index 55c0a4bf..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/CompositeProcessor.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.element; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Composite; - -public class CompositeProcessor extends ComponentProcessor { - public CompositeProcessor(PcmSurrogate model) { - super(model, Composite.class); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/DeploymentProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/DeploymentProcessor.java deleted file mode 100644 index 0b206f07..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/DeploymentProcessor.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.element; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; - -import tools.mdsd.mocore.framework.processor.Processor; - -public class DeploymentProcessor extends Processor { - public DeploymentProcessor(PcmSurrogate model) { - super(model, Deployment.class); - } - - @Override - protected void refine(Deployment discovery) { - // No refinement needed when adding a deployment element - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/InterfaceProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/InterfaceProcessor.java deleted file mode 100644 index 765d08e9..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/InterfaceProcessor.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.element; - -import java.util.List; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceProvisionRelation; - -import tools.mdsd.mocore.framework.processor.Processor; - -public class InterfaceProcessor extends Processor { - private static final String PLACEHOLDER_COMPONENT_NAME_PATTERN = "%s Provider"; - - public InterfaceProcessor(PcmSurrogate model) { - super(model, Interface.class); - } - - @Override - protected void refine(Interface discovery) { - List providesRelations = getModel().getByType(InterfaceProvisionRelation.class); - providesRelations.removeIf(relation -> !relation.getDestination().equals(discovery)); - - // Rule: Each interface has to be provided by a component. - // -> If no provision relation exists yet, add a placeholder provider and relation to the model. - if (providesRelations.isEmpty()) { - String interfaceName = discovery.getValue().getEntityName(); - String componentName = String.format(PLACEHOLDER_COMPONENT_NAME_PATTERN, interfaceName); - Component component = Component.getNamedPlaceholder(componentName); - InterfaceProvisionRelation relation = new InterfaceProvisionRelation(component, discovery, true); - addImplication(relation); - } - } - -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/LinkResourceSpecificationProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/LinkResourceSpecificationProcessor.java deleted file mode 100644 index 796100f6..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/LinkResourceSpecificationProcessor.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.element; - -import java.util.List; -import java.util.Objects; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.LinkResourceSpecification; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.DeploymentDeploymentRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.LinkResourceSpecificationRelation; - -import tools.mdsd.mocore.framework.processor.Processor; - -public class LinkResourceSpecificationProcessor extends Processor { - public LinkResourceSpecificationProcessor(PcmSurrogate model) { - super(model, LinkResourceSpecification.class); - } - - @Override - protected void refine(LinkResourceSpecification discovery) { - List relations = this.getModel() - .getByType(LinkResourceSpecificationRelation.class); - relations.removeIf(relation -> !Objects.equals(relation.getSource(), discovery)); - - if (relations.isEmpty()) { - Deployment sourcePlaceholder = Deployment.getUniquePlaceholder(); - Deployment destinationPlaceholder = Deployment.getUniquePlaceholder(); - DeploymentDeploymentRelation deploymentRelation = new DeploymentDeploymentRelation(sourcePlaceholder, - destinationPlaceholder, true); - LinkResourceSpecificationRelation implicitRelation = new LinkResourceSpecificationRelation(discovery, - deploymentRelation, true); - addImplication(implicitRelation); - } - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/ServiceEffectSpecificationProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/ServiceEffectSpecificationProcessor.java deleted file mode 100644 index 82c442c3..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/ServiceEffectSpecificationProcessor.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.element; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.ServiceEffectSpecification; - -import tools.mdsd.mocore.framework.processor.Processor; - -public class ServiceEffectSpecificationProcessor extends Processor { - public ServiceEffectSpecificationProcessor(PcmSurrogate model) { - super(model, ServiceEffectSpecification.class); - } - - @Override - protected void refine(ServiceEffectSpecification discovery) { - // TODO Evaluate whether refinement should be done for a single specification element - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/SignatureProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/SignatureProcessor.java deleted file mode 100644 index 57dd0808..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/SignatureProcessor.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.element; - -import java.util.List; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Signature; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.SignatureProvisionRelation; - -import tools.mdsd.mocore.framework.processor.Processor; - -public class SignatureProcessor extends Processor { - public SignatureProcessor(PcmSurrogate model) { - super(model, Signature.class); - } - - @Override - protected void refine(Signature discovery) { - // Add providing interface for signature if none exists - List interfaceRelations = getModel().getByType(SignatureProvisionRelation.class); - interfaceRelations.removeIf(relation -> !relation.getSource().equals(discovery)); - if (interfaceRelations.isEmpty()) { - Interface interfaceElement = Interface.getUniquePlaceholder(); - SignatureProvisionRelation relation = new SignatureProvisionRelation(discovery, interfaceElement, true); - addImplication(relation); - } - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentAllocationRelationProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentAllocationRelationProcessor.java deleted file mode 100644 index a4d8d100..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentAllocationRelationProcessor.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAllocationRelation; - -import tools.mdsd.mocore.framework.processor.RelationProcessor; - -public class ComponentAllocationRelationProcessor extends RelationProcessor { - public ComponentAllocationRelationProcessor(PcmSurrogate model) { - super(model, ComponentAllocationRelation.class); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentAssemblyRelationProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentAssemblyRelationProcessor.java deleted file mode 100644 index 44610c8e..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentAssemblyRelationProcessor.java +++ /dev/null @@ -1,103 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAllocationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAssemblyRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.DeploymentDeploymentRelation; - -import tools.mdsd.mocore.framework.processor.RelationProcessor; - -public class ComponentAssemblyRelationProcessor extends RelationProcessor { - public ComponentAssemblyRelationProcessor(PcmSurrogate model) { - super(model, ComponentAssemblyRelation.class); - } - - @Override - protected void refine(ComponentAssemblyRelation discovery) { - // Identify all allocations of the providing and consuming component in the assembly - Component provider = discovery.getSource().getSource(); - Component consumer = discovery.getDestination().getSource(); - Interface providerConsumerInterface = discovery.getSource().getDestination(); - List providerAllocations = getAllocatedContainers(provider); - List consumerAllocations = getAllocatedContainers(consumer); - - // Add link between allocation containers of assembled components if needed - if (providerAllocations.isEmpty()) { - Deployment placeholderDeployment = Deployment.getUniquePlaceholder(); - ComponentAllocationRelation allocation = new ComponentAllocationRelation(provider, - placeholderDeployment, true); - providerAllocations.add(placeholderDeployment); - this.addImplication(allocation); - } - if (consumerAllocations.isEmpty()) { - Deployment placeholderDeployment = Deployment.getUniquePlaceholder(); - ComponentAllocationRelation allocation = new ComponentAllocationRelation(consumer, - placeholderDeployment, true); - consumerAllocations.add(placeholderDeployment); - this.addImplication(allocation); - } - for (Deployment providerContainer : providerAllocations) { - for (Deployment consumerContainer : consumerAllocations) { - if (!providerContainer.equals(consumerContainer)) { - // Connect every providing container with each consuming one, except they are the same container - DeploymentDeploymentRelation containerLink = new DeploymentDeploymentRelation(providerContainer, - consumerContainer, true); - this.addImplication(containerLink); - } - } - } - - // Remove component assembly fully-placeholder relation (non-direct & non-indirect) - List assemblies = this.getModel().getByType(ComponentAssemblyRelation.class); - assemblies.removeIf(assembly -> !assembly.getSource().isPlaceholder() - || !assembly.getDestination().isPlaceholder()); - for (ComponentAssemblyRelation placeholderAssembly : assemblies) { - if (discovery.equals(placeholderAssembly)) { - continue; - } - Component source = placeholderAssembly.getSource().getSource(); - Component destination = placeholderAssembly.getDestination().getSource(); - Interface sourceDestinationInterface = placeholderAssembly.getSource().getDestination(); - // Placeholder are unique and can only be allocated to a single container - Optional optionalSourceContainer = getAllocatedContainers(source) - .stream().findFirst(); - Optional optionalDestinationContainer = getAllocatedContainers(destination) - .stream().findFirst(); - - if (optionalSourceContainer.isPresent() && optionalDestinationContainer.isPresent()) { - Deployment sourceContainer = optionalSourceContainer.get(); - Deployment destinationContainer = optionalDestinationContainer.get(); - - // Container links are bi-directional => Parallel or inverse assemblies are valid - boolean isParallelAssembly = providerAllocations.contains(sourceContainer) - && consumerAllocations.contains(destinationContainer); - boolean isInverseAssembly = providerAllocations.contains(destinationContainer) - && consumerAllocations.contains(sourceContainer); - if (isParallelAssembly || isInverseAssembly) { - this.addImplications(this.getModel().replace(placeholderAssembly, discovery)); - this.addImplications(this.getModel().replace(source, provider)); - this.addImplications(this.getModel().replace(destination, consumer)); - this.addImplications(this.getModel().replace(sourceDestinationInterface, - providerConsumerInterface)); - } - } - } - - super.refine(discovery); - } - - private List getAllocatedContainers(Component component) { - List allocations = this.getModel().getByType(ComponentAllocationRelation.class); - return allocations.stream() - .filter(allocation -> allocation.getSource().equals(component)) - .map(ComponentAllocationRelation::getDestination) - .collect(Collectors.toList()); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentSignatureProvisionRelationProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentSignatureProvisionRelationProcessor.java deleted file mode 100644 index 1b294a29..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentSignatureProvisionRelationProcessor.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentSignatureProvisionRelation; - -import tools.mdsd.mocore.framework.processor.RelationProcessor; - -public class ComponentSignatureProvisionRelationProcessor - extends RelationProcessor { - public ComponentSignatureProvisionRelationProcessor(PcmSurrogate model) { - super(model, ComponentSignatureProvisionRelation.class); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositeProvisionDelegationRelationProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositeProvisionDelegationRelationProcessor.java deleted file mode 100644 index 350f1f5f..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositeProvisionDelegationRelationProcessor.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import java.util.List; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Composite; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositeProvisionDelegationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositionRelation; - -import tools.mdsd.mocore.framework.processor.RelationProcessor; - -public class CompositeProvisionDelegationRelationProcessor - extends RelationProcessor { - public CompositeProvisionDelegationRelationProcessor(PcmSurrogate model) { - super(model, CompositeProvisionDelegationRelation.class); - } - - @Override - protected void refine(CompositeProvisionDelegationRelation discovery) { - Composite discoveryComposite = (Composite) discovery.getSource().getSource(); - Component discoveryChild = discovery.getDestination().getSource(); - - // Check if the sub-component is part of the composite already - List compositions = getModel().getByType(CompositionRelation.class); - compositions.removeIf(relation -> !discoveryComposite.equals(relation.getSource())); - compositions.removeIf(relation -> !discoveryChild.equals(relation.getDestination())); - if (compositions.isEmpty()) { - CompositionRelation composition = new CompositionRelation(discoveryComposite, discoveryChild, true); - addImplication(composition); - } - - super.refine(discovery); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositeRequirementDelegationRelationProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositeRequirementDelegationRelationProcessor.java deleted file mode 100644 index b92683be..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositeRequirementDelegationRelationProcessor.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import java.util.List; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Composite; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositeRequirementDelegationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositionRelation; - -import tools.mdsd.mocore.framework.processor.RelationProcessor; - -public class CompositeRequirementDelegationRelationProcessor - extends RelationProcessor { - public CompositeRequirementDelegationRelationProcessor(PcmSurrogate model) { - super(model, CompositeRequirementDelegationRelation.class); - } - - @Override - protected void refine(CompositeRequirementDelegationRelation discovery) { - Composite discoveryComposite = (Composite) discovery.getSource().getSource(); - Component discoveryChild = discovery.getDestination().getSource(); - - // Check if the sub-component is part of the composite already - List compositions = getModel().getByType(CompositionRelation.class); - compositions.removeIf(relation -> !discoveryComposite.equals(relation.getSource())); - compositions.removeIf(relation -> !discoveryChild.equals(relation.getDestination())); - if (compositions.isEmpty()) { - CompositionRelation composition = new CompositionRelation(discoveryComposite, discoveryChild, true); - addImplication(composition); - } - - super.refine(discovery); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositionRelationProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositionRelationProcessor.java deleted file mode 100644 index 2231cb4a..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositionRelationProcessor.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositionRelation; - -import tools.mdsd.mocore.framework.processor.RelationProcessor; - -public class CompositionRelationProcessor extends RelationProcessor { - public CompositionRelationProcessor(PcmSurrogate model) { - super(model, CompositionRelation.class); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/DeploymentDeploymentRelationProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/DeploymentDeploymentRelationProcessor.java deleted file mode 100644 index f11a82c1..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/DeploymentDeploymentRelationProcessor.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import java.util.List; -import java.util.Objects; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.LinkResourceSpecification; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.DeploymentDeploymentRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.LinkResourceSpecificationRelation; - -import tools.mdsd.mocore.framework.processor.RelationProcessor; - -public class DeploymentDeploymentRelationProcessor extends RelationProcessor { - public DeploymentDeploymentRelationProcessor(PcmSurrogate model) { - super(model, DeploymentDeploymentRelation.class); - } - - @Override - protected void refine(DeploymentDeploymentRelation discovery) { - // Check whether a linking resource specification already exists for the link to be merged - List specifications = this.getModel() - .getByType(LinkResourceSpecificationRelation.class); - specifications.removeIf(specification -> !Objects.equals(discovery, specification.getDestination())); - if (specifications.isEmpty()) { - // Add implicit placeholder specification, if no specification is found for this deployment link - LinkResourceSpecification placeholderSpecification = LinkResourceSpecification.getUniquePlaceholder(); - LinkResourceSpecificationRelation implicitRelation = new LinkResourceSpecificationRelation( - placeholderSpecification, discovery, true); - this.addImplication(implicitRelation); - } - - super.refine(discovery); - } - - @Override - protected void replaceIndirectPlaceholders(DeploymentDeploymentRelation discovery) { - /* - * TL;DR Indirect refinement of depl->depl relations is disabled because it leads to information loss. - * - * In a real system each component has to be allocated to a minimum of one container. Otherwise, the component - * is not a working part of the running system. As a consequence, a placeholder container is created for each - * component without a real container. This placeholder cannot be replaced by any depl->depl relation with the - * same source or destination because the replacement would also imply that the component of the container is - * deployed on the new "replacement" container. This may be true but is false in general. Therefore, the - * replacement of the placeholder container has to be triggered from a lower architectural "layer". - * - * Example: Let's assume we have two components called A and B. When we add A and B to the model, we also add a - * placeholder container A_Cont for A and B_Cont for B. Moreover, a component assembly called A->B is added to - * the model leading to a A_Cont<->B_Cont deployment relation. The resulting model is in a hazard-state due to - * the following problem: If we now add another deployment relation, B_Cont<->C_Cont for example, the indirect - * refinement would assume that C_Cont and A_Cont are the same and initiate the replacement of A_Cont to C_Cont. - * The implication of this replacement is that A and the components of C_Cont are deployed on the same - * container. In general, this implication is not true. Consequently, a replacement of A_Cont may only be - * initiated by a lower-level relation. In the PCM case this relation is the component allocation relation. - */ - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/InterfaceProvisionRelationProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/InterfaceProvisionRelationProcessor.java deleted file mode 100644 index abe7b8b2..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/InterfaceProvisionRelationProcessor.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import java.util.List; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAssemblyRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceRequirementRelation; - -import tools.mdsd.mocore.framework.processor.RelationProcessor; - -public class InterfaceProvisionRelationProcessor extends RelationProcessor { - public InterfaceProvisionRelationProcessor(PcmSurrogate model) { - super(model, InterfaceProvisionRelation.class); - } - - @Override - protected void refine(InterfaceProvisionRelation discovery) { - Interface commonInterface = discovery.getDestination(); - - // Get all requirements from model & filter for same interface as in discovery - List requirementRelations = this.getModel() - .getByType(InterfaceRequirementRelation.class); - requirementRelations.removeIf(relation -> !relation.getDestination().equals(commonInterface)); - - // Create component assembly placeholder for pairs of provision & requirement relations - for (InterfaceRequirementRelation requirementRelation : requirementRelations) { - ComponentAssemblyRelation assemblyRelation = new ComponentAssemblyRelation(discovery, - requirementRelation, true); - this.addImplication(assemblyRelation); - } - - super.refine(discovery); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/InterfaceRequirementRelationProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/InterfaceRequirementRelationProcessor.java deleted file mode 100644 index d4d2f076..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/InterfaceRequirementRelationProcessor.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import java.util.List; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAssemblyRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceRequirementRelation; - -import tools.mdsd.mocore.framework.processor.RelationProcessor; - -public class InterfaceRequirementRelationProcessor - extends RelationProcessor { - public InterfaceRequirementRelationProcessor(PcmSurrogate model) { - super(model, InterfaceRequirementRelation.class); - } - - @Override - protected void refine(InterfaceRequirementRelation discovery) { - Interface commonInterface = discovery.getDestination(); - - // Get all requirements from model & filter for same interface as in discovery - List provisionRelations = this.getModel() - .getByType(InterfaceProvisionRelation.class); - provisionRelations.removeIf(relation -> !relation.getDestination().equals(commonInterface)); - - // Create component assembly placeholder for pairs of provision & requirement relations - for (InterfaceProvisionRelation provisionRelation : provisionRelations) { - ComponentAssemblyRelation assemblyRelation = new ComponentAssemblyRelation(provisionRelation, - discovery, true); - this.addImplication(assemblyRelation); - } - - super.refine(discovery); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/LinkResourceSpecificationRelationProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/LinkResourceSpecificationRelationProcessor.java deleted file mode 100644 index e1f833dd..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/LinkResourceSpecificationRelationProcessor.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.LinkResourceSpecificationRelation; - -import tools.mdsd.mocore.framework.processor.RelationProcessor; - -public class LinkResourceSpecificationRelationProcessor - extends RelationProcessor { - public LinkResourceSpecificationRelationProcessor(PcmSurrogate model) { - super(model, LinkResourceSpecificationRelation.class); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ServiceEffectSpecificationRelationProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ServiceEffectSpecificationRelationProcessor.java deleted file mode 100644 index b2d25bb7..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ServiceEffectSpecificationRelationProcessor.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ServiceEffectSpecificationRelation; - -import tools.mdsd.mocore.framework.processor.RelationProcessor; - -public class ServiceEffectSpecificationRelationProcessor extends RelationProcessor { - public ServiceEffectSpecificationRelationProcessor(PcmSurrogate model) { - super(model, ServiceEffectSpecificationRelation.class); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/SignatureProvisionRelationProcessor.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/SignatureProvisionRelationProcessor.java deleted file mode 100644 index 573dbc6a..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/SignatureProvisionRelationProcessor.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.SignatureProvisionRelation; - -import tools.mdsd.mocore.framework.processor.RelationProcessor; - -public class SignatureProvisionRelationProcessor extends RelationProcessor { - public SignatureProvisionRelationProcessor(PcmSurrogate model) { - super(model, SignatureProvisionRelation.class); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/AtomicComponent.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/AtomicComponent.java deleted file mode 100644 index d9b921e9..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/AtomicComponent.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element; - -import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; -import org.palladiosimulator.pcm.repository.BasicComponent; - -public class AtomicComponent extends Component { - public AtomicComponent(BasicComponent value, boolean isPlaceholder) { - super(value, isPlaceholder); - } - - public static AtomicComponent getNamedPlaceholder(String name) { - BasicComponent value = new FluentRepositoryFactory().newBasicComponent().withName(name).build(); - return new AtomicComponent(value, true); - } - - public static AtomicComponent getUniquePlaceholder() { - String identifier = "Placeholder_" + getUniqueValue(); - return getNamedPlaceholder(identifier); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/Interface.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/Interface.java deleted file mode 100644 index 3b1aed3a..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/Interface.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element; - -import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; -import org.palladiosimulator.pcm.repository.OperationInterface; - -public class Interface extends PcmElement { - public Interface(OperationInterface value, boolean isPlaceholder) { - super(value, isPlaceholder); - } - - public static Interface getUniquePlaceholder() { - String identifier = "Placeholder_" + getUniqueValue(); - OperationInterface value = new FluentRepositoryFactory().newOperationInterface().withName(identifier).build(); - return new Interface(value, true); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/ServiceEffectSpecification.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/ServiceEffectSpecification.java deleted file mode 100644 index fefa0f9f..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/ServiceEffectSpecification.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element; - -import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; -import org.palladiosimulator.pcm.seff.ResourceDemandingSEFF; - -public class ServiceEffectSpecification extends PcmElement { - public ServiceEffectSpecification(ResourceDemandingSEFF value, boolean isPlaceholder) { - super(value, isPlaceholder); - } - - public static ServiceEffectSpecification getUniquePlaceholder() { - ResourceDemandingSEFF value = new FluentRepositoryFactory().newSeff() - .withSeffBehaviour().withStartAction().followedBy().stopAction().createBehaviourNow().buildRDSeff(); - return new ServiceEffectSpecification(value, true); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositionRelation.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositionRelation.java deleted file mode 100644 index 1b73ac30..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositionRelation.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Composite; - -import tools.mdsd.mocore.framework.surrogate.Relation; -import tools.mdsd.mocore.framework.surrogate.Replaceable; - -public class CompositionRelation extends Relation> { - public CompositionRelation(Composite source, Component destination, boolean isPlaceholder) { - super(source, destination, isPlaceholder); - } - - @Override - public CompositionRelation replace(T original, T replacement) { - if (!this.includes(original)) { - // TODO Add message to exception - throw new IllegalArgumentException(); - } - if (this.equals(original)) { - return (CompositionRelation) replacement; - } - Composite source = getSourceReplacement(original, replacement); - Component destination = getDestinationReplacement(original, replacement); - return new CompositionRelation(source, destination, this.isPlaceholder()); - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/AllocationTransformer.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/AllocationTransformer.java deleted file mode 100644 index 0898242f..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/AllocationTransformer.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.transformation; - -import java.util.List; - -import org.palladiosimulator.generator.fluent.allocation.api.IAllocationAddition; -import org.palladiosimulator.generator.fluent.allocation.factory.FluentAllocationFactory; -import org.palladiosimulator.generator.fluent.allocation.structure.AllocationContextCreator; -import org.palladiosimulator.pcm.allocation.Allocation; -import org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment; -import org.palladiosimulator.pcm.system.System; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAllocationRelation; - -import tools.mdsd.mocore.framework.transformation.Transformer; - -public class AllocationTransformer implements Transformer { - @Override - public Allocation transform(PcmSurrogate model) { - System system = new SystemTransformer().transform(model); - ResourceEnvironment resourceEnvironment = new ResourceEnvironmentTransformer().transform(model); - return this.transform(model, system, resourceEnvironment); - } - - public Allocation transform(PcmSurrogate model, System system, ResourceEnvironment resourceEnvironment) { - FluentAllocationFactory allocationFactory = new FluentAllocationFactory(); - IAllocationAddition fluentAllocation = allocationFactory.newAllocation() - .withSystem(system) - .withResourceEnvironment(resourceEnvironment); - - // Add allocation contexts to allocation - List relations = model.getByType(ComponentAllocationRelation.class); - for (ComponentAllocationRelation relation : relations) { - // Get and add context (creator) for specific allocation relation - AllocationContextCreator contextCreator = getCreator(allocationFactory, relation); - fluentAllocation.addToAllocation(contextCreator); - } - - return fluentAllocation.createAllocationNow(); - } - - private AllocationContextCreator getCreator(FluentAllocationFactory fluentFactory, - ComponentAllocationRelation relation) { - AllocationContextCreator contextCreator = fluentFactory.newAllocationContext(); - - // Use name of entities to fetch up-to-date entities from system and resource environment - String assemblyContextName = SystemTransformer.getAssemblyContextName(relation.getSource()); - String deploymentEntityName = relation.getDestination().getValue().getEntityName(); - contextCreator.withAssemblyContext(assemblyContextName).withResourceContainer(deploymentEntityName); - - return contextCreator; - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/RepositoryTransformer.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/RepositoryTransformer.java deleted file mode 100644 index 9f32f7b8..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/RepositoryTransformer.java +++ /dev/null @@ -1,605 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.transformation; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -import org.apache.log4j.Logger; -import org.eclipse.emf.common.util.EList; -import org.palladiosimulator.generator.fluent.repository.api.Repo; -import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; -import org.palladiosimulator.generator.fluent.repository.structure.components.BasicComponentCreator; -import org.palladiosimulator.generator.fluent.repository.structure.components.CompositeComponentCreator; -import org.palladiosimulator.generator.fluent.repository.structure.interfaces.OperationInterfaceCreator; -import org.palladiosimulator.pcm.core.composition.AssemblyConnector; -import org.palladiosimulator.pcm.core.composition.AssemblyContext; -import org.palladiosimulator.pcm.core.composition.CompositionFactory; -import org.palladiosimulator.pcm.core.composition.ProvidedDelegationConnector; -import org.palladiosimulator.pcm.core.composition.RequiredDelegationConnector; -import org.palladiosimulator.pcm.repository.BasicComponent; -import org.palladiosimulator.pcm.repository.CompositeComponent; -import org.palladiosimulator.pcm.repository.OperationInterface; -import org.palladiosimulator.pcm.repository.OperationProvidedRole; -import org.palladiosimulator.pcm.repository.OperationRequiredRole; -import org.palladiosimulator.pcm.repository.OperationSignature; -import org.palladiosimulator.pcm.repository.Repository; -import org.palladiosimulator.pcm.repository.RepositoryComponent; -import org.palladiosimulator.pcm.seff.AbstractAction; -import org.palladiosimulator.pcm.seff.ExternalCallAction; -import org.palladiosimulator.pcm.seff.ResourceDemandingSEFF; -import org.palladiosimulator.pcm.seff.ServiceEffectSpecification; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.AtomicComponent; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Composite; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Signature; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAssemblyRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositeProvisionDelegationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositeRequirementDelegationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceRequirementRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ServiceEffectSpecificationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.SignatureProvisionRelation; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; - -import tools.mdsd.mocore.framework.transformation.Transformer; - -public class RepositoryTransformer implements Transformer { - private static final Logger LOG = Logger.getLogger(RepositoryTransformer.class); - - private static final String DELEGATION_EXCLUSION_NAME_PATTERN = "%s"; - private static final String ROLE_PROVIDES_NAME_PATTERN = "%s Provider"; - private static final String ROLE_REQUIRES_NAME_PATTERN = "%s Consumer"; - - @Override - public Repository transform(PcmSurrogate model) { - FluentRepositoryFactory repositoryFactory = new FluentRepositoryFactory(); - Repo fluentRepository = repositoryFactory.newRepository(); - - List seffRelations = model - .getByType(ServiceEffectSpecificationRelation.class); - List provisionRelations = model.getByType(InterfaceProvisionRelation.class); - List requirementRelations = model.getByType(InterfaceRequirementRelation.class); - List signatureRelations = model.getByType(SignatureProvisionRelation.class); - List interfaces = model.getByType(Interface.class); - - // Add interfaces to fluent repository - for (Interface interfaceInstance : interfaces) { - OperationInterfaceCreator interfaceCreator = getCreator(repositoryFactory, interfaceInstance); - - // Add interface to repository and fetch built interface - fluentRepository.addToRepository(interfaceCreator); - OperationInterface repositoryInterface = repositoryFactory - .fetchOfOperationInterface(interfaceInstance.getValue() - .getEntityName()); - - // Add signatures to the added interface directly - // Avoids the creation of signature creator and tight coupling to fluentApi - for (SignatureProvisionRelation relation : signatureRelations) { - if (relation.getDestination() - .equals(interfaceInstance)) { - Signature signature = relation.getSource(); - signature.getValue() - .setInterface__OperationSignature(repositoryInterface); - } - } - } - - // Add basic components with their roles and seff to fluent repository - for (AtomicComponent component : model.getByType(AtomicComponent.class)) { - BasicComponentCreator componentCreator = getCreator(repositoryFactory, component); - - // Add provided interfaces - for (InterfaceProvisionRelation relation : provisionRelations) { - Interface interfaceInstance = relation.getDestination(); - if (relation.getSource() - .equals(component)) { - String interfaceName = interfaceInstance.getValue() - .getEntityName(); - OperationInterface operationInterface = repositoryFactory.fetchOfOperationInterface(interfaceName); - componentCreator.provides(operationInterface, getProvidedRoleName(interfaceInstance)); - } - } - - // Add required interfaces - for (InterfaceRequirementRelation relation : requirementRelations) { - Interface interfaceInstance = relation.getDestination(); - if (relation.getSource() - .equals(component)) { - String interfaceName = interfaceInstance.getValue() - .getEntityName(); - OperationInterface operationInterface = repositoryFactory.fetchOfOperationInterface(interfaceName); - componentCreator.requires(operationInterface, getRequiredRoleName(interfaceInstance)); - } - } - - // Build component to make changes that are unsupported by fluent api - BasicComponent repositoryComponent = componentCreator.build(); - - // Add service effect specifications to component - // For each provided interface, iterate over each signature of interface and add seff if - // it exists - for (InterfaceProvisionRelation interfaceProvision : provisionRelations) { - if (interfaceProvision.getSource() - .equals(component)) { - OperationInterface operationInterface = repositoryFactory - .fetchOfOperationInterface(interfaceProvision.getDestination() - .getValue() - .getEntityName()); - for (OperationSignature signature : operationInterface.getSignatures__OperationInterface()) { - // Get seff entity for specific signature in interface - Predicate filter = relation -> { - final Signature wrappedSignature = relation.getSource() - .getDestination() - .getSource(); - final Interface wrappedInterface = relation.getSource() - .getSource() - .getDestination(); - return representSameSignature(signature, wrappedSignature.getValue()) - && representSameInterface(operationInterface, wrappedInterface.getValue()); - }; - ServiceEffectSpecification seff = seffRelations.stream() - .filter(relation -> relation.getSource() - .getSource() - .getSource() - .equals(component)) - .filter(filter) - .map(relation -> relation.getDestination() - .getValue()) - .findFirst() - .orElse(org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.ServiceEffectSpecification - .getUniquePlaceholder() - .getValue()); - - // Reset component and signature within seff because they may be out-dated - seff.setBasicComponent_ServiceEffectSpecification(repositoryComponent); - seff.setDescribedService__SEFF(signature); - - // Fix changed identifier of required roles in external call actions - if (seff instanceof ResourceDemandingSEFF) { - ResourceDemandingSEFF rdSeff = (ResourceDemandingSEFF) seff; - EList behavior = rdSeff.getSteps_Behaviour(); - List externalCallActions = behavior.stream() - .filter(action -> action instanceof ExternalCallAction) - .map(action -> (ExternalCallAction) action) - .collect(Collectors.toList()); - - for (ExternalCallAction externalCallAction : externalCallActions) { - OperationSignature externalSignature = externalCallAction - .getCalledService_ExternalService(); - - // Get required role containing called signature of - // externalCallAction from component - Optional requiredRoleOption = repositoryComponent - .getRequiredRoles_InterfaceRequiringEntity() - .stream() - .filter(role -> role instanceof OperationRequiredRole) - .map(role -> (OperationRequiredRole) role) - .filter(role -> role.getRequiredInterface__OperationRequiredRole() - .getSignatures__OperationInterface() - .contains(externalSignature)) - .findFirst(); - if (requiredRoleOption.isEmpty()) { - LOG.warn( - "Failed to find required role for external call to " - + externalSignature.getInterface__OperationSignature() - .getEntityName() - + "#" + externalSignature.getEntityName() + "!"); - continue; - } - OperationRequiredRole requiredRole = requiredRoleOption.get(); - - // Set role in external call action to fetched required role - externalCallAction.setRole_ExternalService(requiredRole); - } - } - } - } - } - - // Add created basic component with roles and seff to repository - fluentRepository.addToRepository(repositoryComponent); - } - - // Add implicitly provided interfaces of composites to model (non-required interface of child). - // Problem: This has to happen from innermost to outermost component. -> Sorted by dependency. - // First step: Get children of each composite - List compositionRelations = model.getByType(CompositionRelation.class); - List composites = model.getByType(Composite.class); - Multimap> compositesChildren = HashMultimap.create(); - for (Composite composite : composites) { - List> children = compositionRelations.stream() - .filter(relation -> relation.getSource().equals(composite)) - .map(relation -> relation.getDestination()) - .collect(Collectors.toList()); - compositesChildren.putAll(composite, children); - } - // Second step: Sort composites - List sortedComposites = new LinkedList<>(composites); - sortedComposites.sort((a, b) -> compareComposites(a, b, compositesChildren)); - // Third step: Get non-required interfaces & their providers - List nonRequiredProvisionRelations = new LinkedList<>(provisionRelations); - nonRequiredProvisionRelations.removeIf( - provisionRelation -> requirementRelations.stream().anyMatch(requirementRelation -> requirementRelation - .getDestination().equals(provisionRelation.getDestination()))); - // Fourth step: Provide non-required interface of children & add delegation - for (Composite composite : sortedComposites) { - for (int i = 0; i < nonRequiredProvisionRelations.size(); i++) { - // Access via index due to concurrent modification -> New last element might be added to list - InterfaceProvisionRelation nonRequiredProvision = nonRequiredProvisionRelations.get(i); - Component provider = nonRequiredProvision.getSource(); - Interface providedInterface = nonRequiredProvision.getDestination(); - - // Only add if provider is direct child of composite - if (isDirectChild(provider, composite, compositesChildren)) { - // Check whether delegation already exists in model - boolean existsDelegation = false; - for (CompositeProvisionDelegationRelation delegationRelation : model - .getByType(CompositeProvisionDelegationRelation.class)) { - if (delegationRelation.getDestination().equals(nonRequiredProvision) - && delegationRelation.getSource().getSource().equals(composite)) { - existsDelegation = true; - break; - } - } - - // Check whether interface should be excluded from recursive delegation - boolean excludeDelegation = isExcludedFromDelegation(provider, providedInterface); - - if (!existsDelegation && !excludeDelegation) { - // Check whether interface provision already exists - InterfaceProvisionRelation provisionRelation = null; - for (InterfaceProvisionRelation provision : provisionRelations) { - if (provision.getSource().equals(composite) - && provision.getDestination().equals(providedInterface)) { - provisionRelation = provision; - } - } - // Create new provision if it does not exist yet - if (Objects.isNull(provisionRelation)) { - provisionRelation = new InterfaceProvisionRelation(composite, - providedInterface, true); - - // Add to model and refresh already fetched relations - model.add(provisionRelation); - nonRequiredProvisionRelations.add(provisionRelation); - provisionRelations = model.getByType(InterfaceProvisionRelation.class); - } - - // Add provided delegation connector - CompositeProvisionDelegationRelation provisionDelegation = new CompositeProvisionDelegationRelation( - provisionRelation, nonRequiredProvision, true); - model.add(provisionDelegation); - } - } - } - } - - // Add composite components with their roles to fluent repository - for (Composite composite : composites) { - CompositeComponentCreator compositeCreator = getCreator(repositoryFactory, composite); - - // Add explicitly provided interfaces - for (InterfaceProvisionRelation relation : provisionRelations) { - Interface interfaceInstance = relation.getDestination(); - if (relation.getSource() - .equals(composite)) { - String interfaceName = interfaceInstance.getValue() - .getEntityName(); - OperationInterface operationInterface = repositoryFactory.fetchOfOperationInterface(interfaceName); - compositeCreator.provides(operationInterface, getProvidedRoleName(interfaceInstance)); - } - } - - // Add required interfaces - for (InterfaceRequirementRelation relation : requirementRelations) { - Interface interfaceInstance = relation.getDestination(); - if (relation.getSource() - .equals(composite)) { - String interfaceName = interfaceInstance.getValue() - .getEntityName(); - OperationInterface operationInterface = repositoryFactory.fetchOfOperationInterface(interfaceName); - compositeCreator.requires(operationInterface, getRequiredRoleName(interfaceInstance)); - } - } - - // Add composite to fluent repository - fluentRepository.addToRepository(compositeCreator); - } - - // Add compositions to repository -> All composites & composites have to be added beforehand - for (CompositionRelation relation : compositionRelations) { - Composite composite = relation.getSource(); - Component destination = relation.getDestination(); - - // Fetch composite from repository - CompositeComponent persistedCompositeComponent = repositoryFactory - .fetchOfCompositeComponent(composite.getValue() - .getEntityName()); - persistedCompositeComponent.getAssemblyContexts__ComposedStructure(); - - // Fetch composite child from repository & create temporary fluent creator - CompositeComponentCreator temporaryCreator = repositoryFactory.newCompositeComponent(); - if (destination instanceof AtomicComponent) { - temporaryCreator.withAssemblyContext(repositoryFactory.fetchOfBasicComponent(destination.getValue() - .getEntityName())); - } else if (destination instanceof Composite) { - temporaryCreator.withAssemblyContext(repositoryFactory.fetchOfCompositeComponent(destination.getValue() - .getEntityName())); - } - - // Copy assembly contexts from temporary to persisted composite - CompositeComponent temporaryComposite = (CompositeComponent) temporaryCreator.build(); - persistedCompositeComponent.getAssemblyContexts__ComposedStructure() - .addAll(temporaryComposite.getAssemblyContexts__ComposedStructure()); - } - - Repository repository = fluentRepository.createRepositoryNow(); - - // Add assembly connectors for assembly relations of components within same composite - for (ComponentAssemblyRelation assemblyRelation : model.getByType(ComponentAssemblyRelation.class)) { - Component provider = assemblyRelation.getSource().getSource(); - Component consumer = assemblyRelation.getDestination().getSource(); - Interface interFace = assemblyRelation.getSource().getDestination(); - - // Get common composites of provider and consumer - List providerComposites = compositionRelations.stream() - .filter(relation -> relation.getDestination().equals(provider)).map(CompositionRelation::getSource) - .collect(Collectors.toList()); - List consumerComposites = compositionRelations.stream() - .filter(relation -> relation.getDestination().equals(consumer)).map(CompositionRelation::getSource) - .collect(Collectors.toList()); - List commonComposites = providerComposites.stream() - .filter(composite -> consumerComposites.contains(composite)).collect(Collectors.toList()); - - // Get real composites of wrappers from repository - List commonRepositoryComposites = new ArrayList<>(); - for (RepositoryComponent repositoryComponent : repository.getComponents__Repository()) { - for (Composite commonComposite : commonComposites) { - if (repositoryComponent.getEntityName().equals(commonComposite.getValue().getEntityName())) { - commonRepositoryComposites.add((CompositeComponent) repositoryComponent); - } - } - } - - // Add assembly connector to each common composite - for (CompositeComponent repositoryComposite : commonRepositoryComposites) { - // Fetch assembly contexts from composite - AssemblyContext providerContext = repositoryComposite.getAssemblyContexts__ComposedStructure().stream() - .filter(context -> context.getEncapsulatedComponent__AssemblyContext().getEntityName() - .equals(provider.getValue().getEntityName())) - .findFirst().orElseThrow(); - AssemblyContext consumerContext = repositoryComposite.getAssemblyContexts__ComposedStructure().stream() - .filter(context -> context.getEncapsulatedComponent__AssemblyContext().getEntityName() - .equals(consumer.getValue().getEntityName())) - .findFirst().orElseThrow(); - - // Fetch roles from contexts - OperationProvidedRole providerRole = (OperationProvidedRole) providerContext - .getEncapsulatedComponent__AssemblyContext() - .getProvidedRoles_InterfaceProvidingEntity().stream() - .filter(role -> role instanceof OperationProvidedRole - && ((OperationProvidedRole) role).getProvidedInterface__OperationProvidedRole() - .getEntityName().equals(interFace.getValue().getEntityName())) - .findFirst().orElseThrow(); - OperationRequiredRole consumerRole = (OperationRequiredRole) consumerContext - .getEncapsulatedComponent__AssemblyContext() - .getRequiredRoles_InterfaceRequiringEntity().stream() - .filter(role -> role instanceof OperationRequiredRole - && ((OperationRequiredRole) role).getRequiredInterface__OperationRequiredRole() - .getEntityName().equals(interFace.getValue().getEntityName())) - .findFirst().orElseThrow(); - - // Construct assembly connector - AssemblyConnector assemblyConnector = CompositionFactory.eINSTANCE.createAssemblyConnector(); - assemblyConnector.setProvidedRole_AssemblyConnector(providerRole); - assemblyConnector.setProvidingAssemblyContext_AssemblyConnector(providerContext); - assemblyConnector.setRequiredRole_AssemblyConnector(consumerRole); - assemblyConnector.setRequiringAssemblyContext_AssemblyConnector(consumerContext); - - // Add connector to composite - repositoryComposite.getConnectors__ComposedStructure().add(assemblyConnector); - } - } - - // Add provided delegation connectors to composite - for (CompositeProvisionDelegationRelation delegationRelation : model - .getByType(CompositeProvisionDelegationRelation.class)) { - // Decompose delegation relation into components & interfaces - Composite compositeWrapper = (Composite) delegationRelation.getSource().getSource(); - Component childWrapper = delegationRelation.getDestination().getSource(); - Interface outerInterfaceWrapper = delegationRelation.getSource().getDestination(); - Interface innerInterfaceWrapper = delegationRelation.getDestination().getDestination(); - - // Fetch composite, assembly context, & roles from repository - CompositeComponent repositoryComposite = (CompositeComponent) repository.getComponents__Repository() - .stream() - .filter(CompositeComponent.class::isInstance) - .filter(component -> component.getEntityName().equals(compositeWrapper.getValue().getEntityName())) - .findFirst().orElseThrow(); - AssemblyContext childContext = repositoryComposite.getAssemblyContexts__ComposedStructure().stream() - .filter(context -> context.getEncapsulatedComponent__AssemblyContext().getEntityName() - .equals(childWrapper.getValue().getEntityName())) - .findFirst().orElseThrow(); - OperationProvidedRole innerRole = (OperationProvidedRole) childContext - .getEncapsulatedComponent__AssemblyContext() - .getProvidedRoles_InterfaceProvidingEntity().stream() - .filter(role -> role instanceof OperationProvidedRole - && ((OperationProvidedRole) role).getProvidedInterface__OperationProvidedRole() - .getEntityName().equals(innerInterfaceWrapper.getValue().getEntityName())) - .findFirst().orElseThrow(); - OperationProvidedRole outerRole = (OperationProvidedRole) repositoryComposite - .getProvidedRoles_InterfaceProvidingEntity().stream() - .filter(role -> role instanceof OperationProvidedRole - && ((OperationProvidedRole) role).getProvidedInterface__OperationProvidedRole() - .getEntityName().equals(outerInterfaceWrapper.getValue().getEntityName())) - .findFirst().orElseThrow(); - - // Create delegation connector - ProvidedDelegationConnector delegationConnector = CompositionFactory.eINSTANCE - .createProvidedDelegationConnector(); - delegationConnector.setAssemblyContext_ProvidedDelegationConnector(childContext); - delegationConnector.setInnerProvidedRole_ProvidedDelegationConnector(innerRole); - delegationConnector.setOuterProvidedRole_ProvidedDelegationConnector(outerRole); - - // Add connector to composite component - repositoryComposite.getConnectors__ComposedStructure().add(delegationConnector); - } - - // Add required delegation connectors to composite - for (CompositeRequirementDelegationRelation delegationRelation : model - .getByType(CompositeRequirementDelegationRelation.class)) { - // Decompose delegation relation into components & interfaces - Composite compositeWrapper = (Composite) delegationRelation.getSource().getSource(); - Component childWrapper = delegationRelation.getDestination().getSource(); - Interface outerInterfaceWrapper = delegationRelation.getSource().getDestination(); - Interface innerInterfaceWrapper = delegationRelation.getDestination().getDestination(); - - // Fetch composite, assembly context, & roles from repository - CompositeComponent repositoryComposite = (CompositeComponent) repository.getComponents__Repository() - .stream() - .filter(component -> component.getEntityName().equals(compositeWrapper.getValue().getEntityName())) - .findFirst().orElseThrow(); - AssemblyContext childContext = repositoryComposite.getAssemblyContexts__ComposedStructure().stream() - .filter(context -> context.getEncapsulatedComponent__AssemblyContext().getEntityName() - .equals(childWrapper.getValue().getEntityName())) - .findFirst().orElseThrow(); - OperationRequiredRole innerRole = (OperationRequiredRole) childContext - .getEncapsulatedComponent__AssemblyContext() - .getRequiredRoles_InterfaceRequiringEntity().stream() - .filter(role -> role instanceof OperationRequiredRole - && ((OperationRequiredRole) role).getRequiredInterface__OperationRequiredRole() - .getEntityName().equals(innerInterfaceWrapper.getValue().getEntityName())) - .findFirst().orElseThrow(); - OperationRequiredRole outerRole = (OperationRequiredRole) repositoryComposite - .getRequiredRoles_InterfaceRequiringEntity().stream() - .filter(role -> role instanceof OperationRequiredRole - && ((OperationRequiredRole) role).getRequiredInterface__OperationRequiredRole() - .getEntityName().equals(outerInterfaceWrapper.getValue().getEntityName())) - .findFirst().orElseThrow(); - - // Create delegation connector - RequiredDelegationConnector delegationConnector = CompositionFactory.eINSTANCE - .createRequiredDelegationConnector(); - delegationConnector.setAssemblyContext_RequiredDelegationConnector(childContext); - delegationConnector.setInnerRequiredRole_RequiredDelegationConnector(innerRole); - delegationConnector.setOuterRequiredRole_RequiredDelegationConnector(outerRole); - - // Add connector to composite component - repositoryComposite.getConnectors__ComposedStructure().add(delegationConnector); - } - - return repository; - - } - - private boolean isDirectChild(Component child, Composite parent, - Multimap> compositesChildren) { - return compositesChildren.get(parent).contains(child); - } - - private boolean isRecursiveChild(Component child, Composite parent, - Multimap> compositesChildren) { - // Case 1: Direct child - if (isDirectChild(child, parent, compositesChildren)) { - return true; - } - - // Case 2: Indirect child - for (Component childOfParent : compositesChildren.get(parent)) { - if (childOfParent instanceof Composite) { - return isRecursiveChild(child, (Composite) childOfParent, compositesChildren); - } - } - - // Case 3: Not child of parent - return false; - } - - protected static boolean isExcludedFromDelegation(Component provider, Interface providedInterface) { - String providerName = provider.getValue().getEntityName(); - String providedInterfaceName = providedInterface.getValue().getEntityName(); - return providedInterfaceName.equals(String.format(DELEGATION_EXCLUSION_NAME_PATTERN, providerName)); - } - - private int compareComposites(Composite a, Composite b, Multimap> compositesChildren) { - if (isRecursiveChild(a, b, compositesChildren)) { - return -1; - } else if (isRecursiveChild(b, a, compositesChildren)) { - return 1; - } - return 0; - } - - private BasicComponentCreator getCreator(FluentRepositoryFactory fluentFactory, AtomicComponent component) { - BasicComponentCreator componentCreator = fluentFactory.newBasicComponent(); - - // TODO Identify important information within wrapped component - // Copy information from wrapped component, dismiss deprecated information. - BasicComponent wrappedComponent = component.getValue(); - componentCreator.withName(wrappedComponent.getEntityName()); - - return componentCreator; - } - - private CompositeComponentCreator getCreator(FluentRepositoryFactory fluentFactory, Composite component) { - CompositeComponentCreator compositeCreator = fluentFactory.newCompositeComponent(); - - // TODO Identify important information within wrapped component - // Copy information from wrapped component, dismiss deprecated information. - RepositoryComponent wrappedComponent = component.getValue(); - compositeCreator.withName(wrappedComponent.getEntityName()); - - return compositeCreator; - } - - private OperationInterfaceCreator getCreator(FluentRepositoryFactory fluentFactory, Interface interfaceInstance) { - OperationInterfaceCreator interfaceCreator = fluentFactory.newOperationInterface(); - - // TODO Identify important information within wrapped interface - // Copy information from wrapped interface, dismiss deprecated information. - OperationInterface wrappedInterface = interfaceInstance.getValue(); - interfaceCreator.withName(wrappedInterface.getEntityName()); - - return interfaceCreator; - } - - protected static String getProvidedRoleName(Interface interfaceInstance) { - String interfaceEntityName = interfaceInstance.getValue() - .getEntityName(); - return String.format(ROLE_PROVIDES_NAME_PATTERN, interfaceEntityName); - } - - protected static String getRequiredRoleName(Interface interfaceInstance) { - String interfaceEntityName = interfaceInstance.getValue() - .getEntityName(); - return String.format(ROLE_REQUIRES_NAME_PATTERN, interfaceEntityName); - } - - // TODO Test and move to evaluation helper - private static boolean representSameSignature(OperationSignature signature, OperationSignature otherSignature) { - boolean equalName = Objects.equals(signature.getEntityName(), otherSignature.getEntityName()); - boolean equalReturn = Objects.equals(signature.getReturnType__OperationSignature(), - otherSignature.getReturnType__OperationSignature()); - boolean equalParameters = signature.getParameters__OperationSignature() - .containsAll(otherSignature.getParameters__OperationSignature()) - && otherSignature.getParameters__OperationSignature() - .containsAll(signature.getParameters__OperationSignature()); - return equalName && equalReturn && equalParameters; - } - - // TODO Test and move to evaluation helper - private static boolean representSameInterface(OperationInterface interFace, OperationInterface otherInterFace) { - boolean equalName = Objects.equals(interFace.getEntityName(), otherInterFace.getEntityName()); - // TODO Check if signatures are equal via representSameSignature - return equalName; - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/ResourceEnvironmentTransformer.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/ResourceEnvironmentTransformer.java deleted file mode 100644 index f8980721..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/ResourceEnvironmentTransformer.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.transformation; - -import java.util.Collection; -import java.util.Objects; -import java.util.Set; - -import org.palladiosimulator.generator.fluent.resourceenvironment.api.IResourceEnvironment; -import org.palladiosimulator.generator.fluent.resourceenvironment.factory.FluentResourceEnvironmentFactory; -import org.palladiosimulator.generator.fluent.resourceenvironment.structure.LinkingResourceCreator; -import org.palladiosimulator.generator.fluent.resourceenvironment.structure.ResourceContainerCreator; -import org.palladiosimulator.pcm.resourceenvironment.LinkingResource; -import org.palladiosimulator.pcm.resourceenvironment.ResourceContainer; -import org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.LinkResourceSpecification; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.LinkResourceSpecificationRelation; - -import com.google.common.collect.HashMultimap; -import tools.mdsd.mocore.framework.transformation.Transformer; - -public class ResourceEnvironmentTransformer implements Transformer { - @Override - public ResourceEnvironment transform(PcmSurrogate model) { - FluentResourceEnvironmentFactory resourceEnvironmentFactory = new FluentResourceEnvironmentFactory(); - IResourceEnvironment fluentResourceEnvironment = resourceEnvironmentFactory.newResourceEnvironment(); - - // Add resource containers to resource environment - for (Deployment deployment : model.getByType(Deployment.class)) { - ResourceContainerCreator containerCreator = getContainerCreator(resourceEnvironmentFactory, deployment); - fluentResourceEnvironment.addToResourceEnvironment(containerCreator); - } - - HashMultimap linkSpecificationMap = HashMultimap.create(); - for (LinkResourceSpecificationRelation linkingRelation : model - .getByType(LinkResourceSpecificationRelation.class)) { - Deployment source = linkingRelation.getDestination().getSource(); - Deployment destination = linkingRelation.getDestination().getDestination(); - LinkResourceSpecification specification = linkingRelation.getSource(); - - // The if clause filters non-wrong but trivial A->A container links - if (!source.equals(destination)) { - linkSpecificationMap.put(specification, source); - linkSpecificationMap.put(specification, destination); - } - } - - // Add linking resources (specification <-> [deployment <-> deployment]) to resource environment - for (LinkResourceSpecification key : linkSpecificationMap.keySet()) { - LinkingResourceCreator linkingResourceCreator = getLinkingResourceCreator(resourceEnvironmentFactory, - linkSpecificationMap.get(key)); - fluentResourceEnvironment.addToResourceEnvironment(linkingResourceCreator); - } - - // Create PCM resource environment - ResourceEnvironment resourceEnvironment = fluentResourceEnvironment.createResourceEnvironmentNow(); - - // Copy resource specifications from old to new containers - for (ResourceContainer container : resourceEnvironment.getResourceContainer_ResourceEnvironment()) { - for (Deployment deployment : model.getByType(Deployment.class)) { - // TODO Use container wrapper.equals - ResourceContainer wrappedContainer = deployment.getValue(); - if (container.getEntityName().equals(wrappedContainer.getEntityName())) { - container.getActiveResourceSpecifications_ResourceContainer() - .addAll(wrappedContainer.getActiveResourceSpecifications_ResourceContainer()); - container.getHddResourceSpecifications().addAll(wrappedContainer.getHddResourceSpecifications()); - } - } - } - - // Add linking resource specifications to PCM linking resources - for (LinkResourceSpecification specification : linkSpecificationMap.keySet()) { - Set deployments = linkSpecificationMap.get(specification); - for (LinkingResource linkingResource : resourceEnvironment.getLinkingResources__ResourceEnvironment()) { - if (Objects.equals(getLinkingResourceName(deployments), linkingResource.getEntityName())) { - linkingResource - .setCommunicationLinkResourceSpecifications_LinkingResource(specification.getValue()); - } - } - } - - return resourceEnvironment; - } - - protected static String getLinkingResourceName(Collection deployments) { - StringBuilder stringBuilder = new StringBuilder(); - for (Deployment deployment : deployments) { - stringBuilder.append(" " + deployment.getValue().getEntityName()); - } - stringBuilder.append(" Link"); - return stringBuilder.toString(); - } - - private ResourceContainerCreator getContainerCreator(FluentResourceEnvironmentFactory fluentFactory, - Deployment deployment) { - ResourceContainer wrappedContainer = deployment.getValue(); - - // Create a container creator instance w/o processing specifications due to missing fluentApi copy support - ResourceContainerCreator containerCreator = fluentFactory.newResourceContainer() - .withName(wrappedContainer.getEntityName()); - return containerCreator; - } - - private LinkingResourceCreator getLinkingResourceCreator(FluentResourceEnvironmentFactory fluentFactory, - Collection deployments) { - // Create a linking resource creator w/o specifications due to missing fluentApi copy support - String entityName = getLinkingResourceName(deployments); - LinkingResourceCreator creator = fluentFactory.newLinkingResource() - .withName(entityName); - for (Deployment deployment : deployments) { - String containerName = deployment.getValue().getEntityName(); - creator.addLinkedResourceContainer(containerName); - } - return creator; - } -} diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/SystemTransformer.java b/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/SystemTransformer.java deleted file mode 100644 index ba950492..00000000 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/SystemTransformer.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.transformation; - -import org.palladiosimulator.generator.fluent.system.api.ISystemAddition; -import org.palladiosimulator.generator.fluent.system.factory.FluentSystemFactory; -import org.palladiosimulator.generator.fluent.system.structure.AssemblyContextCreator; -import org.palladiosimulator.generator.fluent.system.structure.connector.operation.AssemblyConnectorCreator; -import org.palladiosimulator.generator.fluent.system.structure.connector.operation.ProvidedDelegationConnectorCreator; -import org.palladiosimulator.generator.fluent.system.structure.role.OperationProvidedRoleCreator; -import org.palladiosimulator.pcm.repository.Repository; -import org.palladiosimulator.pcm.system.System; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAssemblyRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceRequirementRelation; - -import tools.mdsd.mocore.framework.transformation.Transformer; - -public class SystemTransformer implements Transformer { - private static final String ASSEMBLY_CONTEXT_NAME_PATTERN = "%s Assembly Context"; - private static final String ASSEMBLY_CONNECTOR_NAME_PATTERN = "%s Connector"; - private static final String DELEGATION_ROLE_NAME_PATTERN = "%s Delegation-Provider"; - private static final String DELEGATION_CONNECTOR_NAME_PATTERN = "%s Delegation Connector"; - - @Override - public System transform(PcmSurrogate model) { - Repository repository = new RepositoryTransformer().transform(model); - return this.transform(model, repository); - } - - public System transform(PcmSurrogate model, Repository repository) { - FluentSystemFactory systemFactory = new FluentSystemFactory(); - ISystemAddition fluentSystem = systemFactory.newSystem().addRepository(repository); - - // Add repository components as assembly contexts to system - for (Component component : model.getByType(Component.class)) { - AssemblyContextCreator contextCreator = getAssemblyContextCreator(systemFactory, component); - fluentSystem.addToSystem(contextCreator); - } - - // Add assembly connectors (component assembly relations) - for (ComponentAssemblyRelation relation : model.getByType(ComponentAssemblyRelation.class)) { - AssemblyConnectorCreator connectorCreator = getAssemblyConnectorCreator(systemFactory, relation); - fluentSystem.addToSystem(connectorCreator); - } - - // Add provided delegation connectors for provided non-required interfaces - for (InterfaceProvisionRelation relation : model.getByType(InterfaceProvisionRelation.class)) { - Interface providedInteface = relation.getDestination(); - String providedIntefaceName = providedInteface.getValue().getEntityName(); - Component provider = relation.getSource(); - boolean existsRequirement = model.getByType(InterfaceRequirementRelation.class).stream() - .anyMatch(requirementRelation -> requirementRelation.getDestination().equals(providedInteface)); - boolean isCompositeChild = model.getByType(CompositionRelation.class).stream() - .anyMatch(composition -> composition.getDestination().equals(provider)); - // Check whether interface should be excluded from delegation - boolean excludeDelegation = RepositoryTransformer.isExcludedFromDelegation(provider, providedInteface); - - // Only add delegation if no other component requires interface and only add for most outer provider in case - // of composite structures - // - // Important: Asserts that repository transformer added provision delegation from innermost to outermost - // component in case of a composite structure. If not, no delegation to system is added. - if (!existsRequirement && !isCompositeChild && !excludeDelegation) { - // Create & add provided role to fluent system - String delegationRoleName = String.format(DELEGATION_ROLE_NAME_PATTERN, providedIntefaceName); - OperationProvidedRoleCreator systemProvidedRole = systemFactory.newOperationProvidedRole() - .withName(delegationRoleName) - .withProvidedInterface(providedIntefaceName); - fluentSystem.addToSystem(systemProvidedRole); - - // Create & add delegation between context provided role & system provided role - String delegationConnectorName = String.format(DELEGATION_CONNECTOR_NAME_PATTERN, providedIntefaceName); - ProvidedDelegationConnectorCreator systemDelegation = systemFactory - .newProvidedDelegationConnectorCreator() - .withName(delegationConnectorName) - .withOuterProvidedRole(delegationRoleName) - .withProvidingContext(getAssemblyContextName(provider)) - .withOperationProvidedRole(RepositoryTransformer.getProvidedRoleName(providedInteface)); - fluentSystem.addToSystem(systemDelegation); - } - } - - return fluentSystem.createSystemNow(); - } - - protected static String getAssemblyContextName(Component component) { - String componentEntityName = component.getValue().getEntityName(); - return String.format(ASSEMBLY_CONTEXT_NAME_PATTERN, componentEntityName); - } - - protected static String getAssemblyConnectorName(Interface interfaceInstance) { - String interfaceEntityName = interfaceInstance.getValue().getEntityName(); - return String.format(ASSEMBLY_CONNECTOR_NAME_PATTERN, interfaceEntityName); - } - - private AssemblyContextCreator getAssemblyContextCreator(FluentSystemFactory fluentFactory, - Component component) { - String componentEntityName = component.getValue().getEntityName(); - String assemblyContextName = getAssemblyContextName(component); - AssemblyContextCreator contextCreator = fluentFactory.newAssemblyContext() - .withName(assemblyContextName) - .withEncapsulatedComponent(componentEntityName); - return contextCreator; - } - - private AssemblyConnectorCreator getAssemblyConnectorCreator(FluentSystemFactory fluentFactory, - ComponentAssemblyRelation assemblyRelation) { - // Get wrapper from relation - Component provider = assemblyRelation.getSource().getSource(); - Component consumer = assemblyRelation.getDestination().getSource(); - Interface interfaceInstance = assemblyRelation.getSource().getDestination(); - - // Get entity names of roles, components and connector - String connectorName = getAssemblyConnectorName(interfaceInstance); - String providerName = getAssemblyContextName(provider); - String consumerName = getAssemblyContextName(consumer); - String providedRoleName = RepositoryTransformer.getProvidedRoleName(interfaceInstance); - String requiredRoleName = RepositoryTransformer.getRequiredRoleName(interfaceInstance); - - AssemblyConnectorCreator connectorCreator = fluentFactory.newAssemblyConnector() - .withName(connectorName) - .withProvidingAssemblyContext(providerName) - .withOperationProvidedRole(providedRoleName) - .withRequiringAssemblyContext(consumerName) - .withOperationRequiredRole(requiredRoleName); - return connectorCreator; - } -} diff --git a/releng/org.palladiosimulator.somox.targetplatform/.project b/features/org.palladiosimulator.retriever.feature/.project similarity index 75% rename from releng/org.palladiosimulator.somox.targetplatform/.project rename to features/org.palladiosimulator.retriever.feature/.project index 0c12867f..91856824 100644 --- a/releng/org.palladiosimulator.somox.targetplatform/.project +++ b/features/org.palladiosimulator.retriever.feature/.project @@ -1,6 +1,6 @@ - org.palladiosimulator.somox.targetplatform + org.palladiosimulator.retriever.feature diff --git a/features/org.palladiosimulator.somox.analyzer.rules.feature/build.properties b/features/org.palladiosimulator.retriever.feature/build.properties similarity index 100% rename from features/org.palladiosimulator.somox.analyzer.rules.feature/build.properties rename to features/org.palladiosimulator.retriever.feature/build.properties diff --git a/features/org.palladiosimulator.retriever.feature/feature.xml b/features/org.palladiosimulator.retriever.feature/feature.xml new file mode 100644 index 00000000..14b482f2 --- /dev/null +++ b/features/org.palladiosimulator.retriever.feature/feature.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/features/org.palladiosimulator.somox.analyzer.rules.feature/feature.xml b/features/org.palladiosimulator.somox.analyzer.rules.feature/feature.xml deleted file mode 100644 index a2afa360..00000000 --- a/features/org.palladiosimulator.somox.analyzer.rules.feature/feature.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pom.xml b/pom.xml index fb3c81c6..8bb5744e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,32 +1,33 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - 4.0.0 + 4.0.0 - - org.palladiosimulator - eclipse-parent-updatesite - 0.8.9 - + + org.palladiosimulator + eclipse-parent-updatesite + 0.8.9 + - org.palladiosimulator.somox - parent - 5.2.0-SNAPSHOT - pom + org.palladiosimulator.retriever + parent + 5.2.0-SNAPSHOT + pom - - ${project.basedir}/releng/org.palladiosimulator.somox.targetplatform/org.palladiosimulator.somox.targetplatform.target - + + + ${project.basedir}/releng/org.palladiosimulator.retriever.targetplatform/org.palladiosimulator.retriever.target + - - releng - bundles - features - tests - products - + + releng + bundles + features + tests + products + diff --git a/features/org.palladiosimulator.somox.analyzer.rules.feature/.project b/products/org.palladiosimulator.retriever.product/.project similarity index 73% rename from features/org.palladiosimulator.somox.analyzer.rules.feature/.project rename to products/org.palladiosimulator.retriever.product/.project index d14049ea..8822d8c4 100644 --- a/features/org.palladiosimulator.somox.analyzer.rules.feature/.project +++ b/products/org.palladiosimulator.retriever.product/.project @@ -1,6 +1,6 @@ - org.palladiosimulator.somox.analyzer.rules.feature + org.palladiosimulator.retriever.product diff --git a/products/org.palladiosimulator.retriever.product/org.palladiosimulator.retriever.product b/products/org.palladiosimulator.retriever.product/org.palladiosimulator.retriever.product new file mode 100644 index 00000000..0abaf160 --- /dev/null +++ b/products/org.palladiosimulator.retriever.product/org.palladiosimulator.retriever.product @@ -0,0 +1,65 @@ + + + + + + + + + + -XstartOnFirstThread + -Dorg.eclipse.swt.internal.carbon.smallFonts + + + + + + + + + + + + + + org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/products/org.palladiosimulator.somox.analyzer.rules.product/pom.xml b/products/org.palladiosimulator.retriever.product/pom.xml similarity index 90% rename from products/org.palladiosimulator.somox.analyzer.rules.product/pom.xml rename to products/org.palladiosimulator.retriever.product/pom.xml index 2e0901b0..76be180c 100644 --- a/products/org.palladiosimulator.somox.analyzer.rules.product/pom.xml +++ b/products/org.palladiosimulator.retriever.product/pom.xml @@ -10,9 +10,9 @@ ../../ - org.palladiosimulator.somox - org.palladiosimulator.somox.analyzer.rules.product - [product] SoMoX Rule CLI + org.palladiosimulator.retriever + org.palladiosimulator.retriever.product + [product] Retriever CLI 5.2.0-SNAPSHOT eclipse-repository diff --git a/products/org.palladiosimulator.somox.analyzer.rules.product/org.palladiosimulator.somox.analyzer.rules.main.product b/products/org.palladiosimulator.somox.analyzer.rules.product/org.palladiosimulator.somox.analyzer.rules.main.product deleted file mode 100644 index a0a5a9d5..00000000 --- a/products/org.palladiosimulator.somox.analyzer.rules.product/org.palladiosimulator.somox.analyzer.rules.main.product +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts - - - - - - - - - - - - - org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/products/org.palladiosimulator.somox.analyzer.rules.product/.project b/releng/org.palladiosimulator.retriever.targetplatform/.project similarity index 73% rename from products/org.palladiosimulator.somox.analyzer.rules.product/.project rename to releng/org.palladiosimulator.retriever.targetplatform/.project index 2f93243a..b64c6714 100644 --- a/products/org.palladiosimulator.somox.analyzer.rules.product/.project +++ b/releng/org.palladiosimulator.retriever.targetplatform/.project @@ -1,6 +1,6 @@ - org.palladiosimulator.somox.analyzer.rules.product + org.palladiosimulator.retriever.targetplatform diff --git a/releng/org.palladiosimulator.retriever.targetplatform/org.palladiosimulator.retriever.target b/releng/org.palladiosimulator.retriever.targetplatform/org.palladiosimulator.retriever.target new file mode 100644 index 00000000..6b32877d --- /dev/null +++ b/releng/org.palladiosimulator.retriever.targetplatform/org.palladiosimulator.retriever.target @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/releng/org.palladiosimulator.retriever.updatesite/.project b/releng/org.palladiosimulator.retriever.updatesite/.project new file mode 100644 index 00000000..5adc29e0 --- /dev/null +++ b/releng/org.palladiosimulator.retriever.updatesite/.project @@ -0,0 +1,17 @@ + + + org.palladiosimulator.retriever.updatesite + + + + + + org.eclipse.pde.UpdateSiteBuilder + + + + + + org.eclipse.pde.UpdateSiteNature + + diff --git a/releng/org.palladiosimulator.retriever.updatesite/category.xml b/releng/org.palladiosimulator.retriever.updatesite/category.xml new file mode 100644 index 00000000..f1e8a3ec --- /dev/null +++ b/releng/org.palladiosimulator.retriever.updatesite/category.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + This category contains all features that are part of a full + installation of the SOftware MOdel eXtractor features. + + + diff --git a/releng/org.palladiosimulator.somox.targetplatform/org.palladiosimulator.somox.targetplatform.target b/releng/org.palladiosimulator.somox.targetplatform/org.palladiosimulator.somox.targetplatform.target deleted file mode 100644 index ea5a2151..00000000 --- a/releng/org.palladiosimulator.somox.targetplatform/org.palladiosimulator.somox.targetplatform.target +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/releng/org.palladiosimulator.somox.updatesite/.project b/releng/org.palladiosimulator.somox.updatesite/.project deleted file mode 100644 index 947f99be..00000000 --- a/releng/org.palladiosimulator.somox.updatesite/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - org.palladiosimulator.somox.updatesite - - - - - - org.eclipse.pde.UpdateSiteBuilder - - - - - - org.eclipse.pde.UpdateSiteNature - - diff --git a/releng/org.palladiosimulator.somox.updatesite/category.xml b/releng/org.palladiosimulator.somox.updatesite/category.xml deleted file mode 100644 index 26a3ed23..00000000 --- a/releng/org.palladiosimulator.somox.updatesite/category.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - This category contains all features that are part of a full installation of the SOftware MOdel eXtractor features. - - - diff --git a/tests/org.palladiosimulator.retriever.mocore.test/.classpath b/tests/org.palladiosimulator.retriever.mocore.test/.classpath new file mode 100644 index 00000000..2b79293e --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/.project b/tests/org.palladiosimulator.retriever.mocore.test/.project similarity index 90% rename from bundles/org.palladiosimulator.somox.analyzer.rules.mocore/.project rename to tests/org.palladiosimulator.retriever.mocore.test/.project index 27182219..39f0dc6f 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.mocore/.project +++ b/tests/org.palladiosimulator.retriever.mocore.test/.project @@ -1,6 +1,6 @@ - org.palladiosimulator.somox.analyzer.rules.mocore + org.palladiosimulator.retriever.mocore.test diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/META-INF/MANIFEST.MF b/tests/org.palladiosimulator.retriever.mocore.test/META-INF/MANIFEST.MF similarity index 58% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/META-INF/MANIFEST.MF rename to tests/org.palladiosimulator.retriever.mocore.test/META-INF/MANIFEST.MF index d5432a70..42f2b058 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/META-INF/MANIFEST.MF +++ b/tests/org.palladiosimulator.retriever.mocore.test/META-INF/MANIFEST.MF @@ -1,13 +1,13 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: org.palladiosimulator.somox.analyzer.rules.mocore.test -Bundle-SymbolicName: org.palladiosimulator.somox.analyzer.rules.mocore.test;singleton:=true +Bundle-Name: org.palladiosimulator.retriever.mocore.test +Bundle-SymbolicName: org.palladiosimulator.retriever.mocore.test;singleton:=true Bundle-Version: 1.0.0.qualifier Bundle-Vendor: palladiosimulator.org -Automatic-Module-Name: org.palladiosimulator.somox.analyzer.rules.mocore.test +Automatic-Module-Name: org.palladiosimulator.retriever.mocore.test Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-ActivationPolicy: lazy -Export-Package: org.palladiosimulator.somox.analyzer.rules.mocore.utility +Export-Package: org.palladiosimulator.retriever.mocore.utility Require-Bundle: org.junit, org.junit.jupiter.api, org.junit.jupiter.params, @@ -16,7 +16,7 @@ Require-Bundle: org.junit, org.palladiosimulator.pcm, org.palladiosimulator.pcm.resources, org.palladiosimulator.generator.fluent, - org.palladiosimulator.somox.analyzer.rules.mocore, + org.palladiosimulator.retriever.mocore, org.apache.log4j, org.apache.commons.io, de.uka.ipd.sdq.workflow diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/build.properties b/tests/org.palladiosimulator.retriever.mocore.test/build.properties similarity index 100% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/build.properties rename to tests/org.palladiosimulator.retriever.mocore.test/build.properties diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/discovery/DecompositorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/discovery/DecompositorTest.java similarity index 68% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/discovery/DecompositorTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/discovery/DecompositorTest.java index 9c8d2d66..85201fe0 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/discovery/DecompositorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/discovery/DecompositorTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.discovery; +package org.palladiosimulator.retriever.mocore.discovery; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThrows; @@ -13,17 +13,17 @@ public abstract class DecompositorTest, T> { @Test public void testDecomposeWithValidSource() { - D decompositor = this.createDecompositor(); - T source = this.createValidSource(); - Collection> discoverers = decompositor.decompose(source); + final D decompositor = this.createDecompositor(); + final T source = this.createValidSource(); + final Collection> discoverers = decompositor.decompose(source); assertNotNull(discoverers); assertTrue(discoverers.size() >= 0); } @Test public void testDecomposeWithNullSource() { - D decompositor = this.createDecompositor(); - T source = null; + final D decompositor = this.createDecompositor(); + final T source = null; assertThrows(NullPointerException.class, () -> decompositor.decompose(source)); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/discovery/RepositoryDecompositorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/discovery/RepositoryDecompositorTest.java new file mode 100644 index 00000000..f08e3059 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/discovery/RepositoryDecompositorTest.java @@ -0,0 +1,89 @@ +package org.palladiosimulator.retriever.mocore.discovery; + +import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; +import org.palladiosimulator.pcm.repository.Repository; +import org.palladiosimulator.retriever.mocore.surrogate.element.AtomicComponent; + +import tools.mdsd.mocore.framework.discovery.Discoverer; + +@SuppressWarnings("unchecked") +public class RepositoryDecompositorTest extends DecompositorTest { + @Test + public void testDecomposeEmptyRepository() { + final RepositoryDecompositor decompositor = this.createDecompositor(); + final Repository repository = this.createEmptyRepository(); + + final Collection> discoverers = decompositor.decompose(repository); + assertEquals(10, discoverers.size()); + discoverers.forEach((discoverer) -> assertTrue(discoverer.getDiscoveries() + .isEmpty())); + } + + @Test + public void testDecomposeUncoupledComponents() { + final RepositoryDecompositor decompositor = this.createDecompositor(); + final FluentRepositoryFactory factory = new FluentRepositoryFactory(); + final Repository repository = factory.newRepository() + .addToRepository(factory.newBasicComponent() + .withName("Component_1")) + .addToRepository(factory.newBasicComponent() + .withName("Component_2")) + .addToRepository(factory.newBasicComponent() + .withName("Component_3")) + .addToRepository(factory.newBasicComponent() + .withName("Component_4")) + .addToRepository(factory.newBasicComponent() + .withName("Component_5")) + .createRepositoryNow(); + + final Collection> discoverers = decompositor.decompose(repository); + assertFalse(discoverers.isEmpty()); + + // Remove all discoverers except component discoverer + final List> modifiableDiscoverers = new ArrayList<>(discoverers); + modifiableDiscoverers.removeIf((discoverer) -> discoverer.getDiscoveryType() != AtomicComponent.class); + assertEquals(1, modifiableDiscoverers.size()); + + // Get and check component discoverer + final Discoverer componentDiscoverer = (Discoverer) modifiableDiscoverers + .iterator() + .next(); + assertEquals(5, componentDiscoverer.getDiscoveries() + .size()); + for (int i = 1; i <= 5; i++) { + final int j = i; + assertTrue(componentDiscoverer.getDiscoveries() + .stream() + .anyMatch((final AtomicComponent component) -> component.getValue() + .getEntityName() + .equals("Component_" + j))); + } + } + + // TODO Add tests for interface, signatures, seff, and all relevant relations + // TODO Add tests for composition, delegation + + @Override + protected RepositoryDecompositor createDecompositor() { + return new RepositoryDecompositor(); + } + + @Override + protected Repository createValidSource() { + return this.createEmptyRepository(); + } + + private Repository createEmptyRepository() { + return new FluentRepositoryFactory().newRepository() + .createRepositoryNow(); + } +} diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/orchestration/PcmOrchestratorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/orchestration/PcmOrchestratorTest.java new file mode 100644 index 00000000..aec4d083 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/orchestration/PcmOrchestratorTest.java @@ -0,0 +1,154 @@ +package org.palladiosimulator.retriever.mocore.orchestration; + +import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.LinkResourceSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.element.Signature; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAllocationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAssemblyRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.DeploymentDeploymentRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceRequirementRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.LinkResourceSpecificationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.SignatureProvisionRelation; +import org.palladiosimulator.retriever.mocore.utility.ElementFactory; + +public class PcmOrchestratorTest { + @Test + public void testExistsComponentAfterProcess() { + final PcmOrchestrator orchestrator = new PcmOrchestrator(); + final Component component = ElementFactory.createUniqueComponent(false); + orchestrator.processDiscovery(component); + assertTrue(orchestrator.getModel() + .contains(component)); + } + + @Test + public void testExistImplicitReplaceablesAfterProcess() { + final PcmOrchestrator orchestrator = new PcmOrchestrator(); + final Component component = ElementFactory.createUniqueComponent(false); + orchestrator.processDiscovery(component); + + final PcmSurrogate model = orchestrator.getModel(); + final List deployments = model.getByType(Deployment.class); + final Stream componentDeploymentRelations = model + .getByType(ComponentAllocationRelation.class) + .stream(); + + // Assertions + assertTrue(model.contains(component)); + assertTrue(componentDeploymentRelations.anyMatch(element -> element.getSource() + .equals(component))); + assertFalse(deployments.isEmpty()); + } + + @Test + public void testExistsDeploymentAfterProcess() { + final PcmOrchestrator orchestrator = new PcmOrchestrator(); + final Deployment deployment = ElementFactory.createUniqueDeployment(false); + orchestrator.processDiscovery(deployment); + assertTrue(orchestrator.getModel() + .contains(deployment)); + } + + @Test + public void testChainReplacementOfPlaceholders() { + // Test data + final PcmOrchestrator orchestrator = new PcmOrchestrator(); + + //// Create concrete & placeholder elements + final Signature concreteSignature = ElementFactory.createUniqueSignature(false); + final Interface concreteInterface = ElementFactory.createUniqueInterface(false); + final Component concreteComponent = ElementFactory.createUniqueComponent(false); + final Deployment concreteDeployment = ElementFactory.createUniqueDeployment(false); + final Interface placeholderInterface = Interface.getUniquePlaceholder(); + final Component placeholderComponent = Component.getUniquePlaceholder(); + final Deployment placeholderDeployment = Deployment.getUniquePlaceholder(); + + //// Create non-conflicting relations between elements + final SignatureProvisionRelation placeholderSignatureProvision = new SignatureProvisionRelation( + concreteSignature, placeholderInterface, true); + final InterfaceProvisionRelation placeholderInterfaceProvision = new InterfaceProvisionRelation( + placeholderComponent, placeholderInterface, true); + final ComponentAllocationRelation placeholderAllocation = new ComponentAllocationRelation(placeholderComponent, + placeholderDeployment, true); + final InterfaceProvisionRelation concreteInterfaceProvision = new InterfaceProvisionRelation(concreteComponent, + concreteInterface, false); + final ComponentAllocationRelation concreteAllocation = new ComponentAllocationRelation(concreteComponent, + concreteDeployment, false); + + //// Create relation leading to chain replacement + final SignatureProvisionRelation signatureProvisionRelation = new SignatureProvisionRelation(concreteSignature, + concreteInterface, false); + + //// Add entities to model + final PcmSurrogate model = orchestrator.getModel(); + model.add(concreteSignature); + model.add(concreteInterface); + model.add(concreteComponent); + model.add(concreteDeployment); + model.add(concreteInterfaceProvision); + model.add(concreteAllocation); + model.add(placeholderInterface); + model.add(placeholderComponent); + model.add(placeholderDeployment); + model.add(placeholderSignatureProvision); + model.add(placeholderInterfaceProvision); + model.add(placeholderAllocation); + + // Execution + orchestrator.processDiscovery(signatureProvisionRelation); + + // Assertions: Post-execution + assertTrue(model.contains(concreteSignature)); + assertTrue(model.contains(concreteInterface)); + assertTrue(model.contains(concreteComponent)); + assertTrue(model.contains(concreteDeployment)); + assertTrue(model.contains(signatureProvisionRelation)); + assertTrue(model.contains(concreteInterfaceProvision)); + assertTrue(model.contains(concreteAllocation)); + + assertFalse(model.contains(placeholderInterface)); + assertFalse(model.contains(placeholderComponent)); + assertFalse(model.contains(placeholderDeployment)); + assertFalse(model.contains(placeholderSignatureProvision)); + assertFalse(model.contains(placeholderInterfaceProvision)); + assertFalse(model.contains(placeholderAllocation)); + + assertEquals(1, model.getByType(Signature.class) + .size()); + assertEquals(1, model.getByType(Interface.class) + .size()); + assertEquals(1, model.getByType(Component.class) + .size()); + assertEquals(1, model.getByType(Deployment.class) + .size()); + assertEquals(0, model.getByType(LinkResourceSpecification.class) + .size()); + + assertEquals(1, model.getByType(SignatureProvisionRelation.class) + .size()); + assertEquals(1, model.getByType(InterfaceProvisionRelation.class) + .size()); + assertEquals(0, model.getByType(InterfaceRequirementRelation.class) + .size()); + assertEquals(1, model.getByType(ComponentAllocationRelation.class) + .size()); + assertEquals(0, model.getByType(ComponentAssemblyRelation.class) + .size()); + assertEquals(0, model.getByType(DeploymentDeploymentRelation.class) + .size()); + assertEquals(0, model.getByType(LinkResourceSpecificationRelation.class) + .size()); + } +} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/AtomicComponentProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/AtomicComponentProcessorTest.java similarity index 55% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/AtomicComponentProcessorTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/AtomicComponentProcessorTest.java index 224b6d91..b7cf171d 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/AtomicComponentProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/AtomicComponentProcessorTest.java @@ -1,11 +1,11 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.element; +package org.palladiosimulator.retriever.mocore.processor.element; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.AtomicComponent; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.AtomicComponent; public class AtomicComponentProcessorTest extends ComponentProcessorTest { @Override - protected AtomicComponentProcessor createProcessor(PcmSurrogate model) { + protected AtomicComponentProcessor createProcessor(final PcmSurrogate model) { return new AtomicComponentProcessor(model); } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/ComponentProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/ComponentProcessorTest.java similarity index 53% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/ComponentProcessorTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/ComponentProcessorTest.java index 0fc557c3..28bf25c6 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/ComponentProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/ComponentProcessorTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.element; +package org.palladiosimulator.retriever.mocore.processor.element; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -7,9 +7,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledIf; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAllocationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAllocationRelation; import tools.mdsd.mocore.framework.processor.ProcessorTest; import tools.mdsd.mocore.framework.surrogate.Replaceable; @@ -20,25 +20,29 @@ public abstract class ComponentProcessorTest> @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefineWithValidElementAddsCorrectImplications() { // Test data - PcmSurrogate model = createEmptyModel(); - ComponentProcessor processor = createProcessor(model); - T element = createUniqueReplaceable(); + final PcmSurrogate model = this.createEmptyModel(); + final ComponentProcessor processor = this.createProcessor(model); + final T element = this.createUniqueReplaceable(); // Assertions: Pre-execution - assertTrue(processor.getImplications().isEmpty()); + assertTrue(processor.getImplications() + .isEmpty()); // Execution processor.refine(element); - Set implications = processor.getImplications(); + final Set implications = processor.getImplications(); // Assertions: Post-execution assertEquals(1, implications.size()); - Replaceable implication = implications.stream().findFirst().orElseThrow(); + final Replaceable implication = implications.stream() + .findFirst() + .orElseThrow(); assertEquals(ComponentAllocationRelation.class, implication.getClass()); - ComponentAllocationRelation relation = (ComponentAllocationRelation) implication; + final ComponentAllocationRelation relation = (ComponentAllocationRelation) implication; assertEquals(element, relation.getSource()); assertTrue(relation.isPlaceholder()); - assertTrue(relation.getDestination().isPlaceholder()); + assertTrue(relation.getDestination() + .isPlaceholder()); } @Override diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/CompositeProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/CompositeProcessorTest.java similarity index 54% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/CompositeProcessorTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/CompositeProcessorTest.java index 592c3d85..fc21ab38 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/CompositeProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/CompositeProcessorTest.java @@ -1,11 +1,11 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.element; +package org.palladiosimulator.retriever.mocore.processor.element; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Composite; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; public class CompositeProcessorTest extends ComponentProcessorTest { @Override - protected CompositeProcessor createProcessor(PcmSurrogate model) { + protected CompositeProcessor createProcessor(final PcmSurrogate model) { return new CompositeProcessor(model); } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/DeploymentProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/DeploymentProcessorTest.java similarity index 58% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/DeploymentProcessorTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/DeploymentProcessorTest.java index d7a09c2f..4b3a778c 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/DeploymentProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/DeploymentProcessorTest.java @@ -1,11 +1,11 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.element; +package org.palladiosimulator.retriever.mocore.processor.element; import static org.junit.Assert.assertTrue; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledIf; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; import tools.mdsd.mocore.framework.processor.ProcessorTest; @@ -14,22 +14,24 @@ public class DeploymentProcessorTest extends ProcessorTest implications = processor.getImplications(); + final Set implications = processor.getImplications(); // Assertions: Post-execution assertEquals(1, implications.size()); - Replaceable implication = implications.stream().findFirst().orElseThrow(); + final Replaceable implication = implications.stream() + .findFirst() + .orElseThrow(); assertEquals(InterfaceProvisionRelation.class, implication.getClass()); - InterfaceProvisionRelation relation = (InterfaceProvisionRelation) implication; + final InterfaceProvisionRelation relation = (InterfaceProvisionRelation) implication; assertEquals(element, relation.getDestination()); assertTrue(relation.isPlaceholder()); - assertTrue(relation.getSource().isPlaceholder()); - assertEquals(element.getValue().getEntityName() + " Provider", relation.getSource().getValue().getEntityName()); + assertTrue(relation.getSource() + .isPlaceholder()); + assertEquals(element.getValue() + .getEntityName() + " Provider", relation.getSource() + .getValue() + .getEntityName()); } @Override - protected InterfaceProcessor createProcessor(PcmSurrogate model) { + protected InterfaceProcessor createProcessor(final PcmSurrogate model) { return new InterfaceProcessor(model); } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/LinkResourceSpecificationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/LinkResourceSpecificationProcessorTest.java similarity index 53% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/LinkResourceSpecificationProcessorTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/LinkResourceSpecificationProcessorTest.java index 706d8b95..5fcdfe6a 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/LinkResourceSpecificationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/LinkResourceSpecificationProcessorTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.element; +package org.palladiosimulator.retriever.mocore.processor.element; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -7,9 +7,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledIf; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.LinkResourceSpecification; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.LinkResourceSpecificationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.LinkResourceSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.relation.LinkResourceSpecificationRelation; import tools.mdsd.mocore.framework.processor.ProcessorTest; import tools.mdsd.mocore.framework.surrogate.Replaceable; @@ -20,31 +20,39 @@ public class LinkResourceSpecificationProcessorTest @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefineWithValidElementAddsCorrectImplications() { // Test data - PcmSurrogate model = createEmptyModel(); - LinkResourceSpecificationProcessor processor = createProcessor(model); - LinkResourceSpecification element = createUniqueReplaceable(); + final PcmSurrogate model = this.createEmptyModel(); + final LinkResourceSpecificationProcessor processor = this.createProcessor(model); + final LinkResourceSpecification element = this.createUniqueReplaceable(); // Assertions: Pre-execution - assertTrue(processor.getImplications().isEmpty()); + assertTrue(processor.getImplications() + .isEmpty()); // Execution processor.refine(element); - Set implications = processor.getImplications(); + final Set implications = processor.getImplications(); // Assertions: Post-execution assertEquals(1, implications.size()); - Replaceable implication = implications.stream().findFirst().orElseThrow(); + final Replaceable implication = implications.stream() + .findFirst() + .orElseThrow(); assertEquals(LinkResourceSpecificationRelation.class, implication.getClass()); - LinkResourceSpecificationRelation relation = (LinkResourceSpecificationRelation) implication; + final LinkResourceSpecificationRelation relation = (LinkResourceSpecificationRelation) implication; assertEquals(element, relation.getSource()); assertTrue(relation.isPlaceholder()); - assertTrue(relation.getDestination().isPlaceholder()); - assertTrue(relation.getDestination().getSource().isPlaceholder()); - assertTrue(relation.getDestination().getDestination().isPlaceholder()); + assertTrue(relation.getDestination() + .isPlaceholder()); + assertTrue(relation.getDestination() + .getSource() + .isPlaceholder()); + assertTrue(relation.getDestination() + .getDestination() + .isPlaceholder()); } @Override - protected LinkResourceSpecificationProcessor createProcessor(PcmSurrogate model) { + protected LinkResourceSpecificationProcessor createProcessor(final PcmSurrogate model) { return new LinkResourceSpecificationProcessor(model); } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/ServiceEffectSpecificationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/ServiceEffectSpecificationProcessorTest.java similarity index 65% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/ServiceEffectSpecificationProcessorTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/ServiceEffectSpecificationProcessorTest.java index 7f1a7ba7..029c3263 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/ServiceEffectSpecificationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/ServiceEffectSpecificationProcessorTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.element; +package org.palladiosimulator.retriever.mocore.processor.element; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -7,8 +7,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledIf; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.ServiceEffectSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.ServiceEffectSpecification; import tools.mdsd.mocore.framework.processor.ProcessorTest; import tools.mdsd.mocore.framework.surrogate.Replaceable; @@ -19,23 +19,24 @@ public class ServiceEffectSpecificationProcessorTest @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefineWithValidElementAddsCorrectImplications() { // Test data - PcmSurrogate model = createEmptyModel(); - ServiceEffectSpecificationProcessor processor = createProcessor(model); - ServiceEffectSpecification element = createUniqueReplaceable(); + final PcmSurrogate model = this.createEmptyModel(); + final ServiceEffectSpecificationProcessor processor = this.createProcessor(model); + final ServiceEffectSpecification element = this.createUniqueReplaceable(); // Assertions: Pre-execution - assertTrue(processor.getImplications().isEmpty()); + assertTrue(processor.getImplications() + .isEmpty()); // Execution processor.refine(element); - Set implications = processor.getImplications(); + final Set implications = processor.getImplications(); // Assertions: Post-execution assertEquals(0, implications.size()); } @Override - protected ServiceEffectSpecificationProcessor createProcessor(PcmSurrogate model) { + protected ServiceEffectSpecificationProcessor createProcessor(final PcmSurrogate model) { return new ServiceEffectSpecificationProcessor(model); } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/SignatureProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/SignatureProcessorTest.java similarity index 55% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/SignatureProcessorTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/SignatureProcessorTest.java index 0d07e74d..f82f01bc 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/element/SignatureProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/element/SignatureProcessorTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.element; +package org.palladiosimulator.retriever.mocore.processor.element; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -8,9 +8,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledIf; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Signature; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.SignatureProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Signature; +import org.palladiosimulator.retriever.mocore.surrogate.relation.SignatureProvisionRelation; import tools.mdsd.mocore.framework.processor.ProcessorTest; import tools.mdsd.mocore.framework.surrogate.Replaceable; @@ -20,30 +20,34 @@ public class SignatureProcessorTest extends ProcessorTest implications = new HashSet<>(processor.getImplications()); + final Set implications = new HashSet<>(processor.getImplications()); // Assertions: Post-execution //// Implicit providing interface assertEquals(1, implications.size()); - Replaceable implication = implications.stream().findFirst().orElseThrow(); + final Replaceable implication = implications.stream() + .findFirst() + .orElseThrow(); assertEquals(SignatureProvisionRelation.class, implication.getClass()); - SignatureProvisionRelation relation = (SignatureProvisionRelation) implication; + final SignatureProvisionRelation relation = (SignatureProvisionRelation) implication; assertEquals(element, relation.getSource()); assertTrue(relation.isPlaceholder()); - assertTrue(relation.getDestination().isPlaceholder()); + assertTrue(relation.getDestination() + .isPlaceholder()); } @Override - protected SignatureProcessor createProcessor(PcmSurrogate model) { + protected SignatureProcessor createProcessor(final PcmSurrogate model) { return new SignatureProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAllocationRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAllocationRelationProcessorTest.java new file mode 100644 index 00000000..9b414dd1 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAllocationRelationProcessorTest.java @@ -0,0 +1,48 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAllocationRelation; +import org.palladiosimulator.retriever.mocore.utility.ElementFactory; + +import tools.mdsd.mocore.framework.processor.RelationProcessorTest; + +public class ComponentAllocationRelationProcessorTest extends + RelationProcessorTest, Deployment> { + @Override + protected ComponentAllocationRelation createRelation(final Component source, final Deployment destination, + final boolean isPlaceholder) { + return new ComponentAllocationRelation(source, destination, isPlaceholder); + } + + @Override + protected Component getUniqueNonPlaceholderSourceEntity() { + return ElementFactory.createUniqueComponent(false); + } + + @Override + protected Component getPlaceholderOfSourceEntity(final Component source) { + return new Component<>(source.getValue(), true); + } + + @Override + protected Deployment getUniqueNonPlaceholderDestinationEntity() { + return ElementFactory.createUniqueDeployment(false); + } + + @Override + protected Deployment getPlaceholderOfDestinationEntity(final Deployment destination) { + return new Deployment(destination.getValue(), true); + } + + @Override + protected ComponentAllocationRelationProcessor createProcessor(final PcmSurrogate model) { + return new ComponentAllocationRelationProcessor(model); + } + + @Override + protected PcmSurrogate createEmptyModel() { + return new PcmSurrogate(); + } +} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentAssemblyRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAssemblyRelationProcessorTest.java similarity index 54% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentAssemblyRelationProcessorTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAssemblyRelationProcessorTest.java index 07495515..f60288b6 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentAssemblyRelationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentAssemblyRelationProcessorTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; +package org.palladiosimulator.retriever.mocore.processor.relation; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -9,50 +9,50 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledIf; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAllocationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAssemblyRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.DeploymentDeploymentRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceRequirementRelation; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAllocationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAssemblyRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.DeploymentDeploymentRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceRequirementRelation; import tools.mdsd.mocore.framework.processor.RelationProcessorTest; import tools.mdsd.mocore.framework.surrogate.Replaceable; -public class ComponentAssemblyRelationProcessorTest extends RelationProcessorTest { +public class ComponentAssemblyRelationProcessorTest extends + RelationProcessorTest { private static final Interface RELATION_DESTINATION = Interface.getUniquePlaceholder(); @Test @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefinementRemovesParallelAssemblyPlaceholder() { // Test data - PcmSurrogate model = createEmptyModel(); - ComponentAssemblyRelationProcessor processor = createProcessor(model); + final PcmSurrogate model = this.createEmptyModel(); + final ComponentAssemblyRelationProcessor processor = this.createProcessor(model); - InterfaceProvisionRelation interfaceProvision = getUniqueNonPlaceholderSourceEntity(); - InterfaceRequirementRelation interfaceRequirement = getUniqueNonPlaceholderDestinationEntity(); - ComponentAssemblyRelation relation = createRelation(interfaceProvision, interfaceRequirement, false); + final InterfaceProvisionRelation interfaceProvision = this.getUniqueNonPlaceholderSourceEntity(); + final InterfaceRequirementRelation interfaceRequirement = this.getUniqueNonPlaceholderDestinationEntity(); + final ComponentAssemblyRelation relation = this.createRelation(interfaceProvision, interfaceRequirement, false); - Deployment providingContainer = Deployment.getUniquePlaceholder(); - Deployment requiringContainer = Deployment.getUniquePlaceholder(); - ComponentAllocationRelation providingAllocation = new ComponentAllocationRelation( + final Deployment providingContainer = Deployment.getUniquePlaceholder(); + final Deployment requiringContainer = Deployment.getUniquePlaceholder(); + final ComponentAllocationRelation providingAllocation = new ComponentAllocationRelation( interfaceProvision.getSource(), providingContainer, false); - ComponentAllocationRelation requiringAllocation = new ComponentAllocationRelation( + final ComponentAllocationRelation requiringAllocation = new ComponentAllocationRelation( interfaceRequirement.getSource(), requiringContainer, false); - InterfaceProvisionRelation placeholderProvision = getPlaceholderOfSourceEntity( - getUniqueNonPlaceholderSourceEntity()); - InterfaceRequirementRelation placeholderRequirement = getPlaceholderOfDestinationEntity( - getUniqueNonPlaceholderDestinationEntity()); - ComponentAllocationRelation placeholderProvidingAllocation = new ComponentAllocationRelation( + final InterfaceProvisionRelation placeholderProvision = this + .getPlaceholderOfSourceEntity(this.getUniqueNonPlaceholderSourceEntity()); + final InterfaceRequirementRelation placeholderRequirement = this + .getPlaceholderOfDestinationEntity(this.getUniqueNonPlaceholderDestinationEntity()); + final ComponentAllocationRelation placeholderProvidingAllocation = new ComponentAllocationRelation( placeholderProvision.getSource(), providingContainer, false); - ComponentAllocationRelation placeholderRequiringAllocation = new ComponentAllocationRelation( + final ComponentAllocationRelation placeholderRequiringAllocation = new ComponentAllocationRelation( placeholderRequirement.getSource(), requiringContainer, false); - ComponentAssemblyRelation placeholderRelation = createRelation(placeholderProvision, + final ComponentAssemblyRelation placeholderRelation = this.createRelation(placeholderProvision, placeholderRequirement, true); // Add containers, placeholder assembly & allocations to model @@ -71,7 +71,8 @@ public void testRefinementRemovesParallelAssemblyPlaceholder() { model.add(placeholderRelation); // Assertions: Pre-execution - assertTrue(processor.getImplications().isEmpty()); + assertTrue(processor.getImplications() + .isEmpty()); assertTrue(model.contains(placeholderProvision.getSource())); assertTrue(model.contains(placeholderProvision.getDestination())); assertTrue(model.contains(placeholderRequirement.getSource())); @@ -83,7 +84,7 @@ public void testRefinementRemovesParallelAssemblyPlaceholder() { // Execution processor.refine(relation); - Set implications = new HashSet<>(processor.getImplications()); + final Set implications = new HashSet<>(processor.getImplications()); // Assertions: Post-execution assertFalse(model.contains(placeholderProvision.getSource())); @@ -105,18 +106,18 @@ public void testRefinementRemovesParallelAssemblyPlaceholder() { @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefinementAddsImplicitDeploymentRelation() { // Test data - PcmSurrogate model = createEmptyModel(); - ComponentAssemblyRelationProcessor processor = createProcessor(model); + final PcmSurrogate model = this.createEmptyModel(); + final ComponentAssemblyRelationProcessor processor = this.createProcessor(model); - InterfaceProvisionRelation interfaceProvision = getUniqueNonPlaceholderSourceEntity(); - InterfaceRequirementRelation interfaceRequirement = getUniqueNonPlaceholderDestinationEntity(); - ComponentAssemblyRelation relation = createRelation(interfaceProvision, interfaceRequirement, false); + final InterfaceProvisionRelation interfaceProvision = this.getUniqueNonPlaceholderSourceEntity(); + final InterfaceRequirementRelation interfaceRequirement = this.getUniqueNonPlaceholderDestinationEntity(); + final ComponentAssemblyRelation relation = this.createRelation(interfaceProvision, interfaceRequirement, false); - Deployment providingContainer = Deployment.getUniquePlaceholder(); - Deployment requiringContainer = Deployment.getUniquePlaceholder(); - ComponentAllocationRelation providingAllocation = new ComponentAllocationRelation( + final Deployment providingContainer = Deployment.getUniquePlaceholder(); + final Deployment requiringContainer = Deployment.getUniquePlaceholder(); + final ComponentAllocationRelation providingAllocation = new ComponentAllocationRelation( interfaceProvision.getSource(), providingContainer, false); - ComponentAllocationRelation requiringAllocation = new ComponentAllocationRelation( + final ComponentAllocationRelation requiringAllocation = new ComponentAllocationRelation( interfaceRequirement.getSource(), requiringContainer, false); // Add containers & allocations to model @@ -126,55 +127,58 @@ public void testRefinementAddsImplicitDeploymentRelation() { model.add(requiringAllocation); // Assertions: Pre-execution - assertTrue(processor.getImplications().isEmpty()); + assertTrue(processor.getImplications() + .isEmpty()); // Execution processor.refine(relation); - Set implications = new HashSet<>(processor.getImplications()); + final Set implications = new HashSet<>(processor.getImplications()); // Assertions: Post-execution assertTrue(implications.remove(relation.getSource())); assertTrue(implications.remove(relation.getDestination())); assertEquals(1, implications.size()); - Replaceable implication = implications.stream().findFirst().orElseThrow(); + final Replaceable implication = implications.stream() + .findFirst() + .orElseThrow(); assertEquals(DeploymentDeploymentRelation.class, implication.getClass()); - DeploymentDeploymentRelation implicitDeploymentLink = (DeploymentDeploymentRelation) implication; + final DeploymentDeploymentRelation implicitDeploymentLink = (DeploymentDeploymentRelation) implication; assertEquals(providingContainer, implicitDeploymentLink.getSource()); assertEquals(requiringContainer, implicitDeploymentLink.getDestination()); assertTrue(implicitDeploymentLink.isPlaceholder()); } @Override - protected ComponentAssemblyRelation createRelation(InterfaceProvisionRelation source, - InterfaceRequirementRelation destination, - boolean isPlaceholder) { + protected ComponentAssemblyRelation createRelation(final InterfaceProvisionRelation source, + final InterfaceRequirementRelation destination, final boolean isPlaceholder) { return new ComponentAssemblyRelation(source, destination, isPlaceholder); } @Override protected InterfaceProvisionRelation getUniqueNonPlaceholderSourceEntity() { - Component source = Component.getUniquePlaceholder(); + final Component source = Component.getUniquePlaceholder(); return new InterfaceProvisionRelation(source, RELATION_DESTINATION, false); } @Override - protected InterfaceProvisionRelation getPlaceholderOfSourceEntity(InterfaceProvisionRelation source) { + protected InterfaceProvisionRelation getPlaceholderOfSourceEntity(final InterfaceProvisionRelation source) { return new InterfaceProvisionRelation(source.getSource(), source.getDestination(), true); } @Override protected InterfaceRequirementRelation getUniqueNonPlaceholderDestinationEntity() { - Component source = Component.getUniquePlaceholder(); + final Component source = Component.getUniquePlaceholder(); return new InterfaceRequirementRelation(source, RELATION_DESTINATION, false); } @Override - protected InterfaceRequirementRelation getPlaceholderOfDestinationEntity(InterfaceRequirementRelation destination) { + protected InterfaceRequirementRelation getPlaceholderOfDestinationEntity( + final InterfaceRequirementRelation destination) { return new InterfaceRequirementRelation(destination.getSource(), destination.getDestination(), true); } @Override - protected ComponentAssemblyRelationProcessor createProcessor(PcmSurrogate model) { + protected ComponentAssemblyRelationProcessor createProcessor(final PcmSurrogate model) { return new ComponentAssemblyRelationProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentSignatureProvisionRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentSignatureProvisionRelationProcessorTest.java new file mode 100644 index 00000000..59d2c4c0 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ComponentSignatureProvisionRelationProcessorTest.java @@ -0,0 +1,55 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.Signature; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentSignatureProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.SignatureProvisionRelation; + +import tools.mdsd.mocore.framework.processor.RelationProcessorTest; + +public class ComponentSignatureProvisionRelationProcessorTest extends + RelationProcessorTest { + private static final Interface RELATION_INTERFACE = Interface.getUniquePlaceholder(); + + @Override + protected ComponentSignatureProvisionRelation createRelation(final InterfaceProvisionRelation source, + final SignatureProvisionRelation destination, final boolean isPlaceholder) { + return new ComponentSignatureProvisionRelation(source, destination, isPlaceholder); + } + + @Override + protected InterfaceProvisionRelation getUniqueNonPlaceholderSourceEntity() { + final Component source = Component.getUniquePlaceholder(); + return new InterfaceProvisionRelation(source, RELATION_INTERFACE, false); + } + + @Override + protected InterfaceProvisionRelation getPlaceholderOfSourceEntity(final InterfaceProvisionRelation source) { + return new InterfaceProvisionRelation(source.getSource(), source.getDestination(), true); + } + + @Override + protected SignatureProvisionRelation getUniqueNonPlaceholderDestinationEntity() { + final Signature signature = Signature.getUniquePlaceholder(); + return new SignatureProvisionRelation(signature, RELATION_INTERFACE, false); + } + + @Override + protected SignatureProvisionRelation getPlaceholderOfDestinationEntity( + final SignatureProvisionRelation destination) { + return new SignatureProvisionRelation(destination.getSource(), destination.getDestination(), true); + } + + @Override + protected ComponentSignatureProvisionRelationProcessor createProcessor(final PcmSurrogate model) { + return new ComponentSignatureProvisionRelationProcessor(model); + } + + @Override + protected PcmSurrogate createEmptyModel() { + return new PcmSurrogate(); + } +} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositeProvisionDelegationRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeProvisionDelegationRelationProcessorTest.java similarity index 51% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositeProvisionDelegationRelationProcessorTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeProvisionDelegationRelationProcessorTest.java index 83671330..a0718f8f 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositeProvisionDelegationRelationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeProvisionDelegationRelationProcessorTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; +package org.palladiosimulator.retriever.mocore.processor.relation; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -8,36 +8,36 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledIf; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Composite; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositeProvisionDelegationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositeProvisionDelegationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceProvisionRelation; import tools.mdsd.mocore.framework.processor.RelationProcessorTest; import tools.mdsd.mocore.framework.surrogate.Replaceable; -public class CompositeProvisionDelegationRelationProcessorTest - extends RelationProcessorTest { +public class CompositeProvisionDelegationRelationProcessorTest extends + RelationProcessorTest { private static final Interface RELATION_INTERFACE = Interface.getUniquePlaceholder(); @Test @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefineWithValidRelationAddsCorrectImplications() { // Test data - PcmSurrogate model = createEmptyModel(); - CompositeProvisionDelegationRelationProcessor processor = createProcessor(model); - CompositeProvisionDelegationRelation relation = createUniqueReplaceable(); + final PcmSurrogate model = this.createEmptyModel(); + final CompositeProvisionDelegationRelationProcessor processor = this.createProcessor(model); + final CompositeProvisionDelegationRelation relation = this.createUniqueReplaceable(); // Assertions: Pre-execution - assertTrue(processor.getImplications().isEmpty()); + assertTrue(processor.getImplications() + .isEmpty()); // Execution processor.refine(relation); - Set implications = new HashSet<>(processor.getImplications()); + final Set implications = new HashSet<>(processor.getImplications()); // Assertions: Post-execution assertTrue(implications.remove(relation.getSource())); @@ -45,45 +45,52 @@ public void testRefineWithValidRelationAddsCorrectImplications() { // Implicit CompositionRelation between source & destination component assertEquals(1, implications.size()); - Replaceable implication = implications.stream().findFirst().orElseThrow(); + final Replaceable implication = implications.stream() + .findFirst() + .orElseThrow(); assertEquals(CompositionRelation.class, implication.getClass()); - CompositionRelation implicitComposition = (CompositionRelation) implication; + final CompositionRelation implicitComposition = (CompositionRelation) implication; assertTrue(implicitComposition.isPlaceholder()); - assertTrue(implicitComposition.getSource().equals(relation.getSource().getSource())); - assertTrue(implicitComposition.getDestination().equals(relation.getDestination().getSource())); + assertTrue(implicitComposition.getSource() + .equals(relation.getSource() + .getSource())); + assertTrue(implicitComposition.getDestination() + .equals(relation.getDestination() + .getSource())); } @Override - protected CompositeProvisionDelegationRelation createRelation(InterfaceProvisionRelation source, - InterfaceProvisionRelation destination, boolean isPlaceholder) { + protected CompositeProvisionDelegationRelation createRelation(final InterfaceProvisionRelation source, + final InterfaceProvisionRelation destination, final boolean isPlaceholder) { return new CompositeProvisionDelegationRelation(source, destination, isPlaceholder); } @Override protected InterfaceProvisionRelation getUniqueNonPlaceholderSourceEntity() { - Composite source = Composite.getUniquePlaceholder(); + final Composite source = Composite.getUniquePlaceholder(); return new InterfaceProvisionRelation(source, RELATION_INTERFACE, false); } @Override - protected InterfaceProvisionRelation getPlaceholderOfSourceEntity(InterfaceProvisionRelation source) { + protected InterfaceProvisionRelation getPlaceholderOfSourceEntity(final InterfaceProvisionRelation source) { return new InterfaceProvisionRelation(source.getSource(), source.getDestination(), true); } @Override protected InterfaceProvisionRelation getUniqueNonPlaceholderDestinationEntity() { - Component source = Component.getUniquePlaceholder(); + final Component source = Component.getUniquePlaceholder(); return new InterfaceProvisionRelation(source, RELATION_INTERFACE, false); } @Override - protected InterfaceProvisionRelation getPlaceholderOfDestinationEntity(InterfaceProvisionRelation destination) { + protected InterfaceProvisionRelation getPlaceholderOfDestinationEntity( + final InterfaceProvisionRelation destination) { return new InterfaceProvisionRelation(destination.getSource(), destination.getDestination(), true); } @Override - protected CompositeProvisionDelegationRelationProcessor createProcessor(PcmSurrogate model) { + protected CompositeProvisionDelegationRelationProcessor createProcessor(final PcmSurrogate model) { return new CompositeProvisionDelegationRelationProcessor(model); } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositeRequirementDelegationRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeRequirementDelegationRelationProcessorTest.java similarity index 52% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositeRequirementDelegationRelationProcessorTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeRequirementDelegationRelationProcessorTest.java index 845ea0ae..1b94f8c2 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositeRequirementDelegationRelationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositeRequirementDelegationRelationProcessorTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; +package org.palladiosimulator.retriever.mocore.processor.relation; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -8,36 +8,36 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledIf; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Composite; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositeRequirementDelegationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceRequirementRelation; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositeRequirementDelegationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceRequirementRelation; import tools.mdsd.mocore.framework.processor.RelationProcessorTest; import tools.mdsd.mocore.framework.surrogate.Replaceable; -public class CompositeRequirementDelegationRelationProcessorTest - extends RelationProcessorTest { +public class CompositeRequirementDelegationRelationProcessorTest extends + RelationProcessorTest { private static final Interface RELATION_INTERFACE = Interface.getUniquePlaceholder(); @Test @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefineWithValidRelationAddsCorrectImplications() { // Test data - PcmSurrogate model = createEmptyModel(); - CompositeRequirementDelegationRelationProcessor processor = createProcessor(model); - CompositeRequirementDelegationRelation relation = createUniqueReplaceable(); + final PcmSurrogate model = this.createEmptyModel(); + final CompositeRequirementDelegationRelationProcessor processor = this.createProcessor(model); + final CompositeRequirementDelegationRelation relation = this.createUniqueReplaceable(); // Assertions: Pre-execution - assertTrue(processor.getImplications().isEmpty()); + assertTrue(processor.getImplications() + .isEmpty()); // Execution processor.refine(relation); - Set implications = new HashSet<>(processor.getImplications()); + final Set implications = new HashSet<>(processor.getImplications()); // Assertions: Post-execution assertTrue(implications.remove(relation.getSource())); @@ -45,45 +45,52 @@ public void testRefineWithValidRelationAddsCorrectImplications() { // Implicit CompositionRelation between source & destination component assertEquals(1, implications.size()); - Replaceable implication = implications.stream().findFirst().orElseThrow(); + final Replaceable implication = implications.stream() + .findFirst() + .orElseThrow(); assertEquals(CompositionRelation.class, implication.getClass()); - CompositionRelation implicitComposition = (CompositionRelation) implication; + final CompositionRelation implicitComposition = (CompositionRelation) implication; assertTrue(implicitComposition.isPlaceholder()); - assertTrue(implicitComposition.getSource().equals(relation.getSource().getSource())); - assertTrue(implicitComposition.getDestination().equals(relation.getDestination().getSource())); + assertTrue(implicitComposition.getSource() + .equals(relation.getSource() + .getSource())); + assertTrue(implicitComposition.getDestination() + .equals(relation.getDestination() + .getSource())); } @Override - protected CompositeRequirementDelegationRelation createRelation(InterfaceRequirementRelation source, - InterfaceRequirementRelation destination, boolean isPlaceholder) { + protected CompositeRequirementDelegationRelation createRelation(final InterfaceRequirementRelation source, + final InterfaceRequirementRelation destination, final boolean isPlaceholder) { return new CompositeRequirementDelegationRelation(source, destination, isPlaceholder); } @Override protected InterfaceRequirementRelation getUniqueNonPlaceholderSourceEntity() { - Composite source = Composite.getUniquePlaceholder(); + final Composite source = Composite.getUniquePlaceholder(); return new InterfaceRequirementRelation(source, RELATION_INTERFACE, false); } @Override - protected InterfaceRequirementRelation getPlaceholderOfSourceEntity(InterfaceRequirementRelation source) { + protected InterfaceRequirementRelation getPlaceholderOfSourceEntity(final InterfaceRequirementRelation source) { return new InterfaceRequirementRelation(source.getSource(), source.getDestination(), true); } @Override protected InterfaceRequirementRelation getUniqueNonPlaceholderDestinationEntity() { - Component source = Component.getUniquePlaceholder(); + final Component source = Component.getUniquePlaceholder(); return new InterfaceRequirementRelation(source, RELATION_INTERFACE, false); } @Override - protected InterfaceRequirementRelation getPlaceholderOfDestinationEntity(InterfaceRequirementRelation destination) { + protected InterfaceRequirementRelation getPlaceholderOfDestinationEntity( + final InterfaceRequirementRelation destination) { return new InterfaceRequirementRelation(destination.getSource(), destination.getDestination(), true); } @Override - protected CompositeRequirementDelegationRelationProcessor createProcessor(PcmSurrogate model) { + protected CompositeRequirementDelegationRelationProcessor createProcessor(final PcmSurrogate model) { return new CompositeRequirementDelegationRelationProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositionRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositionRelationProcessorTest.java new file mode 100644 index 00000000..f980eb03 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/CompositionRelationProcessorTest.java @@ -0,0 +1,48 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositionRelation; +import org.palladiosimulator.retriever.mocore.utility.ElementFactory; + +import tools.mdsd.mocore.framework.processor.RelationProcessorTest; + +public class CompositionRelationProcessorTest extends + RelationProcessorTest> { + @Override + protected CompositionRelation createRelation(final Composite source, final Component destination, + final boolean isPlaceholder) { + return new CompositionRelation(source, destination, isPlaceholder); + } + + @Override + protected Composite getUniqueNonPlaceholderSourceEntity() { + return ElementFactory.createUniqueComposite(false); + } + + @Override + protected Composite getPlaceholderOfSourceEntity(final Composite source) { + return new Composite(source.getValue(), true); + } + + @Override + protected Component getUniqueNonPlaceholderDestinationEntity() { + return ElementFactory.createUniqueComponent(false); + } + + @Override + protected Component getPlaceholderOfDestinationEntity(final Component destination) { + return new Component<>(destination.getValue(), true); + } + + @Override + protected CompositionRelationProcessor createProcessor(final PcmSurrogate model) { + return new CompositionRelationProcessor(model); + } + + @Override + protected PcmSurrogate createEmptyModel() { + return new PcmSurrogate(); + } +} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/DeploymentDeploymentRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/DeploymentDeploymentRelationProcessorTest.java similarity index 51% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/DeploymentDeploymentRelationProcessorTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/DeploymentDeploymentRelationProcessorTest.java index fc2307f3..49f05c82 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/DeploymentDeploymentRelationProcessorTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/DeploymentDeploymentRelationProcessorTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; +package org.palladiosimulator.retriever.mocore.processor.relation; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -9,38 +9,38 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledIf; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAllocationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAssemblyRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.DeploymentDeploymentRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceRequirementRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.LinkResourceSpecificationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.utility.ElementFactory; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAllocationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAssemblyRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.DeploymentDeploymentRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceRequirementRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.LinkResourceSpecificationRelation; +import org.palladiosimulator.retriever.mocore.utility.ElementFactory; import tools.mdsd.mocore.framework.processor.RelationProcessorTest; import tools.mdsd.mocore.framework.surrogate.Replaceable; -public class DeploymentDeploymentRelationProcessorTest - extends RelationProcessorTest { +public class DeploymentDeploymentRelationProcessorTest extends + RelationProcessorTest { @Test @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefineWithValidElementAddsCorrectImplications() { // Test data - PcmSurrogate model = createEmptyModel(); - DeploymentDeploymentRelationProcessor processor = createProcessor(model); - DeploymentDeploymentRelation relation = createUniqueReplaceable(); + final PcmSurrogate model = this.createEmptyModel(); + final DeploymentDeploymentRelationProcessor processor = this.createProcessor(model); + final DeploymentDeploymentRelation relation = this.createUniqueReplaceable(); // Assertions: Pre-execution - assertTrue(processor.getImplications().isEmpty()); + assertTrue(processor.getImplications() + .isEmpty()); // Execution processor.refine(relation); - Set implications = new HashSet<>(processor.getImplications()); + final Set implications = new HashSet<>(processor.getImplications()); // Assertions: Post-execution assertTrue(implications.remove(relation.getSource())); @@ -49,33 +49,37 @@ public void testRefineWithValidElementAddsCorrectImplications() { //// Implicit LinkResourceSpecificationRelation assertEquals(1, implications.size()); - Replaceable implication = implications.stream().findFirst().orElseThrow(); + final Replaceable implication = implications.stream() + .findFirst() + .orElseThrow(); assertEquals(LinkResourceSpecificationRelation.class, implication.getClass()); - LinkResourceSpecificationRelation implicitSpecification = (LinkResourceSpecificationRelation) implication; + final LinkResourceSpecificationRelation implicitSpecification = (LinkResourceSpecificationRelation) implication; assertEquals(relation, implicitSpecification.getDestination()); assertTrue(implicitSpecification.isPlaceholder()); - assertTrue(implicitSpecification.getSource().isPlaceholder()); + assertTrue(implicitSpecification.getSource() + .isPlaceholder()); } @Test @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefineDoesNotAddAssemblyIfParallelExists() { // Test data - PcmSurrogate model = createEmptyModel(); - DeploymentDeploymentRelationProcessor processor = createProcessor(model); - DeploymentDeploymentRelation relation = createUniqueReplaceable(); - - Component provider = Component.getUniquePlaceholder(); - Component consumer = Component.getUniquePlaceholder(); - Interface interfc = Interface.getUniquePlaceholder(); - InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, interfc, false); - InterfaceRequirementRelation interfaceRequirement = new InterfaceRequirementRelation(consumer, interfc, false); - ComponentAssemblyRelation assembly = new ComponentAssemblyRelation(interfaceProvision, + final PcmSurrogate model = this.createEmptyModel(); + final DeploymentDeploymentRelationProcessor processor = this.createProcessor(model); + final DeploymentDeploymentRelation relation = this.createUniqueReplaceable(); + + final Component provider = Component.getUniquePlaceholder(); + final Component consumer = Component.getUniquePlaceholder(); + final Interface interfc = Interface.getUniquePlaceholder(); + final InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, interfc, false); + final InterfaceRequirementRelation interfaceRequirement = new InterfaceRequirementRelation(consumer, interfc, + false); + final ComponentAssemblyRelation assembly = new ComponentAssemblyRelation(interfaceProvision, interfaceRequirement, false); - ComponentAllocationRelation providerAllocation = new ComponentAllocationRelation(provider, + final ComponentAllocationRelation providerAllocation = new ComponentAllocationRelation(provider, relation.getSource(), false); - ComponentAllocationRelation consumerAllocation = new ComponentAllocationRelation(consumer, + final ComponentAllocationRelation consumerAllocation = new ComponentAllocationRelation(consumer, relation.getDestination(), false); model.add(assembly); @@ -83,11 +87,12 @@ public void testRefineDoesNotAddAssemblyIfParallelExists() { model.add(consumerAllocation); // Assertions: Pre-execution - assertTrue(processor.getImplications().isEmpty()); + assertTrue(processor.getImplications() + .isEmpty()); // Execution processor.refine(relation); - Set implications = new HashSet<>(processor.getImplications()); + final Set implications = new HashSet<>(processor.getImplications()); // Assertions: Post-execution assertTrue(implications.remove(relation.getSource())); @@ -105,21 +110,22 @@ public void testRefineDoesNotAddAssemblyIfParallelExists() { @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testRefineDoesNotAddAssemblyIfInverseExists() { // Test data - PcmSurrogate model = createEmptyModel(); - DeploymentDeploymentRelationProcessor processor = createProcessor(model); - DeploymentDeploymentRelation relation = createUniqueReplaceable(); - - Component provider = Component.getUniquePlaceholder(); - Component consumer = Component.getUniquePlaceholder(); - Interface interfc = Interface.getUniquePlaceholder(); - InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, interfc, false); - InterfaceRequirementRelation interfaceRequirement = new InterfaceRequirementRelation(consumer, interfc, false); - ComponentAssemblyRelation assembly = new ComponentAssemblyRelation(interfaceProvision, + final PcmSurrogate model = this.createEmptyModel(); + final DeploymentDeploymentRelationProcessor processor = this.createProcessor(model); + final DeploymentDeploymentRelation relation = this.createUniqueReplaceable(); + + final Component provider = Component.getUniquePlaceholder(); + final Component consumer = Component.getUniquePlaceholder(); + final Interface interfc = Interface.getUniquePlaceholder(); + final InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, interfc, false); + final InterfaceRequirementRelation interfaceRequirement = new InterfaceRequirementRelation(consumer, interfc, + false); + final ComponentAssemblyRelation assembly = new ComponentAssemblyRelation(interfaceProvision, interfaceRequirement, false); - ComponentAllocationRelation providerAllocation = new ComponentAllocationRelation(consumer, + final ComponentAllocationRelation providerAllocation = new ComponentAllocationRelation(consumer, relation.getSource(), false); - ComponentAllocationRelation consumerAllocation = new ComponentAllocationRelation(provider, + final ComponentAllocationRelation consumerAllocation = new ComponentAllocationRelation(provider, relation.getDestination(), false); model.add(assembly); @@ -127,11 +133,12 @@ public void testRefineDoesNotAddAssemblyIfInverseExists() { model.add(consumerAllocation); // Assertions: Pre-execution - assertTrue(processor.getImplications().isEmpty()); + assertTrue(processor.getImplications() + .isEmpty()); // Execution processor.refine(relation); - Set implications = new HashSet<>(processor.getImplications()); + final Set implications = new HashSet<>(processor.getImplications()); // Assertions: Post-execution assertTrue(implications.remove(relation.getSource())); @@ -149,13 +156,13 @@ public void testRefineDoesNotAddAssemblyIfInverseExists() { @Test public void testProcessReplacesIndirectPlaceholder() { // Test data - PcmSurrogate model = createEmptyModel(); - DeploymentDeploymentRelationProcessor processor = createProcessor(model); - Deployment source = getUniqueNonPlaceholderSourceEntity(); - Deployment destination = getUniqueNonPlaceholderDestinationEntity(); - Deployment destinationPlaceholder = getPlaceholderOfDestinationEntity(destination); - DeploymentDeploymentRelation relation = createRelation(source, destination, true); - DeploymentDeploymentRelation placeholder = createRelation(source, destinationPlaceholder, true); + final PcmSurrogate model = this.createEmptyModel(); + final DeploymentDeploymentRelationProcessor processor = this.createProcessor(model); + final Deployment source = this.getUniqueNonPlaceholderSourceEntity(); + final Deployment destination = this.getUniqueNonPlaceholderDestinationEntity(); + final Deployment destinationPlaceholder = this.getPlaceholderOfDestinationEntity(destination); + final DeploymentDeploymentRelation relation = this.createRelation(source, destination, true); + final DeploymentDeploymentRelation placeholder = this.createRelation(source, destinationPlaceholder, true); // Execution & Assertions to add placeholder model.add(placeholder); @@ -166,11 +173,12 @@ public void testProcessReplacesIndirectPlaceholder() { assertTrue(model.contains(destinationPlaceholder)); assertFalse(model.contains(destination)); assertFalse(model.contains(relation)); - assertTrue(processor.getImplications().isEmpty()); + assertTrue(processor.getImplications() + .isEmpty()); // Execution to replace placeholder processor.process(relation); - Set implications = processor.getImplications(); + final Set implications = processor.getImplications(); // Assertions - Model State assertTrue(model.contains(placeholder)); @@ -192,13 +200,13 @@ public void testProcessReplacesIndirectPlaceholder() { @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testReplaceIndirectPlaceholdersSameSource() { // Test data - PcmSurrogate model = createEmptyModel(); - DeploymentDeploymentRelationProcessor processor = createProcessor(model); - Deployment source = getUniqueNonPlaceholderSourceEntity(); - Deployment destination = getUniqueNonPlaceholderDestinationEntity(); - Deployment destinationPlaceholder = getPlaceholderOfDestinationEntity(destination); - DeploymentDeploymentRelation relation = createRelation(source, destination, true); - DeploymentDeploymentRelation placeholder = createRelation(source, destinationPlaceholder, true); + final PcmSurrogate model = this.createEmptyModel(); + final DeploymentDeploymentRelationProcessor processor = this.createProcessor(model); + final Deployment source = this.getUniqueNonPlaceholderSourceEntity(); + final Deployment destination = this.getUniqueNonPlaceholderDestinationEntity(); + final Deployment destinationPlaceholder = this.getPlaceholderOfDestinationEntity(destination); + final DeploymentDeploymentRelation relation = this.createRelation(source, destination, true); + final DeploymentDeploymentRelation placeholder = this.createRelation(source, destinationPlaceholder, true); // Execution & Assertions to add placeholder model.add(placeholder); @@ -209,11 +217,12 @@ public void testReplaceIndirectPlaceholdersSameSource() { assertTrue(model.contains(destinationPlaceholder)); assertFalse(model.contains(destination)); assertFalse(model.contains(relation)); - assertTrue(processor.getImplications().isEmpty()); + assertTrue(processor.getImplications() + .isEmpty()); // Execution to replace placeholder processor.replaceIndirectPlaceholders(relation); - Set implications = processor.getImplications(); + final Set implications = processor.getImplications(); // Assertions - Model State assertTrue(model.contains(placeholder)); @@ -235,13 +244,13 @@ public void testReplaceIndirectPlaceholdersSameSource() { @DisabledIf(TEST_API_ONLY_METHOD_NAME) public void testReplaceIndirectPlaceholdersSameDestination() { // Test data - PcmSurrogate model = createEmptyModel(); - DeploymentDeploymentRelationProcessor processor = createProcessor(model); - Deployment source = getUniqueNonPlaceholderSourceEntity(); - Deployment sourcePlaceholder = getPlaceholderOfSourceEntity(source); - Deployment destination = getUniqueNonPlaceholderDestinationEntity(); - DeploymentDeploymentRelation relation = createRelation(source, destination, true); - DeploymentDeploymentRelation placeholder = createRelation(sourcePlaceholder, destination, true); + final PcmSurrogate model = this.createEmptyModel(); + final DeploymentDeploymentRelationProcessor processor = this.createProcessor(model); + final Deployment source = this.getUniqueNonPlaceholderSourceEntity(); + final Deployment sourcePlaceholder = this.getPlaceholderOfSourceEntity(source); + final Deployment destination = this.getUniqueNonPlaceholderDestinationEntity(); + final DeploymentDeploymentRelation relation = this.createRelation(source, destination, true); + final DeploymentDeploymentRelation placeholder = this.createRelation(sourcePlaceholder, destination, true); // Execution & Assertions to add placeholder model.add(placeholder); @@ -252,11 +261,12 @@ public void testReplaceIndirectPlaceholdersSameDestination() { assertTrue(model.contains(destination)); assertFalse(model.contains(source)); assertFalse(model.contains(relation)); - assertTrue(processor.getImplications().isEmpty()); + assertTrue(processor.getImplications() + .isEmpty()); // Execution to replace placeholder processor.replaceIndirectPlaceholders(relation); - Set implications = processor.getImplications(); + final Set implications = processor.getImplications(); // Assertions - Model State assertTrue(model.contains(placeholder)); @@ -274,8 +284,8 @@ public void testReplaceIndirectPlaceholdersSameDestination() { } @Override - protected DeploymentDeploymentRelation createRelation(Deployment source, Deployment destination, - boolean isPlaceholder) { + protected DeploymentDeploymentRelation createRelation(final Deployment source, final Deployment destination, + final boolean isPlaceholder) { return new DeploymentDeploymentRelation(source, destination, isPlaceholder); } @@ -285,22 +295,22 @@ protected Deployment getUniqueNonPlaceholderSourceEntity() { } @Override - protected Deployment getPlaceholderOfSourceEntity(Deployment source) { + protected Deployment getPlaceholderOfSourceEntity(final Deployment source) { return new Deployment(source.getValue(), true); } @Override protected Deployment getUniqueNonPlaceholderDestinationEntity() { - return getUniqueNonPlaceholderSourceEntity(); + return this.getUniqueNonPlaceholderSourceEntity(); } @Override - protected Deployment getPlaceholderOfDestinationEntity(Deployment destination) { - return getPlaceholderOfSourceEntity(destination); + protected Deployment getPlaceholderOfDestinationEntity(final Deployment destination) { + return this.getPlaceholderOfSourceEntity(destination); } @Override - protected DeploymentDeploymentRelationProcessor createProcessor(PcmSurrogate model) { + protected DeploymentDeploymentRelationProcessor createProcessor(final PcmSurrogate model) { return new DeploymentDeploymentRelationProcessor(model); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceProvisionRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceProvisionRelationProcessorTest.java new file mode 100644 index 00000000..bfc23b44 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceProvisionRelationProcessorTest.java @@ -0,0 +1,48 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceProvisionRelation; +import org.palladiosimulator.retriever.mocore.utility.ElementFactory; + +import tools.mdsd.mocore.framework.processor.RelationProcessorTest; + +public class InterfaceProvisionRelationProcessorTest extends + RelationProcessorTest, Interface> { + @Override + protected InterfaceProvisionRelation createRelation(final Component source, final Interface destination, + final boolean isPlaceholder) { + return new InterfaceProvisionRelation(source, destination, isPlaceholder); + } + + @Override + protected Component getUniqueNonPlaceholderSourceEntity() { + return ElementFactory.createUniqueComponent(false); + } + + @Override + protected Component getPlaceholderOfSourceEntity(final Component source) { + return new Component<>(source.getValue(), true); + } + + @Override + protected Interface getUniqueNonPlaceholderDestinationEntity() { + return ElementFactory.createUniqueInterface(false); + } + + @Override + protected Interface getPlaceholderOfDestinationEntity(final Interface destination) { + return new Interface(destination.getValue(), true); + } + + @Override + protected InterfaceProvisionRelationProcessor createProcessor(final PcmSurrogate model) { + return new InterfaceProvisionRelationProcessor(model); + } + + @Override + protected PcmSurrogate createEmptyModel() { + return new PcmSurrogate(); + } +} diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceRequirementRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceRequirementRelationProcessorTest.java new file mode 100644 index 00000000..a17ab84e --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/InterfaceRequirementRelationProcessorTest.java @@ -0,0 +1,48 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceRequirementRelation; +import org.palladiosimulator.retriever.mocore.utility.ElementFactory; + +import tools.mdsd.mocore.framework.processor.RelationProcessorTest; + +public class InterfaceRequirementRelationProcessorTest extends + RelationProcessorTest, Interface> { + @Override + protected InterfaceRequirementRelation createRelation(final Component source, final Interface destination, + final boolean isPlaceholder) { + return new InterfaceRequirementRelation(source, destination, isPlaceholder); + } + + @Override + protected Component getUniqueNonPlaceholderSourceEntity() { + return ElementFactory.createUniqueComponent(false); + } + + @Override + protected Component getPlaceholderOfSourceEntity(final Component source) { + return new Component<>(source.getValue(), true); + } + + @Override + protected Interface getUniqueNonPlaceholderDestinationEntity() { + return ElementFactory.createUniqueInterface(false); + } + + @Override + protected Interface getPlaceholderOfDestinationEntity(final Interface destination) { + return new Interface(destination.getValue(), true); + } + + @Override + protected InterfaceRequirementRelationProcessor createProcessor(final PcmSurrogate model) { + return new InterfaceRequirementRelationProcessor(model); + } + + @Override + protected PcmSurrogate createEmptyModel() { + return new PcmSurrogate(); + } +} diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/LinkResourceSpecificationRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/LinkResourceSpecificationRelationProcessorTest.java new file mode 100644 index 00000000..6d141091 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/LinkResourceSpecificationRelationProcessorTest.java @@ -0,0 +1,51 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.element.LinkResourceSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.relation.DeploymentDeploymentRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.LinkResourceSpecificationRelation; +import org.palladiosimulator.retriever.mocore.utility.ElementFactory; + +import tools.mdsd.mocore.framework.processor.RelationProcessorTest; + +public class LinkResourceSpecificationRelationProcessorTest extends + RelationProcessorTest { + @Override + protected LinkResourceSpecificationRelation createRelation(final LinkResourceSpecification source, + final DeploymentDeploymentRelation destination, final boolean isPlaceholder) { + return new LinkResourceSpecificationRelation(source, destination, isPlaceholder); + } + + @Override + protected LinkResourceSpecification getUniqueNonPlaceholderSourceEntity() { + return ElementFactory.createUniqueLinkResourceSpecification(false); + } + + @Override + protected LinkResourceSpecification getPlaceholderOfSourceEntity(final LinkResourceSpecification source) { + return new LinkResourceSpecification(source.getValue(), true); + } + + @Override + protected DeploymentDeploymentRelation getUniqueNonPlaceholderDestinationEntity() { + return new DeploymentDeploymentRelation(Deployment.getUniquePlaceholder(), Deployment.getUniquePlaceholder(), + false); + } + + @Override + protected DeploymentDeploymentRelation getPlaceholderOfDestinationEntity( + final DeploymentDeploymentRelation destination) { + return new DeploymentDeploymentRelation(destination.getSource(), destination.getDestination(), true); + } + + @Override + protected LinkResourceSpecificationRelationProcessor createProcessor(final PcmSurrogate model) { + return new LinkResourceSpecificationRelationProcessor(model); + } + + @Override + protected PcmSurrogate createEmptyModel() { + return new PcmSurrogate(); + } +} diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ServiceEffectSpecificationRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ServiceEffectSpecificationRelationProcessorTest.java new file mode 100644 index 00000000..651e2920 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/ServiceEffectSpecificationRelationProcessorTest.java @@ -0,0 +1,61 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.ServiceEffectSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.element.Signature; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentSignatureProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ServiceEffectSpecificationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.SignatureProvisionRelation; +import org.palladiosimulator.retriever.mocore.utility.ElementFactory; + +import tools.mdsd.mocore.framework.processor.RelationProcessorTest; + +public class ServiceEffectSpecificationRelationProcessorTest extends + RelationProcessorTest { + @Override + protected ServiceEffectSpecificationRelation createRelation(final ComponentSignatureProvisionRelation source, + final ServiceEffectSpecification destination, final boolean isPlaceholder) { + return new ServiceEffectSpecificationRelation(source, destination, isPlaceholder); + } + + @Override + protected ComponentSignatureProvisionRelation getUniqueNonPlaceholderSourceEntity() { + final Component component = Component.getUniquePlaceholder(); + final Interface interfsc = Interface.getUniquePlaceholder(); + final Signature signature = Signature.getUniquePlaceholder(); + final InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(component, interfsc, true); + final SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, interfsc, true); + return new ComponentSignatureProvisionRelation(interfaceProvision, signatureProvision, false); + + } + + @Override + protected ComponentSignatureProvisionRelation getPlaceholderOfSourceEntity( + final ComponentSignatureProvisionRelation source) { + return new ComponentSignatureProvisionRelation(source.getSource(), source.getDestination(), true); + } + + @Override + protected ServiceEffectSpecification getUniqueNonPlaceholderDestinationEntity() { + return ElementFactory.createUniqueServiceEffectSpecification(false); + } + + @Override + protected ServiceEffectSpecification getPlaceholderOfDestinationEntity( + final ServiceEffectSpecification destination) { + return new ServiceEffectSpecification(destination.getValue(), true); + } + + @Override + protected ServiceEffectSpecificationRelationProcessor createProcessor(final PcmSurrogate model) { + return new ServiceEffectSpecificationRelationProcessor(model); + } + + @Override + protected PcmSurrogate createEmptyModel() { + return new PcmSurrogate(); + } +} diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/SignatureProvisionRelationProcessorTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/SignatureProvisionRelationProcessorTest.java new file mode 100644 index 00000000..cde992df --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/processor/relation/SignatureProvisionRelationProcessorTest.java @@ -0,0 +1,48 @@ +package org.palladiosimulator.retriever.mocore.processor.relation; + +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.Signature; +import org.palladiosimulator.retriever.mocore.surrogate.relation.SignatureProvisionRelation; +import org.palladiosimulator.retriever.mocore.utility.ElementFactory; + +import tools.mdsd.mocore.framework.processor.RelationProcessorTest; + +public class SignatureProvisionRelationProcessorTest extends + RelationProcessorTest { + @Override + protected SignatureProvisionRelation createRelation(final Signature source, final Interface destination, + final boolean isPlaceholder) { + return new SignatureProvisionRelation(source, destination, isPlaceholder); + } + + @Override + protected Signature getUniqueNonPlaceholderSourceEntity() { + return ElementFactory.createUniqueSignature(false); + } + + @Override + protected Signature getPlaceholderOfSourceEntity(final Signature source) { + return new Signature(source.getValue(), true); + } + + @Override + protected Interface getUniqueNonPlaceholderDestinationEntity() { + return ElementFactory.createUniqueInterface(false); + } + + @Override + protected Interface getPlaceholderOfDestinationEntity(final Interface destination) { + return new Interface(destination.getValue(), true); + } + + @Override + protected SignatureProvisionRelationProcessor createProcessor(final PcmSurrogate model) { + return new SignatureProvisionRelationProcessor(model); + } + + @Override + protected PcmSurrogate createEmptyModel() { + return new PcmSurrogate(); + } +} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/PcmSurrogateTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/PcmSurrogateTest.java similarity index 80% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/PcmSurrogateTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/PcmSurrogateTest.java index 3f6fd204..ffa25658 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/PcmSurrogateTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/PcmSurrogateTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate; +package org.palladiosimulator.retriever.mocore.surrogate; import tools.mdsd.mocore.framework.surrogate.ModelTest; import tools.mdsd.mocore.framework.surrogate.Relation; @@ -17,8 +17,8 @@ protected SimpleElement createUniqueReplaceable() { } @Override - protected Relation createRelation(SimpleElement source, SimpleElement destination, - boolean isPlaceholder) { + protected Relation createRelation(final SimpleElement source, + final SimpleElement destination, final boolean isPlaceholder) { return new SimpleRelation(source, destination, isPlaceholder); } } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/AtomicComponentTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/AtomicComponentTest.java similarity index 56% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/AtomicComponentTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/AtomicComponentTest.java index 90011593..59762aab 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/AtomicComponentTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/AtomicComponentTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element; +package org.palladiosimulator.retriever.mocore.surrogate.element; import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; import org.palladiosimulator.pcm.repository.BasicComponent; @@ -8,24 +8,26 @@ public class AtomicComponentTest extends ElementTest { @Override - protected AtomicComponent createElement(BasicComponent value, boolean isPlaceholder) { + protected AtomicComponent createElement(final BasicComponent value, final boolean isPlaceholder) { return new AtomicComponent(value, isPlaceholder); } @Override protected BasicComponent getUniqueValue() { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - BasicComponent value = new FluentRepositoryFactory().newBasicComponent().withName(identifier).build(); + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final BasicComponent value = new FluentRepositoryFactory().newBasicComponent() + .withName(identifier) + .build(); return value; } @Override protected AtomicComponent getUniqueNonPlaceholder() { - return new AtomicComponent(getUniqueValue(), false); + return new AtomicComponent(this.getUniqueValue(), false); } @Override - protected AtomicComponent getPlaceholderOf(AtomicComponent replaceable) { + protected AtomicComponent getPlaceholderOf(final AtomicComponent replaceable) { return new AtomicComponent(replaceable.getValue(), true); } } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/ComponentTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/ComponentTest.java similarity index 56% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/ComponentTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/ComponentTest.java index 7d3a28d1..55aad3c6 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/ComponentTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/ComponentTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element; +package org.palladiosimulator.retriever.mocore.surrogate.element; import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; import org.palladiosimulator.pcm.repository.BasicComponent; @@ -9,24 +9,27 @@ public class ComponentTest extends ElementTest, RepositoryComponent> { @Override - protected Component createElement(RepositoryComponent value, boolean isPlaceholder) { + protected Component createElement(final RepositoryComponent value, + final boolean isPlaceholder) { return new Component<>(value, isPlaceholder); } @Override protected RepositoryComponent getUniqueValue() { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - BasicComponent value = new FluentRepositoryFactory().newBasicComponent().withName(identifier).build(); + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final BasicComponent value = new FluentRepositoryFactory().newBasicComponent() + .withName(identifier) + .build(); return value; } @Override protected Component getUniqueNonPlaceholder() { - return new Component<>(getUniqueValue(), false); + return new Component<>(this.getUniqueValue(), false); } @Override - protected Component getPlaceholderOf(Component replaceable) { + protected Component getPlaceholderOf(final Component replaceable) { return new Component<>(replaceable.getValue(), true); } } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/CompositeTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/CompositeTest.java similarity index 58% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/CompositeTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/CompositeTest.java index 52af1711..b3a41d0a 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/CompositeTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/CompositeTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element; +package org.palladiosimulator.retriever.mocore.surrogate.element; import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; import org.palladiosimulator.pcm.repository.CompositeComponent; @@ -9,24 +9,26 @@ public class CompositeTest extends ElementTest { @Override - protected Composite createElement(CompositeComponent value, boolean isPlaceholder) { + protected Composite createElement(final CompositeComponent value, final boolean isPlaceholder) { return new Composite(value, isPlaceholder); } @Override protected CompositeComponent getUniqueValue() { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - RepositoryComponent value = new FluentRepositoryFactory().newCompositeComponent().withName(identifier).build(); + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final RepositoryComponent value = new FluentRepositoryFactory().newCompositeComponent() + .withName(identifier) + .build(); return (CompositeComponent) value; } @Override protected Composite getUniqueNonPlaceholder() { - return new Composite(getUniqueValue(), false); + return new Composite(this.getUniqueValue(), false); } @Override - protected Composite getPlaceholderOf(Composite replaceable) { + protected Composite getPlaceholderOf(final Composite replaceable) { return new Composite(replaceable.getValue(), true); } } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/DeploymentTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/DeploymentTest.java similarity index 59% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/DeploymentTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/DeploymentTest.java index 8b1b5b68..fdb61ebd 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/DeploymentTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/DeploymentTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element; +package org.palladiosimulator.retriever.mocore.surrogate.element; import org.palladiosimulator.pcm.resourceenvironment.ResourceContainer; import org.palladiosimulator.pcm.resourceenvironment.ResourceenvironmentFactory; @@ -8,25 +8,25 @@ public class DeploymentTest extends ElementTest { @Override - protected Deployment createElement(ResourceContainer value, boolean isPlaceholder) { + protected Deployment createElement(final ResourceContainer value, final boolean isPlaceholder) { return new Deployment(value, isPlaceholder); } @Override protected ResourceContainer getUniqueValue() { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - ResourceContainer value = ResourceenvironmentFactory.eINSTANCE.createResourceContainer(); + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final ResourceContainer value = ResourceenvironmentFactory.eINSTANCE.createResourceContainer(); value.setEntityName(identifier); return value; } @Override protected Deployment getUniqueNonPlaceholder() { - return new Deployment(getUniqueValue(), false); + return new Deployment(this.getUniqueValue(), false); } @Override - protected Deployment getPlaceholderOf(Deployment replaceable) { + protected Deployment getPlaceholderOf(final Deployment replaceable) { return new Deployment(replaceable.getValue(), true); } } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/InterfaceTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/InterfaceTest.java similarity index 56% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/InterfaceTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/InterfaceTest.java index 56b402ee..6d3d155a 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/InterfaceTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/InterfaceTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element; +package org.palladiosimulator.retriever.mocore.surrogate.element; import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; import org.palladiosimulator.pcm.repository.OperationInterface; @@ -8,24 +8,26 @@ public class InterfaceTest extends ElementTest { @Override - protected Interface createElement(OperationInterface value, boolean isPlaceholder) { + protected Interface createElement(final OperationInterface value, final boolean isPlaceholder) { return new Interface(value, isPlaceholder); } @Override protected OperationInterface getUniqueValue() { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - OperationInterface value = new FluentRepositoryFactory().newOperationInterface().withName(identifier).build(); + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final OperationInterface value = new FluentRepositoryFactory().newOperationInterface() + .withName(identifier) + .build(); return value; } @Override protected Interface getUniqueNonPlaceholder() { - return new Interface(getUniqueValue(), false); + return new Interface(this.getUniqueValue(), false); } @Override - protected Interface getPlaceholderOf(Interface replaceable) { + protected Interface getPlaceholderOf(final Interface replaceable) { return new Interface(replaceable.getValue(), true); } } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/LinkResourceSpecificationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/LinkResourceSpecificationTest.java similarity index 57% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/LinkResourceSpecificationTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/LinkResourceSpecificationTest.java index 28be8eb1..198ee4f3 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/LinkResourceSpecificationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/LinkResourceSpecificationTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element; +package org.palladiosimulator.retriever.mocore.surrogate.element; import org.palladiosimulator.pcm.resourceenvironment.CommunicationLinkResourceSpecification; @@ -7,23 +7,24 @@ public class LinkResourceSpecificationTest extends ElementTest { @Override - protected LinkResourceSpecification createElement(CommunicationLinkResourceSpecification value, - boolean isPlaceholder) { + protected LinkResourceSpecification createElement(final CommunicationLinkResourceSpecification value, + final boolean isPlaceholder) { return new LinkResourceSpecification(value, isPlaceholder); } @Override protected CommunicationLinkResourceSpecification getUniqueValue() { - return LinkResourceSpecification.getUniquePlaceholder().getValue(); + return LinkResourceSpecification.getUniquePlaceholder() + .getValue(); } @Override protected LinkResourceSpecification getUniqueNonPlaceholder() { - return new LinkResourceSpecification(getUniqueValue(), false); + return new LinkResourceSpecification(this.getUniqueValue(), false); } @Override - protected LinkResourceSpecification getPlaceholderOf(LinkResourceSpecification replaceable) { + protected LinkResourceSpecification getPlaceholderOf(final LinkResourceSpecification replaceable) { return new LinkResourceSpecification(replaceable.getValue(), true); } } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/ServiceEffectSpecificationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/ServiceEffectSpecificationTest.java new file mode 100644 index 00000000..c8c77119 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/ServiceEffectSpecificationTest.java @@ -0,0 +1,29 @@ +package org.palladiosimulator.retriever.mocore.surrogate.element; + +import org.palladiosimulator.pcm.seff.ResourceDemandingSEFF; +import org.palladiosimulator.retriever.mocore.utility.ElementFactory; + +import tools.mdsd.mocore.framework.surrogate.ElementTest; + +public class ServiceEffectSpecificationTest extends ElementTest { + @Override + protected ServiceEffectSpecification createElement(final ResourceDemandingSEFF value, final boolean isPlaceholder) { + return new ServiceEffectSpecification(value, isPlaceholder); + } + + @Override + protected ResourceDemandingSEFF getUniqueValue() { + return ElementFactory.createUniqueServiceEffectSpecification(false) + .getValue(); + } + + @Override + protected ServiceEffectSpecification getUniqueNonPlaceholder() { + return new ServiceEffectSpecification(this.getUniqueValue(), false); + } + + @Override + protected ServiceEffectSpecification getPlaceholderOf(final ServiceEffectSpecification replaceable) { + return new ServiceEffectSpecification(replaceable.getValue(), true); + } +} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/SignatureTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/SignatureTest.java similarity index 59% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/SignatureTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/SignatureTest.java index 4d5d7c3b..8f0b27f4 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/SignatureTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/element/SignatureTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element; +package org.palladiosimulator.retriever.mocore.surrogate.element; import org.palladiosimulator.pcm.repository.OperationSignature; import org.palladiosimulator.pcm.repository.RepositoryFactory; @@ -8,25 +8,25 @@ public class SignatureTest extends ElementTest { @Override - protected Signature createElement(OperationSignature value, boolean isPlaceholder) { + protected Signature createElement(final OperationSignature value, final boolean isPlaceholder) { return new Signature(value, isPlaceholder); } @Override protected OperationSignature getUniqueValue() { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - OperationSignature value = RepositoryFactory.eINSTANCE.createOperationSignature(); + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final OperationSignature value = RepositoryFactory.eINSTANCE.createOperationSignature(); value.setEntityName(identifier); return value; } @Override protected Signature getUniqueNonPlaceholder() { - return new Signature(getUniqueValue(), false); + return new Signature(this.getUniqueValue(), false); } @Override - protected Signature getPlaceholderOf(Signature replaceable) { + protected Signature getPlaceholderOf(final Signature replaceable) { return new Signature(replaceable.getValue(), true); } } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentAllocationRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAllocationRelationTest.java similarity index 58% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentAllocationRelationTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAllocationRelationTest.java index c2470953..56df20cc 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentAllocationRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAllocationRelationTest.java @@ -1,15 +1,15 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; import tools.mdsd.mocore.framework.surrogate.RelationTest; public class ComponentAllocationRelationTest extends RelationTest, Deployment> { @Override - protected ComponentAllocationRelation createRelation(Component source, Deployment destination, - boolean isPlaceholder) { + protected ComponentAllocationRelation createRelation(final Component source, final Deployment destination, + final boolean isPlaceholder) { return new ComponentAllocationRelation(source, destination, isPlaceholder); } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentAssemblyRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAssemblyRelationTest.java similarity index 57% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentAssemblyRelationTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAssemblyRelationTest.java index 69eaae25..0f632341 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentAssemblyRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentAssemblyRelationTest.java @@ -1,7 +1,7 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; import tools.mdsd.mocore.framework.surrogate.RelationTest; @@ -10,21 +10,20 @@ public class ComponentAssemblyRelationTest private static final Interface RELATION_DESTINATION = Interface.getUniquePlaceholder(); @Override - protected ComponentAssemblyRelation createRelation(InterfaceProvisionRelation source, - InterfaceRequirementRelation destination, - boolean isPlaceholder) { + protected ComponentAssemblyRelation createRelation(final InterfaceProvisionRelation source, + final InterfaceRequirementRelation destination, final boolean isPlaceholder) { return new ComponentAssemblyRelation(source, destination, isPlaceholder); } @Override protected InterfaceProvisionRelation getUniqueSourceEntity() { - Component source = Component.getUniquePlaceholder(); + final Component source = Component.getUniquePlaceholder(); return new InterfaceProvisionRelation(source, RELATION_DESTINATION, true); } @Override protected InterfaceRequirementRelation getUniqueDestinationEntity() { - Component source = Component.getUniquePlaceholder(); + final Component source = Component.getUniquePlaceholder(); return new InterfaceRequirementRelation(source, RELATION_DESTINATION, true); } } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentSignatureProvisionRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentSignatureProvisionRelationTest.java similarity index 59% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentSignatureProvisionRelationTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentSignatureProvisionRelationTest.java index a0f1e427..f3e5de6c 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ComponentSignatureProvisionRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ComponentSignatureProvisionRelationTest.java @@ -1,8 +1,8 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Signature; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.Signature; import tools.mdsd.mocore.framework.surrogate.RelationTest; @@ -11,20 +11,20 @@ public class ComponentSignatureProvisionRelationTest extends private static final Interface RELATION_INTERFACE = Interface.getUniquePlaceholder(); @Override - protected ComponentSignatureProvisionRelation createRelation(InterfaceProvisionRelation source, - SignatureProvisionRelation destination, boolean isPlaceholder) { + protected ComponentSignatureProvisionRelation createRelation(final InterfaceProvisionRelation source, + final SignatureProvisionRelation destination, final boolean isPlaceholder) { return new ComponentSignatureProvisionRelation(source, destination, isPlaceholder); } @Override protected InterfaceProvisionRelation getUniqueSourceEntity() { - Component source = Component.getUniquePlaceholder(); + final Component source = Component.getUniquePlaceholder(); return new InterfaceProvisionRelation(source, RELATION_INTERFACE, true); } @Override protected SignatureProvisionRelation getUniqueDestinationEntity() { - Signature signature = Signature.getUniquePlaceholder(); + final Signature signature = Signature.getUniquePlaceholder(); return new SignatureProvisionRelation(signature, RELATION_INTERFACE, true); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeProvisionDelegationRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeProvisionDelegationRelationTest.java new file mode 100644 index 00000000..9053ae64 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeProvisionDelegationRelationTest.java @@ -0,0 +1,67 @@ +package org.palladiosimulator.retriever.mocore.surrogate.relation; + +import static org.junit.Assert.assertThrows; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.retriever.mocore.surrogate.element.AtomicComponent; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; + +import tools.mdsd.mocore.framework.surrogate.RelationTest; + +public class CompositeProvisionDelegationRelationTest extends + RelationTest { + private static final Interface RELATION_INTERFACE = Interface.getUniquePlaceholder(); + + @Test + public void testConstructorWithEqualSourceAndDestinationRelation() { + final InterfaceProvisionRelation entity = this.getUniqueSourceEntity(); + + assertThrows(IllegalArgumentException.class, + () -> new CompositeProvisionDelegationRelation(entity, entity, false)); + } + + @Test + public void testConstructorWithoutSourceCompositeComponent() { + final AtomicComponent sourceComponent = AtomicComponent.getUniquePlaceholder(); + final Composite destinationComponent = Composite.getUniquePlaceholder(); + final InterfaceProvisionRelation source = new InterfaceProvisionRelation(sourceComponent, RELATION_INTERFACE, + true); + final InterfaceProvisionRelation destination = new InterfaceProvisionRelation(destinationComponent, + RELATION_INTERFACE, true); + + assertThrows(IllegalArgumentException.class, + () -> new CompositeProvisionDelegationRelation(source, destination, false)); + } + + @Test + public void testConstructorWithDifferentRequirementInterfaces() { + final InterfaceProvisionRelation source = this.getUniqueSourceEntity(); + final Component destinationComponent = AtomicComponent.getUniquePlaceholder(); + final Interface destinationInterface = Interface.getUniquePlaceholder(); + final InterfaceProvisionRelation destination = new InterfaceProvisionRelation(destinationComponent, + destinationInterface, true); + + assertThrows(IllegalArgumentException.class, + () -> new CompositeProvisionDelegationRelation(source, destination, false)); + } + + @Override + protected CompositeProvisionDelegationRelation createRelation(final InterfaceProvisionRelation source, + final InterfaceProvisionRelation destination, final boolean isPlaceholder) { + return new CompositeProvisionDelegationRelation(source, destination, isPlaceholder); + } + + @Override + protected InterfaceProvisionRelation getUniqueSourceEntity() { + final Composite source = Composite.getUniquePlaceholder(); + return new InterfaceProvisionRelation(source, RELATION_INTERFACE, true); + } + + @Override + protected InterfaceProvisionRelation getUniqueDestinationEntity() { + final Component source = AtomicComponent.getUniquePlaceholder(); + return new InterfaceProvisionRelation(source, RELATION_INTERFACE, true); + } +} diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeRequirementDelegationRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeRequirementDelegationRelationTest.java new file mode 100644 index 00000000..5c5864f4 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositeRequirementDelegationRelationTest.java @@ -0,0 +1,67 @@ +package org.palladiosimulator.retriever.mocore.surrogate.relation; + +import static org.junit.Assert.assertThrows; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.retriever.mocore.surrogate.element.AtomicComponent; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; + +import tools.mdsd.mocore.framework.surrogate.RelationTest; + +public class CompositeRequirementDelegationRelationTest extends + RelationTest { + private static final Interface RELATION_INTERFACE = Interface.getUniquePlaceholder(); + + @Test + public void testConstructorWithEqualSourceAndDestinationRelation() { + final InterfaceRequirementRelation entity = this.getUniqueSourceEntity(); + + assertThrows(IllegalArgumentException.class, + () -> new CompositeRequirementDelegationRelation(entity, entity, false)); + } + + @Test + public void testConstructorWithoutSourceCompositeComponent() { + final AtomicComponent sourceComponent = AtomicComponent.getUniquePlaceholder(); + final Composite destinationComponent = Composite.getUniquePlaceholder(); + final InterfaceRequirementRelation source = new InterfaceRequirementRelation(sourceComponent, + RELATION_INTERFACE, true); + final InterfaceRequirementRelation destination = new InterfaceRequirementRelation(destinationComponent, + RELATION_INTERFACE, true); + + assertThrows(IllegalArgumentException.class, + () -> new CompositeRequirementDelegationRelation(source, destination, false)); + } + + @Test + public void testConstructorWithDifferentRequirementInterfaces() { + final InterfaceRequirementRelation source = this.getUniqueSourceEntity(); + final Component destinationComponent = AtomicComponent.getUniquePlaceholder(); + final Interface destinationInterface = Interface.getUniquePlaceholder(); + final InterfaceRequirementRelation destination = new InterfaceRequirementRelation(destinationComponent, + destinationInterface, true); + + assertThrows(IllegalArgumentException.class, + () -> new CompositeRequirementDelegationRelation(source, destination, false)); + } + + @Override + protected CompositeRequirementDelegationRelation createRelation(final InterfaceRequirementRelation source, + final InterfaceRequirementRelation destination, final boolean isPlaceholder) { + return new CompositeRequirementDelegationRelation(source, destination, isPlaceholder); + } + + @Override + protected InterfaceRequirementRelation getUniqueSourceEntity() { + final Composite source = Composite.getUniquePlaceholder(); + return new InterfaceRequirementRelation(source, RELATION_INTERFACE, true); + } + + @Override + protected InterfaceRequirementRelation getUniqueDestinationEntity() { + final Component source = AtomicComponent.getUniquePlaceholder(); + return new InterfaceRequirementRelation(source, RELATION_INTERFACE, true); + } +} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositionRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositionRelationTest.java similarity index 57% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositionRelationTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositionRelationTest.java index 95514588..26e7c76e 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositionRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/CompositionRelationTest.java @@ -1,14 +1,14 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Composite; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; import tools.mdsd.mocore.framework.surrogate.RelationTest; public class CompositionRelationTest extends RelationTest> { @Override - protected CompositionRelation createRelation(Composite source, Component destination, - boolean isPlaceholder) { + protected CompositionRelation createRelation(final Composite source, final Component destination, + final boolean isPlaceholder) { return new CompositionRelation(source, destination, isPlaceholder); } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/DeploymentDeploymentRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/DeploymentDeploymentRelationTest.java similarity index 64% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/DeploymentDeploymentRelationTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/DeploymentDeploymentRelationTest.java index c324baa0..e54a6fda 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/DeploymentDeploymentRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/DeploymentDeploymentRelationTest.java @@ -1,14 +1,14 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; import tools.mdsd.mocore.framework.surrogate.RelationTest; public class DeploymentDeploymentRelationTest extends RelationTest { @Override - protected DeploymentDeploymentRelation createRelation(Deployment source, Deployment destination, - boolean isPlaceholder) { + protected DeploymentDeploymentRelation createRelation(final Deployment source, final Deployment destination, + final boolean isPlaceholder) { return new DeploymentDeploymentRelation(source, destination, isPlaceholder); } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/InterfaceProvisionRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceProvisionRelationTest.java similarity index 58% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/InterfaceProvisionRelationTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceProvisionRelationTest.java index 2660aefa..e42ce3ad 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/InterfaceProvisionRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceProvisionRelationTest.java @@ -1,14 +1,14 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; import tools.mdsd.mocore.framework.surrogate.RelationTest; public class InterfaceProvisionRelationTest extends RelationTest, Interface> { @Override - protected InterfaceProvisionRelation createRelation(Component source, Interface destination, - boolean isPlaceholder) { + protected InterfaceProvisionRelation createRelation(final Component source, final Interface destination, + final boolean isPlaceholder) { return new InterfaceProvisionRelation(source, destination, isPlaceholder); } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/InterfaceRequirementRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceRequirementRelationTest.java similarity index 58% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/InterfaceRequirementRelationTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceRequirementRelationTest.java index 858708c6..3b265ed5 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/InterfaceRequirementRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/InterfaceRequirementRelationTest.java @@ -1,15 +1,15 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; import tools.mdsd.mocore.framework.surrogate.RelationTest; public class InterfaceRequirementRelationTest extends RelationTest, Interface> { @Override - protected InterfaceRequirementRelation createRelation(Component source, Interface destination, - boolean isPlaceholder) { + protected InterfaceRequirementRelation createRelation(final Component source, final Interface destination, + final boolean isPlaceholder) { return new InterfaceRequirementRelation(source, destination, isPlaceholder); } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/LinkResourceSpecificationRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/LinkResourceSpecificationRelationTest.java similarity index 55% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/LinkResourceSpecificationRelationTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/LinkResourceSpecificationRelationTest.java index d99d8f20..63e644d5 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/LinkResourceSpecificationRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/LinkResourceSpecificationRelationTest.java @@ -1,15 +1,15 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.LinkResourceSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.element.LinkResourceSpecification; import tools.mdsd.mocore.framework.surrogate.RelationTest; public class LinkResourceSpecificationRelationTest extends RelationTest { @Override - protected LinkResourceSpecificationRelation createRelation(LinkResourceSpecification source, - DeploymentDeploymentRelation destination, boolean isPlaceholder) { + protected LinkResourceSpecificationRelation createRelation(final LinkResourceSpecification source, + final DeploymentDeploymentRelation destination, final boolean isPlaceholder) { return new LinkResourceSpecificationRelation(source, destination, isPlaceholder); } @@ -20,7 +20,7 @@ protected LinkResourceSpecification getUniqueSourceEntity() { @Override protected DeploymentDeploymentRelation getUniqueDestinationEntity() { - return new DeploymentDeploymentRelation(Deployment.getUniquePlaceholder(), - Deployment.getUniquePlaceholder(), true); + return new DeploymentDeploymentRelation(Deployment.getUniquePlaceholder(), Deployment.getUniquePlaceholder(), + true); } } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ServiceEffectSpecificationRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ServiceEffectSpecificationRelationTest.java new file mode 100644 index 00000000..15b56cd6 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/ServiceEffectSpecificationRelationTest.java @@ -0,0 +1,33 @@ +package org.palladiosimulator.retriever.mocore.surrogate.relation; + +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.ServiceEffectSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.element.Signature; + +import tools.mdsd.mocore.framework.surrogate.RelationTest; + +public class ServiceEffectSpecificationRelationTest extends + RelationTest { + @Override + protected ServiceEffectSpecificationRelation createRelation(final ComponentSignatureProvisionRelation source, + final ServiceEffectSpecification destination, final boolean isPlaceholder) { + return new ServiceEffectSpecificationRelation(source, destination, isPlaceholder); + } + + @Override + protected ComponentSignatureProvisionRelation getUniqueSourceEntity() { + final Component component = Component.getUniquePlaceholder(); + final Interface interfsc = Interface.getUniquePlaceholder(); + final Signature signature = Signature.getUniquePlaceholder(); + final InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(component, interfsc, true); + final SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, interfsc, true); + return new ComponentSignatureProvisionRelation(interfaceProvision, signatureProvision, false); + } + + @Override + protected ServiceEffectSpecification getUniqueDestinationEntity() { + return ServiceEffectSpecification.getUniquePlaceholder(); + } + +} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/SignatureProvisionRelationTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/SignatureProvisionRelationTest.java similarity index 57% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/SignatureProvisionRelationTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/SignatureProvisionRelationTest.java index 72381764..f632a28c 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/SignatureProvisionRelationTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/surrogate/relation/SignatureProvisionRelationTest.java @@ -1,14 +1,14 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; +package org.palladiosimulator.retriever.mocore.surrogate.relation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Signature; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.Signature; import tools.mdsd.mocore.framework.surrogate.RelationTest; public class SignatureProvisionRelationTest extends RelationTest { @Override - protected SignatureProvisionRelation createRelation(Signature source, Interface destination, - boolean isPlaceholder) { + protected SignatureProvisionRelation createRelation(final Signature source, final Interface destination, + final boolean isPlaceholder) { return new SignatureProvisionRelation(source, destination, isPlaceholder); } diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/AllocationTransformerTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/AllocationTransformerTest.java new file mode 100644 index 00000000..055e6d30 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/AllocationTransformerTest.java @@ -0,0 +1,50 @@ +package org.palladiosimulator.retriever.mocore.transformation; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.palladiosimulator.retriever.mocore.utility.PcmEvaluationUtility.containsRepresentative; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.palladiosimulator.pcm.allocation.Allocation; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAllocationRelation; + +import tools.mdsd.mocore.framework.transformation.TransformerTest; + +public class AllocationTransformerTest extends TransformerTest { + @ParameterizedTest + @ValueSource(booleans = { true, false }) + public void testTransformSingleAllocation(final boolean isPlaceholderAllocation) { + // Test data + final AllocationTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Component component = Component.getUniquePlaceholder(); + final Deployment deployment = Deployment.getUniquePlaceholder(); + final ComponentAllocationRelation allocationRelation = new ComponentAllocationRelation(component, deployment, + isPlaceholderAllocation); + + model.add(component); + model.add(deployment); + model.add(allocationRelation); + + // Execution + final Allocation allocation = transformer.transform(model); + + // Assertion + assertNotNull(allocation); + assertTrue(containsRepresentative(allocation, allocationRelation)); + } + + @Override + protected AllocationTransformer createTransformer() { + return new AllocationTransformer(); + } + + @Override + protected PcmSurrogate createEmptyModel() { + return new PcmSurrogate(); + } +} diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/RepositoryTransformerTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/RepositoryTransformerTest.java new file mode 100644 index 00000000..2801c6d0 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/RepositoryTransformerTest.java @@ -0,0 +1,285 @@ +package org.palladiosimulator.retriever.mocore.transformation; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.palladiosimulator.retriever.mocore.utility.PcmEvaluationUtility.containsRepresentative; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.palladiosimulator.pcm.repository.Repository; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.AtomicComponent; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.ServiceEffectSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.element.Signature; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentSignatureProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceRequirementRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ServiceEffectSpecificationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.SignatureProvisionRelation; + +import tools.mdsd.mocore.framework.transformation.TransformerTest; + +public class RepositoryTransformerTest extends TransformerTest { + @Test + public void testTransformSingleComponent() { + // Test data + final RepositoryTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final AtomicComponent component = AtomicComponent.getUniquePlaceholder(); + + model.add(component); + + // Execution + final Repository repository = transformer.transform(model); + + // Assertion + assertNotNull(repository); + assertTrue(containsRepresentative(repository, component)); + } + + @Test + public void testTransformSingleEmptyComposite() { + // Test data + final RepositoryTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Composite composite = Composite.getUniquePlaceholder(); + + model.add(composite); + + // Execution + final Repository repository = transformer.transform(model); + + // Assertion + assertNotNull(repository); + assertTrue(containsRepresentative(repository, composite)); + } + + @Test + public void testTransformCompositeWithAtomicComponentChild() { + // Test data + final RepositoryTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Composite composite = Composite.getUniquePlaceholder(); + final AtomicComponent component = AtomicComponent.getUniquePlaceholder(); + final CompositionRelation compositionRelation = new CompositionRelation(composite, component, false); + + model.add(composite); + model.add(component); + model.add(compositionRelation); + + // Execution + final Repository repository = transformer.transform(model); + + // Assertion + assertNotNull(repository); + assertTrue(containsRepresentative(repository, composite)); + assertTrue(containsRepresentative(repository, component)); + assertTrue(containsRepresentative(repository, compositionRelation)); + } + + @Test + public void testTransformCompositeWithCompositeChild() { + // Test data + final RepositoryTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Composite composite = Composite.getUniquePlaceholder(); + final Composite child = Composite.getUniquePlaceholder(); + final CompositionRelation compositionRelation = new CompositionRelation(composite, child, false); + + model.add(composite); + model.add(child); + model.add(compositionRelation); + + // Execution + final Repository repository = transformer.transform(model); + + // Assertion + assertNotNull(repository); + assertTrue(containsRepresentative(repository, composite)); + assertTrue(containsRepresentative(repository, child)); + assertTrue(containsRepresentative(repository, compositionRelation)); + } + + @Test + public void testTransformCompositeWithMultilevelChildren() { + // Test data + final RepositoryTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Composite compositeLevelZero = Composite.getUniquePlaceholder(); + final Composite compositeLevelOne = Composite.getUniquePlaceholder(); + final AtomicComponent component = AtomicComponent.getUniquePlaceholder(); + final CompositionRelation compositionRelationFst = new CompositionRelation(compositeLevelZero, + compositeLevelOne, false); + final CompositionRelation compositionRelationSnd = new CompositionRelation(compositeLevelOne, component, false); + + model.add(compositeLevelZero); + model.add(compositeLevelOne); + model.add(component); + model.add(compositionRelationFst); + model.add(compositionRelationSnd); + + // Execution + final Repository repository = transformer.transform(model); + + // Assertion + assertNotNull(repository); + assertTrue(containsRepresentative(repository, compositeLevelZero)); + assertTrue(containsRepresentative(repository, compositeLevelOne)); + assertTrue(containsRepresentative(repository, component)); + assertTrue(containsRepresentative(repository, compositionRelationFst)); + assertTrue(containsRepresentative(repository, compositionRelationSnd)); + } + + @Test + public void testTransformSingleInterface() { + // Test data + final RepositoryTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Interface element = Interface.getUniquePlaceholder(); + + model.add(element); + + // Execution + final Repository repository = transformer.transform(model); + + // Assertion + assertNotNull(repository); + assertTrue(containsRepresentative(repository, element)); + } + + @ParameterizedTest + @ValueSource(booleans = { true, false }) + public void testTransformInterfaceProvision(final boolean isPlaceholderRelation) { + // Test data + final RepositoryTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Component provider = Component.getUniquePlaceholder(); + final Interface providerInterface = Interface.getUniquePlaceholder(); + final InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, + providerInterface, isPlaceholderRelation); + + model.add(provider); + model.add(providerInterface); + model.add(interfaceProvision); + + // Execution + final Repository repository = transformer.transform(model); + + // Assertion + assertNotNull(repository); + assertTrue(containsRepresentative(repository, provider)); + assertTrue(containsRepresentative(repository, providerInterface)); + assertTrue(containsRepresentative(repository, interfaceProvision)); + } + + @ParameterizedTest + @ValueSource(booleans = { true, false }) + public void testTransformInterfaceRequirement(final boolean isPlaceholderRelation) { + // Test data + final RepositoryTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Component consumer = Component.getUniquePlaceholder(); + final Interface consumerInterface = Interface.getUniquePlaceholder(); + final InterfaceRequirementRelation interfaceRequirement = new InterfaceRequirementRelation(consumer, + consumerInterface, isPlaceholderRelation); + + model.add(consumer); + model.add(consumerInterface); + model.add(interfaceRequirement); + + // Execution + final Repository repository = transformer.transform(model); + + // Assertion + assertNotNull(repository); + assertTrue(containsRepresentative(repository, consumer)); + assertTrue(containsRepresentative(repository, consumerInterface)); + assertTrue(containsRepresentative(repository, interfaceRequirement)); + } + + @ParameterizedTest + @ValueSource(booleans = { true, false }) + public void testTransformSignatureProvision(final boolean isPlaceholderRelation) { + // Test data + final RepositoryTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Component provider = Component.getUniquePlaceholder(); + final Interface providerInterface = Interface.getUniquePlaceholder(); + final InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, + providerInterface, false); + final Signature signature = Signature.getUniquePlaceholder(); + final SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, + providerInterface, isPlaceholderRelation); + + model.add(provider); + model.add(providerInterface); + model.add(interfaceProvision); + model.add(signature); + model.add(signatureProvision); + + // Execution + final Repository repository = transformer.transform(model); + + // Assertion + assertNotNull(repository); + assertTrue(containsRepresentative(repository, provider)); + assertTrue(containsRepresentative(repository, providerInterface)); + assertTrue(containsRepresentative(repository, interfaceProvision)); + assertTrue(containsRepresentative(repository, signatureProvision)); + } + + @ParameterizedTest + @ValueSource(booleans = { true, false }) + public void testTransformComponentSignatureProvisionWithSeff(final boolean isPlaceholderRelation) { + // Test data + final RepositoryTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Component provider = Component.getUniquePlaceholder(); + final Interface providerInterface = Interface.getUniquePlaceholder(); + final InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, + providerInterface, false); + final Signature signature = Signature.getUniquePlaceholder(); + final SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, + providerInterface, false); + final ComponentSignatureProvisionRelation componentSignatureProvisionRelation = new ComponentSignatureProvisionRelation( + interfaceProvision, signatureProvision, false); + final ServiceEffectSpecification seff = ServiceEffectSpecification.getUniquePlaceholder(); + final ServiceEffectSpecificationRelation seffRelation = new ServiceEffectSpecificationRelation( + componentSignatureProvisionRelation, seff, isPlaceholderRelation); + + model.add(provider); + model.add(providerInterface); + model.add(interfaceProvision); + model.add(signature); + model.add(signatureProvision); + model.add(componentSignatureProvisionRelation); + model.add(seff); + model.add(seffRelation); + + // Execution + final Repository repository = transformer.transform(model); + + // Assertion + assertNotNull(repository); + assertTrue(containsRepresentative(repository, provider)); + assertTrue(containsRepresentative(repository, providerInterface)); + assertTrue(containsRepresentative(repository, interfaceProvision)); + assertTrue(containsRepresentative(repository, signatureProvision)); + assertTrue(containsRepresentative(repository, seffRelation)); + } + + @Override + protected RepositoryTransformer createTransformer() { + return new RepositoryTransformer(); + } + + @Override + protected PcmSurrogate createEmptyModel() { + return new PcmSurrogate(); + } +} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/ResourceEnvironmentTransformerTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/ResourceEnvironmentTransformerTest.java similarity index 51% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/ResourceEnvironmentTransformerTest.java rename to tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/ResourceEnvironmentTransformerTest.java index cf9288a4..a9c77f10 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/ResourceEnvironmentTransformerTest.java +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/ResourceEnvironmentTransformerTest.java @@ -1,18 +1,18 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.transformation; +package org.palladiosimulator.retriever.mocore.transformation; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.palladiosimulator.somox.analyzer.rules.mocore.utility.PcmEvaluationUtility.containsRepresentative; +import static org.palladiosimulator.retriever.mocore.utility.PcmEvaluationUtility.containsRepresentative; import java.util.List; import org.junit.jupiter.api.Test; import org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.LinkResourceSpecification; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.DeploymentDeploymentRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.LinkResourceSpecificationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.element.LinkResourceSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.relation.DeploymentDeploymentRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.LinkResourceSpecificationRelation; import tools.mdsd.mocore.framework.transformation.TransformerTest; @@ -21,12 +21,12 @@ public class ResourceEnvironmentTransformerTest @Test public void testTransformIndependentPlaceholderContainers() { // Test data - ResourceEnvironmentTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Deployment fstDeployment = Deployment.getUniquePlaceholder(); - Deployment sndDeployment = Deployment.getUniquePlaceholder(); - Deployment trdDeployment = Deployment.getUniquePlaceholder(); - Deployment fthDeployment = Deployment.getUniquePlaceholder(); + final ResourceEnvironmentTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Deployment fstDeployment = Deployment.getUniquePlaceholder(); + final Deployment sndDeployment = Deployment.getUniquePlaceholder(); + final Deployment trdDeployment = Deployment.getUniquePlaceholder(); + final Deployment fthDeployment = Deployment.getUniquePlaceholder(); model.add(fstDeployment); model.add(sndDeployment); @@ -34,7 +34,7 @@ public void testTransformIndependentPlaceholderContainers() { model.add(fthDeployment); // Execution - ResourceEnvironment environment = transformer.transform(model); + final ResourceEnvironment environment = transformer.transform(model); // Assertion assertNotNull(environment); @@ -47,23 +47,23 @@ public void testTransformIndependentPlaceholderContainers() { @Test public void testTransformConnectedPlaceholderContainers() { // Test data - ResourceEnvironmentTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Deployment fstDeployment = Deployment.getUniquePlaceholder(); - Deployment sndDeployment = Deployment.getUniquePlaceholder(); - Deployment trdDeployment = Deployment.getUniquePlaceholder(); + final ResourceEnvironmentTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Deployment fstDeployment = Deployment.getUniquePlaceholder(); + final Deployment sndDeployment = Deployment.getUniquePlaceholder(); + final Deployment trdDeployment = Deployment.getUniquePlaceholder(); - DeploymentDeploymentRelation fstLinkRelation = new DeploymentDeploymentRelation(fstDeployment, + final DeploymentDeploymentRelation fstLinkRelation = new DeploymentDeploymentRelation(fstDeployment, sndDeployment, false); - DeploymentDeploymentRelation sndLinkRelation = new DeploymentDeploymentRelation(sndDeployment, + final DeploymentDeploymentRelation sndLinkRelation = new DeploymentDeploymentRelation(sndDeployment, trdDeployment, true); - LinkResourceSpecification fstLinkSpecification = LinkResourceSpecification.getUniquePlaceholder(); - LinkResourceSpecificationRelation fstLinkSpecificationRelation = new LinkResourceSpecificationRelation( + final LinkResourceSpecification fstLinkSpecification = LinkResourceSpecification.getUniquePlaceholder(); + final LinkResourceSpecificationRelation fstLinkSpecificationRelation = new LinkResourceSpecificationRelation( fstLinkSpecification, fstLinkRelation, false); - LinkResourceSpecification sndLinkSpecification = LinkResourceSpecification.getUniquePlaceholder(); - LinkResourceSpecificationRelation sndLinkSpecificationRelation = new LinkResourceSpecificationRelation( + final LinkResourceSpecification sndLinkSpecification = LinkResourceSpecification.getUniquePlaceholder(); + final LinkResourceSpecificationRelation sndLinkSpecificationRelation = new LinkResourceSpecificationRelation( sndLinkSpecification, sndLinkRelation, true); model.add(fstDeployment); @@ -75,7 +75,7 @@ public void testTransformConnectedPlaceholderContainers() { model.add(sndLinkSpecificationRelation); // Execution - ResourceEnvironment environment = transformer.transform(model); + final ResourceEnvironment environment = transformer.transform(model); // Assertion assertNotNull(environment); @@ -83,11 +83,15 @@ public void testTransformConnectedPlaceholderContainers() { assertTrue(containsRepresentative(environment, sndDeployment)); assertTrue(containsRepresentative(environment, trdDeployment)); assertTrue(containsRepresentative(environment, fstLinkSpecificationRelation.getSource(), - List.of(fstLinkSpecificationRelation.getDestination().getSource(), - fstLinkSpecificationRelation.getDestination().getDestination()))); + List.of(fstLinkSpecificationRelation.getDestination() + .getSource(), + fstLinkSpecificationRelation.getDestination() + .getDestination()))); assertTrue(containsRepresentative(environment, sndLinkSpecificationRelation.getSource(), - List.of(sndLinkSpecificationRelation.getDestination().getSource(), - sndLinkSpecificationRelation.getDestination().getDestination()))); + List.of(sndLinkSpecificationRelation.getDestination() + .getSource(), + sndLinkSpecificationRelation.getDestination() + .getDestination()))); } @Override diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/SystemTransformerTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/SystemTransformerTest.java new file mode 100644 index 00000000..ff85f57e --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/transformation/SystemTransformerTest.java @@ -0,0 +1,81 @@ +package org.palladiosimulator.retriever.mocore.transformation; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.palladiosimulator.retriever.mocore.utility.PcmEvaluationUtility.containsRepresentative; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.palladiosimulator.pcm.system.System; +import org.palladiosimulator.retriever.mocore.surrogate.PcmSurrogate; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAssemblyRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceRequirementRelation; + +import tools.mdsd.mocore.framework.transformation.TransformerTest; + +public class SystemTransformerTest extends TransformerTest { + @Test + public void testTransformSingleComponent() { + // Test data + final SystemTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + final Component component = Component.getUniquePlaceholder(); + + model.add(component); + + // Execution + final System system = transformer.transform(model); + + // Assertion + assertNotNull(system); + assertTrue(containsRepresentative(system, component)); + } + + @ParameterizedTest + @ValueSource(booleans = { true, false }) + public void testTransformSingleAssemblyRelation(final boolean isPlaceholderAssembly) { + // Test data + final SystemTransformer transformer = this.createTransformer(); + final PcmSurrogate model = this.createEmptyModel(); + + final Component provider = Component.getUniquePlaceholder(); + final Component consumer = Component.getUniquePlaceholder(); + final Interface providerConsumerInterface = Interface.getUniquePlaceholder(); + final InterfaceProvisionRelation provisionRelation = new InterfaceProvisionRelation(provider, + providerConsumerInterface, false); + final InterfaceRequirementRelation requirementRelation = new InterfaceRequirementRelation(consumer, + providerConsumerInterface, false); + final ComponentAssemblyRelation assemblyRelation = new ComponentAssemblyRelation(provisionRelation, + requirementRelation, isPlaceholderAssembly); + + model.add(provider); + model.add(consumer); + model.add(providerConsumerInterface); + model.add(provisionRelation); + model.add(requirementRelation); + model.add(assemblyRelation); + + // Execution + final System system = transformer.transform(model); + + // Assertion + assertNotNull(system); + assertTrue(containsRepresentative(system, provider)); + assertTrue(containsRepresentative(system, consumer)); + assertTrue(containsRepresentative(system, assemblyRelation)); + } + + @Override + protected SystemTransformer createTransformer() { + return new SystemTransformer(); + } + + @Override + protected PcmSurrogate createEmptyModel() { + return new PcmSurrogate(); + } +} diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/utility/ElementFactory.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/utility/ElementFactory.java new file mode 100644 index 00000000..17dead4f --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/utility/ElementFactory.java @@ -0,0 +1,79 @@ +package org.palladiosimulator.retriever.mocore.utility; + +import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; +import org.palladiosimulator.pcm.repository.BasicComponent; +import org.palladiosimulator.pcm.repository.CompositeComponent; +import org.palladiosimulator.pcm.repository.OperationInterface; +import org.palladiosimulator.pcm.repository.OperationSignature; +import org.palladiosimulator.pcm.repository.RepositoryComponent; +import org.palladiosimulator.pcm.repository.RepositoryFactory; +import org.palladiosimulator.pcm.resourceenvironment.CommunicationLinkResourceSpecification; +import org.palladiosimulator.pcm.resourceenvironment.ResourceContainer; +import org.palladiosimulator.pcm.resourceenvironment.ResourceenvironmentFactory; +import org.palladiosimulator.retriever.mocore.surrogate.element.AtomicComponent; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Composite; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.element.Interface; +import org.palladiosimulator.retriever.mocore.surrogate.element.LinkResourceSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.element.ServiceEffectSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.element.Signature; + +import tools.mdsd.mocore.utility.IdentifierGenerator; + +public final class ElementFactory { + private ElementFactory() { + throw new IllegalStateException("Cannot instantiate utility class."); + } + + public static Signature createUniqueSignature(final boolean isPlaceholder) { + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final OperationSignature value = RepositoryFactory.eINSTANCE.createOperationSignature(); + value.setEntityName(identifier); + return new Signature(value, isPlaceholder); + } + + public static Interface createUniqueInterface(final boolean isPlaceholder) { + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final OperationInterface value = new FluentRepositoryFactory().newOperationInterface() + .withName(identifier) + .build(); + return new Interface(value, isPlaceholder); + } + + public static Component createUniqueComponent(final boolean isPlaceholder) { + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final BasicComponent value = new FluentRepositoryFactory().newBasicComponent() + .withName(identifier) + .build(); + return new AtomicComponent(value, isPlaceholder); + } + + public static Composite createUniqueComposite(final boolean isPlaceholder) { + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final RepositoryComponent value = new FluentRepositoryFactory().newCompositeComponent() + .withName(identifier) + .build(); + return new Composite((CompositeComponent) value, isPlaceholder); + } + + public static Deployment createUniqueDeployment(final boolean isPlaceholder) { + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final ResourceContainer value = ResourceenvironmentFactory.eINSTANCE.createResourceContainer(); + value.setEntityName(identifier); + return new Deployment(value, isPlaceholder); + } + + public static LinkResourceSpecification createUniqueLinkResourceSpecification(final boolean isPlaceholder) { + final String identifier = IdentifierGenerator.getUniqueIdentifier(); + final CommunicationLinkResourceSpecification value = ResourceenvironmentFactory.eINSTANCE + .createCommunicationLinkResourceSpecification(); + value.setId(identifier); + return new LinkResourceSpecification(value, isPlaceholder); + } + + public static ServiceEffectSpecification createUniqueServiceEffectSpecification(final boolean isPlaceholder) { + final ServiceEffectSpecification placeholderSpecification = ServiceEffectSpecification.getUniquePlaceholder(); + return new ServiceEffectSpecification(placeholderSpecification.getValue(), isPlaceholder); + } +} diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/utility/PcmEvaluationUtility.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/utility/PcmEvaluationUtility.java new file mode 100644 index 00000000..ab0c0350 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/utility/PcmEvaluationUtility.java @@ -0,0 +1,440 @@ +package org.palladiosimulator.retriever.mocore.utility; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.function.BiFunction; +import java.util.stream.Collectors; + +import org.palladiosimulator.pcm.allocation.Allocation; +import org.palladiosimulator.pcm.allocation.AllocationContext; +import org.palladiosimulator.pcm.core.composition.AssemblyConnector; +import org.palladiosimulator.pcm.core.composition.AssemblyContext; +import org.palladiosimulator.pcm.repository.BasicComponent; +import org.palladiosimulator.pcm.repository.CompositeComponent; +import org.palladiosimulator.pcm.repository.DataType; +import org.palladiosimulator.pcm.repository.Interface; +import org.palladiosimulator.pcm.repository.OperationInterface; +import org.palladiosimulator.pcm.repository.OperationProvidedRole; +import org.palladiosimulator.pcm.repository.OperationRequiredRole; +import org.palladiosimulator.pcm.repository.OperationSignature; +import org.palladiosimulator.pcm.repository.Parameter; +import org.palladiosimulator.pcm.repository.ProvidedRole; +import org.palladiosimulator.pcm.repository.Repository; +import org.palladiosimulator.pcm.repository.RepositoryComponent; +import org.palladiosimulator.pcm.repository.RequiredRole; +import org.palladiosimulator.pcm.resourceenvironment.CommunicationLinkResourceSpecification; +import org.palladiosimulator.pcm.resourceenvironment.LinkingResource; +import org.palladiosimulator.pcm.resourceenvironment.ResourceContainer; +import org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment; +import org.palladiosimulator.pcm.seff.ResourceDemandingSEFF; +import org.palladiosimulator.pcm.system.System; +import org.palladiosimulator.retriever.mocore.surrogate.element.Component; +import org.palladiosimulator.retriever.mocore.surrogate.element.Deployment; +import org.palladiosimulator.retriever.mocore.surrogate.element.LinkResourceSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.element.ServiceEffectSpecification; +import org.palladiosimulator.retriever.mocore.surrogate.element.Signature; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAllocationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ComponentAssemblyRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.CompositionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.DeploymentDeploymentRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceProvisionRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.InterfaceRequirementRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.ServiceEffectSpecificationRelation; +import org.palladiosimulator.retriever.mocore.surrogate.relation.SignatureProvisionRelation; + +import de.uka.ipd.sdq.identifier.Identifier; + +public final class PcmEvaluationUtility { + private PcmEvaluationUtility() { + throw new IllegalStateException("Utility class cannot be instantiated."); + } + + public static boolean representSame(final DataType type, final DataType otherType) { + boolean equalType; + if (type instanceof Identifier && otherType instanceof Identifier) { + equalType = Objects.equals(((Identifier) type).getId(), ((Identifier) otherType).getId()); + } else { + equalType = Objects.equals(type, otherType); + } + return equalType; + } + + public static boolean representSame(final Parameter parameter, final Parameter otherParameter) { + final boolean equalName = Objects.equals(parameter.getParameterName(), otherParameter.getParameterName()); + final boolean equalType = representSame(parameter.getDataType__Parameter(), + otherParameter.getDataType__Parameter()); + return equalName && equalType; + } + + public static boolean representSame(final OperationSignature signature, + final org.palladiosimulator.pcm.repository.Signature otherSignature) { + if (otherSignature instanceof OperationSignature) { + return representSame(signature, (OperationSignature) otherSignature); + } + return false; + } + + public static boolean representSame(final OperationSignature signature, final OperationSignature otherSignature) { + final boolean equalName = Objects.equals(signature.getEntityName(), otherSignature.getEntityName()); + final boolean equalReturn = representSame(signature.getReturnType__OperationSignature(), + otherSignature.getReturnType__OperationSignature()); + final boolean equalParameters = areCollectionsEqual(signature.getParameters__OperationSignature(), + otherSignature.getParameters__OperationSignature(), PcmEvaluationUtility::representSame); + return equalName && equalReturn && equalParameters; + } + + public static boolean representSame(final OperationInterface interFace, final Interface otherInterFace) { + if (otherInterFace instanceof OperationInterface) { + return representSame(interFace, (OperationInterface) otherInterFace); + } + return false; + } + + public static boolean representSame(final OperationInterface interFace, final OperationInterface otherInterFace) { + final boolean equalName = Objects.equals(interFace.getEntityName(), otherInterFace.getEntityName()); + // TODO Check characterization & protocol => Is there a palladio equal check? + return equalName; + } + + public static boolean representSame(final RepositoryComponent component, final RepositoryComponent otherComponent) { + if (otherComponent instanceof BasicComponent && component instanceof BasicComponent) { + return representSame((BasicComponent) component, (BasicComponent) otherComponent); + } else if (otherComponent instanceof CompositeComponent && component instanceof CompositeComponent) { + return representSame((CompositeComponent) component, (CompositeComponent) otherComponent); + } + return false; + } + + public static boolean representSame(final BasicComponent component, final BasicComponent otherComponent) { + final boolean equalName = Objects.equals(component.getEntityName(), otherComponent.getEntityName()); + final boolean equalType = Objects.equals(component.getComponentType(), otherComponent.getComponentType()); + // TODO Check parameter usage => Is there a palladio equal check? + return equalName && equalType; + } + + public static boolean representSame(final CompositeComponent component, final CompositeComponent otherComponent) { + final boolean equalName = Objects.equals(component.getEntityName(), otherComponent.getEntityName()); + final boolean equalType = Objects.equals(component.getComponentType(), otherComponent.getComponentType()); + // TODO Check parameter usage => Is there a palladio equal check? + return equalName && equalType; + } + + public static boolean representSame(final ResourceContainer container, final ResourceContainer otherContainer) { + final boolean equalName = Objects.equals(container.getEntityName(), otherContainer.getEntityName()); + // TODO ResourceSpecifications are removed from old container on copy. Consequently, + // comparing it is not + // possible. + return equalName; + } + + public static boolean representSame(final ResourceDemandingSEFF seff, + final org.palladiosimulator.pcm.seff.ServiceEffectSpecification otherSeff) { + if (otherSeff instanceof ResourceDemandingSEFF) { + return representSame(seff, (ResourceDemandingSEFF) otherSeff); + } + return false; + } + + public static boolean representSame(final ResourceDemandingSEFF seff, final ResourceDemandingSEFF otherSeff) { + final boolean equalIdentifier = Objects.equals(seff.getId(), otherSeff.getId()); + final boolean equalTypeIdentifier = Objects.equals(seff.getSeffTypeID(), otherSeff.getSeffTypeID()); + final boolean equalSteps = areCollectionsEqualIgnoringOrder(mapToIdentifier(seff.getSteps_Behaviour()), + mapToIdentifier(otherSeff.getSteps_Behaviour())); + final boolean equalInternalBehaviors = areCollectionsEqualIgnoringOrder( + mapToIdentifier(seff.getResourceDemandingInternalBehaviours()), + mapToIdentifier(otherSeff.getResourceDemandingInternalBehaviours())); + final boolean equalLoopAction = Objects.equals( + mapToIdentifier(seff.getAbstractLoopAction_ResourceDemandingBehaviour()), + mapToIdentifier(otherSeff.getAbstractLoopAction_ResourceDemandingBehaviour())); + final boolean equalBranchTransition = Objects.equals( + mapToIdentifier(seff.getAbstractBranchTransition_ResourceDemandingBehaviour()), + mapToIdentifier(otherSeff.getAbstractBranchTransition_ResourceDemandingBehaviour())); + return equalIdentifier && equalTypeIdentifier && equalSteps && equalInternalBehaviors && equalLoopAction + && equalBranchTransition; + } + + public static Optional getRepresentative(final ResourceEnvironment resourceEnvironment, + final Deployment container) { + final List containers = resourceEnvironment.getResourceContainer_ResourceEnvironment(); + for (final ResourceContainer environmentContainer : containers) { + if (representSame(container.getValue(), environmentContainer)) { + return Optional.of(environmentContainer); + } + } + return Optional.empty(); + } + + public static Optional getRepresentative(final Repository repository, + final Component component) { + final List components = repository.getComponents__Repository(); + for (final RepositoryComponent repositoryComponent : components) { + if (representSame(component.getValue(), repositoryComponent)) { + return Optional.of(repositoryComponent); + } + } + return Optional.empty(); + } + + public static Optional getRepresentative(final Repository repository, + final org.palladiosimulator.retriever.mocore.surrogate.element.Interface interFace) { + final List interfaces = repository.getInterfaces__Repository(); + for (final Interface repositoryInterface : interfaces) { + if (representSame(interFace.getValue(), repositoryInterface)) { + return Optional.of((OperationInterface) repositoryInterface); + } + } + return Optional.empty(); + } + + public static boolean containsRepresentative(final Repository repository, final Component component) { + return getRepresentative(repository, component).isPresent(); + } + + public static boolean containsRepresentative(final Repository repository, final CompositionRelation composition) { + final CompositeComponent wrappedComposite = composition.getSource() + .getValue(); + final RepositoryComponent wrappedChild = composition.getDestination() + .getValue(); + return repository.getComponents__Repository() + .stream() + .filter(component -> component instanceof CompositeComponent) + .map(component -> (CompositeComponent) component) + .filter(composite -> composite.getEntityName() + .equals(wrappedComposite.getEntityName())) + .flatMap(composite -> composite.getAssemblyContexts__ComposedStructure() + .stream()) + .anyMatch(assemblyContext -> assemblyContext.getEncapsulatedComponent__AssemblyContext() + .getEntityName() + .equals(wrappedChild.getEntityName())); + } + + public static boolean containsRepresentative(final Repository repository, + final org.palladiosimulator.retriever.mocore.surrogate.element.Interface interFace) { + return getRepresentative(repository, interFace).isPresent(); + } + + public static boolean containsRepresentative(final Repository repository, + final InterfaceProvisionRelation interfaceProvision) { + final OperationInterface wrappedInterface = interfaceProvision.getDestination() + .getValue(); + final Optional optionalComponent = getRepresentative(repository, + interfaceProvision.getSource()); + if (optionalComponent.isPresent()) { + final List roles = optionalComponent.get() + .getProvidedRoles_InterfaceProvidingEntity(); + return roles.stream() + .filter(role -> role instanceof OperationProvidedRole) + .map(role -> (OperationProvidedRole) role) + .map(OperationProvidedRole::getProvidedInterface__OperationProvidedRole) + .anyMatch(interFace -> representSame(wrappedInterface, interFace)); + } else { + return false; + } + } + + public static boolean containsRepresentative(final Repository repository, + final InterfaceRequirementRelation interfaceRequirement) { + final OperationInterface wrappedInterface = interfaceRequirement.getDestination() + .getValue(); + final Optional optionalComponent = getRepresentative(repository, + interfaceRequirement.getSource()); + if (optionalComponent.isPresent()) { + final List roles = optionalComponent.get() + .getRequiredRoles_InterfaceRequiringEntity(); + return roles.stream() + .filter(role -> role instanceof OperationRequiredRole) + .map(role -> (OperationRequiredRole) role) + .map(OperationRequiredRole::getRequiredInterface__OperationRequiredRole) + .anyMatch(interFace -> representSame(wrappedInterface, interFace)); + } else { + return false; + } + } + + public static boolean containsRepresentative(final Repository repository, + final SignatureProvisionRelation signatureProvision) { + final Optional optionalOperationInterface = getRepresentative(repository, + signatureProvision.getDestination()); + return optionalOperationInterface.isPresent() && optionalOperationInterface.get() + .getSignatures__OperationInterface() + .stream() + .anyMatch(signature -> representSame(signatureProvision.getSource() + .getValue(), signature)); + } + + public static boolean containsRepresentative(final Repository repository, + final ServiceEffectSpecificationRelation seffProvision) { + final Component provider = seffProvision.getSource() + .getSource() + .getSource(); + final Signature signature = seffProvision.getSource() + .getDestination() + .getSource(); + final ServiceEffectSpecification seff = seffProvision.getDestination(); + + final Optional optionalComponent = getRepresentative(repository, provider); + if (optionalComponent.isPresent() && optionalComponent.get() instanceof BasicComponent) { + final BasicComponent component = (BasicComponent) optionalComponent.get(); + for (final org.palladiosimulator.pcm.seff.ServiceEffectSpecification componentSeff : component + .getServiceEffectSpecifications__BasicComponent()) { + if (representSame(seff.getValue(), componentSeff)) { + final ResourceDemandingSEFF componentRdSeff = (ResourceDemandingSEFF) componentSeff; + return representSame(provider.getValue(), + componentRdSeff.getBasicComponent_ServiceEffectSpecification()) + && representSame(signature.getValue(), componentRdSeff.getDescribedService__SEFF()) + && containsRepresentative(repository, seffProvision.getSource() + .getSource()) + && containsRepresentative(repository, seffProvision.getSource() + .getDestination()); + } + } + } + return false; + } + + public static boolean containsRepresentative(final ResourceEnvironment resourceEnvironment, + final Deployment container) { + return getRepresentative(resourceEnvironment, container).isPresent(); + } + + public static boolean containsRepresentative(final ResourceEnvironment resourceEnvironment, + final DeploymentDeploymentRelation link) { + final List linkingResources = resourceEnvironment.getLinkingResources__ResourceEnvironment(); + for (final LinkingResource linkingResource : linkingResources) { + final List linkedContainers = new LinkedList<>( + linkingResource.getConnectedResourceContainers_LinkingResource()); + boolean containsContainers = true; + for (final Deployment deployment : List.of(link.getSource(), link.getDestination())) { + containsContainers = containsContainers + && linkedContainers.removeIf(element -> representSame(deployment.getValue(), element)); + } + if (containsContainers) { + return true; + } + } + return false; + } + + public static boolean containsRepresentative(final ResourceEnvironment resourceEnvironment, + final LinkResourceSpecification relationSpecification, final Collection deployments) { + final CommunicationLinkResourceSpecification specification = relationSpecification.getValue(); + final List linkingResources = resourceEnvironment.getLinkingResources__ResourceEnvironment(); + for (final LinkingResource linkingResource : linkingResources) { + final List linkedContainers = new LinkedList<>( + linkingResource.getConnectedResourceContainers_LinkingResource()); + final CommunicationLinkResourceSpecification linkSpecification = linkingResource + .getCommunicationLinkResourceSpecifications_LinkingResource(); + boolean containsContainers = true; + for (final Deployment deployment : deployments) { + containsContainers = containsContainers + && linkedContainers.removeIf(element -> representSame(deployment.getValue(), element)); + } + if (containsContainers && linkedContainers.isEmpty()) { + if (specification.getId() + .equals(linkSpecification.getId())) { + return true; + } + } + } + return false; + } + + public static boolean containsRepresentative(final Allocation allocation, + final ComponentAllocationRelation allocationRelation) { + final Component component = allocationRelation.getSource(); + final Deployment deployment = allocationRelation.getDestination(); + + final List allocationContexts = allocation.getAllocationContexts_Allocation(); + for (final AllocationContext allocationContext : allocationContexts) { + if (representSame(deployment.getValue(), allocationContext.getResourceContainer_AllocationContext())) { + final AssemblyContext assemblyContext = allocationContext.getAssemblyContext_AllocationContext(); + if (representSame(component.getValue(), assemblyContext.getEncapsulatedComponent__AssemblyContext())) { + return true; + } + } + } + return false; + } + + public static boolean containsRepresentative(final System system, final Component component) { + final List assemblyContexts = system.getAssemblyContexts__ComposedStructure(); + for (final AssemblyContext assemblyContext : assemblyContexts) { + if (representSame(component.getValue(), assemblyContext.getEncapsulatedComponent__AssemblyContext())) { + return true; + } + } + return false; + } + + public static boolean containsRepresentative(final System system, + final ComponentAssemblyRelation assemblyRelation) { + final RepositoryComponent provider = assemblyRelation.getSource() + .getSource() + .getValue(); + final RepositoryComponent consumer = assemblyRelation.getDestination() + .getSource() + .getValue(); + final OperationInterface providerConsumerInterface = assemblyRelation.getSource() + .getDestination() + .getValue(); + + final List assemblyConnectors = system.getConnectors__ComposedStructure() + .stream() + .filter(connector -> connector instanceof AssemblyConnector) + .map(connector -> (AssemblyConnector) connector) + .collect(Collectors.toList()); + for (final AssemblyConnector connector : assemblyConnectors) { + final RepositoryComponent connectorProvider = connector.getProvidingAssemblyContext_AssemblyConnector() + .getEncapsulatedComponent__AssemblyContext(); + final RepositoryComponent connectorConsumer = connector.getRequiringAssemblyContext_AssemblyConnector() + .getEncapsulatedComponent__AssemblyContext(); + final OperationInterface connectorProviderConsumerInterface = connector.getProvidedRole_AssemblyConnector() + .getProvidedInterface__OperationProvidedRole(); + + final boolean sameProvider = representSame(provider, connectorProvider); + final boolean sameConsumer = representSame(consumer, connectorConsumer); + final boolean sameInterface = representSame(providerConsumerInterface, connectorProviderConsumerInterface); + if (sameProvider && sameConsumer && sameInterface) { + return true; + } + } + return false; + } + + private static boolean areCollectionsEqual(final Collection collection, final Collection otherCollection, + final BiFunction comparisonFunction) { + if (collection.isEmpty() && otherCollection.isEmpty()) { + return true; + } else if (collection.size() != otherCollection.size()) { + return false; + } + + final List list = new LinkedList<>(collection); + final List otherList = new LinkedList<>(otherCollection); + for (int i = 0; i < list.size(); i++) { + if (!comparisonFunction.apply(list.get(i), otherList.get(i))) { + return false; + } + } + return true; + } + + private static boolean areCollectionsEqualIgnoringOrder(final Collection collection, + final Collection otherCollection) { + return collection.containsAll(otherCollection) && otherCollection.containsAll(collection); + } + + private static String mapToIdentifier(final T element) { + return element != null ? element.getId() : null; + } + + private static List mapToIdentifier(final Collection collection) { + return collection.stream() + .dropWhile(element -> element == null) + .map(Identifier::getId) + .collect(Collectors.toList()); + } +} diff --git a/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/workflow/MoCoReJobTest.java b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/workflow/MoCoReJobTest.java new file mode 100644 index 00000000..d8ce96a9 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.mocore.test/src/org/palladiosimulator/retriever/mocore/workflow/MoCoReJobTest.java @@ -0,0 +1,238 @@ +package org.palladiosimulator.retriever.mocore.workflow; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; +import java.util.stream.Collectors; + +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.emf.common.util.EList; +import org.junit.jupiter.api.Test; +import org.palladiosimulator.generator.fluent.repository.api.Repo; +import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; +import org.palladiosimulator.pcm.core.composition.AssemblyConnector; +import org.palladiosimulator.pcm.core.composition.Connector; +import org.palladiosimulator.pcm.core.composition.ProvidedDelegationConnector; +import org.palladiosimulator.pcm.core.composition.RequiredDelegationConnector; +import org.palladiosimulator.pcm.repository.CompositeComponent; +import org.palladiosimulator.pcm.repository.OperationProvidedRole; +import org.palladiosimulator.pcm.repository.Repository; +import org.palladiosimulator.pcm.repository.RepositoryComponent; +import org.palladiosimulator.pcm.system.System; + +import de.uka.ipd.sdq.workflow.blackboard.Blackboard; + +public class MoCoReJobTest { + private final static String BLACKBOARD_OUTPUT_REPOSITORY = "input.repository"; + private final static String BLACKBOARD_INPUT_REPOSITORY = "output.repository"; + private final static String BLACKBOARD_OUTPUT_SYSTEM = "output.system"; + private final static String BLACKBOARD_OUTPUT_ALLOCATION = "output.allocation"; + private final static String BLACKBOARD_OUTPUT_RESOURCEENVIRONMENT = "output.resource"; + + @Test + public void testConstructorWithValidInput() { + final Blackboard blackboard = new Blackboard<>(); + assertDoesNotThrow(() -> new MoCoReJob(blackboard, BLACKBOARD_INPUT_REPOSITORY, BLACKBOARD_OUTPUT_REPOSITORY, + BLACKBOARD_OUTPUT_SYSTEM, BLACKBOARD_OUTPUT_ALLOCATION, BLACKBOARD_OUTPUT_RESOURCEENVIRONMENT)); + } + + @Test + public void testCompositeComponentProcessing() throws Exception { + // Tests constants + final String componentNameOne = "Component One"; + final String contextNameOne = componentNameOne + " Context"; + final String componentNameTwo = "Component Two"; + final String contextNameTwo = componentNameTwo + " Context"; + final String interfaceNameInternal = "Internal Interface"; + final String roleNameInternalRequired = "Role Requirer " + interfaceNameInternal; + final String roleNameInternalProvided = "Role Provider " + interfaceNameInternal; + final String interfaceNameExternalRequired = "External Interface Required"; + final String roleNameExternalRequiredInner = "Inner Role " + interfaceNameExternalRequired; + final String roleNameExternalRequiredOuter = "Outer Role " + interfaceNameExternalRequired; + final String interfaceNameExternalProvided = "External Interface Provided"; + final String roleNameExternalProvidedInner = "Inner Role " + interfaceNameExternalProvided; + final String roleNameExternalProvidedOuter = "Outer Role " + interfaceNameExternalProvided; + + // Create blackboard and fluent repository + final Blackboard blackboard = new Blackboard<>(); + final FluentRepositoryFactory fluentFactory = new FluentRepositoryFactory(); + final Repo fluentRepository = fluentFactory.newRepository(); + + // Create composite component and add to fluent repository + fluentRepository.addToRepository(fluentFactory.newOperationInterface() + .withName(interfaceNameInternal)) + .addToRepository(fluentFactory.newOperationInterface() + .withName(interfaceNameExternalRequired)) + .addToRepository(fluentFactory.newOperationInterface() + .withName(interfaceNameExternalProvided)) + .addToRepository(fluentFactory.newBasicComponent() + .withName(componentNameOne) + .provides(fluentFactory.fetchOfOperationInterface(interfaceNameInternal), roleNameInternalProvided) + .requires(fluentFactory.fetchOfOperationInterface(interfaceNameExternalRequired), + roleNameExternalRequiredInner)) + .addToRepository(fluentFactory.newBasicComponent() + .withName(componentNameTwo) + .requires(fluentFactory.fetchOfOperationInterface(interfaceNameInternal), roleNameInternalRequired) + .provides(fluentFactory.fetchOfOperationInterface(interfaceNameExternalProvided), + roleNameExternalProvidedInner)) + .addToRepository(fluentFactory.newCompositeComponent() + .provides(fluentFactory.fetchOfOperationInterface(interfaceNameExternalProvided), + roleNameExternalProvidedOuter) + .requires(fluentFactory.fetchOfOperationInterface(interfaceNameExternalRequired), + roleNameExternalRequiredOuter) + .withAssemblyContext(fluentFactory.fetchOfComponent(componentNameOne), contextNameOne) + .withAssemblyContext(fluentFactory.fetchOfComponent(componentNameTwo), contextNameTwo) + .withAssemblyConnection(fluentFactory.fetchOfOperationProvidedRole(roleNameInternalProvided), + fluentFactory.fetchOfAssemblyContext(contextNameOne), + fluentFactory.fetchOfOperationRequiredRole(roleNameInternalRequired), + fluentFactory.fetchOfAssemblyContext(contextNameTwo)) + .withProvidedDelegationConnection(fluentFactory.fetchOfAssemblyContext(contextNameTwo), + fluentFactory.fetchOfOperationProvidedRole(roleNameExternalProvidedInner), + fluentFactory.fetchOfOperationProvidedRole(roleNameExternalProvidedOuter)) + .withRequiredDelegationConnection(fluentFactory.fetchOfAssemblyContext(contextNameOne), + fluentFactory.fetchOfOperationRequiredRole(roleNameExternalRequiredInner), + fluentFactory.fetchOfOperationRequiredRole(roleNameExternalRequiredOuter))); + + // Fill blackboard + blackboard.addPartition(BLACKBOARD_INPUT_REPOSITORY, fluentRepository.createRepositoryNow()); + + // Create and run job + final MoCoReJob job = new MoCoReJob(blackboard, BLACKBOARD_INPUT_REPOSITORY, BLACKBOARD_OUTPUT_REPOSITORY, + BLACKBOARD_OUTPUT_SYSTEM, BLACKBOARD_OUTPUT_ALLOCATION, BLACKBOARD_OUTPUT_RESOURCEENVIRONMENT); + job.execute(new NullProgressMonitor()); + + // Check if components exist in repository + final Repository outputRepository = (Repository) blackboard.getPartition(BLACKBOARD_OUTPUT_REPOSITORY); + final EList components = outputRepository.getComponents__Repository(); + final CompositeComponent composite = (CompositeComponent) components.stream() + .filter(component -> component instanceof CompositeComponent) + .findFirst() + .orElseThrow(); + assertEquals(2, composite.getAssemblyContexts__ComposedStructure() + .size()); + + // Check if assembly connector created correctly + final List assemblyConnectors = composite.getConnectors__ComposedStructure() + .stream() + .filter(genericConnector -> genericConnector instanceof AssemblyConnector) + .map(genericConnector -> (AssemblyConnector) genericConnector) + .collect(Collectors.toList()); + assertEquals(1, assemblyConnectors.size()); + final AssemblyConnector assemblyConnector = assemblyConnectors.get(0); + assertEquals(componentNameOne, assemblyConnector.getProvidingAssemblyContext_AssemblyConnector() + .getEncapsulatedComponent__AssemblyContext() + .getEntityName()); + assertEquals(componentNameTwo, assemblyConnector.getRequiringAssemblyContext_AssemblyConnector() + .getEncapsulatedComponent__AssemblyContext() + .getEntityName()); + assertEquals(interfaceNameInternal, assemblyConnector.getProvidedRole_AssemblyConnector() + .getProvidedInterface__OperationProvidedRole() + .getEntityName()); + assertEquals(interfaceNameInternal, assemblyConnector.getRequiredRole_AssemblyConnector() + .getRequiredInterface__OperationRequiredRole() + .getEntityName()); + + // Check if provided delegation created correctly + final List providedDelegations = composite.getConnectors__ComposedStructure() + .stream() + .filter(genericConnector -> genericConnector instanceof ProvidedDelegationConnector) + .map(genericConnector -> (ProvidedDelegationConnector) genericConnector) + .collect(Collectors.toList()); + assertEquals(1, providedDelegations.size()); + final ProvidedDelegationConnector providedDelegationConnector = providedDelegations.get(0); + assertEquals(componentNameTwo, providedDelegationConnector.getAssemblyContext_ProvidedDelegationConnector() + .getEncapsulatedComponent__AssemblyContext() + .getEntityName()); + assertEquals(interfaceNameExternalProvided, + providedDelegationConnector.getInnerProvidedRole_ProvidedDelegationConnector() + .getProvidedInterface__OperationProvidedRole() + .getEntityName()); + assertEquals(interfaceNameExternalProvided, + providedDelegationConnector.getOuterProvidedRole_ProvidedDelegationConnector() + .getProvidedInterface__OperationProvidedRole() + .getEntityName()); + + // Check if required delegation created correctly + final List requiredDelegations = composite.getConnectors__ComposedStructure() + .stream() + .filter(genericConnector -> genericConnector instanceof RequiredDelegationConnector) + .map(genericConnector -> (RequiredDelegationConnector) genericConnector) + .collect(Collectors.toList()); + assertEquals(1, requiredDelegations.size()); + final RequiredDelegationConnector requiredDelegationConnector = requiredDelegations.get(0); + assertEquals(componentNameOne, requiredDelegationConnector.getAssemblyContext_RequiredDelegationConnector() + .getEncapsulatedComponent__AssemblyContext() + .getEntityName()); + assertEquals(interfaceNameExternalRequired, + requiredDelegationConnector.getInnerRequiredRole_RequiredDelegationConnector() + .getRequiredInterface__OperationRequiredRole() + .getEntityName()); + assertEquals(interfaceNameExternalRequired, + requiredDelegationConnector.getOuterRequiredRole_RequiredDelegationConnector() + .getRequiredInterface__OperationRequiredRole() + .getEntityName()); + } + + @Test + public void testRecursiveProvisionLeadsToSystemDelegation() throws Exception { + // Create blackboard and fluent repository + final Blackboard blackboard = new Blackboard<>(); + final FluentRepositoryFactory fluentFactory = new FluentRepositoryFactory(); + final Repo fluentRepository = fluentFactory.newRepository(); + + // Create composite component and add to fluent repository + fluentRepository.addToRepository(fluentFactory.newOperationInterface() + .withName("Doable")) + .addToRepository(fluentFactory.newBasicComponent() + .withName("Child") + .provides(fluentFactory.fetchOfOperationInterface("Doable"), "Doable Role")) + .addToRepository(fluentFactory.newCompositeComponent() + .withName("Inner Parent") + .withAssemblyContext(fluentFactory.fetchOfComponent("Child"))) + .addToRepository(fluentFactory.newCompositeComponent() + .withName("Middle Parent") + .withAssemblyContext(fluentFactory.fetchOfComponent("Inner Parent"))) + .addToRepository(fluentFactory.newCompositeComponent() + .withName("Outer Parent") + .withAssemblyContext(fluentFactory.fetchOfComponent("Middle Parent"))); + + // Fill blackboard + blackboard.addPartition(BLACKBOARD_INPUT_REPOSITORY, fluentRepository.createRepositoryNow()); + + // Create and run job + final MoCoReJob job = new MoCoReJob(blackboard, BLACKBOARD_INPUT_REPOSITORY, BLACKBOARD_OUTPUT_REPOSITORY, + BLACKBOARD_OUTPUT_SYSTEM, BLACKBOARD_OUTPUT_ALLOCATION, BLACKBOARD_OUTPUT_RESOURCEENVIRONMENT); + job.execute(new NullProgressMonitor()); + + // Check inner provision was recursively + final Repository outputRepository = (Repository) blackboard.getPartition(BLACKBOARD_OUTPUT_REPOSITORY); + final EList components = outputRepository.getComponents__Repository(); + final List composites = components.stream() + .filter(component -> component instanceof CompositeComponent) + .map(component -> (CompositeComponent) component) + .toList(); + composites.forEach(composite -> assertTrue(composite.getProvidedRoles_InterfaceProvidingEntity() + .stream() + .anyMatch(role -> role instanceof OperationProvidedRole + && ((OperationProvidedRole) role).getProvidedInterface__OperationProvidedRole() + .getEntityName() + .equals("Doable")))); + + // Check most outer provision was delegated by system + final System outputSystem = (System) blackboard.getPartition(BLACKBOARD_OUTPUT_SYSTEM); + final EList connectors = outputSystem.getConnectors__ComposedStructure(); + assertEquals(1, connectors.size()); + final ProvidedDelegationConnector delegationConnector = (ProvidedDelegationConnector) connectors.get(0); + assertEquals("Outer Parent", delegationConnector.getAssemblyContext_ProvidedDelegationConnector() + .getEncapsulatedComponent__AssemblyContext() + .getEntityName()); + assertEquals("Doable", delegationConnector.getInnerProvidedRole_ProvidedDelegationConnector() + .getProvidedInterface__OperationProvidedRole() + .getEntityName()); + assertEquals("Doable", delegationConnector.getOuterProvidedRole_ProvidedDelegationConnector() + .getProvidedInterface__OperationProvidedRole() + .getEntityName()); + } +} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/.classpath b/tests/org.palladiosimulator.retriever.test/.classpath similarity index 52% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/.classpath rename to tests/org.palladiosimulator.retriever.test/.classpath index 51f0a325..45dbc1c7 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/.classpath +++ b/tests/org.palladiosimulator.retriever.test/.classpath @@ -1,16 +1,17 @@ - + - + - + - + - - + + diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/.gitignore b/tests/org.palladiosimulator.retriever.test/.gitignore similarity index 100% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/.gitignore rename to tests/org.palladiosimulator.retriever.test/.gitignore diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/.project b/tests/org.palladiosimulator.retriever.test/.project similarity index 89% rename from tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/.project rename to tests/org.palladiosimulator.retriever.test/.project index b4740fe0..94ef0bdd 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/.project +++ b/tests/org.palladiosimulator.retriever.test/.project @@ -1,6 +1,6 @@ - org.palladiosimulator.somox.analyzer.rules.mocore.test + org.palladiosimulator.retriever.test diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/META-INF/MANIFEST.MF b/tests/org.palladiosimulator.retriever.test/META-INF/MANIFEST.MF similarity index 56% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/META-INF/MANIFEST.MF rename to tests/org.palladiosimulator.retriever.test/META-INF/MANIFEST.MF index d58ae5e8..7c1fb734 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/META-INF/MANIFEST.MF +++ b/tests/org.palladiosimulator.retriever.test/META-INF/MANIFEST.MF @@ -1,10 +1,10 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: SoMoX Rule Engine Test -Bundle-SymbolicName: org.palladiosimulator.somox.analyzer.rules.engine.test;singleton:=true +Bundle-Name: Retriever Test +Bundle-SymbolicName: org.palladiosimulator.retriever.test;singleton:=true Bundle-Version: 5.2.0.qualifier Bundle-Vendor: palladiosimulator.org -Automatic-Module-Name: org.palladiosimulator.somox.analyzer.rules.engine.test +Automatic-Module-Name: org.palladiosimulator.retriever.extraction.engine.test Bundle-RequiredExecutionEnvironment: JavaSE-17 Require-Bundle: com.google.guava, de.uka.ipd.sdq.workflow, @@ -18,11 +18,12 @@ Require-Bundle: com.google.guava, org.junit, org.palladiosimulator.generator.fluent, org.palladiosimulator.pcm, - org.palladiosimulator.somox.analyzer.rules.engine, - org.palladiosimulator.somox.analyzer.rules.impl, - org.palladiosimulator.somox.analyzer.rules.main, - org.palladiosimulator.somox.analyzer.rules.mocore, + org.palladiosimulator.retriever.mocore, org.palladiosimulator.somox.ast2seff, org.apache.commons.io, org.apache.log4j, - junit-jupiter-api + junit-jupiter-api, + org.palladiosimulator.retriever.extraction, + org.palladiosimulator.retriever.core, + org.palladiosimulator.retriever.extraction.discoverers, + org.palladiosimulator.retriever.extraction.rules diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/build.properties b/tests/org.palladiosimulator.retriever.test/build.properties similarity index 60% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/build.properties rename to tests/org.palladiosimulator.retriever.test/build.properties index d8e2f0e9..34d2e4d2 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/build.properties +++ b/tests/org.palladiosimulator.retriever.test/build.properties @@ -1,5 +1,4 @@ -source.. = src/,\ - xtend-gen/ +source.. = src/ output.. = bin/ bin.includes = META-INF/,\ . diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/pom.xml b/tests/org.palladiosimulator.retriever.test/pom.xml similarity index 72% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/pom.xml rename to tests/org.palladiosimulator.retriever.test/pom.xml index ad999efc..90836f62 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/pom.xml +++ b/tests/org.palladiosimulator.retriever.test/pom.xml @@ -1,4 +1,6 @@ - + 4.0.0 @@ -8,9 +10,9 @@ ../../ - org.palladiosimulator.somox - org.palladiosimulator.somox.analyzer.rules.engine.test - [test-bundle] SoMoX Rule CLI + org.palladiosimulator.retriever + org.palladiosimulator.retriever.test + [test-bundle] Retriever 5.2.0-SNAPSHOT eclipse-test-plugin @@ -43,7 +45,8 @@ wget - https://github.com/acmeair/acmeair/archive/refs/tags/v1.2.0.zip + + https://github.com/acmeair/acmeair/archive/refs/tags/v1.2.0.zip true true ${project.basedir}/res/external/ @@ -56,20 +59,23 @@ wget - https://github.com/DescartesResearch/TeaStore/archive/refs/tags/v1.4.1.zip + + https://github.com/DescartesResearch/TeaStore/archive/refs/tags/v1.4.1.zip true true ${project.basedir}/res/external/ - download-test-resource-spring-petclinic-microservices + + download-test-resource-spring-petclinic-microservices generate-resources wget - https://github.com/spring-petclinic/spring-petclinic-microservices/archive/refs/tags/v2.3.6.zip + + https://github.com/spring-petclinic/spring-petclinic-microservices/archive/refs/tags/v2.3.6.zip true true ${project.basedir}/res/external/ @@ -82,7 +88,8 @@ wget - https://github.com/sqshq/piggymetrics/archive/refs/tags/spring.version.2.0.3.zip + + https://github.com/sqshq/piggymetrics/archive/refs/tags/spring.version.2.0.3.zip true true ${project.basedir}/res/external/ diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/.gitignore b/tests/org.palladiosimulator.retriever.test/res/.gitignore similarity index 100% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/res/.gitignore rename to tests/org.palladiosimulator.retriever.test/res/.gitignore diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/.mvn/extensions.xml b/tests/org.palladiosimulator.retriever.test/res/.mvn/extensions.xml similarity index 100% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/res/.mvn/extensions.xml rename to tests/org.palladiosimulator.retriever.test/res/.mvn/extensions.xml diff --git a/tests/org.palladiosimulator.retriever.test/res/BasicProject/.classpath b/tests/org.palladiosimulator.retriever.test/res/BasicProject/.classpath new file mode 100644 index 00000000..2d08e2aa --- /dev/null +++ b/tests/org.palladiosimulator.retriever.test/res/BasicProject/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/BasicProject/.project b/tests/org.palladiosimulator.retriever.test/res/BasicProject/.project similarity index 100% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/res/BasicProject/.project rename to tests/org.palladiosimulator.retriever.test/res/BasicProject/.project diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/BasicProject/src/basic/ConflictingMethods.java b/tests/org.palladiosimulator.retriever.test/res/BasicProject/src/basic/ConflictingMethods.java similarity index 100% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/res/BasicProject/src/basic/ConflictingMethods.java rename to tests/org.palladiosimulator.retriever.test/res/BasicProject/src/basic/ConflictingMethods.java diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/BasicProject/src/basic/Main.java b/tests/org.palladiosimulator.retriever.test/res/BasicProject/src/basic/Main.java similarity index 100% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/res/BasicProject/src/basic/Main.java rename to tests/org.palladiosimulator.retriever.test/res/BasicProject/src/basic/Main.java diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/JaxRsProject/.classpath b/tests/org.palladiosimulator.retriever.test/res/JaxRsProject/.classpath similarity index 59% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/res/JaxRsProject/.classpath rename to tests/org.palladiosimulator.retriever.test/res/JaxRsProject/.classpath index adeb0a3a..5866ffea 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/JaxRsProject/.classpath +++ b/tests/org.palladiosimulator.retriever.test/res/JaxRsProject/.classpath @@ -1,10 +1,10 @@ - + - + - + diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/SpringProject/.project b/tests/org.palladiosimulator.retriever.test/res/JaxRsProject/.project similarity index 92% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/res/SpringProject/.project rename to tests/org.palladiosimulator.retriever.test/res/JaxRsProject/.project index 272ecb73..89bd8dd3 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/SpringProject/.project +++ b/tests/org.palladiosimulator.retriever.test/res/JaxRsProject/.project @@ -1,6 +1,6 @@ - SpringProject + JaxRsProject diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/JaxRsProject/src/jax_rs/AWebService.java b/tests/org.palladiosimulator.retriever.test/res/JaxRsProject/src/jax_rs/AWebService.java similarity index 100% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/res/JaxRsProject/src/jax_rs/AWebService.java rename to tests/org.palladiosimulator.retriever.test/res/JaxRsProject/src/jax_rs/AWebService.java diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/JaxRsProject/src/module-info.java b/tests/org.palladiosimulator.retriever.test/res/JaxRsProject/src/module-info.java similarity index 100% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/res/JaxRsProject/src/module-info.java rename to tests/org.palladiosimulator.retriever.test/res/JaxRsProject/src/module-info.java diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/SpringProject/.classpath b/tests/org.palladiosimulator.retriever.test/res/SpringProject/.classpath similarity index 59% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/res/SpringProject/.classpath rename to tests/org.palladiosimulator.retriever.test/res/SpringProject/.classpath index adeb0a3a..5866ffea 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/SpringProject/.classpath +++ b/tests/org.palladiosimulator.retriever.test/res/SpringProject/.classpath @@ -1,10 +1,10 @@ - + - + - + diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/JaxRsProject/.project b/tests/org.palladiosimulator.retriever.test/res/SpringProject/.project similarity index 100% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/res/JaxRsProject/.project rename to tests/org.palladiosimulator.retriever.test/res/SpringProject/.project diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/SpringProject/src/module-info.java b/tests/org.palladiosimulator.retriever.test/res/SpringProject/src/module-info.java similarity index 100% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/res/SpringProject/src/module-info.java rename to tests/org.palladiosimulator.retriever.test/res/SpringProject/src/module-info.java diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/SpringProject/src/spring/AComponent.java b/tests/org.palladiosimulator.retriever.test/res/SpringProject/src/spring/AComponent.java similarity index 100% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/res/SpringProject/src/spring/AComponent.java rename to tests/org.palladiosimulator.retriever.test/res/SpringProject/src/spring/AComponent.java diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/ACMETest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/ACMETest.java new file mode 100644 index 00000000..533afe81 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/ACMETest.java @@ -0,0 +1,29 @@ +package org.palladiosimulator.retriever.test.integration; + +import org.palladiosimulator.retriever.extraction.rules.JaxRSRules; + +public class ACMETest extends CaseStudyTest { + + protected ACMETest() { + super("external/acmeair-1.2.0", new JaxRSRules()); + } + + @Override + void testRetrieverRepository() { + this.assertComponentExists("com_acmeair_wxs_service_FlightServiceImpl"); + + this.assertComponentProvidesOperation("com_acmeair_morphia_services_CustomerServiceImpl", + "com_acmeair_service_CustomerService", "getCustomerByUsername"); + this.assertComponentProvidesOperation("com_acmeair_wxs_service_FlightServiceImpl", + "com_acmeair_service_FlightService", "getFlightByAirports"); + this.assertComponentProvidesOperation("com_acmeair_morphia_services_BookingServiceImpl", + "com_acmeair_service_BookingService", "bookFlight"); + + this.assertMaxParameterCount(2, "com_acmeair_service_BookingService", "bookFlight"); + + this.assertComponentRequiresComponent("com_acmeair_web_FlightsREST", + "com_acmeair_morphia_services_FlightServiceImpl"); + this.assertComponentRequiresComponent("com_acmeair_web_LoginREST", + "com_acmeair_morphia_services_CustomerServiceImpl"); + } +} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/BasicTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/BasicTest.java similarity index 70% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/BasicTest.java rename to tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/BasicTest.java index b140adee..c42db32b 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/BasicTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/BasicTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.test.integration; +package org.palladiosimulator.retriever.test.integration; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; @@ -19,27 +19,27 @@ import org.palladiosimulator.pcm.repository.PrimitiveDataType; import org.palladiosimulator.pcm.repository.PrimitiveTypeEnum; import org.palladiosimulator.pcm.repository.Repository; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; -import org.palladiosimulator.somox.analyzer.rules.engine.Rule; -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; -import org.palladiosimulator.somox.analyzer.rules.impl.JaxRSRules; -import org.palladiosimulator.somox.analyzer.rules.main.RuleEngineException; -import org.palladiosimulator.somox.analyzer.rules.workflow.RuleEngineJob; +import org.palladiosimulator.retriever.core.main.RetrieverException; +import org.palladiosimulator.retriever.core.workflow.RetrieverJob; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; +import org.palladiosimulator.retriever.extraction.engine.Rule; +import org.palladiosimulator.retriever.extraction.rules.JaxRSRules; import de.uka.ipd.sdq.workflow.jobs.JobFailedException; import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; -public class BasicTest extends RuleEngineTest { +public class BasicTest extends CaseStudyTest { private static final String PROJECT_NAME = "BasicProject"; private static final Rule[] RULES = { new JaxRSRules() }; protected BasicTest() { super(PROJECT_NAME, RULES); - loadArtifacts(Artifacts.RULEENGINE); + this.loadArtifacts(Artifacts.RETRIEVER); } - private OperationInterface getConflictingMethods(List interfaces) { + private OperationInterface getConflictingMethods(final List interfaces) { OperationInterface conflictingMethods = null; for (final Interface iface : interfaces) { if ("basic_ConflictingMethods".equals(iface.getEntityName())) { @@ -52,12 +52,13 @@ private OperationInterface getConflictingMethods(List interfaces) { } /** - * Tests the basic functionality of the RuleEngineAnalyzer. Requires it to execute without an - * exception and produce an output file. + * Tests the basic functionality of Retriever. Requires it to execute without an exception and + * produce an output file. */ @Test void testExecutesAndProducesFile() { - assertTrue(new File(getConfig().getOutputFolder() + assertTrue(new File(this.getConfig() + .getOutputFolder() .appendSegment("pcm.repository") .devicePath()).exists()); } @@ -65,7 +66,7 @@ void testExecutesAndProducesFile() { @Disabled("FIXME: Reliance on outdated JaxRS rule") @Test void testArray() { - final OperationInterface conflictingMethods = getConflictingMethods(getInterfaces()); + final OperationInterface conflictingMethods = this.getConflictingMethods(this.getInterfaces()); for (final OperationSignature sig : conflictingMethods.getSignatures__OperationInterface()) { for (final Parameter param : sig.getParameters__OperationSignature()) { if ("intArray".equals(param.getParameterName())) { @@ -80,12 +81,12 @@ void testArray() { } /** - * The RuleEngine produced inconsistent results if executed multiple times. Arguments and - * methods appear multiple times. This probably has something to do with (discouraged) static - * states somewhere in the stack. + * Retriever produced inconsistent results if executed multiple times. Arguments and methods + * appear multiple times. This probably has something to do with (discouraged) static states + * somewhere in the stack. * * @throws ModelAnalyzerException - * forwarded from RuleEngineAnalyzer. Should cause the test to fail. + * forwarded from Retriever. Should cause the test to fail. * @throws UserCanceledException * should not happen since no user is in the loop. * @throws JobFailedException @@ -93,8 +94,8 @@ void testArray() { */ @Disabled("FIXME: Reliance on outdated JaxRS rule") @Test - void testRepeatability() throws RuleEngineException, JobFailedException, UserCanceledException { - OperationInterface conflictingMethods = getConflictingMethods(getInterfaces()); + void testRepeatability() throws RetrieverException, JobFailedException, UserCanceledException { + OperationInterface conflictingMethods = this.getConflictingMethods(this.getInterfaces()); int firstIntArgCount = 0; for (final OperationSignature sig : conflictingMethods.getSignatures__OperationInterface()) { for (final Parameter param : sig.getParameters__OperationSignature()) { @@ -104,16 +105,16 @@ void testRepeatability() throws RuleEngineException, JobFailedException, UserCan } } - // Run the RuleEngine again on the same project - RuleEngineConfiguration ruleEngineConfig = getConfig(); - ruleEngineConfig.setOutputFolder(ruleEngineConfig.getOutputFolder() + // Run Retriever again on the same project + final RetrieverConfiguration retrieverConfig = this.getConfig(); + retrieverConfig.setOutputFolder(retrieverConfig.getOutputFolder() .appendSegment("repeated")); - final RuleEngineJob ruleEngine = new RuleEngineJob(ruleEngineConfig); - ruleEngine.execute(new NullProgressMonitor()); - final Repository repo = (Repository) ruleEngine.getBlackboard() - .getPartition(RuleEngineBlackboard.KEY_REPOSITORY); + final RetrieverJob retrieverJob = new RetrieverJob(retrieverConfig); + retrieverJob.execute(new NullProgressMonitor()); + final Repository repo = (Repository) retrieverJob.getBlackboard() + .getPartition(RetrieverBlackboard.KEY_REPOSITORY); - conflictingMethods = getConflictingMethods(repo.getInterfaces__Repository()); + conflictingMethods = this.getConflictingMethods(repo.getInterfaces__Repository()); int secondIntArgCount = 0; for (final OperationSignature sig : conflictingMethods.getSignatures__OperationInterface()) { @@ -130,7 +131,7 @@ void testRepeatability() throws RuleEngineException, JobFailedException, UserCan @Disabled("This bug is inherited from Palladio, this can only be fixed after it is fixed there.") @Test void testShort() { - final OperationInterface conflictingMethods = getConflictingMethods(getInterfaces()); + final OperationInterface conflictingMethods = this.getConflictingMethods(this.getInterfaces()); for (final OperationSignature sig : conflictingMethods.getSignatures__OperationInterface()) { for (final Parameter param : sig.getParameters__OperationSignature()) { if ("shortArg".equals(param.getParameterName())) { @@ -145,7 +146,7 @@ void testShort() { @Disabled("FIXME: Reliance on outdated JaxRS rule") @Test void testVararg() { - final OperationInterface conflictingMethods = getConflictingMethods(getInterfaces()); + final OperationInterface conflictingMethods = this.getConflictingMethods(this.getInterfaces()); for (final OperationSignature sig : conflictingMethods.getSignatures__OperationInterface()) { for (final Parameter param : sig.getParameters__OperationSignature()) { if ("longVararg".equals(param.getParameterName())) { diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/RuleEngineTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/CaseStudyTest.java similarity index 58% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/RuleEngineTest.java rename to tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/CaseStudyTest.java index 36b2cf6b..cd0ba822 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/RuleEngineTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/CaseStudyTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.test.integration; +package org.palladiosimulator.retriever.test.integration; import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -37,12 +37,12 @@ import org.palladiosimulator.pcm.repository.RepositoryComponent; import org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment; import org.palladiosimulator.pcm.system.System; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; -import org.palladiosimulator.somox.analyzer.rules.configuration.RuleEngineConfigurationImpl; -import org.palladiosimulator.somox.analyzer.rules.engine.Rule; -import org.palladiosimulator.somox.analyzer.rules.engine.RuleEngineConfiguration; -import org.palladiosimulator.somox.analyzer.rules.engine.ServiceConfiguration; -import org.palladiosimulator.somox.analyzer.rules.workflow.RuleEngineJob; +import org.palladiosimulator.retriever.core.configuration.RetrieverConfigurationImpl; +import org.palladiosimulator.retriever.core.workflow.RetrieverJob; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; +import org.palladiosimulator.retriever.extraction.engine.RetrieverConfiguration; +import org.palladiosimulator.retriever.extraction.engine.Rule; +import org.palladiosimulator.retriever.extraction.engine.ServiceConfiguration; import com.google.common.collect.Sets; @@ -50,13 +50,13 @@ import de.uka.ipd.sdq.workflow.jobs.UserCanceledException; @TestInstance(Lifecycle.PER_CLASS) -abstract class RuleEngineTest { +abstract class CaseStudyTest { public static final URI TEST_DIR = CommonPlugin .asLocalURI(URI.createFileURI(URI.decode(new File("res").getAbsolutePath()))); - private URI outDir; + private final URI outDir; - public static void validate(EObject eObject) { + public static void validate(final EObject eObject) { EcoreUtil.resolveAll(eObject); assertEquals(Diagnostic.OK, Diagnostician.INSTANCE.validate(eObject) .getSeverity()); @@ -65,8 +65,8 @@ public static void validate(EObject eObject) { // Seperate instances for every child test private final Logger logger = Logger.getLogger(this.getClass()); - private final RuleEngineConfiguration config = new RuleEngineConfigurationImpl(); - private final RuleEngineJob ruleEngine; + private final RetrieverConfiguration config = new RetrieverConfigurationImpl(); + private final RetrieverJob retrieverJob; private final boolean executedSuccessfully; private Repository repository; private System system; @@ -75,37 +75,36 @@ public static void validate(EObject eObject) { private final Set rules; /** - * Tests the basic functionality of the RuleEngineAnalyzer. Requires it to execute without an - * exception and produce an output file. + * Sets up a generic case study test for Retriever. * * @param projectDirectory * the name of the project directory that will be analyzed * @param rules * the rules to execute */ - protected RuleEngineTest(String projectDirectory, Rule... rules) { + protected CaseStudyTest(final String projectDirectory, final Rule... rules) { this.rules = Set.of(rules); - outDir = TEST_DIR.appendSegment("out") + this.outDir = TEST_DIR.appendSegment("out") .appendSegment(this.getClass() .getSimpleName()); - config.setInputFolder(TEST_DIR.appendSegments(projectDirectory.split("/"))); - config.setOutputFolder(outDir); + this.config.setInputFolder(TEST_DIR.appendSegments(projectDirectory.split("/"))); + this.config.setOutputFolder(this.outDir); - ServiceConfiguration ruleConfig = config.getConfig(Rule.class); - for (Rule rule : rules) { + final ServiceConfiguration ruleConfig = this.config.getConfig(Rule.class); + for (final Rule rule : rules) { ruleConfig.select(rule); } - ruleEngine = new RuleEngineJob(config); + this.retrieverJob = new RetrieverJob(this.config); boolean executedSuccessfully; try { - ruleEngine.execute(new NullProgressMonitor()); + this.retrieverJob.execute(new NullProgressMonitor()); executedSuccessfully = true; } catch (JobFailedException | UserCanceledException e) { - logger.error(e); + this.logger.error(e); executedSuccessfully = false; } this.executedSuccessfully = executedSuccessfully; @@ -114,50 +113,55 @@ protected RuleEngineTest(String projectDirectory, Rule... rules) { // Assertion utilities private void assertSuccessfulExecution() { - assertTrue(executedSuccessfully, "Failed to run RuleEngine!"); + assertTrue(this.executedSuccessfully, "Failed to run Retriever!"); } - public void assertMaxParameterCount(int expectedMaxParameterCount, String interfaceName, String operationName) { - assertInterfaceExists(interfaceName); - assertOperationExists(interfaceName, operationName); - assertEquals(expectedMaxParameterCount, getSignatureMaxParameterCount(interfaceName, operationName)); + public void assertMaxParameterCount(final int expectedMaxParameterCount, final String interfaceName, + final String operationName) { + this.assertInterfaceExists(interfaceName); + this.assertOperationExists(interfaceName, operationName); + assertEquals(expectedMaxParameterCount, this.getSignatureMaxParameterCount(interfaceName, operationName)); } - public void assertComponentExists(String name) { - assertTrue(getComponents().stream() + public void assertComponentExists(final String name) { + assertTrue(this.getComponents() + .stream() .anyMatch(x -> x.getEntityName() .equals(name)), "component \"" + name + "\" must exist"); } - public void assertInterfaceExists(String name) { - assertTrue(getInterfaces().stream() + public void assertInterfaceExists(final String name) { + assertTrue(this.getInterfaces() + .stream() .filter(OperationInterface.class::isInstance) .anyMatch(x -> x.getEntityName() .equals(name)), "interface \"" + name + "\" must exist"); } - public void assertOperationExists(String interfaceName, String operationName) { - assertFalse(getOperationSignature(interfaceName, operationName).isEmpty(), - "interface \"" + interfaceName + "\" must contain operation \"" + operationName + "\""); + public void assertOperationExists(final String interfaceName, final String operationName) { + assertFalse(this.getOperationSignature(interfaceName, operationName) + .isEmpty(), "interface \"" + interfaceName + "\" must contain operation \"" + operationName + "\""); } - public void assertComponentRequiresComponent(String requiringName, String providingName) { - Optional requiringComponent = getComponents().stream() + public void assertComponentRequiresComponent(final String requiringName, final String providingName) { + final Optional requiringComponent = this.getComponents() + .stream() .filter(x -> x.getEntityName() .equals(requiringName)) .findFirst(); assertTrue(requiringComponent.isPresent(), "\"" + requiringName + "\" must exist"); - Optional providingComponent = getComponents().stream() + final Optional providingComponent = this.getComponents() + .stream() .filter(x -> x.getEntityName() .equals(providingName)) .findFirst(); assertTrue(providingComponent.isPresent(), "\"" + providingName + "\" must exist"); - List interfaces = getInterfaces(); + final List interfaces = this.getInterfaces(); assertFalse(interfaces.isEmpty(), "an interface must exist in order for a component to require another"); - Set requiredObjects = requiringComponent.get() + final Set requiredObjects = requiringComponent.get() .getRequiredRoles_InterfaceRequiringEntity() .stream() .flatMap(x -> x.eCrossReferences() @@ -165,12 +169,12 @@ public void assertComponentRequiresComponent(String requiringName, String provid .collect(Collectors.toSet()); assertFalse(requiredObjects.isEmpty(), "\"" + requiringName + "\" must require something"); - Set requiredInterfaces = interfaces.stream() + final Set requiredInterfaces = interfaces.stream() .filter(requiredObjects::contains) .collect(Collectors.toSet()); assertFalse(requiredInterfaces.isEmpty(), "\"" + requiringName + "\" must require an interface"); - Set providedObjects = providingComponent.get() + final Set providedObjects = providingComponent.get() .getProvidedRoles_InterfaceProvidingEntity() .stream() .flatMap(x -> x.eCrossReferences() @@ -178,7 +182,7 @@ public void assertComponentRequiresComponent(String requiringName, String provid .collect(Collectors.toSet()); assertFalse(providedObjects.isEmpty(), "\"" + providingName + "\" must provide something"); - Set providedInterfaces = interfaces.stream() + final Set providedInterfaces = interfaces.stream() .filter(providedObjects::contains) .collect(Collectors.toSet()); assertFalse(providedInterfaces.isEmpty(), "\"" + providingName + "\" must provide an interface"); @@ -188,26 +192,29 @@ public void assertComponentRequiresComponent(String requiringName, String provid "\"" + requiringName + "\" must require an interface that \"" + providingName + "\" provides"); } - public void assertInSameCompositeComponent(String childComponentNameA, String childComponentNameB) { - Optional childComponentA = getComponents().stream() + public void assertInSameCompositeComponent(final String childComponentNameA, final String childComponentNameB) { + final Optional childComponentA = this.getComponents() + .stream() .filter(x -> x.getEntityName() .equals(childComponentNameA)) .findFirst(); assertTrue(childComponentA.isPresent(), "\"" + childComponentNameA + "\" must exist"); - Optional childComponentB = getComponents().stream() + final Optional childComponentB = this.getComponents() + .stream() .filter(x -> x.getEntityName() .equals(childComponentNameB)) .findFirst(); assertTrue(childComponentB.isPresent(), "\"" + childComponentNameB + "\" must exist"); - List allCompositeComponents = getComponents().stream() + final List allCompositeComponents = this.getComponents() + .stream() .filter(CompositeComponent.class::isInstance) .map(CompositeComponent.class::cast) .collect(Collectors.toList()); assertFalse(allCompositeComponents.isEmpty(), "There must be a composite component"); - Set compositeComponentsA = allCompositeComponents.stream() + final Set compositeComponentsA = allCompositeComponents.stream() .filter(x -> x.getAssemblyContexts__ComposedStructure() .stream() .anyMatch(y -> y.getEncapsulatedComponent__AssemblyContext() @@ -215,7 +222,7 @@ public void assertInSameCompositeComponent(String childComponentNameA, String ch .collect(Collectors.toSet()); assertFalse(compositeComponentsA.isEmpty(), childComponentNameA + " must be part of a composite component"); - Set compositeComponentsB = allCompositeComponents.stream() + final Set compositeComponentsB = allCompositeComponents.stream() .filter(x -> x.getAssemblyContexts__ComposedStructure() .stream() .anyMatch(y -> y.getEncapsulatedComponent__AssemblyContext() @@ -228,17 +235,19 @@ public void assertInSameCompositeComponent(String childComponentNameA, String ch childComponentNameA + " and " + childComponentNameB + " must be part of the same composite component"); } - public void assertComponentProvidesOperation(String componentName, String interfaceName, String operationName) { - Optional component = getComponents().stream() + public void assertComponentProvidesOperation(final String componentName, final String interfaceName, + final String operationName) { + final Optional component = this.getComponents() + .stream() .filter(x -> x.getEntityName() .equals(componentName)) .findFirst(); assertTrue(component.isPresent(), "Component \"" + componentName + "\" must exist"); - List interfaces = getInterfaces(); + final List interfaces = this.getInterfaces(); assertFalse(interfaces.isEmpty(), "an interface must exist in order for a component to provide an operation"); - Set providedObjects = component.get() + final Set providedObjects = component.get() .getProvidedRoles_InterfaceProvidingEntity() .stream() .flatMap(x -> x.eCrossReferences() @@ -246,74 +255,75 @@ public void assertComponentProvidesOperation(String componentName, String interf .collect(Collectors.toSet()); assertFalse(providedObjects.isEmpty(), "\"" + componentName + "\" must provide something"); - Set providedInterfaces = interfaces.stream() + final Set providedInterfaces = interfaces.stream() .filter(providedObjects::contains) .collect(Collectors.toSet()); assertFalse(providedInterfaces.isEmpty(), "\"" + componentName + "\" must provide an interface"); - Set specifiedInterfaces = providedInterfaces.stream() + final Set specifiedInterfaces = providedInterfaces.stream() .filter(x -> x.getEntityName() .equals(interfaceName)) .collect(Collectors.toSet()); assertFalse(specifiedInterfaces.isEmpty(), "\"" + componentName + "\" must provide interface \"" + interfaceName + "\""); - assertOperationExists(interfaceName, operationName); + this.assertOperationExists(interfaceName, operationName); } // Getters - public RuleEngineConfiguration getConfig() { - assertSuccessfulExecution(); - return config; + public RetrieverConfiguration getConfig() { + this.assertSuccessfulExecution(); + return this.config; } public List getComponents() { - assertSuccessfulExecution(); - return Collections.unmodifiableList(repository.getComponents__Repository()); + this.assertSuccessfulExecution(); + return Collections.unmodifiableList(this.repository.getComponents__Repository()); } public List getDatatypes() { - assertSuccessfulExecution(); - return Collections.unmodifiableList(repository.getDataTypes__Repository()); + this.assertSuccessfulExecution(); + return Collections.unmodifiableList(this.repository.getDataTypes__Repository()); } public List getFailuretypes() { - assertSuccessfulExecution(); - return Collections.unmodifiableList(repository.getFailureTypes__Repository()); + this.assertSuccessfulExecution(); + return Collections.unmodifiableList(this.repository.getFailureTypes__Repository()); } public List getInterfaces() { - assertSuccessfulExecution(); - return Collections.unmodifiableList(repository.getInterfaces__Repository()); + this.assertSuccessfulExecution(); + return Collections.unmodifiableList(this.repository.getInterfaces__Repository()); } public Repository getRepository() { - assertSuccessfulExecution(); - assertNotNull(repository); - return repository; + this.assertSuccessfulExecution(); + assertNotNull(this.repository); + return this.repository; } public System getSystem() { - assertSuccessfulExecution(); - assertNotNull(system); - return system; + this.assertSuccessfulExecution(); + assertNotNull(this.system); + return this.system; } public ResourceEnvironment getResourceEnvironment() { - assertSuccessfulExecution(); - assertNotNull(resourceEnvironment); - return resourceEnvironment; + this.assertSuccessfulExecution(); + assertNotNull(this.resourceEnvironment); + return this.resourceEnvironment; } public Allocation getAllocation() { - assertSuccessfulExecution(); - assertNotNull(allocation); - return allocation; + this.assertSuccessfulExecution(); + assertNotNull(this.allocation); + return this.allocation; } - private Set getOperationSignature(String interfaceName, String signatureName) { - return getInterfaces().stream() + private Set getOperationSignature(final String interfaceName, final String signatureName) { + return this.getInterfaces() + .stream() .filter(OperationInterface.class::isInstance) .map(OperationInterface.class::cast) .filter(x -> x.getEntityName() @@ -322,8 +332,8 @@ private Set getOperationSignature(String interfaceName, Stri .stream() .filter(y -> { // Ignore uniqueness postfix - String name = y.getEntityName(); - int postfixStart = name.indexOf('$'); + final String name = y.getEntityName(); + final int postfixStart = name.indexOf('$'); if (postfixStart > -1) { return name.substring(0, postfixStart) .equals(signatureName); @@ -334,17 +344,17 @@ private Set getOperationSignature(String interfaceName, Stri .reduce(new HashSet<>(), Sets::union); } - public RuleEngineBlackboard getBlackboard() { - assertSuccessfulExecution(); - return ruleEngine.getBlackboard(); + public RetrieverBlackboard getBlackboard() { + this.assertSuccessfulExecution(); + return this.retrieverJob.getBlackboard(); } public Set getRules() { - return Collections.unmodifiableSet(rules); + return Collections.unmodifiableSet(this.rules); } - public int getSignatureMaxParameterCount(String interfaceName, String signatureName) { - final Set sigs = getOperationSignature(interfaceName, signatureName); + public int getSignatureMaxParameterCount(final String interfaceName, final String signatureName) { + final Set sigs = this.getOperationSignature(interfaceName, signatureName); return sigs.stream() .map(OperationSignature::getParameters__OperationSignature) .map(List::size) @@ -354,34 +364,34 @@ public int getSignatureMaxParameterCount(String interfaceName, String signatureN // Resource loading protected enum Artifacts { - RULEENGINE, MOCORE, + RETRIEVER, MOCORE, } - protected void loadArtifacts(Artifacts artifacts) { - assertSuccessfulExecution(); + protected void loadArtifacts(final Artifacts artifacts) { + this.assertSuccessfulExecution(); switch (artifacts) { - case RULEENGINE: - repository = ModelLoader.loadRepository(outDir.appendSegment("pcm.repository") + case RETRIEVER: + this.repository = ModelLoader.loadRepository(this.outDir.appendSegment("pcm.repository") .toString()); - system = null; - resourceEnvironment = null; - allocation = null; + this.system = null; + this.resourceEnvironment = null; + this.allocation = null; break; case MOCORE: - String fileName = config.getInputFolder() + String fileName = this.config.getInputFolder() .lastSegment(); if (fileName.isEmpty()) { - fileName = config.getInputFolder() + fileName = this.config.getInputFolder() .trimSegments(1) .lastSegment(); } - String mocoreBase = outDir.appendSegment(fileName) + final String mocoreBase = this.outDir.appendSegment(fileName) .toString() + "."; - repository = ModelLoader.loadRepository(mocoreBase + "repository"); - system = ModelLoader.loadSystem(mocoreBase + "system"); - resourceEnvironment = ModelLoader.loadResourceEnvironment(mocoreBase + "resourceenvironment"); - allocation = ModelLoader.loadAllocation(mocoreBase + "allocation"); + this.repository = ModelLoader.loadRepository(mocoreBase + "repository"); + this.system = ModelLoader.loadSystem(mocoreBase + "system"); + this.resourceEnvironment = ModelLoader.loadResourceEnvironment(mocoreBase + "resourceenvironment"); + this.allocation = ModelLoader.loadAllocation(mocoreBase + "allocation"); break; default: throw new IllegalArgumentException("Unhandled artifact type!"); @@ -390,10 +400,10 @@ protected void loadArtifacts(Artifacts artifacts) { // Template methods - void testRuleEngineRepository() { + void testRetrieverRepository() { } - void testRuleEngineSeff() { + void testRetrieverSeff() { } void testMoCoReRepository() { @@ -414,49 +424,49 @@ void testMoCoReAllocation() { // Tests @Test - void ruleEngineRepository() { - loadArtifacts(Artifacts.RULEENGINE); - testRuleEngineRepository(); + void retrieverRepository() { + this.loadArtifacts(Artifacts.RETRIEVER); + this.testRetrieverRepository(); } @Test - void ruleEngineSeff() { - loadArtifacts(Artifacts.RULEENGINE); - testRuleEngineSeff(); + void retrieverSeff() { + this.loadArtifacts(Artifacts.RETRIEVER); + this.testRetrieverSeff(); } @Test @Disabled("There are no tests for MoCoRe yet") void moCoReRepository() { - loadArtifacts(Artifacts.MOCORE); - testMoCoReRepository(); + this.loadArtifacts(Artifacts.MOCORE); + this.testMoCoReRepository(); } @Test @Disabled("There are no tests for MoCoRe yet") void moCoReSeff() { - loadArtifacts(Artifacts.MOCORE); - testMoCoReSeff(); + this.loadArtifacts(Artifacts.MOCORE); + this.testMoCoReSeff(); } @Test @Disabled("There are no tests for MoCoRe yet") void moCoReSystem() { - loadArtifacts(Artifacts.MOCORE); - testMoCoReSystem(); + this.loadArtifacts(Artifacts.MOCORE); + this.testMoCoReSystem(); } @Test @Disabled("There are no tests for MoCoRe yet") void moCoReResourceEnvironment() { - loadArtifacts(Artifacts.MOCORE); - testMoCoReResourceEnvironment(); + this.loadArtifacts(Artifacts.MOCORE); + this.testMoCoReResourceEnvironment(); } @Test @Disabled("There are no tests for MoCoRe yet") void moCoReAllocation() { - loadArtifacts(Artifacts.MOCORE); - testMoCoReAllocation(); + this.loadArtifacts(Artifacts.MOCORE); + this.testMoCoReAllocation(); } } diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/JaxRsTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/JaxRsTest.java new file mode 100644 index 00000000..19aa288f --- /dev/null +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/JaxRsTest.java @@ -0,0 +1,15 @@ +package org.palladiosimulator.retriever.test.integration; + +import org.palladiosimulator.retriever.extraction.rules.JaxRSRules; + +public class JaxRsTest extends CaseStudyTest { + + protected JaxRsTest() { + super("JaxRsProject", new JaxRSRules()); + } + + @Override + void testRetrieverRepository() { + this.assertComponentExists("jax_rs_AWebService"); + } +} diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/PetclinicTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/PetclinicTest.java new file mode 100644 index 00000000..39499c10 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/PetclinicTest.java @@ -0,0 +1,46 @@ +package org.palladiosimulator.retriever.test.integration; + +import org.junit.jupiter.api.Disabled; +import org.palladiosimulator.retriever.extraction.rules.SpringRules; + +@Disabled("TODO: Currently broken") +public class PetclinicTest extends CaseStudyTest { + + protected PetclinicTest() { + super("external/spring-petclinic-microservices-2.3.6", new SpringRules()); + } + + @Override + void testRetrieverRepository() { + // TODO: Temporarily disabled due to rule changes. + if (this.getClass() != null) { + return; + } + + this.assertComponentExists("org_springframework_samples_petclinic_api_boundary_web_ApiGatewayController"); + + this.assertComponentProvidesOperation("org_springframework_samples_petclinic_vets_web_VetResource", + "/vets-service/vets[GET]", "/vets-service/vets[GET]"); + this.assertComponentProvidesOperation("org_springframework_samples_petclinic_visits_web_VisitResource", + "/visits-service", "/visits-service/pets/visits[GET]"); + this.assertComponentProvidesOperation("org_springframework_samples_petclinic_customers_web_PetResource", + "/customers-service/owners/*/pets", "/customers-service/owners/*/pets[GET]"); + + this.assertMaxParameterCount(2, "/customers-service/owners[PUT]", "/customers-service/owners[PUT]"); + this.assertMaxParameterCount(1, "/api-gateway/api/gateway/owners[GET]", "/api-gateway/api/gateway/owners[GET]"); + + this.assertComponentRequiresComponent("org_springframework_samples_petclinic_customers_web_PetResource", + "org_springframework_samples_petclinic_customers_model_PetRepository"); + this.assertComponentRequiresComponent("org_springframework_samples_petclinic_customers_web_PetResource", + "org_springframework_samples_petclinic_customers_model_OwnerRepository"); + + this.assertInSameCompositeComponent("org_springframework_samples_petclinic_customers_web_PetResource", + "org_springframework_samples_petclinic_customers_model_PetRepository"); + this.assertInSameCompositeComponent("org_springframework_samples_petclinic_customers_web_PetResource", + "org_springframework_samples_petclinic_customers_web_OwnerResource"); + this.assertInSameCompositeComponent("org_springframework_samples_petclinic_visits_web_VisitResource", + "org_springframework_samples_petclinic_visits_model_VisitRepository"); + this.assertInSameCompositeComponent("org_springframework_samples_petclinic_vets_web_VetResource", + "org_springframework_samples_petclinic_vets_model_VetRepository"); + } +} diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/PiggymetricsTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/PiggymetricsTest.java new file mode 100644 index 00000000..5c9613d6 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/PiggymetricsTest.java @@ -0,0 +1,51 @@ +package org.palladiosimulator.retriever.test.integration; + +import org.junit.jupiter.api.Disabled; +import org.palladiosimulator.retriever.extraction.rules.SpringRules; + +@Disabled("TODO: Currently broken") +public class PiggymetricsTest extends CaseStudyTest { + + protected PiggymetricsTest() { + super("external/piggymetrics-spring.version.2.0.3", new SpringRules()); + } + + @Override + void testRetrieverRepository() { + // TODO: Temporarily disabled due to rule changes. + if (this.getClass() != null) { + return; + } + + this.assertComponentExists("com_piggymetrics_account_client_AuthServiceClient"); + this.assertComponentExists("com_piggymetrics_notification_service_NotificationServiceImpl"); + + this.assertComponentProvidesOperation("com_piggymetrics_statistics_controller_StatisticsController", + "/statistics", "/statistics/current"); + this.assertComponentProvidesOperation("com_piggymetrics_account_controller_AccountController", "/accounts", + "/accounts"); + this.assertComponentProvidesOperation("com_piggymetrics_notification_controller_RecipientController", + "/notifications/recipients", "/notifications/recipients"); + + this.assertMaxParameterCount(2, "com_piggymetrics_notification_service_RecipientService", "markNotified"); + + this.assertComponentRequiresComponent("com_piggymetrics_notification_client_AccountServiceClient", + "com_piggymetrics_account_controller_AccountController"); + + this.assertComponentRequiresComponent("com_piggymetrics_auth_service_UserServiceImpl", + "com_piggymetrics_auth_repository_UserRepository"); + this.assertComponentRequiresComponent("com_piggymetrics_notification_controller_RecipientController", + "com_piggymetrics_notification_service_RecipientServiceImpl"); + + this.assertInSameCompositeComponent("com_piggymetrics_notification_controller_RecipientController", + "com_piggymetrics_notification_service_NotificationServiceImpl"); + this.assertInSameCompositeComponent("com_piggymetrics_notification_controller_RecipientController", + "com_piggymetrics_notification_service_RecipientServiceImpl"); + this.assertInSameCompositeComponent("com_piggymetrics_notification_service_NotificationServiceImpl", + "com_piggymetrics_notification_client_AccountServiceClient"); + this.assertInSameCompositeComponent("com_piggymetrics_account_controller_AccountController", + "com_piggymetrics_account_client_AuthServiceClient"); + this.assertInSameCompositeComponent("com_piggymetrics_account_controller_AccountController", + "com_piggymetrics_account_client_StatisticsServiceClient"); + } +} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/SeffAssociationTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/SeffAssociationTest.java similarity index 70% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/SeffAssociationTest.java rename to tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/SeffAssociationTest.java index 61d8e29d..2e73df41 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/SeffAssociationTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/SeffAssociationTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.test.integration; +package org.palladiosimulator.retriever.test.integration; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; @@ -13,11 +13,11 @@ import org.eclipse.jdt.core.dom.TypeDeclaration; import org.junit.jupiter.api.Test; import org.palladiosimulator.pcm.seff.ServiceEffectSpecification; -import org.palladiosimulator.somox.analyzer.rules.blackboard.RuleEngineBlackboard; -import org.palladiosimulator.somox.analyzer.rules.impl.SpringRules; -import org.palladiosimulator.somox.discoverer.JavaDiscoverer; +import org.palladiosimulator.retriever.extraction.blackboard.RetrieverBlackboard; +import org.palladiosimulator.retriever.extraction.discoverers.JavaDiscoverer; +import org.palladiosimulator.retriever.extraction.rules.SpringRules; -public class SeffAssociationTest extends RuleEngineTest { +public class SeffAssociationTest extends CaseStudyTest { SeffAssociationTest() { super("SpringProject", new SpringRules()); @@ -28,11 +28,11 @@ public class SeffAssociationTest extends RuleEngineTest { */ @Test void allAssociationsReferToMethods() { - RuleEngineBlackboard blackboard = getBlackboard(); - Map associations = blackboard.getSeffAssociations(); + final RetrieverBlackboard blackboard = this.getBlackboard(); + final Map associations = blackboard.getSeffAssociations(); - for (Map.Entry association : associations.entrySet()) { - ASTNode astNode = association.getKey(); + for (final Map.Entry association : associations.entrySet()) { + final ASTNode astNode = association.getKey(); assertTrue(astNode instanceof MethodDeclaration, "All ASTNodes in the SEFF/AST associations must be MethodDeclarations"); // SEFF names may have a "$N" suffix after the signature name, where N is a positive @@ -46,11 +46,11 @@ void allAssociationsReferToMethods() { } @Override - void testRuleEngineSeff() { - RuleEngineBlackboard blackboard = getBlackboard(); + void testRetrieverSeff() { + final RetrieverBlackboard blackboard = this.getBlackboard(); @SuppressWarnings("unchecked") - MethodDeclaration methodDeclaration = blackboard + final MethodDeclaration methodDeclaration = blackboard .getDiscoveredFiles(JavaDiscoverer.DISCOVERER_ID, CompilationUnit.class) .values() .stream() @@ -67,7 +67,7 @@ void testRuleEngineSeff() { .findAny() .orElseGet(() -> fail("AController::aMethod must be present in AST")); - Map associations = blackboard.getSeffAssociations(); + final Map associations = blackboard.getSeffAssociations(); // Assume that the SPRING rule detects constructors of components. assertTrue(associations.containsKey(methodDeclaration), diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/SpringTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/SpringTest.java new file mode 100644 index 00000000..f6aaf724 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/SpringTest.java @@ -0,0 +1,15 @@ +package org.palladiosimulator.retriever.test.integration; + +import org.palladiosimulator.retriever.extraction.rules.SpringRules; + +public class SpringTest extends CaseStudyTest { + + protected SpringTest() { + super("SpringProject", new SpringRules()); + } + + @Override + void testRetrieverRepository() { + this.assertComponentExists("spring_AController"); + } +} diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/TeaStoreTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/TeaStoreTest.java new file mode 100644 index 00000000..9195eb69 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/integration/TeaStoreTest.java @@ -0,0 +1,28 @@ +package org.palladiosimulator.retriever.test.integration; + +import org.junit.jupiter.api.Disabled; +import org.palladiosimulator.retriever.extraction.rules.SpringRules; + +@Disabled("TODO: Currently broken") +public class TeaStoreTest extends CaseStudyTest { + + protected TeaStoreTest() { + super("external/TeaStore-1.4.1", new SpringRules()); + } + + @Override + void testRetrieverRepository() { + // TODO: Temporarily disabled due to rule changes. + if (this.getClass() != null) { + return; + } + + this.assertComponentExists("tools_descartes_teastore_auth_security_BCryptProvider"); + this.assertInterfaceExists("tools_descartes_teastore_kieker_probes_records_IPayloadCharacterization"); + + this.assertComponentProvidesOperation("tools_descartes_teastore_recommender_algorithm_AbstractRecommender", + "tools_descartes_teastore_recommender_algorithm_IRecommender", "train"); + this.assertComponentProvidesOperation("tools_descartes_teastore_recommender_algorithm_AbstractRecommender", + "tools_descartes_teastore_recommender_algorithm_IRecommender", "recommendProducts"); + } +} diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/CompositeTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/CompositeTest.java new file mode 100644 index 00000000..003d3b83 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/CompositeTest.java @@ -0,0 +1,215 @@ +package org.palladiosimulator.retriever.test.model; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.List; + +import org.junit.jupiter.api.Test; +import org.palladiosimulator.retriever.extraction.commonalities.CompUnitOrName; +import org.palladiosimulator.retriever.extraction.commonalities.Component; +import org.palladiosimulator.retriever.extraction.commonalities.ComponentBuilder; +import org.palladiosimulator.retriever.extraction.commonalities.Composite; +import org.palladiosimulator.retriever.extraction.commonalities.CompositeBuilder; +import org.palladiosimulator.retriever.extraction.commonalities.EntireInterface; +import org.palladiosimulator.retriever.extraction.commonalities.JavaInterfaceName; +import org.palladiosimulator.retriever.extraction.commonalities.JavaOperationName; +import org.palladiosimulator.retriever.extraction.commonalities.Operation; +import org.palladiosimulator.retriever.extraction.commonalities.OperationInterface; +import org.palladiosimulator.retriever.extraction.commonalities.Provisions; +import org.palladiosimulator.retriever.extraction.commonalities.Requirements; + +public class CompositeTest { + + @Test + void emptyComposite() { + final CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); + final Composite result = compositeBuilder.construct(List.of(), + new Requirements(List.of(), List.of(), List.of()), new Provisions(List.of(), List.of()), List.of()); + + assertTrue(result.parts() + .isEmpty(), "empty composite should have no parts"); + assertTrue(result.requirements() + .isEmpty(), "empty composite should have no requirements"); + assertTrue(result.provisions() + .isEmpty(), "empty composite should have no provisions"); + } + + @Test + void singletonComposite() { + final OperationInterface provision = new Operation(null, new JavaOperationName("Interface", "providedMethod")); + final EntireInterface requirement = new EntireInterface(new JavaInterfaceName("RequiredInterface")); + + final ComponentBuilder componentBuilder = new ComponentBuilder(new CompUnitOrName("Component")); + componentBuilder.provisions() + .add(provision); + componentBuilder.requirements() + .add(requirement); + + final CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); + compositeBuilder.addPart(componentBuilder); + + final List allDependencies = List.of(provision, requirement); + final List visibleProvisions = List.of(provision); + + final Composite result = compositeBuilder.construct(List.of(), + new Requirements(List.of(), allDependencies, visibleProvisions), + new Provisions(List.of(), allDependencies), visibleProvisions); + + assertEquals(1, result.parts() + .size(), "this composite should have exactly one part"); + assertTrue(result.requirements() + .isEmpty(), "this composite should not have requirements"); + assertTrue(result.provisions() + .isEmpty(), "this composite should not have provisions"); + + final Component component = result.parts() + .stream() + .findFirst() + .get(); + assertEquals(1, component.provisions() + .get() + .size(), "this component should only have one provision"); + assertEquals(1, component.requirements() + .get() + .size(), "this component should only have one requirement"); + } + + @Test + void exposingSingletonComposite() { + final OperationInterface provision = new Operation(null, new JavaOperationName("Interface", "providedMethod")); + final EntireInterface requirement = new EntireInterface(new JavaInterfaceName("RequiredInterface")); + + final ComponentBuilder componentBuilder = new ComponentBuilder(new CompUnitOrName("Component")); + componentBuilder.provisions() + .add(provision); + componentBuilder.requirements() + .add(requirement); + + final CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); + compositeBuilder.addPart(componentBuilder); + + final List allDependencies = List.of(provision, requirement); + final List visibleProvisions = List.of(provision); + + final Composite result = compositeBuilder.construct(List.of(), + new Requirements(List.of(requirement), allDependencies, visibleProvisions), + new Provisions(List.of(provision), allDependencies), visibleProvisions); + + assertEquals(1, result.parts() + .size(), "this composite should have exactly one part"); + assertEquals(1, result.requirements() + .size(), "this composite should have exactly one requirement"); + assertEquals(1, result.provisions() + .size(), "this composite should have exactly one provision"); + } + + @Test + void twoComponentComposite() { + final OperationInterface provision1 = new Operation(null, + new JavaOperationName("InterfaceA", "providedMethodA")); + final OperationInterface provision2 = new Operation(null, + new JavaOperationName("InterfaceB", "providedMethodB")); + final EntireInterface requirement1 = new EntireInterface(new JavaInterfaceName("RequiredInterfaceA")); + final EntireInterface requirement2 = new EntireInterface(new JavaInterfaceName("RequiredInterfaceB")); + + final ComponentBuilder componentBuilder1 = new ComponentBuilder(new CompUnitOrName("Component 1")); + componentBuilder1.provisions() + .add(provision1); + componentBuilder1.requirements() + .add(requirement1); + + final ComponentBuilder componentBuilder2 = new ComponentBuilder(new CompUnitOrName("Component 2")); + componentBuilder2.provisions() + .add(provision2); + componentBuilder2.requirements() + .add(requirement2); + + final CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); + compositeBuilder.addPart(componentBuilder1); + compositeBuilder.addPart(componentBuilder2); + + final List allDependencies = List.of(provision1, provision2, requirement1, requirement2); + final List visibleProvisions = List.of(provision1, provision2); + + final Composite result = compositeBuilder.construct(List.of(), + new Requirements(List.of(requirement1, requirement2), allDependencies, visibleProvisions), + new Provisions(List.of(provision1, provision2), allDependencies), visibleProvisions); + + assertEquals(2, result.parts() + .size(), "this composite should have exactly two parts"); + assertEquals(2, result.requirements() + .size(), "this composite should have exactly two requirements"); + assertEquals(2, result.provisions() + .size(), "this composite should have exactly two provisions"); + } + + @Test + void overlappingTwoComponentComposite() { + final OperationInterface provision = new Operation(null, new JavaOperationName("Interface", "providedMethod")); + final EntireInterface requirement = new EntireInterface(new JavaInterfaceName("RequiredInterface")); + final EntireInterface additionalRequirement1 = new EntireInterface(new JavaInterfaceName("RequiredInterfaceA")); + final EntireInterface additionalRequirement2 = new EntireInterface(new JavaInterfaceName("RequiredInterfaceB")); + + final ComponentBuilder componentBuilder1 = new ComponentBuilder(new CompUnitOrName("Component 1")); + componentBuilder1.provisions() + .add(provision); + componentBuilder1.requirements() + .add(requirement); + componentBuilder1.requirements() + .add(additionalRequirement1); + + final ComponentBuilder componentBuilder2 = new ComponentBuilder(new CompUnitOrName("Component 2")); + componentBuilder2.provisions() + .add(provision); + componentBuilder2.requirements() + .add(requirement); + componentBuilder2.requirements() + .add(additionalRequirement2); + + final CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); + compositeBuilder.addPart(componentBuilder1); + compositeBuilder.addPart(componentBuilder2); + + final List allDependencies = List.of(provision, requirement, additionalRequirement1, + additionalRequirement2); + final List visibleProvisions = List.of(provision); + + final Composite result = compositeBuilder.construct(List.of(), + new Requirements(List.of(requirement), allDependencies, visibleProvisions), + new Provisions(List.of(provision), allDependencies), visibleProvisions); + + assertEquals(2, result.parts() + .size(), "this composite should have exactly two parts"); + assertEquals(1, result.requirements() + .size(), "this composite should have exactly one requirement"); + assertEquals(1, result.provisions() + .size(), "this composite should have exactly one provision"); + } + + @Test + void impreciseExposure() { + // TODO: Re-think this test. + final OperationInterface provision = new Operation(null, new JavaOperationName("Interface", "providedMethod")); + final OperationInterface impreciseProvision = new EntireInterface(new JavaInterfaceName("Interface")); + + final ComponentBuilder componentBuilder = new ComponentBuilder(new CompUnitOrName("Component")); + componentBuilder.provisions() + .add(provision); + + final CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); + compositeBuilder.addPart(componentBuilder); + + final List allDependencies = List.of(provision); + final List visibleProvisions = List.of(provision); + + final Composite result = compositeBuilder.construct(List.of(), + new Requirements(List.of(), allDependencies, visibleProvisions), + new Provisions(List.of(impreciseProvision), allDependencies), visibleProvisions); + + assertEquals(1, result.parts() + .size(), "this composite should have exactly one part"); + assertEquals(1, result.provisions() + .size(), "this composite should have exactly one provision"); + } +} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/model/InterfaceTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/InterfaceTest.java similarity index 56% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/model/InterfaceTest.java rename to tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/InterfaceTest.java index 62018bd4..b3794bcf 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/model/InterfaceTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/InterfaceTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.test.model; +package org.palladiosimulator.retriever.test.model; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -11,46 +11,46 @@ import java.util.stream.Collectors; import org.junit.jupiter.api.Test; -import org.palladiosimulator.somox.analyzer.rules.model.Component; -import org.palladiosimulator.somox.analyzer.rules.model.ComponentBuilder; -import org.palladiosimulator.somox.analyzer.rules.model.EntireInterface; -import org.palladiosimulator.somox.analyzer.rules.model.JavaInterfaceName; -import org.palladiosimulator.somox.analyzer.rules.model.JavaOperationName; -import org.palladiosimulator.somox.analyzer.rules.model.Operation; -import org.palladiosimulator.somox.analyzer.rules.model.OperationInterface; -import org.palladiosimulator.somox.analyzer.rules.model.RESTName; +import org.palladiosimulator.retriever.extraction.commonalities.Component; +import org.palladiosimulator.retriever.extraction.commonalities.ComponentBuilder; +import org.palladiosimulator.retriever.extraction.commonalities.EntireInterface; +import org.palladiosimulator.retriever.extraction.commonalities.JavaInterfaceName; +import org.palladiosimulator.retriever.extraction.commonalities.JavaOperationName; +import org.palladiosimulator.retriever.extraction.commonalities.Operation; +import org.palladiosimulator.retriever.extraction.commonalities.OperationInterface; +import org.palladiosimulator.retriever.extraction.commonalities.RESTName; public class InterfaceTest { @Test void singleJavaOperation() { - ComponentBuilder builder = new ComponentBuilder(null); - Operation expectedOperation = new Operation(null, new JavaOperationName("Interface", "method")); + final ComponentBuilder builder = new ComponentBuilder(null); + final Operation expectedOperation = new Operation(null, new JavaOperationName("Interface", "method")); builder.provisions() .add(expectedOperation); - List allDependencies = List.of(expectedOperation); - List visibleProvisions = List.of(expectedOperation); + final List allDependencies = List.of(expectedOperation); + final List visibleProvisions = List.of(expectedOperation); - Component builtComponent = builder.create(allDependencies, visibleProvisions); + final Component builtComponent = builder.create(allDependencies, visibleProvisions); assertTrue(builtComponent.provisions() .containsPartOf(expectedOperation)); - Map> simplifiedProvisions = builtComponent.provisions() + final Map> simplifiedProvisions = builtComponent.provisions() .simplified(); - Set interfaces = simplifiedProvisions.keySet(); + final Set interfaces = simplifiedProvisions.keySet(); assertFalse(interfaces.isEmpty(), "empty result"); assertEquals(1, interfaces.size(), "more than one interface"); - OperationInterface commonInterface = interfaces.stream() + final OperationInterface commonInterface = interfaces.stream() .findFirst() .get(); assertEquals(expectedOperation, commonInterface, "operation does not have the correct interface"); - List operations = simplifiedProvisions.get(expectedOperation); + final List operations = simplifiedProvisions.get(expectedOperation); assertEquals(1, operations.size(), "more than one operation in the interface"); - List firstMethodCandidates = operations.stream() + final List firstMethodCandidates = operations.stream() .filter(x -> Optional.of("method") .equals(x.getName() .forInterface("Interface"))) @@ -63,33 +63,33 @@ void singleJavaOperation() { @Test void singlePathOperation() { - ComponentBuilder builder = new ComponentBuilder(null); - Operation expectedOperation = new Operation(null, new RESTName("test-host", "/method", Optional.empty())); + final ComponentBuilder builder = new ComponentBuilder(null); + final Operation expectedOperation = new Operation(null, new RESTName("test-host", "/method", Optional.empty())); builder.provisions() .add(expectedOperation); - List allDependencies = List.of(expectedOperation); - List visibleProvisions = List.of(expectedOperation); + final List allDependencies = List.of(expectedOperation); + final List visibleProvisions = List.of(expectedOperation); - Component builtComponent = builder.create(allDependencies, visibleProvisions); + final Component builtComponent = builder.create(allDependencies, visibleProvisions); assertTrue(builtComponent.provisions() .containsPartOf(expectedOperation)); - Map> simplifiedProvisions = builtComponent.provisions() + final Map> simplifiedProvisions = builtComponent.provisions() .simplified(); - Set interfaces = simplifiedProvisions.keySet(); + final Set interfaces = simplifiedProvisions.keySet(); assertFalse(interfaces.isEmpty(), "empty result"); assertEquals(1, interfaces.size(), "more than one interface"); - OperationInterface commonInterface = interfaces.stream() + final OperationInterface commonInterface = interfaces.stream() .findFirst() .get(); assertEquals(expectedOperation, commonInterface, "operation does not have the correct interface"); - List operations = simplifiedProvisions.get(commonInterface); + final List operations = simplifiedProvisions.get(commonInterface); assertEquals(1, operations.size(), "more than one operation in the interface"); - List firstMethodCandidates = operations.stream() + final List firstMethodCandidates = operations.stream() .filter(x -> Optional.of("test-host/method") .equals(x.getName() .forInterface("test-host/method"))) @@ -102,37 +102,37 @@ void singlePathOperation() { @Test void entireJavaInterface() { - ComponentBuilder builder = new ComponentBuilder(null); - Operation firstMethod = new Operation(null, new JavaOperationName("CommonInterface", "firstMethod")); - Operation secondMethod = new Operation(null, new JavaOperationName("CommonInterface", "secondMethod")); + final ComponentBuilder builder = new ComponentBuilder(null); + final Operation firstMethod = new Operation(null, new JavaOperationName("CommonInterface", "firstMethod")); + final Operation secondMethod = new Operation(null, new JavaOperationName("CommonInterface", "secondMethod")); builder.provisions() .add(firstMethod); builder.provisions() .add(secondMethod); - List allDependencies = List.of(firstMethod, secondMethod); - List visibleProvisions = List.of(firstMethod, secondMethod); + final List allDependencies = List.of(firstMethod, secondMethod); + final List visibleProvisions = List.of(firstMethod, secondMethod); - Component builtComponent = builder.create(allDependencies, visibleProvisions); - EntireInterface expectedInterface = new EntireInterface(new JavaInterfaceName("CommonInterface")); + final Component builtComponent = builder.create(allDependencies, visibleProvisions); + final EntireInterface expectedInterface = new EntireInterface(new JavaInterfaceName("CommonInterface")); assertTrue(builtComponent.provisions() .containsPartOf(expectedInterface)); - Map> simplifiedProvisions = builtComponent.provisions() + final Map> simplifiedProvisions = builtComponent.provisions() .simplified(); - Set interfaces = simplifiedProvisions.keySet(); + final Set interfaces = simplifiedProvisions.keySet(); assertFalse(interfaces.isEmpty(), "empty result"); assertEquals(1, interfaces.size(), "more than one interface"); - OperationInterface commonInterface = interfaces.stream() + final OperationInterface commonInterface = interfaces.stream() .findFirst() .get(); assertEquals(expectedInterface, commonInterface, "common interface is not correct"); - List operations = simplifiedProvisions.get(commonInterface); + final List operations = simplifiedProvisions.get(commonInterface); assertEquals(2, operations.size(), "wrong number of operations in the interface"); - List firstMethodCandidates = operations.stream() + final List firstMethodCandidates = operations.stream() .filter(x -> Optional.of("firstMethod") .equals(x.getName() .forInterface("CommonInterface"))) @@ -141,7 +141,7 @@ void entireJavaInterface() { assertFalse(firstMethodCandidates.isEmpty(), "interface does not contain first method"); assertEquals(1, firstMethodCandidates.size(), "interface contains multiple instances of first method"); - List secondMethodCandidates = operations.stream() + final List secondMethodCandidates = operations.stream() .filter(x -> Optional.of("secondMethod") .equals(x.getName() .forInterface("CommonInterface"))) @@ -155,40 +155,40 @@ void entireJavaInterface() { @Test void entirePathInterface() { - ComponentBuilder builder = new ComponentBuilder(null); - Operation firstMethod = new Operation(null, + final ComponentBuilder builder = new ComponentBuilder(null); + final Operation firstMethod = new Operation(null, new RESTName("test-host", "/common_interface/first_method", Optional.empty())); - Operation secondMethod = new Operation(null, + final Operation secondMethod = new Operation(null, new RESTName("test-host", "/common_interface/second_method", Optional.empty())); builder.provisions() .add(firstMethod); builder.provisions() .add(secondMethod); - List allDependencies = List.of(firstMethod, secondMethod); - List visibleProvisions = List.of(firstMethod, secondMethod); + final List allDependencies = List.of(firstMethod, secondMethod); + final List visibleProvisions = List.of(firstMethod, secondMethod); - Component builtComponent = builder.create(allDependencies, visibleProvisions); - EntireInterface expectedInterface = new EntireInterface( + final Component builtComponent = builder.create(allDependencies, visibleProvisions); + final EntireInterface expectedInterface = new EntireInterface( new RESTName("test-host", "/common_interface", Optional.empty())); assertTrue(builtComponent.provisions() .containsPartOf(expectedInterface)); - Map> simplifiedProvisions = builtComponent.provisions() + final Map> simplifiedProvisions = builtComponent.provisions() .simplified(); - Set interfaces = simplifiedProvisions.keySet(); + final Set interfaces = simplifiedProvisions.keySet(); assertFalse(interfaces.isEmpty(), "empty result"); assertEquals(1, interfaces.size(), "more than one interface"); - OperationInterface commonInterface = interfaces.stream() + final OperationInterface commonInterface = interfaces.stream() .findFirst() .get(); assertEquals(expectedInterface, commonInterface, "common interface is not correct"); - List operations = simplifiedProvisions.get(commonInterface); + final List operations = simplifiedProvisions.get(commonInterface); assertEquals(2, operations.size(), "wrong number of operations in the interface"); - List firstMethodCandidates = operations.stream() + final List firstMethodCandidates = operations.stream() .filter(x -> Optional.of("test-host/common_interface/first_method") .equals(x.getName() .forInterface("test-host/common_interface"))) @@ -197,7 +197,7 @@ void entirePathInterface() { assertFalse(firstMethodCandidates.isEmpty(), "interface does not contain first method"); assertEquals(1, firstMethodCandidates.size(), "interface contains multiple instances of first method"); - List secondMethodCandidates = operations.stream() + final List secondMethodCandidates = operations.stream() .filter(x -> Optional.of("test-host/common_interface/second_method") .equals(x.getName() .forInterface("test-host/common_interface"))) diff --git a/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/PathTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/PathTest.java new file mode 100644 index 00000000..d589c116 --- /dev/null +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/model/PathTest.java @@ -0,0 +1,61 @@ +package org.palladiosimulator.retriever.test.model; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Optional; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.palladiosimulator.retriever.extraction.commonalities.EntireInterface; +import org.palladiosimulator.retriever.extraction.commonalities.HTTPMethod; +import org.palladiosimulator.retriever.extraction.commonalities.Operation; +import org.palladiosimulator.retriever.extraction.commonalities.RESTName; + +public class PathTest { + + @Test + void pathNamesAreReflective() { + final String host = "test-host"; + final String path = "/some/path"; + final RESTName pathName = new RESTName(host, path, Optional.empty()); + assertTrue(pathName.isPartOf(host + path)); + } + + @Test + void pathsArePartOfTheirPrefixes() { + final String path = "/some/path"; + final RESTName interfaceName = new RESTName("test-host", path, Optional.empty()); + final RESTName specificName = new RESTName("test-host", path + "/that/is/more/specific", Optional.empty()); + + assertTrue(specificName.isPartOf(interfaceName.getName()), "specific path is not part of its prefix"); + assertFalse(interfaceName.isPartOf(specificName.getName()), "prefix is part of a longer path"); + } + + @Test + void prefixesAreSeparatorAware() { + // This is NOT a legal prefix of "/some/path/..." + final String somePath = "/some/pa"; + final EntireInterface entireInterface = new EntireInterface( + new RESTName("test-host", somePath, Optional.empty())); + final RESTName specificPathName = new RESTName("test-host", "/some/path/that/is/more/specific", + Optional.empty()); + final Operation operation = new Operation(null, specificPathName); + + assertFalse(operation.isPartOf(entireInterface), "operation is part of illegal prefix"); + } + + @Disabled("This requirement has been temporarily softened for the Spring Gateway") + @Test + void httpMethodsAreSpecializations() { + final String path = "/some/path"; + final RESTName generalName = new RESTName("test-host", path, Optional.empty()); + final RESTName specificName = new RESTName("test-host", path, Optional.of(HTTPMethod.GET)); + + final Operation generalOperation = new Operation(null, generalName); + final Operation specificOperation = new Operation(null, specificName); + + assertTrue(specificOperation.isPartOf(generalOperation)); + assertFalse(generalOperation.isPartOf(specificOperation)); + } +} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/PersistenceJobTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/PersistenceJobTest.java similarity index 82% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/PersistenceJobTest.java rename to tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/PersistenceJobTest.java index a17322f4..95944769 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/PersistenceJobTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/PersistenceJobTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.test.workflow; +package org.palladiosimulator.retriever.test.workflow; import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; @@ -19,7 +19,7 @@ import org.palladiosimulator.pcm.repository.Repository; import org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment; import org.palladiosimulator.pcm.system.System; -import org.palladiosimulator.somox.analyzer.rules.workflow.PersistenceJob; +import org.palladiosimulator.retriever.core.workflow.PersistenceJob; import de.uka.ipd.sdq.workflow.blackboard.Blackboard; @@ -39,7 +39,7 @@ public void cleanUpDirectories() throws IOException { @Test public void testConstructorWithValidInput() { - Blackboard blackboard = new Blackboard(); + final Blackboard blackboard = new Blackboard<>(); assertDoesNotThrow( () -> new PersistenceJob(blackboard, INPUT_FOLDER, TEMPORARY_OUTPUT_FOLDER, BLACKBOARD_INPUT_REPOSITORY, BLACKBOARD_INPUT_SYSTEM, BLACKBOARD_INPUT_ALLOCATION, BLACKBOARD_INPUT_RESOURCEENVIRONMENT)); @@ -47,20 +47,20 @@ public void testConstructorWithValidInput() { @Test public void testSaveEmptyModelsToCurrentDirectory() { - Blackboard blackboard = new Blackboard(); - PersistenceJob job = new PersistenceJob(blackboard, INPUT_FOLDER, TEMPORARY_OUTPUT_FOLDER, + final Blackboard blackboard = new Blackboard<>(); + final PersistenceJob job = new PersistenceJob(blackboard, INPUT_FOLDER, TEMPORARY_OUTPUT_FOLDER, BLACKBOARD_INPUT_REPOSITORY, BLACKBOARD_INPUT_SYSTEM, BLACKBOARD_INPUT_ALLOCATION, BLACKBOARD_INPUT_RESOURCEENVIRONMENT); // Initialize models - Repository repository = new FluentRepositoryFactory().newRepository() + final Repository repository = new FluentRepositoryFactory().newRepository() .createRepositoryNow(); - System system = new FluentSystemFactory().newSystem() + final System system = new FluentSystemFactory().newSystem() .addRepository(repository) .createSystemNow(); - ResourceEnvironment resource = new FluentResourceEnvironmentFactory().newResourceEnvironment() + final ResourceEnvironment resource = new FluentResourceEnvironmentFactory().newResourceEnvironment() .createResourceEnvironmentNow(); - Allocation allocation = new FluentAllocationFactory().newAllocation() + final Allocation allocation = new FluentAllocationFactory().newAllocation() .createAllocationNow(); // Add models to blackboard diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/PostAnalysisJobTest.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/PostAnalysisJobTest.java similarity index 72% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/PostAnalysisJobTest.java rename to tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/PostAnalysisJobTest.java index 2ea1590f..dda33f56 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/PostAnalysisJobTest.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/PostAnalysisJobTest.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.test.workflow; +package org.palladiosimulator.retriever.test.workflow; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -51,10 +51,10 @@ import org.palladiosimulator.pcm.seff.ServiceEffectSpecification; import org.palladiosimulator.pcm.seff.StartAction; import org.palladiosimulator.pcm.seff.StopAction; -import org.palladiosimulator.somox.analyzer.rules.mocore.workflow.MoCoReJob; -import org.palladiosimulator.somox.analyzer.rules.test.workflow.utility.MethodDeclarationVisitor; -import org.palladiosimulator.somox.analyzer.rules.workflow.PersistenceJob; -import org.palladiosimulator.somox.analyzer.rules.workflow.SeffMergerJob; +import org.palladiosimulator.retriever.core.workflow.PersistenceJob; +import org.palladiosimulator.retriever.core.workflow.SeffMergerJob; +import org.palladiosimulator.retriever.mocore.workflow.MoCoReJob; +import org.palladiosimulator.retriever.test.workflow.utility.MethodDeclarationVisitor; import org.palladiosimulator.somox.ast2seff.jobs.Ast2SeffJob; import com.google.common.collect.HashMultimap; @@ -79,49 +79,50 @@ public class PostAnalysisJobTest { @BeforeEach public void setupEnvironment() throws IOException { - Repository repository = RepositoryFactory.eINSTANCE.createRepository(); - Map ast2seffMap = new HashMap<>(); + final Repository repository = RepositoryFactory.eINSTANCE.createRepository(); + final Map ast2seffMap = new HashMap<>(); - Path directoryPath = Path.of(DIRECTORY_CASESTUDY); - Map compilationUnits = parseCasestudyPackage(directoryPath); + final Path directoryPath = Path.of(DIRECTORY_CASESTUDY); + final Map compilationUnits = this.parseCasestudyPackage(directoryPath); // For each comp. unit fill repository & ast2seff map with correct elements - for (CompilationUnit compilationUnit : compilationUnits.values()) { - List methodDeclarations = MethodDeclarationVisitor.perform(compilationUnit); + for (final CompilationUnit compilationUnit : compilationUnits.values()) { + final List methodDeclarations = MethodDeclarationVisitor.perform(compilationUnit); // Associate method declarations with class names (-> usually single class per comp. // unit) - Multimap classDeclarations = HashMultimap.create(); - for (MethodDeclaration methodDeclaration : methodDeclarations) { - TypeDeclaration typeDeclaration = (TypeDeclaration) methodDeclaration.getParent(); - String className = typeDeclaration.getName() + final Multimap classDeclarations = HashMultimap.create(); + for (final MethodDeclaration methodDeclaration : methodDeclarations) { + final TypeDeclaration typeDeclaration = (TypeDeclaration) methodDeclaration.getParent(); + final String className = typeDeclaration.getName() .toString(); classDeclarations.put(className, methodDeclaration); } // For each class create one component, one interface, associated signatures, & seffs - for (String className : classDeclarations.keySet()) { + for (final String className : classDeclarations.keySet()) { // Create component - BasicComponent component = RepositoryFactory.eINSTANCE.createBasicComponent(); + final BasicComponent component = RepositoryFactory.eINSTANCE.createBasicComponent(); component.setEntityName(className); component.setRepository__RepositoryComponent(repository); // Create operation interface - OperationInterface operationInterface = RepositoryFactory.eINSTANCE.createOperationInterface(); + final OperationInterface operationInterface = RepositoryFactory.eINSTANCE.createOperationInterface(); operationInterface.setEntityName(className + "able"); operationInterface.setRepository__Interface(repository); // Add interface to component via provided role - OperationProvidedRole providedRole = RepositoryFactory.eINSTANCE.createOperationProvidedRole(); + final OperationProvidedRole providedRole = RepositoryFactory.eINSTANCE.createOperationProvidedRole(); providedRole.setProvidedInterface__OperationProvidedRole(operationInterface); component.getProvidedRoles_InterfaceProvidingEntity() .add(providedRole); // Create signatures & Create seffs - for (MethodDeclaration methodDeclaration : classDeclarations.get(className)) { - String methodName = methodDeclaration.getName() + for (final MethodDeclaration methodDeclaration : classDeclarations.get(className)) { + final String methodName = methodDeclaration.getName() .toString(); - OperationSignature operationSignature = RepositoryFactory.eINSTANCE.createOperationSignature(); + final OperationSignature operationSignature = RepositoryFactory.eINSTANCE + .createOperationSignature(); operationSignature.setEntityName(methodName); // Add signature to interface @@ -129,7 +130,7 @@ public void setupEnvironment() throws IOException { .add(operationSignature); // Create seff for signature & add to component - ResourceDemandingSEFF seff = SeffFactory.eINSTANCE.createResourceDemandingSEFF(); + final ResourceDemandingSEFF seff = SeffFactory.eINSTANCE.createResourceDemandingSEFF(); seff.setBasicComponent_ServiceEffectSpecification(component); seff.setDescribedService__SEFF(operationSignature); @@ -140,25 +141,25 @@ public void setupEnvironment() throws IOException { } // Add required roles manually - List> requiredRelations = List.of(Pair.create("EntityService", "EntityRepository"), + final List> requiredRelations = List.of(Pair.create("EntityService", "EntityRepository"), Pair.create("EntityService", "Entity"), Pair.create("EntityRepository", "Entity")); - for (Pair requiredRelation : requiredRelations) { - BasicComponent requirerer = (BasicComponent) repository.getComponents__Repository() + for (final Pair requiredRelation : requiredRelations) { + final BasicComponent requirerer = (BasicComponent) repository.getComponents__Repository() .stream() .filter(component -> component.getEntityName() .equals(requiredRelation.getElement1())) .findFirst() .orElseThrow(); - BasicComponent provider = (BasicComponent) repository.getComponents__Repository() + final BasicComponent provider = (BasicComponent) repository.getComponents__Repository() .stream() .filter(component -> component.getEntityName() .equals(requiredRelation.getElement2())) .findFirst() .orElseThrow(); - OperationInterface providerInterface = ((OperationProvidedRole) provider + final OperationInterface providerInterface = ((OperationProvidedRole) provider .getProvidedRoles_InterfaceProvidingEntity() .get(0)).getProvidedInterface__OperationProvidedRole(); - OperationRequiredRole requiredRole = RepositoryFactory.eINSTANCE.createOperationRequiredRole(); + final OperationRequiredRole requiredRole = RepositoryFactory.eINSTANCE.createOperationRequiredRole(); requiredRole.setRequiredInterface__OperationRequiredRole(providerInterface); requirerer.getRequiredRoles_InterfaceRequiringEntity() .add(requiredRole); @@ -191,21 +192,22 @@ public static void setupOutputDirectory() throws IOException { @Test public void processAnalysedCasestudyWithAst2SeffJob() throws Exception { // Construct & execute job - Ast2SeffJob ast2SeffJob = new Ast2SeffJob(this.getBlackboard(), KEY_SEFF_ASSOCIATIONS, KEY_AST2SEFF_REPOSITORY); + final Ast2SeffJob ast2SeffJob = new Ast2SeffJob(this.getBlackboard(), KEY_SEFF_ASSOCIATIONS, + KEY_AST2SEFF_REPOSITORY); ast2SeffJob.execute(new NullProgressMonitor()); // Get output repo from blackboard & extract all seff elements - Repository outputRepository = (Repository) this.getBlackboard() + final Repository outputRepository = (Repository) this.getBlackboard() .getPartition(KEY_AST2SEFF_REPOSITORY); - List seffs = outputRepository.getComponents__Repository() + final List seffs = outputRepository.getComponents__Repository() .stream() .flatMap(component -> ((BasicComponent) component).getServiceEffectSpecifications__BasicComponent() .stream()) .collect(Collectors.toList()); // Assert all seffs have at least start & stop action - for (ServiceEffectSpecification seff : seffs) { - EList actions = ((ResourceDemandingSEFF) seff).getSteps_Behaviour(); + for (final ServiceEffectSpecification seff : seffs) { + final EList actions = ((ResourceDemandingSEFF) seff).getSteps_Behaviour(); assertTrue(actions.size() >= 2); assertTrue(actions.stream() .anyMatch(action -> action instanceof StartAction)); @@ -217,20 +219,21 @@ public void processAnalysedCasestudyWithAst2SeffJob() throws Exception { @Test public void mergeAst2SeffOutputWithRepository() throws Exception { // Construct jobs - Ast2SeffJob ast2SeffJob = new Ast2SeffJob(this.getBlackboard(), KEY_SEFF_ASSOCIATIONS, KEY_AST2SEFF_REPOSITORY); - SeffMergerJob seffMergerJob = new SeffMergerJob(this.getBlackboard(), KEY_AST2SEFF_REPOSITORY, + final Ast2SeffJob ast2SeffJob = new Ast2SeffJob(this.getBlackboard(), KEY_SEFF_ASSOCIATIONS, + KEY_AST2SEFF_REPOSITORY); + final SeffMergerJob seffMergerJob = new SeffMergerJob(this.getBlackboard(), KEY_AST2SEFF_REPOSITORY, KEY_ANALYSIS_REPOSITORY); // Assert empty seffs in analysis repository - Repository analysisRepository = (Repository) this.getBlackboard() + final Repository analysisRepository = (Repository) this.getBlackboard() .getPartition(KEY_ANALYSIS_REPOSITORY); List analysisRepositorySeffs = analysisRepository.getComponents__Repository() .stream() .flatMap(component -> ((BasicComponent) component).getServiceEffectSpecifications__BasicComponent() .stream()) .collect(Collectors.toList()); - for (ServiceEffectSpecification seff : analysisRepositorySeffs) { - EList actions = ((ResourceDemandingSEFF) seff).getSteps_Behaviour(); + for (final ServiceEffectSpecification seff : analysisRepositorySeffs) { + final EList actions = ((ResourceDemandingSEFF) seff).getSteps_Behaviour(); assertTrue(actions.isEmpty()); } @@ -244,8 +247,8 @@ public void mergeAst2SeffOutputWithRepository() throws Exception { .flatMap(component -> ((BasicComponent) component).getServiceEffectSpecifications__BasicComponent() .stream()) .collect(Collectors.toList()); - for (ServiceEffectSpecification seff : analysisRepositorySeffs) { - EList actions = ((ResourceDemandingSEFF) seff).getSteps_Behaviour(); + for (final ServiceEffectSpecification seff : analysisRepositorySeffs) { + final EList actions = ((ResourceDemandingSEFF) seff).getSteps_Behaviour(); assertTrue(actions.size() >= 2); assertTrue(actions.stream() .anyMatch(action -> action instanceof StartAction)); @@ -257,10 +260,11 @@ public void mergeAst2SeffOutputWithRepository() throws Exception { @Test public void refineIntermediateRepository() throws Exception { // Construct jobs - Ast2SeffJob ast2SeffJob = new Ast2SeffJob(this.getBlackboard(), KEY_SEFF_ASSOCIATIONS, KEY_AST2SEFF_REPOSITORY); - SeffMergerJob seffMergerJob = new SeffMergerJob(this.getBlackboard(), KEY_AST2SEFF_REPOSITORY, + final Ast2SeffJob ast2SeffJob = new Ast2SeffJob(this.getBlackboard(), KEY_SEFF_ASSOCIATIONS, + KEY_AST2SEFF_REPOSITORY); + final SeffMergerJob seffMergerJob = new SeffMergerJob(this.getBlackboard(), KEY_AST2SEFF_REPOSITORY, KEY_ANALYSIS_REPOSITORY); - MoCoReJob mocoreJob = new MoCoReJob(this.getBlackboard(), KEY_ANALYSIS_REPOSITORY, KEY_MOCORE_REPOSITORY, + final MoCoReJob mocoreJob = new MoCoReJob(this.getBlackboard(), KEY_ANALYSIS_REPOSITORY, KEY_MOCORE_REPOSITORY, KEY_MOCORE_SYSTEM, KEY_MOCORE_ALLOCATION, KEY_MOCORE_RESOURCE_ENVIRONMENT); // Execute jobs @@ -269,13 +273,14 @@ public void refineIntermediateRepository() throws Exception { mocoreJob.execute(new NullProgressMonitor()); // Fetch output models from blackboard - Repository repository = (Repository) this.getBlackboard() + final Repository repository = (Repository) this.getBlackboard() .getPartition(KEY_MOCORE_REPOSITORY); - org.palladiosimulator.pcm.system.System system = (org.palladiosimulator.pcm.system.System) this.getBlackboard() + final org.palladiosimulator.pcm.system.System system = (org.palladiosimulator.pcm.system.System) this + .getBlackboard() .getPartition(KEY_MOCORE_SYSTEM); - Allocation allocation = (Allocation) this.getBlackboard() + final Allocation allocation = (Allocation) this.getBlackboard() .getPartition(KEY_MOCORE_ALLOCATION); - ResourceEnvironment resourceEnvironment = (ResourceEnvironment) this.getBlackboard() + final ResourceEnvironment resourceEnvironment = (ResourceEnvironment) this.getBlackboard() .getPartition(KEY_MOCORE_RESOURCE_ENVIRONMENT); // Check repository validity @@ -285,13 +290,13 @@ public void refineIntermediateRepository() throws Exception { .size()); repository.getInterfaces__Repository() .forEach(interFace -> { - OperationInterface operationInterface = (OperationInterface) interFace; + final OperationInterface operationInterface = (OperationInterface) interFace; assertFalse(operationInterface.getSignatures__OperationInterface() .isEmpty()); }); repository.getComponents__Repository() .forEach(component -> { - BasicComponent basicComponent = (BasicComponent) component; + final BasicComponent basicComponent = (BasicComponent) component; assertFalse(basicComponent.getServiceEffectSpecifications__BasicComponent() .isEmpty()); assertFalse(basicComponent.getProvidedRoles_InterfaceProvidingEntity() @@ -322,14 +327,15 @@ public void refineIntermediateRepository() throws Exception { @Test public void persistModels() throws Exception { // Construct jobs - Ast2SeffJob ast2SeffJob = new Ast2SeffJob(this.getBlackboard(), KEY_SEFF_ASSOCIATIONS, KEY_AST2SEFF_REPOSITORY); - SeffMergerJob seffMergerJob = new SeffMergerJob(this.getBlackboard(), KEY_AST2SEFF_REPOSITORY, + final Ast2SeffJob ast2SeffJob = new Ast2SeffJob(this.getBlackboard(), KEY_SEFF_ASSOCIATIONS, + KEY_AST2SEFF_REPOSITORY); + final SeffMergerJob seffMergerJob = new SeffMergerJob(this.getBlackboard(), KEY_AST2SEFF_REPOSITORY, KEY_ANALYSIS_REPOSITORY); - MoCoReJob mocoreJob = new MoCoReJob(this.getBlackboard(), KEY_ANALYSIS_REPOSITORY, KEY_MOCORE_REPOSITORY, + final MoCoReJob mocoreJob = new MoCoReJob(this.getBlackboard(), KEY_ANALYSIS_REPOSITORY, KEY_MOCORE_REPOSITORY, KEY_MOCORE_SYSTEM, KEY_MOCORE_ALLOCATION, KEY_MOCORE_RESOURCE_ENVIRONMENT); - URI inputDirectory = URI.createURI(DIRECTORY_CASESTUDY); - URI outputDirectory = URI.createURI(this.temporaryOutputDirectory.toString()); - PersistenceJob persistenceJob = new PersistenceJob(this.getBlackboard(), inputDirectory, outputDirectory, + final URI inputDirectory = URI.createURI(DIRECTORY_CASESTUDY); + final URI outputDirectory = URI.createURI(this.temporaryOutputDirectory.toString()); + final PersistenceJob persistenceJob = new PersistenceJob(this.getBlackboard(), inputDirectory, outputDirectory, KEY_MOCORE_REPOSITORY, KEY_MOCORE_SYSTEM, KEY_MOCORE_ALLOCATION, KEY_MOCORE_RESOURCE_ENVIRONMENT); // Execute jobs @@ -339,35 +345,35 @@ public void persistModels() throws Exception { persistenceJob.execute(new NullProgressMonitor()); // Check if model files were created successfully - List paths = Files.walk(this.temporaryOutputDirectory) + final List paths = Files.walk(this.temporaryOutputDirectory) .toList(); - Path repositoryPath = paths.stream() + final Path repositoryPath = paths.stream() .filter(path -> com.google.common.io.Files.getFileExtension(path.toString()) .equals("repository")) .findFirst() .orElseThrow(); - Path systemPath = paths.stream() + final Path systemPath = paths.stream() .filter(path -> com.google.common.io.Files.getFileExtension(path.toString()) .equals("system")) .findFirst() .orElseThrow(); - Path resourceEnvironmentPath = paths.stream() + final Path resourceEnvironmentPath = paths.stream() .filter(path -> com.google.common.io.Files.getFileExtension(path.toString()) .equals("resourceenvironment")) .findFirst() .orElseThrow(); - Path allocationPath = paths.stream() + final Path allocationPath = paths.stream() .filter(path -> com.google.common.io.Files.getFileExtension(path.toString()) .equals("allocation")) .findFirst() .orElseThrow(); // Load model files saved to disk - Repository persistedRepository = ModelLoader.loadRepository(repositoryPath.toString()); - org.palladiosimulator.pcm.system.System persistedSystem = ModelLoader.loadSystem(systemPath.toString()); - ResourceEnvironment persistedResourceEnvironment = ModelLoader + final Repository persistedRepository = ModelLoader.loadRepository(repositoryPath.toString()); + final org.palladiosimulator.pcm.system.System persistedSystem = ModelLoader.loadSystem(systemPath.toString()); + final ResourceEnvironment persistedResourceEnvironment = ModelLoader .loadResourceEnvironment(resourceEnvironmentPath.toString()); - Allocation persistedAllocation = ModelLoader.loadAllocation(allocationPath.toString()); + final Allocation persistedAllocation = ModelLoader.loadAllocation(allocationPath.toString()); // Check loaded repository validity assertEquals(3, persistedRepository.getComponents__Repository() @@ -376,13 +382,13 @@ public void persistModels() throws Exception { .size()); persistedRepository.getInterfaces__Repository() .forEach(interFace -> { - OperationInterface operationInterface = (OperationInterface) interFace; + final OperationInterface operationInterface = (OperationInterface) interFace; assertFalse(operationInterface.getSignatures__OperationInterface() .isEmpty()); }); persistedRepository.getComponents__Repository() .forEach(component -> { - BasicComponent basicComponent = (BasicComponent) component; + final BasicComponent basicComponent = (BasicComponent) component; assertFalse(basicComponent.getServiceEffectSpecifications__BasicComponent() .isEmpty()); assertFalse(basicComponent.getProvidedRoles_InterfaceProvidingEntity() @@ -399,7 +405,7 @@ public void persistModels() throws Exception { // correctly persistedSystem.getAssemblyContexts__ComposedStructure() .forEach(assemblyContext -> { - BasicComponent basicComponent = (BasicComponent) assemblyContext + final BasicComponent basicComponent = (BasicComponent) assemblyContext .getEncapsulatedComponent__AssemblyContext(); assertFalse(basicComponent.getServiceEffectSpecifications__BasicComponent() .isEmpty()); @@ -425,7 +431,7 @@ public void persistModels() throws Exception { // resolved correctly persistedAllocation.getAllocationContexts_Allocation() .forEach(allocationContext -> { - BasicComponent basicComponent = (BasicComponent) allocationContext + final BasicComponent basicComponent = (BasicComponent) allocationContext .getAssemblyContext_AllocationContext() .getEncapsulatedComponent__AssemblyContext(); assertFalse(basicComponent.getServiceEffectSpecifications__BasicComponent() @@ -439,10 +445,10 @@ protected Blackboard getBlackboard() { return this.blackboard; } - private Map parseCasestudyPackage(Path directory) { - ASTParser parser = getASTParser(); - String[] classpathEntries = getEntries(directory, ".jar"); - final String[] sources = getEntries(directory, ".java"); + private Map parseCasestudyPackage(final Path directory) { + final ASTParser parser = this.getASTParser(); + final String[] classpathEntries = this.getEntries(directory, ".jar"); + final String[] sources = this.getEntries(directory, ".java"); final String[] encodings = new String[sources.length]; Arrays.fill(encodings, StandardCharsets.UTF_8.toString()); final Map compilationUnits = new HashMap<>(); @@ -461,7 +467,7 @@ public void acceptAST(final String sourceFilePath, final CompilationUnit ast) { } private ASTParser getASTParser() { - String javaCoreVersion = JavaCore.latestSupportedJavaVersion(); + final String javaCoreVersion = JavaCore.latestSupportedJavaVersion(); final ASTParser parser = ASTParser.newParser(AST.getJLSLatest()); parser.setResolveBindings(true); parser.setBindingsRecovery(true); @@ -471,7 +477,7 @@ private ASTParser getASTParser() { return parser; } - private String[] getEntries(Path directory, String suffix) { + private String[] getEntries(final Path directory, final String suffix) { try (Stream paths = Files.walk(directory)) { return paths.filter(path -> Files.isRegularFile(path) && path.getFileName() .toString() diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/casestudy/Entity.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/Entity.java similarity index 51% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/casestudy/Entity.java rename to tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/Entity.java index 464edb97..94ea3bfd 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/casestudy/Entity.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/Entity.java @@ -1,13 +1,13 @@ -package org.palladiosimulator.somox.analyzer.rules.test.workflow.casestudy; +package org.palladiosimulator.retriever.test.workflow.casestudy; public class Entity { private final String identifier; - public Entity(String identifier) { + public Entity(final String identifier) { this.identifier = identifier; } public String getIdentifier() { - return identifier; + return this.identifier; } } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/casestudy/EntityRepository.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/EntityRepository.java similarity index 60% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/casestudy/EntityRepository.java rename to tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/EntityRepository.java index e00229eb..a23fbfa4 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/casestudy/EntityRepository.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/EntityRepository.java @@ -1,13 +1,13 @@ -package org.palladiosimulator.somox.analyzer.rules.test.workflow.casestudy; +package org.palladiosimulator.retriever.test.workflow.casestudy; public class EntityRepository { private static int identifierCounter = Integer.MIN_VALUE; - public Entity findByIdentifier(String identifier) { + public Entity findByIdentifier(final String identifier) { return new Entity(identifier); } - public Entity persist(Entity entity) { + public Entity persist(final Entity entity) { if (entity.getIdentifier() == null) { return new Entity(String.valueOf(identifierCounter++)); } else { @@ -15,7 +15,7 @@ public Entity persist(Entity entity) { } } - public boolean remove(Entity entity) { + public boolean remove(final Entity entity) { return true; } } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/casestudy/EntityService.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/EntityService.java similarity index 54% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/casestudy/EntityService.java rename to tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/EntityService.java index 0f71e896..aa004a43 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/casestudy/EntityService.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/casestudy/EntityService.java @@ -1,21 +1,21 @@ -package org.palladiosimulator.somox.analyzer.rules.test.workflow.casestudy; +package org.palladiosimulator.retriever.test.workflow.casestudy; public class EntityService { private final EntityRepository entityRepository; - public EntityService(EntityRepository entityRepository) { + public EntityService(final EntityRepository entityRepository) { this.entityRepository = entityRepository; } - public Entity get(String identifier) { + public Entity get(final String identifier) { return this.entityRepository.findByIdentifier(identifier); } - public Entity save(Entity entity) { + public Entity save(final Entity entity) { return this.entityRepository.persist(entity); } - public void delete(Entity entity) { + public void delete(final Entity entity) { this.entityRepository.remove(entity); } } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/utility/MethodDeclarationVisitor.java b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/utility/MethodDeclarationVisitor.java similarity index 65% rename from tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/utility/MethodDeclarationVisitor.java rename to tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/utility/MethodDeclarationVisitor.java index fc338262..b66febab 100644 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/workflow/utility/MethodDeclarationVisitor.java +++ b/tests/org.palladiosimulator.retriever.test/src/org/palladiosimulator/retriever/test/workflow/utility/MethodDeclarationVisitor.java @@ -1,4 +1,4 @@ -package org.palladiosimulator.somox.analyzer.rules.test.workflow.utility; +package org.palladiosimulator.retriever.test.workflow.utility; import java.util.ArrayList; import java.util.Collections; @@ -11,19 +11,19 @@ public final class MethodDeclarationVisitor extends ASTVisitor { private final List declarations = new ArrayList<>(); - public static List perform(ASTNode node) { - MethodDeclarationVisitor visitor = new MethodDeclarationVisitor(); + public static List perform(final ASTNode node) { + final MethodDeclarationVisitor visitor = new MethodDeclarationVisitor(); node.accept(visitor); return visitor.getMethods(); } @Override public boolean visit(final MethodDeclaration method) { - declarations.add(method); + this.declarations.add(method); return super.visit(method); } public List getMethods() { - return Collections.unmodifiableList(declarations); + return Collections.unmodifiableList(this.declarations); } } diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/.classpath b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/.classpath deleted file mode 100644 index 3628e336..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/discovery/RepositoryDecompositorTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/discovery/RepositoryDecompositorTest.java deleted file mode 100644 index 0c0e02d9..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/discovery/RepositoryDecompositorTest.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.discovery; - -import static org.junit.Assert.assertTrue; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.junit.jupiter.api.Test; -import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; -import org.palladiosimulator.pcm.repository.Repository; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.AtomicComponent; - -import tools.mdsd.mocore.framework.discovery.Discoverer; - -@SuppressWarnings("unchecked") -public class RepositoryDecompositorTest extends DecompositorTest { - @Test - public void testDecomposeEmptyRepository() { - RepositoryDecompositor decompositor = createDecompositor(); - Repository repository = createEmptyRepository(); - - Collection> discoverers = decompositor.decompose(repository); - assertEquals(10, discoverers.size()); - discoverers.forEach((discoverer) -> assertTrue(discoverer.getDiscoveries().isEmpty())); - } - - @Test - public void testDecomposeUncoupledComponents() { - RepositoryDecompositor decompositor = createDecompositor(); - FluentRepositoryFactory factory = new FluentRepositoryFactory(); - Repository repository = factory.newRepository() - .addToRepository(factory.newBasicComponent().withName("Component_1")) - .addToRepository(factory.newBasicComponent().withName("Component_2")) - .addToRepository(factory.newBasicComponent().withName("Component_3")) - .addToRepository(factory.newBasicComponent().withName("Component_4")) - .addToRepository(factory.newBasicComponent().withName("Component_5")) - .createRepositoryNow(); - - Collection> discoverers = decompositor.decompose(repository); - assertFalse(discoverers.isEmpty()); - - // Remove all discoverers except component discoverer - List> modifiableDiscoverers = new ArrayList<>(discoverers); - modifiableDiscoverers.removeIf((discoverer) -> discoverer.getDiscoveryType() != AtomicComponent.class); - assertEquals(1, modifiableDiscoverers.size()); - - // Get and check component discoverer - Discoverer componentDiscoverer = (Discoverer) modifiableDiscoverers.iterator() - .next(); - assertEquals(5, componentDiscoverer.getDiscoveries().size()); - for (int i = 1; i <= 5; i++) { - final int j = i; - assertTrue(componentDiscoverer.getDiscoveries().stream() - .anyMatch((AtomicComponent component) -> component.getValue().getEntityName() - .equals("Component_" + j))); - } - } - - // TODO Add tests for interface, signatures, seff, and all relevant relations - // TODO Add tests for composition, delegation - - @Override - protected RepositoryDecompositor createDecompositor() { - return new RepositoryDecompositor(); - } - - @Override - protected Repository createValidSource() { - return createEmptyRepository(); - } - - private Repository createEmptyRepository() { - return new FluentRepositoryFactory().newRepository().createRepositoryNow(); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/orchestration/PcmOrchestratorTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/orchestration/PcmOrchestratorTest.java deleted file mode 100644 index b85a276a..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/orchestration/PcmOrchestratorTest.java +++ /dev/null @@ -1,138 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.orchestration; - -import static org.junit.Assert.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.List; -import java.util.stream.Stream; - -import org.junit.jupiter.api.Test; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.LinkResourceSpecification; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Signature; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAllocationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAssemblyRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.DeploymentDeploymentRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceRequirementRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.LinkResourceSpecificationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.SignatureProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.utility.ElementFactory; - -public class PcmOrchestratorTest { - @Test - public void testExistsComponentAfterProcess() { - PcmOrchestrator orchestrator = new PcmOrchestrator(); - Component component = ElementFactory.createUniqueComponent(false); - orchestrator.processDiscovery(component); - assertTrue(orchestrator.getModel().contains(component)); - } - - @Test - public void testExistImplicitReplaceablesAfterProcess() { - PcmOrchestrator orchestrator = new PcmOrchestrator(); - Component component = ElementFactory.createUniqueComponent(false); - orchestrator.processDiscovery(component); - - PcmSurrogate model = orchestrator.getModel(); - List deployments = model.getByType(Deployment.class); - Stream componentDeploymentRelations = model - .getByType(ComponentAllocationRelation.class).stream(); - - // Assertions - assertTrue(model.contains(component)); - assertTrue(componentDeploymentRelations.anyMatch(element -> element.getSource().equals(component))); - assertFalse(deployments.isEmpty()); - } - - @Test - public void testExistsDeploymentAfterProcess() { - PcmOrchestrator orchestrator = new PcmOrchestrator(); - Deployment deployment = ElementFactory.createUniqueDeployment(false); - orchestrator.processDiscovery(deployment); - assertTrue(orchestrator.getModel().contains(deployment)); - } - - @Test - public void testChainReplacementOfPlaceholders() { - // Test data - PcmOrchestrator orchestrator = new PcmOrchestrator(); - - //// Create concrete & placeholder elements - Signature concreteSignature = ElementFactory.createUniqueSignature(false); - Interface concreteInterface = ElementFactory.createUniqueInterface(false); - Component concreteComponent = ElementFactory.createUniqueComponent(false); - Deployment concreteDeployment = ElementFactory.createUniqueDeployment(false); - Interface placeholderInterface = Interface.getUniquePlaceholder(); - Component placeholderComponent = Component.getUniquePlaceholder(); - Deployment placeholderDeployment = Deployment.getUniquePlaceholder(); - - //// Create non-conflicting relations between elements - SignatureProvisionRelation placeholderSignatureProvision = new SignatureProvisionRelation(concreteSignature, - placeholderInterface, true); - InterfaceProvisionRelation placeholderInterfaceProvision = new InterfaceProvisionRelation(placeholderComponent, - placeholderInterface, true); - ComponentAllocationRelation placeholderAllocation = new ComponentAllocationRelation(placeholderComponent, - placeholderDeployment, true); - InterfaceProvisionRelation concreteInterfaceProvision = new InterfaceProvisionRelation(concreteComponent, - concreteInterface, false); - ComponentAllocationRelation concreteAllocation = new ComponentAllocationRelation(concreteComponent, - concreteDeployment, false); - - //// Create relation leading to chain replacement - SignatureProvisionRelation signatureProvisionRelation = new SignatureProvisionRelation(concreteSignature, - concreteInterface, false); - - //// Add entities to model - PcmSurrogate model = orchestrator.getModel(); - model.add(concreteSignature); - model.add(concreteInterface); - model.add(concreteComponent); - model.add(concreteDeployment); - model.add(concreteInterfaceProvision); - model.add(concreteAllocation); - model.add(placeholderInterface); - model.add(placeholderComponent); - model.add(placeholderDeployment); - model.add(placeholderSignatureProvision); - model.add(placeholderInterfaceProvision); - model.add(placeholderAllocation); - - // Execution - orchestrator.processDiscovery(signatureProvisionRelation); - - // Assertions: Post-execution - assertTrue(model.contains(concreteSignature)); - assertTrue(model.contains(concreteInterface)); - assertTrue(model.contains(concreteComponent)); - assertTrue(model.contains(concreteDeployment)); - assertTrue(model.contains(signatureProvisionRelation)); - assertTrue(model.contains(concreteInterfaceProvision)); - assertTrue(model.contains(concreteAllocation)); - - assertFalse(model.contains(placeholderInterface)); - assertFalse(model.contains(placeholderComponent)); - assertFalse(model.contains(placeholderDeployment)); - assertFalse(model.contains(placeholderSignatureProvision)); - assertFalse(model.contains(placeholderInterfaceProvision)); - assertFalse(model.contains(placeholderAllocation)); - - assertEquals(1, model.getByType(Signature.class).size()); - assertEquals(1, model.getByType(Interface.class).size()); - assertEquals(1, model.getByType(Component.class).size()); - assertEquals(1, model.getByType(Deployment.class).size()); - assertEquals(0, model.getByType(LinkResourceSpecification.class).size()); - - assertEquals(1, model.getByType(SignatureProvisionRelation.class).size()); - assertEquals(1, model.getByType(InterfaceProvisionRelation.class).size()); - assertEquals(0, model.getByType(InterfaceRequirementRelation.class).size()); - assertEquals(1, model.getByType(ComponentAllocationRelation.class).size()); - assertEquals(0, model.getByType(ComponentAssemblyRelation.class).size()); - assertEquals(0, model.getByType(DeploymentDeploymentRelation.class).size()); - assertEquals(0, model.getByType(LinkResourceSpecificationRelation.class).size()); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentAllocationRelationProcessorTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentAllocationRelationProcessorTest.java deleted file mode 100644 index 15b00723..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentAllocationRelationProcessorTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAllocationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.utility.ElementFactory; - -import tools.mdsd.mocore.framework.processor.RelationProcessorTest; - -public class ComponentAllocationRelationProcessorTest - extends RelationProcessorTest, Deployment> { - @Override - protected ComponentAllocationRelation createRelation(Component source, Deployment destination, - boolean isPlaceholder) { - return new ComponentAllocationRelation(source, destination, isPlaceholder); - } - - @Override - protected Component getUniqueNonPlaceholderSourceEntity() { - return ElementFactory.createUniqueComponent(false); - } - - @Override - protected Component getPlaceholderOfSourceEntity(Component source) { - return new Component<>(source.getValue(), true); - } - - @Override - protected Deployment getUniqueNonPlaceholderDestinationEntity() { - return ElementFactory.createUniqueDeployment(false); - } - - @Override - protected Deployment getPlaceholderOfDestinationEntity(Deployment destination) { - return new Deployment(destination.getValue(), true); - } - - @Override - protected ComponentAllocationRelationProcessor createProcessor(PcmSurrogate model) { - return new ComponentAllocationRelationProcessor(model); - } - - @Override - protected PcmSurrogate createEmptyModel() { - return new PcmSurrogate(); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentSignatureProvisionRelationProcessorTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentSignatureProvisionRelationProcessorTest.java deleted file mode 100644 index a486c07b..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ComponentSignatureProvisionRelationProcessorTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Signature; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentSignatureProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.SignatureProvisionRelation; - -import tools.mdsd.mocore.framework.processor.RelationProcessorTest; - -public class ComponentSignatureProvisionRelationProcessorTest - extends RelationProcessorTest { - private static final Interface RELATION_INTERFACE = Interface.getUniquePlaceholder(); - - @Override - protected ComponentSignatureProvisionRelation createRelation(InterfaceProvisionRelation source, - SignatureProvisionRelation destination, boolean isPlaceholder) { - return new ComponentSignatureProvisionRelation(source, destination, isPlaceholder); - } - - @Override - protected InterfaceProvisionRelation getUniqueNonPlaceholderSourceEntity() { - Component source = Component.getUniquePlaceholder(); - return new InterfaceProvisionRelation(source, RELATION_INTERFACE, false); - } - - @Override - protected InterfaceProvisionRelation getPlaceholderOfSourceEntity(InterfaceProvisionRelation source) { - return new InterfaceProvisionRelation(source.getSource(), source.getDestination(), true); - } - - @Override - protected SignatureProvisionRelation getUniqueNonPlaceholderDestinationEntity() { - Signature signature = Signature.getUniquePlaceholder(); - return new SignatureProvisionRelation(signature, RELATION_INTERFACE, false); - } - - @Override - protected SignatureProvisionRelation getPlaceholderOfDestinationEntity(SignatureProvisionRelation destination) { - return new SignatureProvisionRelation(destination.getSource(), destination.getDestination(), true); - } - - @Override - protected ComponentSignatureProvisionRelationProcessor createProcessor(PcmSurrogate model) { - return new ComponentSignatureProvisionRelationProcessor(model); - } - - @Override - protected PcmSurrogate createEmptyModel() { - return new PcmSurrogate(); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositionRelationProcessorTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositionRelationProcessorTest.java deleted file mode 100644 index f069b4fd..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/CompositionRelationProcessorTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Composite; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.utility.ElementFactory; - -import tools.mdsd.mocore.framework.processor.RelationProcessorTest; - -public class CompositionRelationProcessorTest extends RelationProcessorTest> { - @Override - protected CompositionRelation createRelation(Composite source, Component destination, - boolean isPlaceholder) { - return new CompositionRelation(source, destination, isPlaceholder); - } - - @Override - protected Composite getUniqueNonPlaceholderSourceEntity() { - return ElementFactory.createUniqueComposite(false); - } - - @Override - protected Composite getPlaceholderOfSourceEntity(Composite source) { - return new Composite(source.getValue(), true); - } - - @Override - protected Component getUniqueNonPlaceholderDestinationEntity() { - return ElementFactory.createUniqueComponent(false); - } - - @Override - protected Component getPlaceholderOfDestinationEntity(Component destination) { - return new Component<>(destination.getValue(), true); - } - - @Override - protected CompositionRelationProcessor createProcessor(PcmSurrogate model) { - return new CompositionRelationProcessor(model); - } - - @Override - protected PcmSurrogate createEmptyModel() { - return new PcmSurrogate(); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/InterfaceProvisionRelationProcessorTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/InterfaceProvisionRelationProcessorTest.java deleted file mode 100644 index edf39b11..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/InterfaceProvisionRelationProcessorTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.utility.ElementFactory; - -import tools.mdsd.mocore.framework.processor.RelationProcessorTest; - -public class InterfaceProvisionRelationProcessorTest extends RelationProcessorTest, Interface> { - @Override - protected InterfaceProvisionRelation createRelation(Component source, Interface destination, - boolean isPlaceholder) { - return new InterfaceProvisionRelation(source, destination, isPlaceholder); - } - - @Override - protected Component getUniqueNonPlaceholderSourceEntity() { - return ElementFactory.createUniqueComponent(false); - } - - @Override - protected Component getPlaceholderOfSourceEntity(Component source) { - return new Component<>(source.getValue(), true); - } - - @Override - protected Interface getUniqueNonPlaceholderDestinationEntity() { - return ElementFactory.createUniqueInterface(false); - } - - @Override - protected Interface getPlaceholderOfDestinationEntity(Interface destination) { - return new Interface(destination.getValue(), true); - } - - @Override - protected InterfaceProvisionRelationProcessor createProcessor(PcmSurrogate model) { - return new InterfaceProvisionRelationProcessor(model); - } - - @Override - protected PcmSurrogate createEmptyModel() { - return new PcmSurrogate(); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/InterfaceRequirementRelationProcessorTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/InterfaceRequirementRelationProcessorTest.java deleted file mode 100644 index d1a651c0..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/InterfaceRequirementRelationProcessorTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceRequirementRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.utility.ElementFactory; - -import tools.mdsd.mocore.framework.processor.RelationProcessorTest; - -public class InterfaceRequirementRelationProcessorTest - extends RelationProcessorTest, Interface> { - @Override - protected InterfaceRequirementRelation createRelation(Component source, Interface destination, - boolean isPlaceholder) { - return new InterfaceRequirementRelation(source, destination, isPlaceholder); - } - - @Override - protected Component getUniqueNonPlaceholderSourceEntity() { - return ElementFactory.createUniqueComponent(false); - } - - @Override - protected Component getPlaceholderOfSourceEntity(Component source) { - return new Component<>(source.getValue(), true); - } - - @Override - protected Interface getUniqueNonPlaceholderDestinationEntity() { - return ElementFactory.createUniqueInterface(false); - } - - @Override - protected Interface getPlaceholderOfDestinationEntity(Interface destination) { - return new Interface(destination.getValue(), true); - } - - @Override - protected InterfaceRequirementRelationProcessor createProcessor(PcmSurrogate model) { - return new InterfaceRequirementRelationProcessor(model); - } - - @Override - protected PcmSurrogate createEmptyModel() { - return new PcmSurrogate(); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/LinkResourceSpecificationRelationProcessorTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/LinkResourceSpecificationRelationProcessorTest.java deleted file mode 100644 index c298aede..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/LinkResourceSpecificationRelationProcessorTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.LinkResourceSpecification; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.DeploymentDeploymentRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.LinkResourceSpecificationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.utility.ElementFactory; - -import tools.mdsd.mocore.framework.processor.RelationProcessorTest; - -public class LinkResourceSpecificationRelationProcessorTest - extends RelationProcessorTest { - @Override - protected LinkResourceSpecificationRelation createRelation(LinkResourceSpecification source, - DeploymentDeploymentRelation destination, boolean isPlaceholder) { - return new LinkResourceSpecificationRelation(source, destination, isPlaceholder); - } - - @Override - protected LinkResourceSpecification getUniqueNonPlaceholderSourceEntity() { - return ElementFactory.createUniqueLinkResourceSpecification(false); - } - - @Override - protected LinkResourceSpecification getPlaceholderOfSourceEntity(LinkResourceSpecification source) { - return new LinkResourceSpecification(source.getValue(), true); - } - - @Override - protected DeploymentDeploymentRelation getUniqueNonPlaceholderDestinationEntity() { - return new DeploymentDeploymentRelation(Deployment.getUniquePlaceholder(), - Deployment.getUniquePlaceholder(), false); - } - - @Override - protected DeploymentDeploymentRelation getPlaceholderOfDestinationEntity(DeploymentDeploymentRelation destination) { - return new DeploymentDeploymentRelation(destination.getSource(), destination.getDestination(), true); - } - - @Override - protected LinkResourceSpecificationRelationProcessor createProcessor(PcmSurrogate model) { - return new LinkResourceSpecificationRelationProcessor(model); - } - - @Override - protected PcmSurrogate createEmptyModel() { - return new PcmSurrogate(); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ServiceEffectSpecificationRelationProcessorTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ServiceEffectSpecificationRelationProcessorTest.java deleted file mode 100644 index 7c53689c..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/ServiceEffectSpecificationRelationProcessorTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.ServiceEffectSpecification; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Signature; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentSignatureProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ServiceEffectSpecificationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.SignatureProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.utility.ElementFactory; - -import tools.mdsd.mocore.framework.processor.RelationProcessorTest; - -public class ServiceEffectSpecificationRelationProcessorTest extends - RelationProcessorTest { - @Override - protected ServiceEffectSpecificationRelation createRelation(ComponentSignatureProvisionRelation source, - ServiceEffectSpecification destination, - boolean isPlaceholder) { - return new ServiceEffectSpecificationRelation(source, destination, isPlaceholder); - } - - @Override - protected ComponentSignatureProvisionRelation getUniqueNonPlaceholderSourceEntity() { - Component component = Component.getUniquePlaceholder(); - Interface interfsc = Interface.getUniquePlaceholder(); - Signature signature = Signature.getUniquePlaceholder(); - InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(component, - interfsc, true); - SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, - interfsc, true); - return new ComponentSignatureProvisionRelation(interfaceProvision, signatureProvision, false); - - } - - @Override - protected ComponentSignatureProvisionRelation getPlaceholderOfSourceEntity( - ComponentSignatureProvisionRelation source) { - return new ComponentSignatureProvisionRelation(source.getSource(), source.getDestination(), true); - } - - @Override - protected ServiceEffectSpecification getUniqueNonPlaceholderDestinationEntity() { - return ElementFactory.createUniqueServiceEffectSpecification(false); - } - - @Override - protected ServiceEffectSpecification getPlaceholderOfDestinationEntity(ServiceEffectSpecification destination) { - return new ServiceEffectSpecification(destination.getValue(), true); - } - - @Override - protected ServiceEffectSpecificationRelationProcessor createProcessor(PcmSurrogate model) { - return new ServiceEffectSpecificationRelationProcessor(model); - } - - @Override - protected PcmSurrogate createEmptyModel() { - return new PcmSurrogate(); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/SignatureProvisionRelationProcessorTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/SignatureProvisionRelationProcessorTest.java deleted file mode 100644 index 9cb016a2..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/processor/relation/SignatureProvisionRelationProcessorTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.processor.relation; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Signature; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.SignatureProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.utility.ElementFactory; - -import tools.mdsd.mocore.framework.processor.RelationProcessorTest; - -public class SignatureProvisionRelationProcessorTest extends RelationProcessorTest { - @Override - protected SignatureProvisionRelation createRelation(Signature source, Interface destination, - boolean isPlaceholder) { - return new SignatureProvisionRelation(source, destination, isPlaceholder); - } - - @Override - protected Signature getUniqueNonPlaceholderSourceEntity() { - return ElementFactory.createUniqueSignature(false); - } - - @Override - protected Signature getPlaceholderOfSourceEntity(Signature source) { - return new Signature(source.getValue(), true); - } - - @Override - protected Interface getUniqueNonPlaceholderDestinationEntity() { - return ElementFactory.createUniqueInterface(false); - } - - @Override - protected Interface getPlaceholderOfDestinationEntity(Interface destination) { - return new Interface(destination.getValue(), true); - } - - @Override - protected SignatureProvisionRelationProcessor createProcessor(PcmSurrogate model) { - return new SignatureProvisionRelationProcessor(model); - } - - @Override - protected PcmSurrogate createEmptyModel() { - return new PcmSurrogate(); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/ServiceEffectSpecificationTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/ServiceEffectSpecificationTest.java deleted file mode 100644 index 22f0a2db..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/element/ServiceEffectSpecificationTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element; - -import org.palladiosimulator.pcm.seff.ResourceDemandingSEFF; -import org.palladiosimulator.somox.analyzer.rules.mocore.utility.ElementFactory; - -import tools.mdsd.mocore.framework.surrogate.ElementTest; - -public class ServiceEffectSpecificationTest - extends ElementTest { - @Override - protected ServiceEffectSpecification createElement(ResourceDemandingSEFF value, boolean isPlaceholder) { - return new ServiceEffectSpecification(value, isPlaceholder); - } - - @Override - protected ResourceDemandingSEFF getUniqueValue() { - return ElementFactory.createUniqueServiceEffectSpecification(false).getValue(); - } - - @Override - protected ServiceEffectSpecification getUniqueNonPlaceholder() { - return new ServiceEffectSpecification(getUniqueValue(), false); - } - - @Override - protected ServiceEffectSpecification getPlaceholderOf(ServiceEffectSpecification replaceable) { - return new ServiceEffectSpecification(replaceable.getValue(), true); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositeProvisionDelegationRelationTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositeProvisionDelegationRelationTest.java deleted file mode 100644 index c5f3c178..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositeProvisionDelegationRelationTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; - -import static org.junit.Assert.assertThrows; - -import org.junit.jupiter.api.Test; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.AtomicComponent; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Composite; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; - -import tools.mdsd.mocore.framework.surrogate.RelationTest; - -public class CompositeProvisionDelegationRelationTest extends RelationTest { - private static final Interface RELATION_INTERFACE = Interface.getUniquePlaceholder(); - - @Test - public void testConstructorWithEqualSourceAndDestinationRelation() { - InterfaceProvisionRelation entity = getUniqueSourceEntity(); - - assertThrows(IllegalArgumentException.class, - () -> new CompositeProvisionDelegationRelation(entity, entity, false)); - } - - @Test - public void testConstructorWithoutSourceCompositeComponent() { - AtomicComponent sourceComponent = AtomicComponent.getUniquePlaceholder(); - Composite destinationComponent = Composite.getUniquePlaceholder(); - InterfaceProvisionRelation source = new InterfaceProvisionRelation(sourceComponent, - RELATION_INTERFACE, true); - InterfaceProvisionRelation destination = new InterfaceProvisionRelation(destinationComponent, - RELATION_INTERFACE, true); - - assertThrows(IllegalArgumentException.class, - () -> new CompositeProvisionDelegationRelation(source, destination, false)); - } - - @Test - public void testConstructorWithDifferentRequirementInterfaces() { - InterfaceProvisionRelation source = getUniqueSourceEntity(); - Component destinationComponent = AtomicComponent.getUniquePlaceholder(); - Interface destinationInterface = Interface.getUniquePlaceholder(); - InterfaceProvisionRelation destination = new InterfaceProvisionRelation(destinationComponent, - destinationInterface, true); - - assertThrows(IllegalArgumentException.class, - () -> new CompositeProvisionDelegationRelation(source, destination, false)); - } - - @Override - protected CompositeProvisionDelegationRelation createRelation(InterfaceProvisionRelation source, - InterfaceProvisionRelation destination, - boolean isPlaceholder) { - return new CompositeProvisionDelegationRelation(source, destination, isPlaceholder); - } - - @Override - protected InterfaceProvisionRelation getUniqueSourceEntity() { - Composite source = Composite.getUniquePlaceholder(); - return new InterfaceProvisionRelation(source, RELATION_INTERFACE, true); - } - - @Override - protected InterfaceProvisionRelation getUniqueDestinationEntity() { - Component source = AtomicComponent.getUniquePlaceholder(); - return new InterfaceProvisionRelation(source, RELATION_INTERFACE, true); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositeRequirementDelegationRelationTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositeRequirementDelegationRelationTest.java deleted file mode 100644 index 8e98ecdc..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/CompositeRequirementDelegationRelationTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; - -import static org.junit.Assert.assertThrows; - -import org.junit.jupiter.api.Test; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.AtomicComponent; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Composite; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; - -import tools.mdsd.mocore.framework.surrogate.RelationTest; - -public class CompositeRequirementDelegationRelationTest extends RelationTest { - private static final Interface RELATION_INTERFACE = Interface.getUniquePlaceholder(); - - @Test - public void testConstructorWithEqualSourceAndDestinationRelation() { - InterfaceRequirementRelation entity = getUniqueSourceEntity(); - - assertThrows(IllegalArgumentException.class, - () -> new CompositeRequirementDelegationRelation(entity, entity, false)); - } - - @Test - public void testConstructorWithoutSourceCompositeComponent() { - AtomicComponent sourceComponent = AtomicComponent.getUniquePlaceholder(); - Composite destinationComponent = Composite.getUniquePlaceholder(); - InterfaceRequirementRelation source = new InterfaceRequirementRelation(sourceComponent, - RELATION_INTERFACE, true); - InterfaceRequirementRelation destination = new InterfaceRequirementRelation(destinationComponent, - RELATION_INTERFACE, true); - - assertThrows(IllegalArgumentException.class, - () -> new CompositeRequirementDelegationRelation(source, destination, false)); - } - - @Test - public void testConstructorWithDifferentRequirementInterfaces() { - InterfaceRequirementRelation source = getUniqueSourceEntity(); - Component destinationComponent = AtomicComponent.getUniquePlaceholder(); - Interface destinationInterface = Interface.getUniquePlaceholder(); - InterfaceRequirementRelation destination = new InterfaceRequirementRelation(destinationComponent, - destinationInterface, true); - - assertThrows(IllegalArgumentException.class, - () -> new CompositeRequirementDelegationRelation(source, destination, false)); - } - - @Override - protected CompositeRequirementDelegationRelation createRelation(InterfaceRequirementRelation source, - InterfaceRequirementRelation destination, - boolean isPlaceholder) { - return new CompositeRequirementDelegationRelation(source, destination, isPlaceholder); - } - - @Override - protected InterfaceRequirementRelation getUniqueSourceEntity() { - Composite source = Composite.getUniquePlaceholder(); - return new InterfaceRequirementRelation(source, RELATION_INTERFACE, true); - } - - @Override - protected InterfaceRequirementRelation getUniqueDestinationEntity() { - Component source = AtomicComponent.getUniquePlaceholder(); - return new InterfaceRequirementRelation(source, RELATION_INTERFACE, true); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ServiceEffectSpecificationRelationTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ServiceEffectSpecificationRelationTest.java deleted file mode 100644 index 579910c8..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/surrogate/relation/ServiceEffectSpecificationRelationTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation; - -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.ServiceEffectSpecification; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Signature; - -import tools.mdsd.mocore.framework.surrogate.RelationTest; - -public class ServiceEffectSpecificationRelationTest extends RelationTest { - @Override - protected ServiceEffectSpecificationRelation createRelation(ComponentSignatureProvisionRelation source, - ServiceEffectSpecification destination, boolean isPlaceholder) { - return new ServiceEffectSpecificationRelation(source, destination, isPlaceholder); - } - - @Override - protected ComponentSignatureProvisionRelation getUniqueSourceEntity() { - Component component = Component.getUniquePlaceholder(); - Interface interfsc = Interface.getUniquePlaceholder(); - Signature signature = Signature.getUniquePlaceholder(); - InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(component, - interfsc, true); - SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, - interfsc, true); - return new ComponentSignatureProvisionRelation(interfaceProvision, signatureProvision, false); - } - - @Override - protected ServiceEffectSpecification getUniqueDestinationEntity() { - return ServiceEffectSpecification.getUniquePlaceholder(); - } - -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/AllocationTransformerTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/AllocationTransformerTest.java deleted file mode 100644 index f7ce9fae..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/AllocationTransformerTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.transformation; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.palladiosimulator.somox.analyzer.rules.mocore.utility.PcmEvaluationUtility.containsRepresentative; - -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; -import org.palladiosimulator.pcm.allocation.Allocation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAllocationRelation; - -import tools.mdsd.mocore.framework.transformation.TransformerTest; - -public class AllocationTransformerTest extends TransformerTest { - @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void testTransformSingleAllocation(boolean isPlaceholderAllocation) { - // Test data - AllocationTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Component component = Component.getUniquePlaceholder(); - Deployment deployment = Deployment.getUniquePlaceholder(); - ComponentAllocationRelation allocationRelation = new ComponentAllocationRelation(component, - deployment, isPlaceholderAllocation); - - model.add(component); - model.add(deployment); - model.add(allocationRelation); - - // Execution - Allocation allocation = transformer.transform(model); - - // Assertion - assertNotNull(allocation); - assertTrue(containsRepresentative(allocation, allocationRelation)); - } - - @Override - protected AllocationTransformer createTransformer() { - return new AllocationTransformer(); - } - - @Override - protected PcmSurrogate createEmptyModel() { - return new PcmSurrogate(); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/RepositoryTransformerTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/RepositoryTransformerTest.java deleted file mode 100644 index 7126031e..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/RepositoryTransformerTest.java +++ /dev/null @@ -1,285 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.transformation; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.palladiosimulator.somox.analyzer.rules.mocore.utility.PcmEvaluationUtility.containsRepresentative; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; -import org.palladiosimulator.pcm.repository.Repository; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.AtomicComponent; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Composite; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.ServiceEffectSpecification; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Signature; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentSignatureProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceRequirementRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ServiceEffectSpecificationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.SignatureProvisionRelation; - -import tools.mdsd.mocore.framework.transformation.TransformerTest; - -public class RepositoryTransformerTest extends TransformerTest { - @Test - public void testTransformSingleComponent() { - // Test data - RepositoryTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - AtomicComponent component = AtomicComponent.getUniquePlaceholder(); - - model.add(component); - - // Execution - Repository repository = transformer.transform(model); - - // Assertion - assertNotNull(repository); - assertTrue(containsRepresentative(repository, component)); - } - - @Test - public void testTransformSingleEmptyComposite() { - // Test data - RepositoryTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Composite composite = Composite.getUniquePlaceholder(); - - model.add(composite); - - // Execution - Repository repository = transformer.transform(model); - - // Assertion - assertNotNull(repository); - assertTrue(containsRepresentative(repository, composite)); - } - - @Test - public void testTransformCompositeWithAtomicComponentChild() { - // Test data - RepositoryTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Composite composite = Composite.getUniquePlaceholder(); - AtomicComponent component = AtomicComponent.getUniquePlaceholder(); - CompositionRelation compositionRelation = new CompositionRelation(composite, component, false); - - model.add(composite); - model.add(component); - model.add(compositionRelation); - - // Execution - Repository repository = transformer.transform(model); - - // Assertion - assertNotNull(repository); - assertTrue(containsRepresentative(repository, composite)); - assertTrue(containsRepresentative(repository, component)); - assertTrue(containsRepresentative(repository, compositionRelation)); - } - - @Test - public void testTransformCompositeWithCompositeChild() { - // Test data - RepositoryTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Composite composite = Composite.getUniquePlaceholder(); - Composite child = Composite.getUniquePlaceholder(); - CompositionRelation compositionRelation = new CompositionRelation(composite, child, false); - - model.add(composite); - model.add(child); - model.add(compositionRelation); - - // Execution - Repository repository = transformer.transform(model); - - // Assertion - assertNotNull(repository); - assertTrue(containsRepresentative(repository, composite)); - assertTrue(containsRepresentative(repository, child)); - assertTrue(containsRepresentative(repository, compositionRelation)); - } - - @Test - public void testTransformCompositeWithMultilevelChildren() { - // Test data - RepositoryTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Composite compositeLevelZero = Composite.getUniquePlaceholder(); - Composite compositeLevelOne = Composite.getUniquePlaceholder(); - AtomicComponent component = AtomicComponent.getUniquePlaceholder(); - CompositionRelation compositionRelationFst = new CompositionRelation(compositeLevelZero, - compositeLevelOne, false); - CompositionRelation compositionRelationSnd = new CompositionRelation(compositeLevelOne, component, false); - - model.add(compositeLevelZero); - model.add(compositeLevelOne); - model.add(component); - model.add(compositionRelationFst); - model.add(compositionRelationSnd); - - // Execution - Repository repository = transformer.transform(model); - - // Assertion - assertNotNull(repository); - assertTrue(containsRepresentative(repository, compositeLevelZero)); - assertTrue(containsRepresentative(repository, compositeLevelOne)); - assertTrue(containsRepresentative(repository, component)); - assertTrue(containsRepresentative(repository, compositionRelationFst)); - assertTrue(containsRepresentative(repository, compositionRelationSnd)); - } - - @Test - public void testTransformSingleInterface() { - // Test data - RepositoryTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Interface element = Interface.getUniquePlaceholder(); - - model.add(element); - - // Execution - Repository repository = transformer.transform(model); - - // Assertion - assertNotNull(repository); - assertTrue(containsRepresentative(repository, element)); - } - - @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void testTransformInterfaceProvision(boolean isPlaceholderRelation) { - // Test data - RepositoryTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Component provider = Component.getUniquePlaceholder(); - Interface providerInterface = Interface.getUniquePlaceholder(); - InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, - providerInterface, isPlaceholderRelation); - - model.add(provider); - model.add(providerInterface); - model.add(interfaceProvision); - - // Execution - Repository repository = transformer.transform(model); - - // Assertion - assertNotNull(repository); - assertTrue(containsRepresentative(repository, provider)); - assertTrue(containsRepresentative(repository, providerInterface)); - assertTrue(containsRepresentative(repository, interfaceProvision)); - } - - @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void testTransformInterfaceRequirement(boolean isPlaceholderRelation) { - // Test data - RepositoryTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Component consumer = Component.getUniquePlaceholder(); - Interface consumerInterface = Interface.getUniquePlaceholder(); - InterfaceRequirementRelation interfaceRequirement = new InterfaceRequirementRelation(consumer, - consumerInterface, isPlaceholderRelation); - - model.add(consumer); - model.add(consumerInterface); - model.add(interfaceRequirement); - - // Execution - Repository repository = transformer.transform(model); - - // Assertion - assertNotNull(repository); - assertTrue(containsRepresentative(repository, consumer)); - assertTrue(containsRepresentative(repository, consumerInterface)); - assertTrue(containsRepresentative(repository, interfaceRequirement)); - } - - @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void testTransformSignatureProvision(boolean isPlaceholderRelation) { - // Test data - RepositoryTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Component provider = Component.getUniquePlaceholder(); - Interface providerInterface = Interface.getUniquePlaceholder(); - InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, - providerInterface, false); - Signature signature = Signature.getUniquePlaceholder(); - SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, - providerInterface, isPlaceholderRelation); - - model.add(provider); - model.add(providerInterface); - model.add(interfaceProvision); - model.add(signature); - model.add(signatureProvision); - - // Execution - Repository repository = transformer.transform(model); - - // Assertion - assertNotNull(repository); - assertTrue(containsRepresentative(repository, provider)); - assertTrue(containsRepresentative(repository, providerInterface)); - assertTrue(containsRepresentative(repository, interfaceProvision)); - assertTrue(containsRepresentative(repository, signatureProvision)); - } - - @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void testTransformComponentSignatureProvisionWithSeff(boolean isPlaceholderRelation) { - // Test data - RepositoryTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Component provider = Component.getUniquePlaceholder(); - Interface providerInterface = Interface.getUniquePlaceholder(); - InterfaceProvisionRelation interfaceProvision = new InterfaceProvisionRelation(provider, - providerInterface, false); - Signature signature = Signature.getUniquePlaceholder(); - SignatureProvisionRelation signatureProvision = new SignatureProvisionRelation(signature, - providerInterface, false); - ComponentSignatureProvisionRelation componentSignatureProvisionRelation = new ComponentSignatureProvisionRelation( - interfaceProvision, signatureProvision, false); - ServiceEffectSpecification seff = ServiceEffectSpecification.getUniquePlaceholder(); - ServiceEffectSpecificationRelation seffRelation = new ServiceEffectSpecificationRelation( - componentSignatureProvisionRelation, seff, isPlaceholderRelation); - - model.add(provider); - model.add(providerInterface); - model.add(interfaceProvision); - model.add(signature); - model.add(signatureProvision); - model.add(componentSignatureProvisionRelation); - model.add(seff); - model.add(seffRelation); - - // Execution - Repository repository = transformer.transform(model); - - // Assertion - assertNotNull(repository); - assertTrue(containsRepresentative(repository, provider)); - assertTrue(containsRepresentative(repository, providerInterface)); - assertTrue(containsRepresentative(repository, interfaceProvision)); - assertTrue(containsRepresentative(repository, signatureProvision)); - assertTrue(containsRepresentative(repository, seffRelation)); - } - - @Override - protected RepositoryTransformer createTransformer() { - return new RepositoryTransformer(); - } - - @Override - protected PcmSurrogate createEmptyModel() { - return new PcmSurrogate(); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/SystemTransformerTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/SystemTransformerTest.java deleted file mode 100644 index 0808277d..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/transformation/SystemTransformerTest.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.transformation; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.palladiosimulator.somox.analyzer.rules.mocore.utility.PcmEvaluationUtility.containsRepresentative; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; -import org.palladiosimulator.pcm.system.System; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.PcmSurrogate; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAssemblyRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceRequirementRelation; - -import tools.mdsd.mocore.framework.transformation.TransformerTest; - -public class SystemTransformerTest extends TransformerTest { - @Test - public void testTransformSingleComponent() { - // Test data - SystemTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - Component component = Component.getUniquePlaceholder(); - - model.add(component); - - // Execution - System system = transformer.transform(model); - - // Assertion - assertNotNull(system); - assertTrue(containsRepresentative(system, component)); - } - - @ParameterizedTest - @ValueSource(booleans = { true, false }) - public void testTransformSingleAssemblyRelation(boolean isPlaceholderAssembly) { - // Test data - SystemTransformer transformer = createTransformer(); - PcmSurrogate model = createEmptyModel(); - - Component provider = Component.getUniquePlaceholder(); - Component consumer = Component.getUniquePlaceholder(); - Interface providerConsumerInterface = Interface.getUniquePlaceholder(); - InterfaceProvisionRelation provisionRelation = new InterfaceProvisionRelation(provider, - providerConsumerInterface, false); - InterfaceRequirementRelation requirementRelation = new InterfaceRequirementRelation(consumer, - providerConsumerInterface, false); - ComponentAssemblyRelation assemblyRelation = new ComponentAssemblyRelation(provisionRelation, - requirementRelation, isPlaceholderAssembly); - - model.add(provider); - model.add(consumer); - model.add(providerConsumerInterface); - model.add(provisionRelation); - model.add(requirementRelation); - model.add(assemblyRelation); - - // Execution - System system = transformer.transform(model); - - // Assertion - assertNotNull(system); - assertTrue(containsRepresentative(system, provider)); - assertTrue(containsRepresentative(system, consumer)); - assertTrue(containsRepresentative(system, assemblyRelation)); - } - - @Override - protected SystemTransformer createTransformer() { - return new SystemTransformer(); - } - - @Override - protected PcmSurrogate createEmptyModel() { - return new PcmSurrogate(); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/utility/ElementFactory.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/utility/ElementFactory.java deleted file mode 100644 index 66b03024..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/utility/ElementFactory.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.utility; - -import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; -import org.palladiosimulator.pcm.repository.BasicComponent; -import org.palladiosimulator.pcm.repository.CompositeComponent; -import org.palladiosimulator.pcm.repository.OperationInterface; -import org.palladiosimulator.pcm.repository.OperationSignature; -import org.palladiosimulator.pcm.repository.RepositoryComponent; -import org.palladiosimulator.pcm.repository.RepositoryFactory; -import org.palladiosimulator.pcm.resourceenvironment.CommunicationLinkResourceSpecification; -import org.palladiosimulator.pcm.resourceenvironment.ResourceContainer; -import org.palladiosimulator.pcm.resourceenvironment.ResourceenvironmentFactory; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.AtomicComponent; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Composite; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.LinkResourceSpecification; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.ServiceEffectSpecification; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Signature; - -import tools.mdsd.mocore.utility.IdentifierGenerator; - -public final class ElementFactory { - private ElementFactory() { - throw new IllegalStateException("Cannot instantiate utility class."); - } - - public static Signature createUniqueSignature(boolean isPlaceholder) { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - OperationSignature value = RepositoryFactory.eINSTANCE.createOperationSignature(); - value.setEntityName(identifier); - return new Signature(value, isPlaceholder); - } - - public static Interface createUniqueInterface(boolean isPlaceholder) { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - OperationInterface value = new FluentRepositoryFactory().newOperationInterface().withName(identifier).build(); - return new Interface(value, isPlaceholder); - } - - public static Component createUniqueComponent(boolean isPlaceholder) { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - BasicComponent value = new FluentRepositoryFactory().newBasicComponent().withName(identifier).build(); - return new AtomicComponent(value, isPlaceholder); - } - - public static Composite createUniqueComposite(boolean isPlaceholder) { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - RepositoryComponent value = new FluentRepositoryFactory().newCompositeComponent().withName(identifier).build(); - return new Composite((CompositeComponent) value, isPlaceholder); - } - - public static Deployment createUniqueDeployment(boolean isPlaceholder) { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - ResourceContainer value = ResourceenvironmentFactory.eINSTANCE.createResourceContainer(); - value.setEntityName(identifier); - return new Deployment(value, isPlaceholder); - } - - public static LinkResourceSpecification createUniqueLinkResourceSpecification(boolean isPlaceholder) { - String identifier = IdentifierGenerator.getUniqueIdentifier(); - CommunicationLinkResourceSpecification value = ResourceenvironmentFactory.eINSTANCE - .createCommunicationLinkResourceSpecification(); - value.setId(identifier); - return new LinkResourceSpecification(value, isPlaceholder); - } - - public static ServiceEffectSpecification createUniqueServiceEffectSpecification(boolean isPlaceholder) { - ServiceEffectSpecification placeholderSpecification = ServiceEffectSpecification.getUniquePlaceholder(); - return new ServiceEffectSpecification(placeholderSpecification.getValue(), isPlaceholder); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/utility/PcmEvaluationUtility.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/utility/PcmEvaluationUtility.java deleted file mode 100644 index fa125f55..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/utility/PcmEvaluationUtility.java +++ /dev/null @@ -1,410 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.utility; - -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.function.BiFunction; -import java.util.stream.Collectors; - -import org.palladiosimulator.pcm.allocation.Allocation; -import org.palladiosimulator.pcm.allocation.AllocationContext; -import org.palladiosimulator.pcm.core.composition.AssemblyConnector; -import org.palladiosimulator.pcm.core.composition.AssemblyContext; -import org.palladiosimulator.pcm.repository.BasicComponent; -import org.palladiosimulator.pcm.repository.CompositeComponent; -import org.palladiosimulator.pcm.repository.DataType; -import org.palladiosimulator.pcm.repository.Interface; -import org.palladiosimulator.pcm.repository.OperationInterface; -import org.palladiosimulator.pcm.repository.OperationProvidedRole; -import org.palladiosimulator.pcm.repository.OperationRequiredRole; -import org.palladiosimulator.pcm.repository.OperationSignature; -import org.palladiosimulator.pcm.repository.Parameter; -import org.palladiosimulator.pcm.repository.ProvidedRole; -import org.palladiosimulator.pcm.repository.Repository; -import org.palladiosimulator.pcm.repository.RepositoryComponent; -import org.palladiosimulator.pcm.repository.RequiredRole; -import org.palladiosimulator.pcm.resourceenvironment.CommunicationLinkResourceSpecification; -import org.palladiosimulator.pcm.resourceenvironment.LinkingResource; -import org.palladiosimulator.pcm.resourceenvironment.ResourceContainer; -import org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment; -import org.palladiosimulator.pcm.seff.ResourceDemandingSEFF; -import org.palladiosimulator.pcm.system.System; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Component; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Deployment; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.LinkResourceSpecification; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.ServiceEffectSpecification; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Signature; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAllocationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ComponentAssemblyRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.CompositionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.DeploymentDeploymentRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceProvisionRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.InterfaceRequirementRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.ServiceEffectSpecificationRelation; -import org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.relation.SignatureProvisionRelation; - -import de.uka.ipd.sdq.identifier.Identifier; - -public final class PcmEvaluationUtility { - private PcmEvaluationUtility() { - throw new IllegalStateException("Utility class cannot be instantiated."); - } - - public static boolean representSame(DataType type, DataType otherType) { - boolean equalType; - if (type instanceof Identifier && otherType instanceof Identifier) { - equalType = Objects.equals(((Identifier) type).getId(), - ((Identifier) otherType).getId()); - } else { - equalType = Objects.equals(type, otherType); - } - return equalType; - } - - public static boolean representSame(Parameter parameter, Parameter otherParameter) { - boolean equalName = Objects.equals(parameter.getParameterName(), otherParameter.getParameterName()); - boolean equalType = representSame(parameter.getDataType__Parameter(), otherParameter.getDataType__Parameter()); - return equalName && equalType; - } - - public static boolean representSame(OperationSignature signature, - org.palladiosimulator.pcm.repository.Signature otherSignature) { - if (otherSignature instanceof OperationSignature) { - return representSame(signature, (OperationSignature) otherSignature); - } - return false; - } - - public static boolean representSame(OperationSignature signature, OperationSignature otherSignature) { - boolean equalName = Objects.equals(signature.getEntityName(), otherSignature.getEntityName()); - boolean equalReturn = representSame(signature.getReturnType__OperationSignature(), - otherSignature.getReturnType__OperationSignature()); - boolean equalParameters = areCollectionsEqual(signature.getParameters__OperationSignature(), - otherSignature.getParameters__OperationSignature(), PcmEvaluationUtility::representSame); - return equalName && equalReturn && equalParameters; - } - - public static boolean representSame(OperationInterface interFace, Interface otherInterFace) { - if (otherInterFace instanceof OperationInterface) { - return representSame(interFace, (OperationInterface) otherInterFace); - } - return false; - } - - public static boolean representSame(OperationInterface interFace, OperationInterface otherInterFace) { - boolean equalName = Objects.equals(interFace.getEntityName(), otherInterFace.getEntityName()); - // TODO Check characterization & protocol => Is there a palladio equal check? - return equalName; - } - - public static boolean representSame(RepositoryComponent component, RepositoryComponent otherComponent) { - if (otherComponent instanceof BasicComponent && component instanceof BasicComponent) { - return representSame((BasicComponent) component, (BasicComponent) otherComponent); - } else if (otherComponent instanceof CompositeComponent && component instanceof CompositeComponent) { - return representSame((CompositeComponent) component, (CompositeComponent) otherComponent); - } - return false; - } - - public static boolean representSame(BasicComponent component, BasicComponent otherComponent) { - boolean equalName = Objects.equals(component.getEntityName(), otherComponent.getEntityName()); - boolean equalType = Objects.equals(component.getComponentType(), otherComponent.getComponentType()); - // TODO Check parameter usage => Is there a palladio equal check? - return equalName && equalType; - } - - public static boolean representSame(CompositeComponent component, CompositeComponent otherComponent) { - boolean equalName = Objects.equals(component.getEntityName(), otherComponent.getEntityName()); - boolean equalType = Objects.equals(component.getComponentType(), otherComponent.getComponentType()); - // TODO Check parameter usage => Is there a palladio equal check? - return equalName && equalType; - } - - public static boolean representSame(ResourceContainer container, ResourceContainer otherContainer) { - boolean equalName = Objects.equals(container.getEntityName(), otherContainer.getEntityName()); - // TODO ResourceSpecifications are removed from old container on copy. Consequently, comparing it is not - // possible. - return equalName; - } - - public static boolean representSame(ResourceDemandingSEFF seff, - org.palladiosimulator.pcm.seff.ServiceEffectSpecification otherSeff) { - if (otherSeff instanceof ResourceDemandingSEFF) { - return representSame(seff, (ResourceDemandingSEFF) otherSeff); - } - return false; - } - - public static boolean representSame(ResourceDemandingSEFF seff, ResourceDemandingSEFF otherSeff) { - boolean equalIdentifier = Objects.equals(seff.getId(), otherSeff.getId()); - boolean equalTypeIdentifier = Objects.equals(seff.getSeffTypeID(), otherSeff.getSeffTypeID()); - boolean equalSteps = areCollectionsEqualIgnoringOrder( - mapToIdentifier(seff.getSteps_Behaviour()), - mapToIdentifier(otherSeff.getSteps_Behaviour())); - boolean equalInternalBehaviors = areCollectionsEqualIgnoringOrder( - mapToIdentifier(seff.getResourceDemandingInternalBehaviours()), - mapToIdentifier(otherSeff.getResourceDemandingInternalBehaviours())); - boolean equalLoopAction = Objects.equals( - mapToIdentifier(seff.getAbstractLoopAction_ResourceDemandingBehaviour()), - mapToIdentifier(otherSeff.getAbstractLoopAction_ResourceDemandingBehaviour())); - boolean equalBranchTransition = Objects.equals( - mapToIdentifier(seff.getAbstractBranchTransition_ResourceDemandingBehaviour()), - mapToIdentifier(otherSeff.getAbstractBranchTransition_ResourceDemandingBehaviour())); - return equalIdentifier && equalTypeIdentifier && equalSteps && equalInternalBehaviors - && equalLoopAction && equalBranchTransition; - } - - public static Optional getRepresentative(ResourceEnvironment resourceEnvironment, - Deployment container) { - List containers = resourceEnvironment.getResourceContainer_ResourceEnvironment(); - for (ResourceContainer environmentContainer : containers) { - if (representSame(container.getValue(), environmentContainer)) { - return Optional.of(environmentContainer); - } - } - return Optional.empty(); - } - - public static Optional getRepresentative(Repository repository, Component component) { - List components = repository.getComponents__Repository(); - for (RepositoryComponent repositoryComponent : components) { - if (representSame(component.getValue(), repositoryComponent)) { - return Optional.of(repositoryComponent); - } - } - return Optional.empty(); - } - - public static Optional getRepresentative(Repository repository, - org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface interFace) { - List interfaces = repository.getInterfaces__Repository(); - for (Interface repositoryInterface : interfaces) { - if (representSame(interFace.getValue(), repositoryInterface)) { - return Optional.of((OperationInterface) repositoryInterface); - } - } - return Optional.empty(); - } - - public static boolean containsRepresentative(Repository repository, Component component) { - return getRepresentative(repository, component).isPresent(); - } - - public static boolean containsRepresentative(Repository repository, CompositionRelation composition) { - CompositeComponent wrappedComposite = composition.getSource().getValue(); - RepositoryComponent wrappedChild = composition.getDestination().getValue(); - return repository.getComponents__Repository() - .stream() - .filter(component -> component instanceof CompositeComponent) - .map(component -> (CompositeComponent) component) - .filter(composite -> composite.getEntityName().equals(wrappedComposite.getEntityName())) - .flatMap(composite -> composite.getAssemblyContexts__ComposedStructure().stream()) - .anyMatch(assemblyContext -> assemblyContext.getEncapsulatedComponent__AssemblyContext().getEntityName() - .equals(wrappedChild.getEntityName())); - } - - public static boolean containsRepresentative(Repository repository, - org.palladiosimulator.somox.analyzer.rules.mocore.surrogate.element.Interface interFace) { - return getRepresentative(repository, interFace).isPresent(); - } - - public static boolean containsRepresentative(Repository repository, - InterfaceProvisionRelation interfaceProvision) { - OperationInterface wrappedInterface = interfaceProvision.getDestination().getValue(); - Optional optionalComponent = getRepresentative(repository, interfaceProvision.getSource()); - if (optionalComponent.isPresent()) { - List roles = optionalComponent.get().getProvidedRoles_InterfaceProvidingEntity(); - return roles.stream() - .filter(role -> role instanceof OperationProvidedRole) - .map(role -> (OperationProvidedRole) role) - .map(OperationProvidedRole::getProvidedInterface__OperationProvidedRole) - .anyMatch(interFace -> representSame(wrappedInterface, interFace)); - } else { - return false; - } - } - - public static boolean containsRepresentative(Repository repository, - InterfaceRequirementRelation interfaceRequirement) { - OperationInterface wrappedInterface = interfaceRequirement.getDestination().getValue(); - Optional optionalComponent = getRepresentative(repository, - interfaceRequirement.getSource()); - if (optionalComponent.isPresent()) { - List roles = optionalComponent.get().getRequiredRoles_InterfaceRequiringEntity(); - return roles.stream() - .filter(role -> role instanceof OperationRequiredRole) - .map(role -> (OperationRequiredRole) role) - .map(OperationRequiredRole::getRequiredInterface__OperationRequiredRole) - .anyMatch(interFace -> representSame(wrappedInterface, interFace)); - } else { - return false; - } - } - - public static boolean containsRepresentative(Repository repository, SignatureProvisionRelation signatureProvision) { - Optional optionalOperationInterface = getRepresentative(repository, - signatureProvision.getDestination()); - return optionalOperationInterface.isPresent() - && optionalOperationInterface.get().getSignatures__OperationInterface().stream() - .anyMatch(signature -> representSame(signatureProvision.getSource().getValue(), signature)); - } - - public static boolean containsRepresentative(Repository repository, - ServiceEffectSpecificationRelation seffProvision) { - Component provider = seffProvision.getSource().getSource().getSource(); - Signature signature = seffProvision.getSource().getDestination().getSource(); - ServiceEffectSpecification seff = seffProvision.getDestination(); - - Optional optionalComponent = getRepresentative(repository, provider); - if (optionalComponent.isPresent() && optionalComponent.get() instanceof BasicComponent) { - BasicComponent component = (BasicComponent) optionalComponent.get(); - for (org.palladiosimulator.pcm.seff.ServiceEffectSpecification componentSeff : component - .getServiceEffectSpecifications__BasicComponent()) { - if (representSame(seff.getValue(), componentSeff)) { - ResourceDemandingSEFF componentRdSeff = (ResourceDemandingSEFF) componentSeff; - return representSame(provider.getValue(), - componentRdSeff.getBasicComponent_ServiceEffectSpecification()) - && representSame(signature.getValue(), componentRdSeff.getDescribedService__SEFF()) - && containsRepresentative(repository, seffProvision.getSource().getSource()) - && containsRepresentative(repository, seffProvision.getSource().getDestination()); - } - } - } - return false; - } - - public static boolean containsRepresentative(ResourceEnvironment resourceEnvironment, Deployment container) { - return getRepresentative(resourceEnvironment, container).isPresent(); - } - - public static boolean containsRepresentative(ResourceEnvironment resourceEnvironment, - DeploymentDeploymentRelation link) { - List linkingResources = resourceEnvironment.getLinkingResources__ResourceEnvironment(); - for (LinkingResource linkingResource : linkingResources) { - List linkedContainers = new LinkedList<>( - linkingResource.getConnectedResourceContainers_LinkingResource()); - boolean containsContainers = true; - for (Deployment deployment : List.of(link.getSource(), link.getDestination())) { - containsContainers = containsContainers - && linkedContainers.removeIf(element -> representSame(deployment.getValue(), element)); - } - if (containsContainers) { - return true; - } - } - return false; - } - - public static boolean containsRepresentative(ResourceEnvironment resourceEnvironment, - LinkResourceSpecification relationSpecification, Collection deployments) { - CommunicationLinkResourceSpecification specification = relationSpecification.getValue(); - List linkingResources = resourceEnvironment.getLinkingResources__ResourceEnvironment(); - for (LinkingResource linkingResource : linkingResources) { - List linkedContainers = new LinkedList<>( - linkingResource.getConnectedResourceContainers_LinkingResource()); - CommunicationLinkResourceSpecification linkSpecification = linkingResource - .getCommunicationLinkResourceSpecifications_LinkingResource(); - boolean containsContainers = true; - for (Deployment deployment : deployments) { - containsContainers = containsContainers - && linkedContainers.removeIf(element -> representSame(deployment.getValue(), element)); - } - if (containsContainers && linkedContainers.isEmpty()) { - if (specification.getId().equals(linkSpecification.getId())) { - return true; - } - } - } - return false; - } - - public static boolean containsRepresentative(Allocation allocation, - ComponentAllocationRelation allocationRelation) { - Component component = allocationRelation.getSource(); - Deployment deployment = allocationRelation.getDestination(); - - List allocationContexts = allocation.getAllocationContexts_Allocation(); - for (AllocationContext allocationContext : allocationContexts) { - if (representSame(deployment.getValue(), allocationContext.getResourceContainer_AllocationContext())) { - AssemblyContext assemblyContext = allocationContext.getAssemblyContext_AllocationContext(); - if (representSame(component.getValue(), assemblyContext.getEncapsulatedComponent__AssemblyContext())) { - return true; - } - } - } - return false; - } - - public static boolean containsRepresentative(System system, Component component) { - List assemblyContexts = system.getAssemblyContexts__ComposedStructure(); - for (AssemblyContext assemblyContext : assemblyContexts) { - if (representSame(component.getValue(), assemblyContext.getEncapsulatedComponent__AssemblyContext())) { - return true; - } - } - return false; - } - - public static boolean containsRepresentative(System system, ComponentAssemblyRelation assemblyRelation) { - RepositoryComponent provider = assemblyRelation.getSource().getSource().getValue(); - RepositoryComponent consumer = assemblyRelation.getDestination().getSource().getValue(); - OperationInterface providerConsumerInterface = assemblyRelation.getSource().getDestination().getValue(); - - List assemblyConnectors = system.getConnectors__ComposedStructure().stream() - .filter(connector -> connector instanceof AssemblyConnector) - .map(connector -> (AssemblyConnector) connector) - .collect(Collectors.toList()); - for (AssemblyConnector connector : assemblyConnectors) { - RepositoryComponent connectorProvider = connector.getProvidingAssemblyContext_AssemblyConnector() - .getEncapsulatedComponent__AssemblyContext(); - RepositoryComponent connectorConsumer = connector.getRequiringAssemblyContext_AssemblyConnector() - .getEncapsulatedComponent__AssemblyContext(); - OperationInterface connectorProviderConsumerInterface = connector.getProvidedRole_AssemblyConnector() - .getProvidedInterface__OperationProvidedRole(); - - boolean sameProvider = representSame(provider, connectorProvider); - boolean sameConsumer = representSame(consumer, connectorConsumer); - boolean sameInterface = representSame(providerConsumerInterface, connectorProviderConsumerInterface); - if (sameProvider && sameConsumer && sameInterface) { - return true; - } - } - return false; - } - - private static boolean areCollectionsEqual(Collection collection, - Collection otherCollection, BiFunction comparisonFunction) { - if (collection.isEmpty() && otherCollection.isEmpty()) { - return true; - } else if (collection.size() != otherCollection.size()) { - return false; - } - - List list = new LinkedList<>(collection); - List otherList = new LinkedList<>(otherCollection); - for (int i = 0; i < list.size(); i++) { - if (!comparisonFunction.apply(list.get(i), otherList.get(i))) { - return false; - } - } - return true; - } - - private static boolean areCollectionsEqualIgnoringOrder(Collection collection, - Collection otherCollection) { - return collection.containsAll(otherCollection) && otherCollection.containsAll(collection); - } - - private static String mapToIdentifier(T element) { - return element != null ? element.getId() : null; - } - - private static List mapToIdentifier(Collection collection) { - return collection.stream() - .dropWhile(element -> element == null) - .map(Identifier::getId) - .collect(Collectors.toList()); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/workflow/MoCoReJobTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/workflow/MoCoReJobTest.java deleted file mode 100644 index d1292788..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.mocore.test/src/org/palladiosimulator/somox/analyzer/rules/mocore/workflow/MoCoReJobTest.java +++ /dev/null @@ -1,216 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.mocore.workflow; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.List; -import java.util.stream.Collectors; - -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.emf.common.util.EList; -import org.junit.jupiter.api.Test; -import org.palladiosimulator.generator.fluent.repository.api.Repo; -import org.palladiosimulator.generator.fluent.repository.factory.FluentRepositoryFactory; -import org.palladiosimulator.pcm.core.composition.AssemblyConnector; -import org.palladiosimulator.pcm.core.composition.Connector; -import org.palladiosimulator.pcm.core.composition.ProvidedDelegationConnector; -import org.palladiosimulator.pcm.core.composition.RequiredDelegationConnector; -import org.palladiosimulator.pcm.repository.CompositeComponent; -import org.palladiosimulator.pcm.repository.OperationProvidedRole; -import org.palladiosimulator.pcm.repository.Repository; -import org.palladiosimulator.pcm.repository.RepositoryComponent; -import org.palladiosimulator.pcm.system.System; - -import de.uka.ipd.sdq.workflow.blackboard.Blackboard; - -public class MoCoReJobTest { - private final static String BLACKBOARD_OUTPUT_REPOSITORY = "input.repository"; - private final static String BLACKBOARD_INPUT_REPOSITORY = "output.repository"; - private final static String BLACKBOARD_OUTPUT_SYSTEM = "output.system"; - private final static String BLACKBOARD_OUTPUT_ALLOCATION = "output.allocation"; - private final static String BLACKBOARD_OUTPUT_RESOURCEENVIRONMENT = "output.resource"; - - @Test - public void testConstructorWithValidInput() { - Blackboard blackboard = new Blackboard(); - assertDoesNotThrow(() -> new MoCoReJob(blackboard, BLACKBOARD_INPUT_REPOSITORY, - BLACKBOARD_OUTPUT_REPOSITORY, BLACKBOARD_OUTPUT_SYSTEM, BLACKBOARD_OUTPUT_ALLOCATION, - BLACKBOARD_OUTPUT_RESOURCEENVIRONMENT)); - } - - @Test - public void testCompositeComponentProcessing() throws Exception { - // Tests constants - String componentNameOne = "Component One"; - String contextNameOne = componentNameOne + " Context"; - String componentNameTwo = "Component Two"; - String contextNameTwo = componentNameTwo + " Context"; - String interfaceNameInternal = "Internal Interface"; - String roleNameInternalRequired = "Role Requirer " + interfaceNameInternal; - String roleNameInternalProvided = "Role Provider " + interfaceNameInternal; - String interfaceNameExternalRequired = "External Interface Required"; - String roleNameExternalRequiredInner = "Inner Role " + interfaceNameExternalRequired; - String roleNameExternalRequiredOuter = "Outer Role " + interfaceNameExternalRequired; - String interfaceNameExternalProvided = "External Interface Provided"; - String roleNameExternalProvidedInner = "Inner Role " + interfaceNameExternalProvided; - String roleNameExternalProvidedOuter = "Outer Role " + interfaceNameExternalProvided; - - // Create blackboard and fluent repository - Blackboard blackboard = new Blackboard(); - FluentRepositoryFactory fluentFactory = new FluentRepositoryFactory(); - Repo fluentRepository = fluentFactory.newRepository(); - - // Create composite component and add to fluent repository - fluentRepository - .addToRepository(fluentFactory.newOperationInterface().withName(interfaceNameInternal)) - .addToRepository(fluentFactory.newOperationInterface().withName(interfaceNameExternalRequired)) - .addToRepository(fluentFactory.newOperationInterface().withName(interfaceNameExternalProvided)) - .addToRepository(fluentFactory.newBasicComponent() - .withName(componentNameOne) - .provides(fluentFactory.fetchOfOperationInterface(interfaceNameInternal), - roleNameInternalProvided) - .requires(fluentFactory.fetchOfOperationInterface(interfaceNameExternalRequired), - roleNameExternalRequiredInner)) - .addToRepository(fluentFactory.newBasicComponent() - .withName(componentNameTwo) - .requires(fluentFactory.fetchOfOperationInterface(interfaceNameInternal), - roleNameInternalRequired) - .provides(fluentFactory.fetchOfOperationInterface(interfaceNameExternalProvided), - roleNameExternalProvidedInner)) - .addToRepository(fluentFactory.newCompositeComponent() - .provides(fluentFactory.fetchOfOperationInterface(interfaceNameExternalProvided), - roleNameExternalProvidedOuter) - .requires(fluentFactory.fetchOfOperationInterface(interfaceNameExternalRequired), - roleNameExternalRequiredOuter) - .withAssemblyContext(fluentFactory.fetchOfComponent(componentNameOne), contextNameOne) - .withAssemblyContext(fluentFactory.fetchOfComponent(componentNameTwo), contextNameTwo) - .withAssemblyConnection( - fluentFactory.fetchOfOperationProvidedRole(roleNameInternalProvided), - fluentFactory.fetchOfAssemblyContext(contextNameOne), - fluentFactory.fetchOfOperationRequiredRole(roleNameInternalRequired), - fluentFactory.fetchOfAssemblyContext(contextNameTwo)) - .withProvidedDelegationConnection(fluentFactory.fetchOfAssemblyContext(contextNameTwo), - fluentFactory.fetchOfOperationProvidedRole(roleNameExternalProvidedInner), - fluentFactory.fetchOfOperationProvidedRole(roleNameExternalProvidedOuter)) - .withRequiredDelegationConnection(fluentFactory.fetchOfAssemblyContext(contextNameOne), - fluentFactory.fetchOfOperationRequiredRole(roleNameExternalRequiredInner), - fluentFactory.fetchOfOperationRequiredRole(roleNameExternalRequiredOuter))); - - // Fill blackboard - blackboard.addPartition(BLACKBOARD_INPUT_REPOSITORY, fluentRepository.createRepositoryNow()); - - // Create and run job - MoCoReJob job = new MoCoReJob(blackboard, BLACKBOARD_INPUT_REPOSITORY, - BLACKBOARD_OUTPUT_REPOSITORY, BLACKBOARD_OUTPUT_SYSTEM, BLACKBOARD_OUTPUT_ALLOCATION, - BLACKBOARD_OUTPUT_RESOURCEENVIRONMENT); - job.execute(new NullProgressMonitor()); - - // Check if components exist in repository - Repository outputRepository = (Repository) blackboard.getPartition(BLACKBOARD_OUTPUT_REPOSITORY); - EList components = outputRepository.getComponents__Repository(); - CompositeComponent composite = (CompositeComponent) components.stream() - .filter(component -> component instanceof CompositeComponent).findFirst().orElseThrow(); - assertEquals(2, composite.getAssemblyContexts__ComposedStructure().size()); - - // Check if assembly connector created correctly - List assemblyConnectors = composite.getConnectors__ComposedStructure().stream() - .filter(genericConnector -> genericConnector instanceof AssemblyConnector) - .map(genericConnector -> (AssemblyConnector) genericConnector).collect(Collectors.toList()); - assertEquals(1, assemblyConnectors.size()); - AssemblyConnector assemblyConnector = assemblyConnectors.get(0); - assertEquals(componentNameOne, assemblyConnector.getProvidingAssemblyContext_AssemblyConnector() - .getEncapsulatedComponent__AssemblyContext().getEntityName()); - assertEquals(componentNameTwo, assemblyConnector.getRequiringAssemblyContext_AssemblyConnector() - .getEncapsulatedComponent__AssemblyContext().getEntityName()); - assertEquals(interfaceNameInternal, assemblyConnector.getProvidedRole_AssemblyConnector() - .getProvidedInterface__OperationProvidedRole().getEntityName()); - assertEquals(interfaceNameInternal, assemblyConnector.getRequiredRole_AssemblyConnector() - .getRequiredInterface__OperationRequiredRole().getEntityName()); - - // Check if provided delegation created correctly - List providedDelegations = composite.getConnectors__ComposedStructure().stream() - .filter(genericConnector -> genericConnector instanceof ProvidedDelegationConnector) - .map(genericConnector -> (ProvidedDelegationConnector) genericConnector).collect(Collectors.toList()); - assertEquals(1, providedDelegations.size()); - ProvidedDelegationConnector providedDelegationConnector = providedDelegations.get(0); - assertEquals(componentNameTwo, providedDelegationConnector.getAssemblyContext_ProvidedDelegationConnector() - .getEncapsulatedComponent__AssemblyContext().getEntityName()); - assertEquals(interfaceNameExternalProvided, - providedDelegationConnector.getInnerProvidedRole_ProvidedDelegationConnector() - .getProvidedInterface__OperationProvidedRole().getEntityName()); - assertEquals(interfaceNameExternalProvided, - providedDelegationConnector.getOuterProvidedRole_ProvidedDelegationConnector() - .getProvidedInterface__OperationProvidedRole().getEntityName()); - - // Check if required delegation created correctly - List requiredDelegations = composite.getConnectors__ComposedStructure().stream() - .filter(genericConnector -> genericConnector instanceof RequiredDelegationConnector) - .map(genericConnector -> (RequiredDelegationConnector) genericConnector).collect(Collectors.toList()); - assertEquals(1, requiredDelegations.size()); - RequiredDelegationConnector requiredDelegationConnector = requiredDelegations.get(0); - assertEquals(componentNameOne, requiredDelegationConnector.getAssemblyContext_RequiredDelegationConnector() - .getEncapsulatedComponent__AssemblyContext().getEntityName()); - assertEquals(interfaceNameExternalRequired, - requiredDelegationConnector.getInnerRequiredRole_RequiredDelegationConnector() - .getRequiredInterface__OperationRequiredRole().getEntityName()); - assertEquals(interfaceNameExternalRequired, - requiredDelegationConnector.getOuterRequiredRole_RequiredDelegationConnector() - .getRequiredInterface__OperationRequiredRole().getEntityName()); - } - - @Test - public void testRecursiveProvisionLeadsToSystemDelegation() throws Exception { - // Create blackboard and fluent repository - Blackboard blackboard = new Blackboard(); - FluentRepositoryFactory fluentFactory = new FluentRepositoryFactory(); - Repo fluentRepository = fluentFactory.newRepository(); - - // Create composite component and add to fluent repository - fluentRepository - .addToRepository(fluentFactory.newOperationInterface().withName("Doable")) - .addToRepository(fluentFactory.newBasicComponent() - .withName("Child") - .provides(fluentFactory.fetchOfOperationInterface("Doable"), "Doable Role")) - .addToRepository(fluentFactory.newCompositeComponent() - .withName("Inner Parent") - .withAssemblyContext(fluentFactory.fetchOfComponent("Child"))) - .addToRepository(fluentFactory.newCompositeComponent() - .withName("Middle Parent") - .withAssemblyContext(fluentFactory.fetchOfComponent("Inner Parent"))) - .addToRepository(fluentFactory.newCompositeComponent() - .withName("Outer Parent") - .withAssemblyContext(fluentFactory.fetchOfComponent("Middle Parent"))); - - // Fill blackboard - blackboard.addPartition(BLACKBOARD_INPUT_REPOSITORY, fluentRepository.createRepositoryNow()); - - // Create and run job - MoCoReJob job = new MoCoReJob(blackboard, BLACKBOARD_INPUT_REPOSITORY, - BLACKBOARD_OUTPUT_REPOSITORY, BLACKBOARD_OUTPUT_SYSTEM, BLACKBOARD_OUTPUT_ALLOCATION, - BLACKBOARD_OUTPUT_RESOURCEENVIRONMENT); - job.execute(new NullProgressMonitor()); - - // Check inner provision was recursively - Repository outputRepository = (Repository) blackboard.getPartition(BLACKBOARD_OUTPUT_REPOSITORY); - EList components = outputRepository.getComponents__Repository(); - List composites = components.stream() - .filter(component -> component instanceof CompositeComponent) - .map(component -> (CompositeComponent) component).toList(); - composites.forEach(composite -> assertTrue(composite.getProvidedRoles_InterfaceProvidingEntity().stream() - .anyMatch(role -> role instanceof OperationProvidedRole && ((OperationProvidedRole) role) - .getProvidedInterface__OperationProvidedRole().getEntityName().equals("Doable")))); - - // Check most outer provision was delegated by system - System outputSystem = (System) blackboard.getPartition(BLACKBOARD_OUTPUT_SYSTEM); - EList connectors = outputSystem.getConnectors__ComposedStructure(); - assertEquals(1, connectors.size()); - ProvidedDelegationConnector delegationConnector = (ProvidedDelegationConnector) connectors.get(0); - assertEquals("Outer Parent", delegationConnector.getAssemblyContext_ProvidedDelegationConnector() - .getEncapsulatedComponent__AssemblyContext().getEntityName()); - assertEquals("Doable", delegationConnector.getInnerProvidedRole_ProvidedDelegationConnector() - .getProvidedInterface__OperationProvidedRole().getEntityName()); - assertEquals("Doable", delegationConnector.getOuterProvidedRole_ProvidedDelegationConnector() - .getProvidedInterface__OperationProvidedRole().getEntityName()); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/BasicProject/.classpath b/tests/org.palladiosimulator.somox.analyzer.rules.test/res/BasicProject/.classpath deleted file mode 100644 index 57bca725..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/res/BasicProject/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/ACMETest.java b/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/ACMETest.java deleted file mode 100644 index eeccd731..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/ACMETest.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.test.integration; - -import org.palladiosimulator.somox.analyzer.rules.impl.JaxRSRules; - -public class ACMETest extends RuleEngineTest { - - protected ACMETest() { - super("external/acmeair-1.2.0", new JaxRSRules()); - } - - @Override - void testRuleEngineRepository() { - assertComponentExists("com_acmeair_wxs_service_FlightServiceImpl"); - - assertComponentProvidesOperation("com_acmeair_morphia_services_CustomerServiceImpl", - "com_acmeair_service_CustomerService", "getCustomerByUsername"); - assertComponentProvidesOperation("com_acmeair_wxs_service_FlightServiceImpl", - "com_acmeair_service_FlightService", "getFlightByAirports"); - assertComponentProvidesOperation("com_acmeair_morphia_services_BookingServiceImpl", - "com_acmeair_service_BookingService", "bookFlight"); - - assertMaxParameterCount(2, "com_acmeair_service_BookingService", "bookFlight"); - - assertComponentRequiresComponent("com_acmeair_web_FlightsREST", - "com_acmeair_morphia_services_FlightServiceImpl"); - assertComponentRequiresComponent("com_acmeair_web_LoginREST", - "com_acmeair_morphia_services_CustomerServiceImpl"); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/JaxRsTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/JaxRsTest.java deleted file mode 100644 index c0fc8adf..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/JaxRsTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.test.integration; - -import org.palladiosimulator.somox.analyzer.rules.impl.JaxRSRules; - -public class JaxRsTest extends RuleEngineTest { - - protected JaxRsTest() { - super("JaxRsProject", new JaxRSRules()); - } - - @Override - void testRuleEngineRepository() { - assertComponentExists("jax_rs_AWebService"); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/PetclinicTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/PetclinicTest.java deleted file mode 100644 index 33839336..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/PetclinicTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.test.integration; - -import org.junit.jupiter.api.Disabled; -import org.palladiosimulator.somox.analyzer.rules.impl.SpringRules; - -@Disabled("TODO: Currently broken") -public class PetclinicTest extends RuleEngineTest { - - protected PetclinicTest() { - super("external/spring-petclinic-microservices-2.3.6", new SpringRules()); - } - - @Override - void testRuleEngineRepository() { - // TODO: Temporarily disabled due to rule changes. - if (getClass() != null) - return; - - assertComponentExists("org_springframework_samples_petclinic_api_boundary_web_ApiGatewayController"); - - assertComponentProvidesOperation("org_springframework_samples_petclinic_vets_web_VetResource", - "/vets-service/vets[GET]", "/vets-service/vets[GET]"); - assertComponentProvidesOperation("org_springframework_samples_petclinic_visits_web_VisitResource", - "/visits-service", "/visits-service/pets/visits[GET]"); - assertComponentProvidesOperation("org_springframework_samples_petclinic_customers_web_PetResource", - "/customers-service/owners/*/pets", "/customers-service/owners/*/pets[GET]"); - - assertMaxParameterCount(2, "/customers-service/owners[PUT]", "/customers-service/owners[PUT]"); - assertMaxParameterCount(1, "/api-gateway/api/gateway/owners[GET]", "/api-gateway/api/gateway/owners[GET]"); - - assertComponentRequiresComponent("org_springframework_samples_petclinic_customers_web_PetResource", - "org_springframework_samples_petclinic_customers_model_PetRepository"); - assertComponentRequiresComponent("org_springframework_samples_petclinic_customers_web_PetResource", - "org_springframework_samples_petclinic_customers_model_OwnerRepository"); - - assertInSameCompositeComponent("org_springframework_samples_petclinic_customers_web_PetResource", - "org_springframework_samples_petclinic_customers_model_PetRepository"); - assertInSameCompositeComponent("org_springframework_samples_petclinic_customers_web_PetResource", - "org_springframework_samples_petclinic_customers_web_OwnerResource"); - assertInSameCompositeComponent("org_springframework_samples_petclinic_visits_web_VisitResource", - "org_springframework_samples_petclinic_visits_model_VisitRepository"); - assertInSameCompositeComponent("org_springframework_samples_petclinic_vets_web_VetResource", - "org_springframework_samples_petclinic_vets_model_VetRepository"); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/PiggymetricsTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/PiggymetricsTest.java deleted file mode 100644 index 6760dc54..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/PiggymetricsTest.java +++ /dev/null @@ -1,50 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.test.integration; - -import org.junit.jupiter.api.Disabled; -import org.palladiosimulator.somox.analyzer.rules.impl.SpringRules; - -@Disabled("TODO: Currently broken") -public class PiggymetricsTest extends RuleEngineTest { - - protected PiggymetricsTest() { - super("external/piggymetrics-spring.version.2.0.3", new SpringRules()); - } - - @Override - void testRuleEngineRepository() { - // TODO: Temporarily disabled due to rule changes. - if (getClass() != null) - return; - - assertComponentExists("com_piggymetrics_account_client_AuthServiceClient"); - assertComponentExists("com_piggymetrics_notification_service_NotificationServiceImpl"); - - assertComponentProvidesOperation("com_piggymetrics_statistics_controller_StatisticsController", "/statistics", - "/statistics/current"); - assertComponentProvidesOperation("com_piggymetrics_account_controller_AccountController", "/accounts", - "/accounts"); - assertComponentProvidesOperation("com_piggymetrics_notification_controller_RecipientController", - "/notifications/recipients", "/notifications/recipients"); - - assertMaxParameterCount(2, "com_piggymetrics_notification_service_RecipientService", "markNotified"); - - assertComponentRequiresComponent("com_piggymetrics_notification_client_AccountServiceClient", - "com_piggymetrics_account_controller_AccountController"); - - assertComponentRequiresComponent("com_piggymetrics_auth_service_UserServiceImpl", - "com_piggymetrics_auth_repository_UserRepository"); - assertComponentRequiresComponent("com_piggymetrics_notification_controller_RecipientController", - "com_piggymetrics_notification_service_RecipientServiceImpl"); - - assertInSameCompositeComponent("com_piggymetrics_notification_controller_RecipientController", - "com_piggymetrics_notification_service_NotificationServiceImpl"); - assertInSameCompositeComponent("com_piggymetrics_notification_controller_RecipientController", - "com_piggymetrics_notification_service_RecipientServiceImpl"); - assertInSameCompositeComponent("com_piggymetrics_notification_service_NotificationServiceImpl", - "com_piggymetrics_notification_client_AccountServiceClient"); - assertInSameCompositeComponent("com_piggymetrics_account_controller_AccountController", - "com_piggymetrics_account_client_AuthServiceClient"); - assertInSameCompositeComponent("com_piggymetrics_account_controller_AccountController", - "com_piggymetrics_account_client_StatisticsServiceClient"); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/SpringTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/SpringTest.java deleted file mode 100644 index 7fec3547..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/SpringTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.test.integration; - -import org.palladiosimulator.somox.analyzer.rules.impl.SpringRules; - -public class SpringTest extends RuleEngineTest { - - protected SpringTest() { - super("SpringProject", new SpringRules()); - } - - @Override - void testRuleEngineRepository() { - assertComponentExists("spring_AController"); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/TeaStoreTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/TeaStoreTest.java deleted file mode 100644 index 225570ae..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/integration/TeaStoreTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.test.integration; - -import org.junit.jupiter.api.Disabled; -import org.palladiosimulator.somox.analyzer.rules.impl.SpringRules; - -@Disabled("TODO: Currently broken") -public class TeaStoreTest extends RuleEngineTest { - - protected TeaStoreTest() { - super("external/TeaStore-1.4.1", new SpringRules()); - } - - @Override - void testRuleEngineRepository() { - // TODO: Temporarily disabled due to rule changes. - if (getClass() != null) - return; - - assertComponentExists("tools_descartes_teastore_auth_security_BCryptProvider"); - assertInterfaceExists("tools_descartes_teastore_kieker_probes_records_IPayloadCharacterization"); - - assertComponentProvidesOperation("tools_descartes_teastore_recommender_algorithm_AbstractRecommender", - "tools_descartes_teastore_recommender_algorithm_IRecommender", "train"); - assertComponentProvidesOperation("tools_descartes_teastore_recommender_algorithm_AbstractRecommender", - "tools_descartes_teastore_recommender_algorithm_IRecommender", "recommendProducts"); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/model/CompositeTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/model/CompositeTest.java deleted file mode 100644 index 763033ad..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/model/CompositeTest.java +++ /dev/null @@ -1,213 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.test.model; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.List; - -import org.junit.jupiter.api.Test; -import org.palladiosimulator.somox.analyzer.rules.model.CompUnitOrName; -import org.palladiosimulator.somox.analyzer.rules.model.Component; -import org.palladiosimulator.somox.analyzer.rules.model.ComponentBuilder; -import org.palladiosimulator.somox.analyzer.rules.model.Composite; -import org.palladiosimulator.somox.analyzer.rules.model.CompositeBuilder; -import org.palladiosimulator.somox.analyzer.rules.model.EntireInterface; -import org.palladiosimulator.somox.analyzer.rules.model.JavaInterfaceName; -import org.palladiosimulator.somox.analyzer.rules.model.JavaOperationName; -import org.palladiosimulator.somox.analyzer.rules.model.Operation; -import org.palladiosimulator.somox.analyzer.rules.model.OperationInterface; -import org.palladiosimulator.somox.analyzer.rules.model.Provisions; -import org.palladiosimulator.somox.analyzer.rules.model.Requirements; - -public class CompositeTest { - - @Test - void emptyComposite() { - CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); - Composite result = compositeBuilder.construct(List.of(), new Requirements(List.of(), List.of(), List.of()), - new Provisions(List.of(), List.of()), List.of()); - - assertTrue(result.parts() - .isEmpty(), "empty composite should have no parts"); - assertTrue(result.requirements() - .isEmpty(), "empty composite should have no requirements"); - assertTrue(result.provisions() - .isEmpty(), "empty composite should have no provisions"); - } - - @Test - void singletonComposite() { - OperationInterface provision = new Operation(null, new JavaOperationName("Interface", "providedMethod")); - EntireInterface requirement = new EntireInterface(new JavaInterfaceName("RequiredInterface")); - - ComponentBuilder componentBuilder = new ComponentBuilder(new CompUnitOrName("Component")); - componentBuilder.provisions() - .add(provision); - componentBuilder.requirements() - .add(requirement); - - CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); - compositeBuilder.addPart(componentBuilder); - - List allDependencies = List.of(provision, requirement); - List visibleProvisions = List.of(provision); - - Composite result = compositeBuilder.construct(List.of(), - new Requirements(List.of(), allDependencies, visibleProvisions), - new Provisions(List.of(), allDependencies), visibleProvisions); - - assertEquals(1, result.parts() - .size(), "this composite should have exactly one part"); - assertTrue(result.requirements() - .isEmpty(), "this composite should not have requirements"); - assertTrue(result.provisions() - .isEmpty(), "this composite should not have provisions"); - - Component component = result.parts() - .stream() - .findFirst() - .get(); - assertEquals(1, component.provisions() - .get() - .size(), "this component should only have one provision"); - assertEquals(1, component.requirements() - .get() - .size(), "this component should only have one requirement"); - } - - @Test - void exposingSingletonComposite() { - OperationInterface provision = new Operation(null, new JavaOperationName("Interface", "providedMethod")); - EntireInterface requirement = new EntireInterface(new JavaInterfaceName("RequiredInterface")); - - ComponentBuilder componentBuilder = new ComponentBuilder(new CompUnitOrName("Component")); - componentBuilder.provisions() - .add(provision); - componentBuilder.requirements() - .add(requirement); - - CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); - compositeBuilder.addPart(componentBuilder); - - List allDependencies = List.of(provision, requirement); - List visibleProvisions = List.of(provision); - - Composite result = compositeBuilder.construct(List.of(), - new Requirements(List.of(requirement), allDependencies, visibleProvisions), - new Provisions(List.of(provision), allDependencies), visibleProvisions); - - assertEquals(1, result.parts() - .size(), "this composite should have exactly one part"); - assertEquals(1, result.requirements() - .size(), "this composite should have exactly one requirement"); - assertEquals(1, result.provisions() - .size(), "this composite should have exactly one provision"); - } - - @Test - void twoComponentComposite() { - OperationInterface provision1 = new Operation(null, new JavaOperationName("InterfaceA", "providedMethodA")); - OperationInterface provision2 = new Operation(null, new JavaOperationName("InterfaceB", "providedMethodB")); - EntireInterface requirement1 = new EntireInterface(new JavaInterfaceName("RequiredInterfaceA")); - EntireInterface requirement2 = new EntireInterface(new JavaInterfaceName("RequiredInterfaceB")); - - ComponentBuilder componentBuilder1 = new ComponentBuilder(new CompUnitOrName("Component 1")); - componentBuilder1.provisions() - .add(provision1); - componentBuilder1.requirements() - .add(requirement1); - - ComponentBuilder componentBuilder2 = new ComponentBuilder(new CompUnitOrName("Component 2")); - componentBuilder2.provisions() - .add(provision2); - componentBuilder2.requirements() - .add(requirement2); - - CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); - compositeBuilder.addPart(componentBuilder1); - compositeBuilder.addPart(componentBuilder2); - - List allDependencies = List.of(provision1, provision2, requirement1, requirement2); - List visibleProvisions = List.of(provision1, provision2); - - Composite result = compositeBuilder.construct(List.of(), - new Requirements(List.of(requirement1, requirement2), allDependencies, visibleProvisions), - new Provisions(List.of(provision1, provision2), allDependencies), visibleProvisions); - - assertEquals(2, result.parts() - .size(), "this composite should have exactly two parts"); - assertEquals(2, result.requirements() - .size(), "this composite should have exactly two requirements"); - assertEquals(2, result.provisions() - .size(), "this composite should have exactly two provisions"); - } - - @Test - void overlappingTwoComponentComposite() { - OperationInterface provision = new Operation(null, new JavaOperationName("Interface", "providedMethod")); - EntireInterface requirement = new EntireInterface(new JavaInterfaceName("RequiredInterface")); - EntireInterface additionalRequirement1 = new EntireInterface(new JavaInterfaceName("RequiredInterfaceA")); - EntireInterface additionalRequirement2 = new EntireInterface(new JavaInterfaceName("RequiredInterfaceB")); - - ComponentBuilder componentBuilder1 = new ComponentBuilder(new CompUnitOrName("Component 1")); - componentBuilder1.provisions() - .add(provision); - componentBuilder1.requirements() - .add(requirement); - componentBuilder1.requirements() - .add(additionalRequirement1); - - ComponentBuilder componentBuilder2 = new ComponentBuilder(new CompUnitOrName("Component 2")); - componentBuilder2.provisions() - .add(provision); - componentBuilder2.requirements() - .add(requirement); - componentBuilder2.requirements() - .add(additionalRequirement2); - - CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); - compositeBuilder.addPart(componentBuilder1); - compositeBuilder.addPart(componentBuilder2); - - List allDependencies = List.of(provision, requirement, additionalRequirement1, - additionalRequirement2); - List visibleProvisions = List.of(provision); - - Composite result = compositeBuilder.construct(List.of(), - new Requirements(List.of(requirement), allDependencies, visibleProvisions), - new Provisions(List.of(provision), allDependencies), visibleProvisions); - - assertEquals(2, result.parts() - .size(), "this composite should have exactly two parts"); - assertEquals(1, result.requirements() - .size(), "this composite should have exactly one requirement"); - assertEquals(1, result.provisions() - .size(), "this composite should have exactly one provision"); - } - - @Test - void impreciseExposure() { - // TODO: Re-think this test. - OperationInterface provision = new Operation(null, new JavaOperationName("Interface", "providedMethod")); - OperationInterface impreciseProvision = new EntireInterface(new JavaInterfaceName("Interface")); - - ComponentBuilder componentBuilder = new ComponentBuilder(new CompUnitOrName("Component")); - componentBuilder.provisions() - .add(provision); - - CompositeBuilder compositeBuilder = new CompositeBuilder("CompositeComponent"); - compositeBuilder.addPart(componentBuilder); - - List allDependencies = List.of(provision); - List visibleProvisions = List.of(provision); - - Composite result = compositeBuilder.construct(List.of(), - new Requirements(List.of(), allDependencies, visibleProvisions), - new Provisions(List.of(impreciseProvision), allDependencies), visibleProvisions); - - assertEquals(1, result.parts() - .size(), "this composite should have exactly one part"); - assertEquals(1, result.provisions() - .size(), "this composite should have exactly one provision"); - } -} diff --git a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/model/PathTest.java b/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/model/PathTest.java deleted file mode 100644 index f478d1a6..00000000 --- a/tests/org.palladiosimulator.somox.analyzer.rules.test/src/org/palladiosimulator/somox/analyzer/rules/test/model/PathTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.palladiosimulator.somox.analyzer.rules.test.model; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.Optional; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.palladiosimulator.somox.analyzer.rules.model.EntireInterface; -import org.palladiosimulator.somox.analyzer.rules.model.HTTPMethod; -import org.palladiosimulator.somox.analyzer.rules.model.Operation; -import org.palladiosimulator.somox.analyzer.rules.model.RESTName; - -public class PathTest { - - @Test - void pathNamesAreReflective() { - String host = "test-host"; - String path = "/some/path"; - RESTName pathName = new RESTName(host, path, Optional.empty()); - assertTrue(pathName.isPartOf(host + path)); - } - - @Test - void pathsArePartOfTheirPrefixes() { - String path = "/some/path"; - RESTName interfaceName = new RESTName("test-host", path, Optional.empty()); - RESTName specificName = new RESTName("test-host", path + "/that/is/more/specific", Optional.empty()); - - assertTrue(specificName.isPartOf(interfaceName.getName()), "specific path is not part of its prefix"); - assertFalse(interfaceName.isPartOf(specificName.getName()), "prefix is part of a longer path"); - } - - @Test - void prefixesAreSeparatorAware() { - // This is NOT a legal prefix of "/some/path/..." - String somePath = "/some/pa"; - EntireInterface entireInterface = new EntireInterface(new RESTName("test-host", somePath, Optional.empty())); - RESTName specificPathName = new RESTName("test-host", "/some/path/that/is/more/specific", Optional.empty()); - Operation operation = new Operation(null, specificPathName); - - assertFalse(operation.isPartOf(entireInterface), "operation is part of illegal prefix"); - } - - @Disabled("This requirement has been temporarily softened for the Spring Gateway") - @Test - void httpMethodsAreSpecializations() { - String path = "/some/path"; - RESTName generalName = new RESTName("test-host", path, Optional.empty()); - RESTName specificName = new RESTName("test-host", path, Optional.of(HTTPMethod.GET)); - - Operation generalOperation = new Operation(null, generalName); - Operation specificOperation = new Operation(null, specificName); - - assertTrue(specificOperation.isPartOf(generalOperation)); - assertFalse(generalOperation.isPartOf(specificOperation)); - } -}