diff --git a/config.json b/config.json index ba90e41e..a8ee1fed 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,6 @@ { - "systemName": "sample-spring-microservices-new", - "repositoryURL": "https://github.com/piomin/sample-spring-microservices-new.git", - "baseBranch": "master" + "systemName": "cwa-server", + "repositoryURL": "https://github.com/corona-warn-app/cwa-server.git", + "baseCommit": "c61d55f6f83b6d005cb6aca9e9b455afac572d72", + "baseBranch": "main" } \ No newline at end of file diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index d774d3ed..5aea0c2d 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -81,7 +81,7 @@ exec:java - edu.university.ecs.lab.intermediate.create.IRExtractionRunner + edu.university.ecs.lab.intermediate.IRExtractionRunner @@ -99,7 +99,7 @@ exec:java - edu.university.ecs.lab.intermediate.merge.IRMergeRunner + edu.university.ecs.lab.intermediate.IRMergeRunner @@ -108,7 +108,7 @@ exec:java - edu.university.ecs.lab.detection.ExcelOutputRunner + edu.university.ecs.lab.detection_old.ExcelOutputRunner diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 06133fa3..00000000 --- a/docs/index.html +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - CIMET2 Project Home - - - - - -
-

CIMET2

-

Change Impact Microservice Evolution Tool v2

-
- -
-

Project Motivation

-

- CIMET2 allows developers to avoid degrading the architecture of their Microservice Systems BEFORE - changes are implemented. In a world where Microservice Systems rule them all developers need a way to navigate the complex interconnections between services and understand how - new changes impact them. Our tool disrupts the traditional development process of Microservice Systems, save time, save money and use CIMET2! -

-
- -
-

Setup

- - - - - -

Installation

-

- To install the project, follow these steps: -

    -
  1. Clone the repository: git clone https://github.com/cloudhubs/cimet2.git
  2. -
  3. Navigate to the project directory: e.g. cd repository
  4. -
  5. Install dependencies: mvn install
  6. -
-

- - -

Running the Project

-

- After the installation is complete, you can run the project using either Maven or by executing the JAR file: -

- - Ensure you have a configuration file named "config.json" present in the same directory as the JAR. A sample configuration file is below... - -
- - {
- "systemName": "systemName",
- "repositoryURL": "http://gitRepository.git",
- "baseBranch": "master"
- } -
-

-
- -
-

Demo

- - -
- - - - - - - diff --git a/docs/setup-linux.html b/docs/setup-linux.html deleted file mode 100644 index 006626d9..00000000 --- a/docs/setup-linux.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - CIMET2 - Linux Setup - - - - -
-

CIMET2 Linux Setup

-
- -
-

Installing Git, Java, and Maven on Linux

- -

Step 1: Install Git

-

Install Git using your package manager. For Ubuntu: sudo apt install git, or download from here.

- -

Step 2: Install Java

-

Install OpenJDK: sudo apt install openjdk-17-jdk, or download from here.

- -

Step 3: Install Maven

-

Install Maven: sudo apt install maven, or download from here.

- -

Step 4: Running a JAR File

-

To run a JAR file, use the following command:

-

java -jar yourfile.jar

-
- - - diff --git a/docs/setup-macos.html b/docs/setup-macos.html deleted file mode 100644 index 1d21fc23..00000000 --- a/docs/setup-macos.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - CIMET2 - macOS Setup - - - - -
-

CIMET2 macOS Setup

-
- -
-

Installing Git, Java, and Maven on macOS

- -

Step 1: Install Git

-

Install Git using Homebrew by running: brew install git. You can also download from here.

- -

Step 2: Install Java

-

Install Java using Homebrew: brew install java. Follow Oracle’s guide for manual installation.

- -

Step 3: Install Maven

-

Install Maven using Homebrew: brew install maven, or download from here.

- -

Step 4: Running a JAR File

-

To run a JAR file, use the following command:

-

java -jar yourfile.jar

-
- - - diff --git a/docs/setup-windows.html b/docs/setup-windows.html deleted file mode 100644 index d95f91f0..00000000 --- a/docs/setup-windows.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - CIMET2 - Windows Setup - - - - -
-

CIMET2 Windows Setup

-
- -
-

Installing Git, Java, and Maven on Windows

- -

Step 1: Install Git

-

Download Git from here. Follow the installation instructions.

- -

Step 2: Install Java

-

Download and install Java from here. Set the JAVA_HOME environment variable.

- -

Step 3: Install Maven

-

Download Maven from here. Extract the files and add bin to your system's PATH.

- -

Step 4: Running a JAR File

-

To run a JAR file, use the following command:

-

java -jar yourfile.jar

-
- - - diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index f953eb9b..00000000 --- a/package-lock.json +++ /dev/null @@ -1,2137 +0,0 @@ -{ - "name": "cimet2", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "cimet2", - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "@babel/core": "^7.25.2", - "@babel/preset-env": "^7.25.4", - "acorn": "^8.12.1", - "acorn-walk": "^8.3.3" - } - }, - "node_modules/@ampproject/remapping": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", - "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", - "dependencies": { - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.24" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@babel/code-frame": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.24.7.tgz", - "integrity": "sha512-BcYH1CVJBO9tvyIZ2jVeXgSIMvGZ2FDRvDdOIVQyuklNKSsx+eppDEBq/g47Ayw+RqNFE+URvOShmf+f/qwAlA==", - "dependencies": { - "@babel/highlight": "^7.24.7", - "picocolors": "^1.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/compat-data": { - "version": "7.25.4", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.25.4.tgz", - "integrity": "sha512-+LGRog6RAsCJrrrg/IO6LGmpphNe5DiK30dGjCoxxeGv49B10/3XYGxPsAwrDlMFcFEvdAUavDT8r9k/hSyQqQ==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/core": { - "version": "7.25.2", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.25.2.tgz", - "integrity": "sha512-BBt3opiCOxUr9euZ5/ro/Xv8/V7yJ5bjYMqG/C1YAo8MIKAnumZalCN+msbci3Pigy4lIQfPUpfMM27HMGaYEA==", - "dependencies": { - "@ampproject/remapping": "^2.2.0", - "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.25.0", - "@babel/helper-compilation-targets": "^7.25.2", - "@babel/helper-module-transforms": "^7.25.2", - "@babel/helpers": "^7.25.0", - "@babel/parser": "^7.25.0", - "@babel/template": "^7.25.0", - "@babel/traverse": "^7.25.2", - "@babel/types": "^7.25.2", - "convert-source-map": "^2.0.0", - "debug": "^4.1.0", - "gensync": "^1.0.0-beta.2", - "json5": "^2.2.3", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/babel" - } - }, - "node_modules/@babel/generator": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.25.6.tgz", - "integrity": "sha512-VPC82gr1seXOpkjAAKoLhP50vx4vGNlF4msF64dSFq1P8RfB+QAuJWGHPXXPc8QyfVWwwB/TNNU4+ayZmHNbZw==", - "dependencies": { - "@babel/types": "^7.25.6", - "@jridgewell/gen-mapping": "^0.3.5", - "@jridgewell/trace-mapping": "^0.3.25", - "jsesc": "^2.5.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-annotate-as-pure": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.24.7.tgz", - "integrity": "sha512-BaDeOonYvhdKw+JoMVkAixAAJzG2jVPIwWoKBPdYuY9b452e2rPuI9QPYh3KpofZ3pW2akOmwZLOiOsHMiqRAg==", - "dependencies": { - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-builder-binary-assignment-operator-visitor": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.24.7.tgz", - "integrity": "sha512-xZeCVVdwb4MsDBkkyZ64tReWYrLRHlMN72vP7Bdm3OUOuyFZExhsHUUnuWnm2/XOlAJzR0LfPpB56WXZn0X/lA==", - "dependencies": { - "@babel/traverse": "^7.24.7", - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-compilation-targets": { - "version": "7.25.2", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.25.2.tgz", - "integrity": "sha512-U2U5LsSaZ7TAt3cfaymQ8WHh0pxvdHoEk6HVpaexxixjyEquMh0L0YNJNM6CTGKMXV1iksi0iZkGw4AcFkPaaw==", - "dependencies": { - "@babel/compat-data": "^7.25.2", - "@babel/helper-validator-option": "^7.24.8", - "browserslist": "^4.23.1", - "lru-cache": "^5.1.1", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-create-class-features-plugin": { - "version": "7.25.4", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.25.4.tgz", - "integrity": "sha512-ro/bFs3/84MDgDmMwbcHgDa8/E6J3QKNTk4xJJnVeFtGE+tL0K26E3pNxhYz2b67fJpt7Aphw5XcploKXuCvCQ==", - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.24.7", - "@babel/helper-member-expression-to-functions": "^7.24.8", - "@babel/helper-optimise-call-expression": "^7.24.7", - "@babel/helper-replace-supers": "^7.25.0", - "@babel/helper-skip-transparent-expression-wrappers": "^7.24.7", - "@babel/traverse": "^7.25.4", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-create-regexp-features-plugin": { - "version": "7.25.2", - "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.25.2.tgz", - "integrity": "sha512-+wqVGP+DFmqwFD3EH6TMTfUNeqDehV3E/dl+Sd54eaXqm17tEUNbEIn4sVivVowbvUpOtIGxdo3GoXyDH9N/9g==", - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.24.7", - "regexpu-core": "^5.3.1", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-define-polyfill-provider": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.6.2.tgz", - "integrity": "sha512-LV76g+C502biUK6AyZ3LK10vDpDyCzZnhZFXkH1L75zHPj68+qc8Zfpx2th+gzwA2MzyK+1g/3EPl62yFnVttQ==", - "dependencies": { - "@babel/helper-compilation-targets": "^7.22.6", - "@babel/helper-plugin-utils": "^7.22.5", - "debug": "^4.1.1", - "lodash.debounce": "^4.0.8", - "resolve": "^1.14.2" - }, - "peerDependencies": { - "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" - } - }, - "node_modules/@babel/helper-member-expression-to-functions": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.24.8.tgz", - "integrity": "sha512-LABppdt+Lp/RlBxqrh4qgf1oEH/WxdzQNDJIu5gC/W1GyvPVrOBiItmmM8wan2fm4oYqFuFfkXmlGpLQhPY8CA==", - "dependencies": { - "@babel/traverse": "^7.24.8", - "@babel/types": "^7.24.8" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-imports": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.24.7.tgz", - "integrity": "sha512-8AyH3C+74cgCVVXow/myrynrAGv+nTVg5vKu2nZph9x7RcRwzmh0VFallJuFTZ9mx6u4eSdXZfcOzSqTUm0HCA==", - "dependencies": { - "@babel/traverse": "^7.24.7", - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-module-transforms": { - "version": "7.25.2", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.25.2.tgz", - "integrity": "sha512-BjyRAbix6j/wv83ftcVJmBt72QtHI56C7JXZoG2xATiLpmoC7dpd8WnkikExHDVPpi/3qCmO6WY1EaXOluiecQ==", - "dependencies": { - "@babel/helper-module-imports": "^7.24.7", - "@babel/helper-simple-access": "^7.24.7", - "@babel/helper-validator-identifier": "^7.24.7", - "@babel/traverse": "^7.25.2" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-optimise-call-expression": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.24.7.tgz", - "integrity": "sha512-jKiTsW2xmWwxT1ixIdfXUZp+P5yURx2suzLZr5Hi64rURpDYdMW0pv+Uf17EYk2Rd428Lx4tLsnjGJzYKDM/6A==", - "dependencies": { - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-plugin-utils": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.24.8.tgz", - "integrity": "sha512-FFWx5142D8h2Mgr/iPVGH5G7w6jDn4jUSpZTyDnQO0Yn7Ks2Kuz6Pci8H6MPCoUJegd/UZQ3tAvfLCxQSnWWwg==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-remap-async-to-generator": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.25.0.tgz", - "integrity": "sha512-NhavI2eWEIz/H9dbrG0TuOicDhNexze43i5z7lEqwYm0WEZVTwnPpA0EafUTP7+6/W79HWIP2cTe3Z5NiSTVpw==", - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.24.7", - "@babel/helper-wrap-function": "^7.25.0", - "@babel/traverse": "^7.25.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-replace-supers": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.25.0.tgz", - "integrity": "sha512-q688zIvQVYtZu+i2PsdIu/uWGRpfxzr5WESsfpShfZECkO+d2o+WROWezCi/Q6kJ0tfPa5+pUGUlfx2HhrA3Bg==", - "dependencies": { - "@babel/helper-member-expression-to-functions": "^7.24.8", - "@babel/helper-optimise-call-expression": "^7.24.7", - "@babel/traverse": "^7.25.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/helper-simple-access": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.24.7.tgz", - "integrity": "sha512-zBAIvbCMh5Ts+b86r/CjU+4XGYIs+R1j951gxI3KmmxBMhCg4oQMsv6ZXQ64XOm/cvzfU1FmoCyt6+owc5QMYg==", - "dependencies": { - "@babel/traverse": "^7.24.7", - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-skip-transparent-expression-wrappers": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.24.7.tgz", - "integrity": "sha512-IO+DLT3LQUElMbpzlatRASEyQtfhSE0+m465v++3jyyXeBTBUjtVZg28/gHeV5mrTJqvEKhKroBGAvhW+qPHiQ==", - "dependencies": { - "@babel/traverse": "^7.24.7", - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-string-parser": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.24.8.tgz", - "integrity": "sha512-pO9KhhRcuUyGnJWwyEgnRJTSIZHiT+vMD0kPeD+so0l7mxkMT19g3pjY9GTnHySck/hDzq+dtW/4VgnMkippsQ==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-identifier": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.7.tgz", - "integrity": "sha512-rR+PBcQ1SMQDDyF6X0wxtG8QyLCgUB0eRAGguqRLfkCA87l7yAP7ehq8SNj96OOGTO8OBV70KhuFYcIkHXOg0w==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-option": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.24.8.tgz", - "integrity": "sha512-xb8t9tD1MHLungh/AIoWYN+gVHaB9kwlu8gffXGSt3FFEIT7RjS+xWbc2vUD1UTZdIpKj/ab3rdqJ7ufngyi2Q==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-wrap-function": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.25.0.tgz", - "integrity": "sha512-s6Q1ebqutSiZnEjaofc/UKDyC4SbzV5n5SrA2Gq8UawLycr3i04f1dX4OzoQVnexm6aOCh37SQNYlJ/8Ku+PMQ==", - "dependencies": { - "@babel/template": "^7.25.0", - "@babel/traverse": "^7.25.0", - "@babel/types": "^7.25.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helpers": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.25.6.tgz", - "integrity": "sha512-Xg0tn4HcfTijTwfDwYlvVCl43V6h4KyVVX2aEm4qdO/PC6L2YvzLHFdmxhoeSA3eslcE6+ZVXHgWwopXYLNq4Q==", - "dependencies": { - "@babel/template": "^7.25.0", - "@babel/types": "^7.25.6" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/highlight": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.24.7.tgz", - "integrity": "sha512-EStJpq4OuY8xYfhGVXngigBJRWxftKX9ksiGDnmlY3o7B/V7KIAc9X4oiK87uPJSc/vs5L869bem5fhZa8caZw==", - "dependencies": { - "@babel/helper-validator-identifier": "^7.24.7", - "chalk": "^2.4.2", - "js-tokens": "^4.0.0", - "picocolors": "^1.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/parser": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.25.6.tgz", - "integrity": "sha512-trGdfBdbD0l1ZPmcJ83eNxB9rbEax4ALFTF7fN386TMYbeCQbyme5cOEXQhbGXKebwGaB/J52w1mrklMcbgy6Q==", - "dependencies": { - "@babel/types": "^7.25.6" - }, - "bin": { - "parser": "bin/babel-parser.js" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@babel/plugin-bugfix-firefox-class-in-computed-class-key": { - "version": "7.25.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-firefox-class-in-computed-class-key/-/plugin-bugfix-firefox-class-in-computed-class-key-7.25.3.tgz", - "integrity": "sha512-wUrcsxZg6rqBXG05HG1FPYgsP6EvwF4WpBbxIpWIIYnH8wG0gzx3yZY3dtEHas4sTAOGkbTsc9EGPxwff8lRoA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.8", - "@babel/traverse": "^7.25.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-bugfix-safari-class-field-initializer-scope": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-class-field-initializer-scope/-/plugin-bugfix-safari-class-field-initializer-scope-7.25.0.tgz", - "integrity": "sha512-Bm4bH2qsX880b/3ziJ8KD711LT7z4u8CFudmjqle65AZj/HNUFhEf90dqYv6O86buWvSBmeQDjv0Tn2aF/bIBA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.8" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.25.0.tgz", - "integrity": "sha512-lXwdNZtTmeVOOFtwM/WDe7yg1PL8sYhRk/XH0FzbR2HDQ0xC+EnQ/JHeoMYSavtU115tnUk0q9CDyq8si+LMAA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.8" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.24.7.tgz", - "integrity": "sha512-+izXIbke1T33mY4MSNnrqhPXDz01WYhEf3yF5NbnUtkiNnm+XBZJl3kNfoK6NKmYlz/D07+l2GWVK/QfDkNCuQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.24.7", - "@babel/plugin-transform-optional-chaining": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.13.0" - } - }, - "node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/-/plugin-bugfix-v8-static-class-fields-redefine-readonly-7.25.0.tgz", - "integrity": "sha512-tggFrk1AIShG/RUQbEwt2Tr/E+ObkfwrPjR6BjbRvsx24+PSjK8zrq0GWPNCjo8qpRx4DuJzlcvWJqlm+0h3kw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.8", - "@babel/traverse": "^7.25.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-proposal-private-property-in-object": { - "version": "7.21.0-placeholder-for-preset-env.2", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", - "integrity": "sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==", - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-async-generators": { - "version": "7.8.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", - "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-class-properties": { - "version": "7.12.13", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", - "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.12.13" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-class-static-block": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz", - "integrity": "sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.14.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-dynamic-import": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz", - "integrity": "sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-export-namespace-from": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-export-namespace-from/-/plugin-syntax-export-namespace-from-7.8.3.tgz", - "integrity": "sha512-MXf5laXo6c1IbEbegDmzGPwGNTsHZmEy6QGznu5Sh2UCWvueywb2ee+CCE4zQiZstxU9BMoQO9i6zUFSY0Kj0Q==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.3" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-import-assertions": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.25.6.tgz", - "integrity": "sha512-aABl0jHw9bZ2karQ/uUD6XP4u0SG22SJrOHFoL6XB1R7dTovOP4TzTlsxOYC5yQ1pdscVK2JTUnF6QL3ARoAiQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.8" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-import-attributes": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.25.6.tgz", - "integrity": "sha512-sXaDXaJN9SNLymBdlWFA+bjzBhFD617ZaFiY13dGt7TVslVvVgA6fkZOP7Ki3IGElC45lwHdOTrCtKZGVAWeLQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.8" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-import-meta": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", - "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.10.4" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-json-strings": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", - "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-logical-assignment-operators": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", - "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.10.4" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", - "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-numeric-separator": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", - "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.10.4" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-object-rest-spread": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", - "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-optional-catch-binding": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", - "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-optional-chaining": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", - "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.8.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-private-property-in-object": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz", - "integrity": "sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.14.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-top-level-await": { - "version": "7.14.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", - "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.14.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-syntax-unicode-sets-regex": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-unicode-sets-regex/-/plugin-syntax-unicode-sets-regex-7.18.6.tgz", - "integrity": "sha512-727YkEAPwSIQTv5im8QHz3upqp92JTWhidIC81Tdx4VJYIte/VndKf1qKrfnnhPLiPghStWfvC/iFaMCQu7Nqg==", - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.18.6", - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-transform-arrow-functions": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.24.7.tgz", - "integrity": "sha512-Dt9LQs6iEY++gXUwY03DNFat5C2NbO48jj+j/bSAz6b3HgPs39qcPiYt77fDObIcFwj3/C2ICX9YMwGflUoSHQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-async-generator-functions": { - "version": "7.25.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-generator-functions/-/plugin-transform-async-generator-functions-7.25.4.tgz", - "integrity": "sha512-jz8cV2XDDTqjKPwVPJBIjORVEmSGYhdRa8e5k5+vN+uwcjSrSxUaebBRa4ko1jqNF2uxyg8G6XYk30Jv285xzg==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.8", - "@babel/helper-remap-async-to-generator": "^7.25.0", - "@babel/plugin-syntax-async-generators": "^7.8.4", - "@babel/traverse": "^7.25.4" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-async-to-generator": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.24.7.tgz", - "integrity": "sha512-SQY01PcJfmQ+4Ash7NE+rpbLFbmqA2GPIgqzxfFTL4t1FKRq4zTms/7htKpoCUI9OcFYgzqfmCdH53s6/jn5fA==", - "dependencies": { - "@babel/helper-module-imports": "^7.24.7", - "@babel/helper-plugin-utils": "^7.24.7", - "@babel/helper-remap-async-to-generator": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-block-scoped-functions": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.24.7.tgz", - "integrity": "sha512-yO7RAz6EsVQDaBH18IDJcMB1HnrUn2FJ/Jslc/WtPPWcjhpUJXU/rjbwmluzp7v/ZzWcEhTMXELnnsz8djWDwQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-block-scoping": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.25.0.tgz", - "integrity": "sha512-yBQjYoOjXlFv9nlXb3f1casSHOZkWr29NX+zChVanLg5Nc157CrbEX9D7hxxtTpuFy7Q0YzmmWfJxzvps4kXrQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.8" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-class-properties": { - "version": "7.25.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-properties/-/plugin-transform-class-properties-7.25.4.tgz", - "integrity": "sha512-nZeZHyCWPfjkdU5pA/uHiTaDAFUEqkpzf1YoQT2NeSynCGYq9rxfyI3XpQbfx/a0hSnFH6TGlEXvae5Vi7GD8g==", - "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.25.4", - "@babel/helper-plugin-utils": "^7.24.8" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-class-static-block": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-static-block/-/plugin-transform-class-static-block-7.24.7.tgz", - "integrity": "sha512-HMXK3WbBPpZQufbMG4B46A90PkuuhN9vBCb5T8+VAHqvAqvcLi+2cKoukcpmUYkszLhScU3l1iudhrks3DggRQ==", - "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.24.7", - "@babel/helper-plugin-utils": "^7.24.7", - "@babel/plugin-syntax-class-static-block": "^7.14.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.12.0" - } - }, - "node_modules/@babel/plugin-transform-classes": { - "version": "7.25.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.25.4.tgz", - "integrity": "sha512-oexUfaQle2pF/b6E0dwsxQtAol9TLSO88kQvym6HHBWFliV2lGdrPieX+WgMRLSJDVzdYywk7jXbLPuO2KLTLg==", - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.24.7", - "@babel/helper-compilation-targets": "^7.25.2", - "@babel/helper-plugin-utils": "^7.24.8", - "@babel/helper-replace-supers": "^7.25.0", - "@babel/traverse": "^7.25.4", - "globals": "^11.1.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-computed-properties": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.24.7.tgz", - "integrity": "sha512-25cS7v+707Gu6Ds2oY6tCkUwsJ9YIDbggd9+cu9jzzDgiNq7hR/8dkzxWfKWnTic26vsI3EsCXNd4iEB6e8esQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7", - "@babel/template": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-destructuring": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.24.8.tgz", - "integrity": "sha512-36e87mfY8TnRxc7yc6M9g9gOB7rKgSahqkIKwLpz4Ppk2+zC2Cy1is0uwtuSG6AE4zlTOUa+7JGz9jCJGLqQFQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.8" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-dotall-regex": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.24.7.tgz", - "integrity": "sha512-ZOA3W+1RRTSWvyqcMJDLqbchh7U4NRGqwRfFSVbOLS/ePIP4vHB5e8T8eXcuqyN1QkgKyj5wuW0lcS85v4CrSw==", - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.24.7", - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-duplicate-keys": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.24.7.tgz", - "integrity": "sha512-JdYfXyCRihAe46jUIliuL2/s0x0wObgwwiGxw/UbgJBr20gQBThrokO4nYKgWkD7uBaqM7+9x5TU7NkExZJyzw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-duplicate-named-capturing-groups-regex": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-named-capturing-groups-regex/-/plugin-transform-duplicate-named-capturing-groups-regex-7.25.0.tgz", - "integrity": "sha512-YLpb4LlYSc3sCUa35un84poXoraOiQucUTTu8X1j18JV+gNa8E0nyUf/CjZ171IRGr4jEguF+vzJU66QZhn29g==", - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.25.0", - "@babel/helper-plugin-utils": "^7.24.8" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-transform-dynamic-import": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dynamic-import/-/plugin-transform-dynamic-import-7.24.7.tgz", - "integrity": "sha512-sc3X26PhZQDb3JhORmakcbvkeInvxz+A8oda99lj7J60QRuPZvNAk9wQlTBS1ZynelDrDmTU4pw1tyc5d5ZMUg==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7", - "@babel/plugin-syntax-dynamic-import": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-exponentiation-operator": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.24.7.tgz", - "integrity": "sha512-Rqe/vSc9OYgDajNIK35u7ot+KeCoetqQYFXM4Epf7M7ez3lWlOjrDjrwMei6caCVhfdw+mIKD4cgdGNy5JQotQ==", - "dependencies": { - "@babel/helper-builder-binary-assignment-operator-visitor": "^7.24.7", - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-export-namespace-from": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-export-namespace-from/-/plugin-transform-export-namespace-from-7.24.7.tgz", - "integrity": "sha512-v0K9uNYsPL3oXZ/7F9NNIbAj2jv1whUEtyA6aujhekLs56R++JDQuzRcP2/z4WX5Vg/c5lE9uWZA0/iUoFhLTA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7", - "@babel/plugin-syntax-export-namespace-from": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-for-of": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.24.7.tgz", - "integrity": "sha512-wo9ogrDG1ITTTBsy46oGiN1dS9A7MROBTcYsfS8DtsImMkHk9JXJ3EWQM6X2SUw4x80uGPlwj0o00Uoc6nEE3g==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-function-name": { - "version": "7.25.1", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.25.1.tgz", - "integrity": "sha512-TVVJVdW9RKMNgJJlLtHsKDTydjZAbwIsn6ySBPQaEAUU5+gVvlJt/9nRmqVbsV/IBanRjzWoaAQKLoamWVOUuA==", - "dependencies": { - "@babel/helper-compilation-targets": "^7.24.8", - "@babel/helper-plugin-utils": "^7.24.8", - "@babel/traverse": "^7.25.1" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-json-strings": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-json-strings/-/plugin-transform-json-strings-7.24.7.tgz", - "integrity": "sha512-2yFnBGDvRuxAaE/f0vfBKvtnvvqU8tGpMHqMNpTN2oWMKIR3NqFkjaAgGwawhqK/pIN2T3XdjGPdaG0vDhOBGw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7", - "@babel/plugin-syntax-json-strings": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-literals": { - "version": "7.25.2", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.25.2.tgz", - "integrity": "sha512-HQI+HcTbm9ur3Z2DkO+jgESMAMcYLuN/A7NRw9juzxAezN9AvqvUTnpKP/9kkYANz6u7dFlAyOu44ejuGySlfw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.8" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-logical-assignment-operators": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-logical-assignment-operators/-/plugin-transform-logical-assignment-operators-7.24.7.tgz", - "integrity": "sha512-4D2tpwlQ1odXmTEIFWy9ELJcZHqrStlzK/dAOWYyxX3zT0iXQB6banjgeOJQXzEc4S0E0a5A+hahxPaEFYftsw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7", - "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-member-expression-literals": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.24.7.tgz", - "integrity": "sha512-T/hRC1uqrzXMKLQ6UCwMT85S3EvqaBXDGf0FaMf4446Qx9vKwlghvee0+uuZcDUCZU5RuNi4781UQ7R308zzBw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-modules-amd": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.24.7.tgz", - "integrity": "sha512-9+pB1qxV3vs/8Hdmz/CulFB8w2tuu6EB94JZFsjdqxQokwGa9Unap7Bo2gGBGIvPmDIVvQrom7r5m/TCDMURhg==", - "dependencies": { - "@babel/helper-module-transforms": "^7.24.7", - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-modules-commonjs": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.24.8.tgz", - "integrity": "sha512-WHsk9H8XxRs3JXKWFiqtQebdh9b/pTk4EgueygFzYlTKAg0Ud985mSevdNjdXdFBATSKVJGQXP1tv6aGbssLKA==", - "dependencies": { - "@babel/helper-module-transforms": "^7.24.8", - "@babel/helper-plugin-utils": "^7.24.8", - "@babel/helper-simple-access": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-modules-systemjs": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.25.0.tgz", - "integrity": "sha512-YPJfjQPDXxyQWg/0+jHKj1llnY5f/R6a0p/vP4lPymxLu7Lvl4k2WMitqi08yxwQcCVUUdG9LCUj4TNEgAp3Jw==", - "dependencies": { - "@babel/helper-module-transforms": "^7.25.0", - "@babel/helper-plugin-utils": "^7.24.8", - "@babel/helper-validator-identifier": "^7.24.7", - "@babel/traverse": "^7.25.0" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-modules-umd": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.24.7.tgz", - "integrity": "sha512-3aytQvqJ/h9z4g8AsKPLvD4Zqi2qT+L3j7XoFFu1XBlZWEl2/1kWnhmAbxpLgPrHSY0M6UA02jyTiwUVtiKR6A==", - "dependencies": { - "@babel/helper-module-transforms": "^7.24.7", - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-named-capturing-groups-regex": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.24.7.tgz", - "integrity": "sha512-/jr7h/EWeJtk1U/uz2jlsCioHkZk1JJZVcc8oQsJ1dUlaJD83f4/6Zeh2aHt9BIFokHIsSeDfhUmju0+1GPd6g==", - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.24.7", - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/plugin-transform-new-target": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.24.7.tgz", - "integrity": "sha512-RNKwfRIXg4Ls/8mMTza5oPF5RkOW8Wy/WgMAp1/F1yZ8mMbtwXW+HDoJiOsagWrAhI5f57Vncrmr9XeT4CVapA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-nullish-coalescing-operator": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-nullish-coalescing-operator/-/plugin-transform-nullish-coalescing-operator-7.24.7.tgz", - "integrity": "sha512-Ts7xQVk1OEocqzm8rHMXHlxvsfZ0cEF2yomUqpKENHWMF4zKk175Y4q8H5knJes6PgYad50uuRmt3UJuhBw8pQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7", - "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-numeric-separator": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-numeric-separator/-/plugin-transform-numeric-separator-7.24.7.tgz", - "integrity": "sha512-e6q1TiVUzvH9KRvicuxdBTUj4AdKSRwzIyFFnfnezpCfP2/7Qmbb8qbU2j7GODbl4JMkblitCQjKYUaX/qkkwA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7", - "@babel/plugin-syntax-numeric-separator": "^7.10.4" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-object-rest-spread": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.24.7.tgz", - "integrity": "sha512-4QrHAr0aXQCEFni2q4DqKLD31n2DL+RxcwnNjDFkSG0eNQ/xCavnRkfCUjsyqGC2OviNJvZOF/mQqZBw7i2C5Q==", - "dependencies": { - "@babel/helper-compilation-targets": "^7.24.7", - "@babel/helper-plugin-utils": "^7.24.7", - "@babel/plugin-syntax-object-rest-spread": "^7.8.3", - "@babel/plugin-transform-parameters": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-object-super": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.24.7.tgz", - "integrity": "sha512-A/vVLwN6lBrMFmMDmPPz0jnE6ZGx7Jq7d6sT/Ev4H65RER6pZ+kczlf1DthF5N0qaPHBsI7UXiE8Zy66nmAovg==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7", - "@babel/helper-replace-supers": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-optional-catch-binding": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-catch-binding/-/plugin-transform-optional-catch-binding-7.24.7.tgz", - "integrity": "sha512-uLEndKqP5BfBbC/5jTwPxLh9kqPWWgzN/f8w6UwAIirAEqiIVJWWY312X72Eub09g5KF9+Zn7+hT7sDxmhRuKA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7", - "@babel/plugin-syntax-optional-catch-binding": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-optional-chaining": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.24.8.tgz", - "integrity": "sha512-5cTOLSMs9eypEy8JUVvIKOu6NgvbJMnpG62VpIHrTmROdQ+L5mDAaI40g25k5vXti55JWNX5jCkq3HZxXBQANw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.8", - "@babel/helper-skip-transparent-expression-wrappers": "^7.24.7", - "@babel/plugin-syntax-optional-chaining": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-parameters": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.24.7.tgz", - "integrity": "sha512-yGWW5Rr+sQOhK0Ot8hjDJuxU3XLRQGflvT4lhlSY0DFvdb3TwKaY26CJzHtYllU0vT9j58hc37ndFPsqT1SrzA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-private-methods": { - "version": "7.25.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-private-methods/-/plugin-transform-private-methods-7.25.4.tgz", - "integrity": "sha512-ao8BG7E2b/URaUQGqN3Tlsg+M3KlHY6rJ1O1gXAEUnZoyNQnvKyH87Kfg+FoxSeyWUB8ISZZsC91C44ZuBFytw==", - "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.25.4", - "@babel/helper-plugin-utils": "^7.24.8" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-private-property-in-object": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-private-property-in-object/-/plugin-transform-private-property-in-object-7.24.7.tgz", - "integrity": "sha512-9z76mxwnwFxMyxZWEgdgECQglF2Q7cFLm0kMf8pGwt+GSJsY0cONKj/UuO4bOH0w/uAel3ekS4ra5CEAyJRmDA==", - "dependencies": { - "@babel/helper-annotate-as-pure": "^7.24.7", - "@babel/helper-create-class-features-plugin": "^7.24.7", - "@babel/helper-plugin-utils": "^7.24.7", - "@babel/plugin-syntax-private-property-in-object": "^7.14.5" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-property-literals": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.24.7.tgz", - "integrity": "sha512-EMi4MLQSHfd2nrCqQEWxFdha2gBCqU4ZcCng4WBGZ5CJL4bBRW0ptdqqDdeirGZcpALazVVNJqRmsO8/+oNCBA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-regenerator": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.24.7.tgz", - "integrity": "sha512-lq3fvXPdimDrlg6LWBoqj+r/DEWgONuwjuOuQCSYgRroXDH/IdM1C0IZf59fL5cHLpjEH/O6opIRBbqv7ELnuA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7", - "regenerator-transform": "^0.15.2" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-reserved-words": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.24.7.tgz", - "integrity": "sha512-0DUq0pHcPKbjFZCfTss/pGkYMfy3vFWydkUBd9r0GHpIyfs2eCDENvqadMycRS9wZCXR41wucAfJHJmwA0UmoQ==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-shorthand-properties": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.24.7.tgz", - "integrity": "sha512-KsDsevZMDsigzbA09+vacnLpmPH4aWjcZjXdyFKGzpplxhbeB4wYtury3vglQkg6KM/xEPKt73eCjPPf1PgXBA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-spread": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.24.7.tgz", - "integrity": "sha512-x96oO0I09dgMDxJaANcRyD4ellXFLLiWhuwDxKZX5g2rWP1bTPkBSwCYv96VDXVT1bD9aPj8tppr5ITIh8hBng==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-sticky-regex": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.24.7.tgz", - "integrity": "sha512-kHPSIJc9v24zEml5geKg9Mjx5ULpfncj0wRpYtxbvKyTtHCYDkVE3aHQ03FrpEo4gEe2vrJJS1Y9CJTaThA52g==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-template-literals": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.24.7.tgz", - "integrity": "sha512-AfDTQmClklHCOLxtGoP7HkeMw56k1/bTQjwsfhL6pppo/M4TOBSq+jjBUBLmV/4oeFg4GWMavIl44ZeCtmmZTw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-typeof-symbol": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.24.8.tgz", - "integrity": "sha512-adNTUpDCVnmAE58VEqKlAA6ZBlNkMnWD0ZcW76lyNFN3MJniyGFZfNwERVk8Ap56MCnXztmDr19T4mPTztcuaw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.8" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-unicode-escapes": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.24.7.tgz", - "integrity": "sha512-U3ap1gm5+4edc2Q/P+9VrBNhGkfnf+8ZqppY71Bo/pzZmXhhLdqgaUl6cuB07O1+AQJtCLfaOmswiNbSQ9ivhw==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-unicode-property-regex": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-property-regex/-/plugin-transform-unicode-property-regex-7.24.7.tgz", - "integrity": "sha512-uH2O4OV5M9FZYQrwc7NdVmMxQJOCCzFeYudlZSzUAHRFeOujQefa92E74TQDVskNHCzOXoigEuoyzHDhaEaK5w==", - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.24.7", - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-unicode-regex": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.24.7.tgz", - "integrity": "sha512-hlQ96MBZSAXUq7ltkjtu3FJCCSMx/j629ns3hA3pXnBXjanNP0LHi+JpPeA81zaWgVK1VGH95Xuy7u0RyQ8kMg==", - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.24.7", - "@babel/helper-plugin-utils": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-transform-unicode-sets-regex": { - "version": "7.25.4", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-sets-regex/-/plugin-transform-unicode-sets-regex-7.25.4.tgz", - "integrity": "sha512-qesBxiWkgN1Q+31xUE9RcMk79eOXXDCv6tfyGMRSs4RGlioSg2WVyQAm07k726cSE56pa+Kb0y9epX2qaXzTvA==", - "dependencies": { - "@babel/helper-create-regexp-features-plugin": "^7.25.2", - "@babel/helper-plugin-utils": "^7.24.8" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0" - } - }, - "node_modules/@babel/preset-env": { - "version": "7.25.4", - "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.25.4.tgz", - "integrity": "sha512-W9Gyo+KmcxjGahtt3t9fb14vFRWvPpu5pT6GBlovAK6BTBcxgjfVMSQCfJl4oi35ODrxP6xx2Wr8LNST57Mraw==", - "dependencies": { - "@babel/compat-data": "^7.25.4", - "@babel/helper-compilation-targets": "^7.25.2", - "@babel/helper-plugin-utils": "^7.24.8", - "@babel/helper-validator-option": "^7.24.8", - "@babel/plugin-bugfix-firefox-class-in-computed-class-key": "^7.25.3", - "@babel/plugin-bugfix-safari-class-field-initializer-scope": "^7.25.0", - "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.25.0", - "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.24.7", - "@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly": "^7.25.0", - "@babel/plugin-proposal-private-property-in-object": "7.21.0-placeholder-for-preset-env.2", - "@babel/plugin-syntax-async-generators": "^7.8.4", - "@babel/plugin-syntax-class-properties": "^7.12.13", - "@babel/plugin-syntax-class-static-block": "^7.14.5", - "@babel/plugin-syntax-dynamic-import": "^7.8.3", - "@babel/plugin-syntax-export-namespace-from": "^7.8.3", - "@babel/plugin-syntax-import-assertions": "^7.24.7", - "@babel/plugin-syntax-import-attributes": "^7.24.7", - "@babel/plugin-syntax-import-meta": "^7.10.4", - "@babel/plugin-syntax-json-strings": "^7.8.3", - "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4", - "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", - "@babel/plugin-syntax-numeric-separator": "^7.10.4", - "@babel/plugin-syntax-object-rest-spread": "^7.8.3", - "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", - "@babel/plugin-syntax-optional-chaining": "^7.8.3", - "@babel/plugin-syntax-private-property-in-object": "^7.14.5", - "@babel/plugin-syntax-top-level-await": "^7.14.5", - "@babel/plugin-syntax-unicode-sets-regex": "^7.18.6", - "@babel/plugin-transform-arrow-functions": "^7.24.7", - "@babel/plugin-transform-async-generator-functions": "^7.25.4", - "@babel/plugin-transform-async-to-generator": "^7.24.7", - "@babel/plugin-transform-block-scoped-functions": "^7.24.7", - "@babel/plugin-transform-block-scoping": "^7.25.0", - "@babel/plugin-transform-class-properties": "^7.25.4", - "@babel/plugin-transform-class-static-block": "^7.24.7", - "@babel/plugin-transform-classes": "^7.25.4", - "@babel/plugin-transform-computed-properties": "^7.24.7", - "@babel/plugin-transform-destructuring": "^7.24.8", - "@babel/plugin-transform-dotall-regex": "^7.24.7", - "@babel/plugin-transform-duplicate-keys": "^7.24.7", - "@babel/plugin-transform-duplicate-named-capturing-groups-regex": "^7.25.0", - "@babel/plugin-transform-dynamic-import": "^7.24.7", - "@babel/plugin-transform-exponentiation-operator": "^7.24.7", - "@babel/plugin-transform-export-namespace-from": "^7.24.7", - "@babel/plugin-transform-for-of": "^7.24.7", - "@babel/plugin-transform-function-name": "^7.25.1", - "@babel/plugin-transform-json-strings": "^7.24.7", - "@babel/plugin-transform-literals": "^7.25.2", - "@babel/plugin-transform-logical-assignment-operators": "^7.24.7", - "@babel/plugin-transform-member-expression-literals": "^7.24.7", - "@babel/plugin-transform-modules-amd": "^7.24.7", - "@babel/plugin-transform-modules-commonjs": "^7.24.8", - "@babel/plugin-transform-modules-systemjs": "^7.25.0", - "@babel/plugin-transform-modules-umd": "^7.24.7", - "@babel/plugin-transform-named-capturing-groups-regex": "^7.24.7", - "@babel/plugin-transform-new-target": "^7.24.7", - "@babel/plugin-transform-nullish-coalescing-operator": "^7.24.7", - "@babel/plugin-transform-numeric-separator": "^7.24.7", - "@babel/plugin-transform-object-rest-spread": "^7.24.7", - "@babel/plugin-transform-object-super": "^7.24.7", - "@babel/plugin-transform-optional-catch-binding": "^7.24.7", - "@babel/plugin-transform-optional-chaining": "^7.24.8", - "@babel/plugin-transform-parameters": "^7.24.7", - "@babel/plugin-transform-private-methods": "^7.25.4", - "@babel/plugin-transform-private-property-in-object": "^7.24.7", - "@babel/plugin-transform-property-literals": "^7.24.7", - "@babel/plugin-transform-regenerator": "^7.24.7", - "@babel/plugin-transform-reserved-words": "^7.24.7", - "@babel/plugin-transform-shorthand-properties": "^7.24.7", - "@babel/plugin-transform-spread": "^7.24.7", - "@babel/plugin-transform-sticky-regex": "^7.24.7", - "@babel/plugin-transform-template-literals": "^7.24.7", - "@babel/plugin-transform-typeof-symbol": "^7.24.8", - "@babel/plugin-transform-unicode-escapes": "^7.24.7", - "@babel/plugin-transform-unicode-property-regex": "^7.24.7", - "@babel/plugin-transform-unicode-regex": "^7.24.7", - "@babel/plugin-transform-unicode-sets-regex": "^7.25.4", - "@babel/preset-modules": "0.1.6-no-external-plugins", - "babel-plugin-polyfill-corejs2": "^0.4.10", - "babel-plugin-polyfill-corejs3": "^0.10.6", - "babel-plugin-polyfill-regenerator": "^0.6.1", - "core-js-compat": "^3.37.1", - "semver": "^6.3.1" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/preset-modules": { - "version": "0.1.6-no-external-plugins", - "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.6-no-external-plugins.tgz", - "integrity": "sha512-HrcgcIESLm9aIR842yhJ5RWan/gebQUJ6E/E5+rf0y9o6oj7w0Br+sWuL6kEQ/o/AdfvR1Je9jG18/gnpwjEyA==", - "dependencies": { - "@babel/helper-plugin-utils": "^7.0.0", - "@babel/types": "^7.4.4", - "esutils": "^2.0.2" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0 || ^8.0.0-0 <8.0.0" - } - }, - "node_modules/@babel/regjsgen": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@babel/regjsgen/-/regjsgen-0.8.0.tgz", - "integrity": "sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA==" - }, - "node_modules/@babel/runtime": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.6.tgz", - "integrity": "sha512-VBj9MYyDb9tuLq7yzqjgzt6Q+IBQLrGZfdjOekyEirZPHxXWoTSGUTMrpsfi58Up73d13NfYLv8HT9vmznjzhQ==", - "dependencies": { - "regenerator-runtime": "^0.14.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/template": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.0.tgz", - "integrity": "sha512-aOOgh1/5XzKvg1jvVz7AVrx2piJ2XBi227DHmbY6y+bM9H2FlN+IfecYu4Xl0cNiiVejlsCri89LUsbj8vJD9Q==", - "dependencies": { - "@babel/code-frame": "^7.24.7", - "@babel/parser": "^7.25.0", - "@babel/types": "^7.25.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/traverse": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.25.6.tgz", - "integrity": "sha512-9Vrcx5ZW6UwK5tvqsj0nGpp/XzqthkT0dqIc9g1AdtygFToNtTF67XzYS//dm+SAK9cp3B9R4ZO/46p63SCjlQ==", - "dependencies": { - "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.25.6", - "@babel/parser": "^7.25.6", - "@babel/template": "^7.25.0", - "@babel/types": "^7.25.6", - "debug": "^4.3.1", - "globals": "^11.1.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/types": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.6.tgz", - "integrity": "sha512-/l42B1qxpG6RdfYf343Uw1vmDjeNhneUXtzhojE7pDgfpEypmRhI6j1kr17XCVv4Cgl9HdAiQY2x0GwKm7rWCw==", - "dependencies": { - "@babel/helper-string-parser": "^7.24.8", - "@babel/helper-validator-identifier": "^7.24.7", - "to-fast-properties": "^2.0.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", - "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", - "dependencies": { - "@jridgewell/set-array": "^1.2.1", - "@jridgewell/sourcemap-codec": "^1.4.10", - "@jridgewell/trace-mapping": "^0.3.24" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/set-array": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", - "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", - "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==" - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.25", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", - "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", - "dependencies": { - "@jridgewell/resolve-uri": "^3.1.0", - "@jridgewell/sourcemap-codec": "^1.4.14" - } - }, - "node_modules/acorn": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", - "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-walk": { - "version": "8.3.3", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.3.tgz", - "integrity": "sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==", - "dependencies": { - "acorn": "^8.11.0" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/babel-plugin-polyfill-corejs2": { - "version": "0.4.11", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.11.tgz", - "integrity": "sha512-sMEJ27L0gRHShOh5G54uAAPaiCOygY/5ratXuiyb2G46FmlSpc9eFCzYVyDiPxfNbwzA7mYahmjQc5q+CZQ09Q==", - "dependencies": { - "@babel/compat-data": "^7.22.6", - "@babel/helper-define-polyfill-provider": "^0.6.2", - "semver": "^6.3.1" - }, - "peerDependencies": { - "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" - } - }, - "node_modules/babel-plugin-polyfill-corejs3": { - "version": "0.10.6", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.10.6.tgz", - "integrity": "sha512-b37+KR2i/khY5sKmWNVQAnitvquQbNdWy6lJdsr0kmquCKEEUgMKK4SboVM3HtfnZilfjr4MMQ7vY58FVWDtIA==", - "dependencies": { - "@babel/helper-define-polyfill-provider": "^0.6.2", - "core-js-compat": "^3.38.0" - }, - "peerDependencies": { - "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" - } - }, - "node_modules/babel-plugin-polyfill-regenerator": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.6.2.tgz", - "integrity": "sha512-2R25rQZWP63nGwaAswvDazbPXfrM3HwVoBXK6HcqeKrSrL/JqcC/rDcf95l4r7LXLyxDXc8uQDa064GubtCABg==", - "dependencies": { - "@babel/helper-define-polyfill-provider": "^0.6.2" - }, - "peerDependencies": { - "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" - } - }, - "node_modules/browserslist": { - "version": "4.23.3", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.3.tgz", - "integrity": "sha512-btwCFJVjI4YWDNfau8RhZ+B1Q/VLoUITrm3RlP6y1tYGWIOa+InuYiRGXUBXo8nA1qKmHMyLB/iVQg5TT4eFoA==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "dependencies": { - "caniuse-lite": "^1.0.30001646", - "electron-to-chromium": "^1.5.4", - "node-releases": "^2.0.18", - "update-browserslist-db": "^1.1.0" - }, - "bin": { - "browserslist": "cli.js" - }, - "engines": { - "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" - } - }, - "node_modules/caniuse-lite": { - "version": "1.0.30001659", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001659.tgz", - "integrity": "sha512-Qxxyfv3RdHAfJcXelgf0hU4DFUVXBGTjqrBUZLUh8AtlGnsDo+CnncYtTd95+ZKfnANUOzxyIQCuU/UeBZBYoA==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/caniuse-lite" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ] - }, - "node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" - }, - "node_modules/convert-source-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", - "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==" - }, - "node_modules/core-js-compat": { - "version": "3.38.1", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.38.1.tgz", - "integrity": "sha512-JRH6gfXxGmrzF3tZ57lFx97YARxCXPaMzPo6jELZhv88pBH5VXpQ+y0znKGlFnzuaihqhLbefxSJxWJMPtfDzw==", - "dependencies": { - "browserslist": "^4.23.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } - }, - "node_modules/debug": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", - "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/electron-to-chromium": { - "version": "1.5.18", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.18.tgz", - "integrity": "sha512-1OfuVACu+zKlmjsNdcJuVQuVE61sZOLbNM4JAQ1Rvh6EOj0/EUKhMJjRH73InPlXSh8HIJk1cVZ8pyOV/FMdUQ==" - }, - "node_modules/escalade": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", - "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", - "engines": { - "node": ">=6" - } - }, - "node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/function-bind": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/gensync": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", - "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", - "engines": { - "node": ">=4" - } - }, - "node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "engines": { - "node": ">=4" - } - }, - "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "dependencies": { - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/is-core-module": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.1.tgz", - "integrity": "sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==", - "dependencies": { - "hasown": "^2.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" - }, - "node_modules/jsesc": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", - "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", - "bin": { - "jsesc": "bin/jsesc" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/json5": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", - "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", - "bin": { - "json5": "lib/cli.js" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/lodash.debounce": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", - "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==" - }, - "node_modules/lru-cache": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", - "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "dependencies": { - "yallist": "^3.0.2" - } - }, - "node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" - }, - "node_modules/node-releases": { - "version": "2.0.18", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.18.tgz", - "integrity": "sha512-d9VeXT4SJ7ZeOqGX6R5EM022wpL+eWPooLI+5UpWn2jCT1aosUQEhQP214x33Wkwx3JQMvIm+tIoVOdodFS40g==" - }, - "node_modules/path-parse": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" - }, - "node_modules/picocolors": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", - "integrity": "sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==" - }, - "node_modules/regenerate": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", - "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==" - }, - "node_modules/regenerate-unicode-properties": { - "version": "10.1.1", - "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-10.1.1.tgz", - "integrity": "sha512-X007RyZLsCJVVrjgEFVpLUTZwyOZk3oiL75ZcuYjlIWd6rNJtOjkBwQc5AsRrpbKVkxN6sklw/k/9m2jJYOf8Q==", - "dependencies": { - "regenerate": "^1.4.2" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/regenerator-runtime": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", - "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==" - }, - "node_modules/regenerator-transform": { - "version": "0.15.2", - "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.15.2.tgz", - "integrity": "sha512-hfMp2BoF0qOk3uc5V20ALGDS2ddjQaLrdl7xrGXvAIow7qeWRM2VA2HuCHkUKk9slq3VwEwLNK3DFBqDfPGYtg==", - "dependencies": { - "@babel/runtime": "^7.8.4" - } - }, - "node_modules/regexpu-core": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.3.2.tgz", - "integrity": "sha512-RAM5FlZz+Lhmo7db9L298p2vHP5ZywrVXmVXpmAD9GuL5MPH6t9ROw1iA/wfHkQ76Qe7AaPF0nGuim96/IrQMQ==", - "dependencies": { - "@babel/regjsgen": "^0.8.0", - "regenerate": "^1.4.2", - "regenerate-unicode-properties": "^10.1.0", - "regjsparser": "^0.9.1", - "unicode-match-property-ecmascript": "^2.0.0", - "unicode-match-property-value-ecmascript": "^2.1.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/regjsparser": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.9.1.tgz", - "integrity": "sha512-dQUtn90WanSNl+7mQKcXAgZxvUe7Z0SqXlgzv0za4LwiUhyzBC58yQO3liFoUgu8GiJVInAhJjkj1N0EtQ5nkQ==", - "dependencies": { - "jsesc": "~0.5.0" - }, - "bin": { - "regjsparser": "bin/parser" - } - }, - "node_modules/regjsparser/node_modules/jsesc": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", - "integrity": "sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==", - "bin": { - "jsesc": "bin/jsesc" - } - }, - "node_modules/resolve": { - "version": "1.22.8", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", - "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", - "dependencies": { - "is-core-module": "^2.13.0", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - }, - "bin": { - "resolve": "bin/resolve" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "bin": { - "semver": "bin/semver.js" - } - }, - "node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/supports-preserve-symlinks-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/to-fast-properties": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", - "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", - "engines": { - "node": ">=4" - } - }, - "node_modules/unicode-canonical-property-names-ecmascript": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz", - "integrity": "sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ==", - "engines": { - "node": ">=4" - } - }, - "node_modules/unicode-match-property-ecmascript": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz", - "integrity": "sha512-5kaZCrbp5mmbz5ulBkDkbY0SsPOjKqVS35VpL9ulMPfSl0J0Xsm+9Evphv9CoIZFwre7aJoa94AY6seMKGVN5Q==", - "dependencies": { - "unicode-canonical-property-names-ecmascript": "^2.0.0", - "unicode-property-aliases-ecmascript": "^2.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/unicode-match-property-value-ecmascript": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-2.1.0.tgz", - "integrity": "sha512-qxkjQt6qjg/mYscYMC0XKRn3Rh0wFPlfxB0xkt9CfyTvpX1Ra0+rAmdX2QyAobptSEvuy4RtpPRui6XkV+8wjA==", - "engines": { - "node": ">=4" - } - }, - "node_modules/unicode-property-aliases-ecmascript": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.1.0.tgz", - "integrity": "sha512-6t3foTQI9qne+OZoVQB/8x8rk2k1eVy1gRXhV3oFQ5T6R1dqQ1xtin3XqSlx3+ATBkliTaR/hHyJBm+LVPNM8w==", - "engines": { - "node": ">=4" - } - }, - "node_modules/update-browserslist-db": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz", - "integrity": "sha512-EdRAaAyk2cUE1wOf2DkEhzxqOQvFOoRJFNS6NeyJ01Gp2beMRpBAINjM2iDXE3KCuKhwnvHIQCJm6ThL2Z+HzQ==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/browserslist" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/browserslist" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "dependencies": { - "escalade": "^3.1.2", - "picocolors": "^1.0.1" - }, - "bin": { - "update-browserslist-db": "cli.js" - }, - "peerDependencies": { - "browserslist": ">= 4.21.0" - } - }, - "node_modules/yallist": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", - "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==" - } - } -} diff --git a/package.json b/package.json deleted file mode 100644 index b1984ca9..00000000 --- a/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "cimet2", - "version": "1.0.0", - "description": "This project tracks microservice system evolution changes across repositories.", - "main": "index.js", - "directories": { - "doc": "docs" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "dependencies": { - "@babel/core": "^7.25.2", - "@babel/preset-env": "^7.25.4", - "acorn": "^8.12.1", - "acorn-walk": "^8.3.3" - } -} diff --git a/pom.xml b/pom.xml index 39395631..e45d0cfe 100644 --- a/pom.xml +++ b/pom.xml @@ -14,18 +14,22 @@ jar + + + github + https://maven.pkg.github.com/cloudhubs/cimet-extract-lib + + true + + + + - org.freemarker freemarker 2.3.32 - - com.github.javaparser - javaparser-symbol-solver-core - 3.16.3 - org.projectlombok lombok @@ -48,16 +52,6 @@ org.eclipse.jgit 6.8.0.202311291450-r - - org.apache.logging.log4j - log4j-api - 2.23.1 - - - org.apache.logging.log4j - log4j-core - 2.23.1 - org.jgrapht jgrapht-core @@ -68,6 +62,11 @@ jackson-core 2.17.1 + + com.fasterxml.jackson.core + jackson-annotations + 2.17.1 + javax.json javax.json-api @@ -100,6 +99,11 @@ poi-ooxml 5.2.3 + + edu.university.ecs.lab + cimet-extract-lib + 1.0.0 + @@ -194,7 +198,7 @@ run-ir - edu.university.ecs.lab.intermediate.create.IRExtractionRunner + edu.university.ecs.lab.intermediate.IRExtractionRunner exec:java @@ -216,7 +220,7 @@ run-merge - edu.university.ecs.lab.intermediate.merge.IRMergeRunner + edu.university.ecs.lab.intermediate.IRMergeRunner exec:java @@ -227,7 +231,7 @@ run-history - edu.university.ecs.lab.detection.ExcelOutputRunner + edu.university.ecs.lab.detection_old.ExcelOutputRunner exec:java diff --git a/scripts/parser.js b/scripts/parser.js deleted file mode 100644 index a3fb8454..00000000 --- a/scripts/parser.js +++ /dev/null @@ -1,119 +0,0 @@ -const acorn = require("acorn"); -const walk = require("acorn-walk"); - -// Sample AngularJS code (same as before) -const jsCode = ` -'use strict'; - -/** - * @ngdoc service - * @name alertApp.dataService - * @description - * # dataService - * Factory in the alertApp. - */ -angular.module('oauthApp') - .factory('dataService', function ($http, $q) { - var userApi = '/user-service/'; - var taskApi = '/task-service/'; - var loggedInUserApi = '/api/loggedinuser/me'; - - var makeRestCall = function (url) { - return $http.get(url) - .then(function (response) { - if (typeof response.data === 'object') { - return response.data; - } else { - return $q.reject(response.data); - } - }, function (response) { - return $q.reject(response.data); - }); - }; - - return { - getAllUserData: function () { - return makeRestCall(userApi); - }, - getAllTaskData: function () { - return makeRestCall(taskApi); - }, - getUserDataByUserName: function (userName) { - return makeRestCall(userApi + userName); - }, - getTaskDataByTaskId: function (taskId) { - return makeRestCall(taskApi + taskId); - }, - getTaskDataByUserName: function (userName) { - return makeRestCall(taskApi + 'usertask' + '/' + userName); - }, - getLoggedInUser: function () { - return makeRestCall(loggedInUserApi); - } - }; - }); -`; - -// Parse the JavaScript code to get the AST -const ast = acorn.parse(jsCode, { sourceType: "module", ecmaVersion: 2020 }); - -// Object to store variable values -const variableValues = {}; - -// Function to check if a node is a makeRestCall invocation -function isMakeRestCall(node) { - return ( - node.type === "CallExpression" && - node.callee.type === "Identifier" && - node.callee.name === "makeRestCall" - ); -} - -// Create URL -function resolveNode(node) { - if (node.type === "Literal") { - // Return literal value - return node.value; - } else if (node.type === "Identifier") { - // Check if the variable is known - return variableValues[node.name] || '{?}'; - } else if (node.type === "BinaryExpression" && node.operator === "+") { - // Resolve both sides of the binary expression (concatenation) - const left = resolveNode(node.left); - const right = resolveNode(node.right); - return concatPaths(left, right); - } else if (node.type === "CallExpression") { - // Handle function calls as unknown - return '{?}'; - } else { - // Handle any other case as unknown - return '{?}'; - } -} - -// Helper function to concatenate paths, ensuring proper `/` separation -function concatPaths(left, right) { - // Ensure that '/' is properly placed between the segments - const leftStr = left.endsWith('/') ? left.slice(0, -1) : left; - const rightStr = right.startsWith('/') ? right.slice(1) : right; - return leftStr + '/' + rightStr; -} - -// Walk through the AST and find variable declarations and makeRestCall calls -walk.simple(ast, { - // Store values of found variables - VariableDeclarator(node) { - if (node.id.type === "Identifier" && node.init && node.init.type === "Literal") { - variableValues[node.id.name] = node.init.value; - } - }, - // Process the makeRestCall invocations and resolve the URLs - CallExpression(node) { - if (isMakeRestCall(node)) { - const urlArgument = node.arguments[0]; - const resolvedUrl = resolveNode(urlArgument); - console.log(`Resolved REST call URL: ${resolvedUrl}`); - - } - } -}); diff --git a/scripts/parser2.js b/scripts/parser2.js deleted file mode 100644 index 9a8d4b6b..00000000 --- a/scripts/parser2.js +++ /dev/null @@ -1,120 +0,0 @@ -const babel = require("@babel/core"); -const traverse = require("@babel/traverse").default; -const t = require("@babel/types"); - -const jsCode = ` -'use strict'; - -/** - * @ngdoc service - * @name alertApp.dataService - * @description - * # dataService - * Factory in the alertApp. - */ -angular.module('oauthApp') - .factory('dataService', function ($http, $q) { - var userApi = '/user-service/'; - var taskApi = '/task-service/'; - var loggedInUserApi = '/api/loggedinuser/me'; - - var makeRestCall = function (url) { - return $http.get(url) - .then(function (response) { - if (typeof response.data === 'object') { - return response.data; - } else { - return $q.reject(response.data); - } - }, function (response) { - return $q.reject(response.data); - }); - }; - - return { - getAllUserData: function () { - return makeRestCall(userApi); - }, - getAllTaskData: function () { - return makeRestCall(taskApi); - }, - getUserDataByUserName: function (userName) { - return makeRestCall(userApi + userName); - }, - getTaskDataByTaskId: function (taskId) { - return makeRestCall(taskApi + taskId); - }, - getTaskDataByUserName: function (userName) { - return makeRestCall(taskApi + 'usertask' + '/' + userName); - }, - getLoggedInUser: function () { - return makeRestCall(loggedInUserApi); - } - }; - }); -`; - -// Transform the code to get the AST -const output = babel.transform(jsCode, { - ast: true, - code: false, - presets: ["@babel/preset-env"], -}); - -// Map to store variable values -const variableValues = {}; - -// Function to check if a call is an API call ($http.get or similar) -function isApiCall(node) { - return ( - t.isMemberExpression(node.callee) && - t.isIdentifier(node.callee.object, { name: "$http" }) && - (t.isIdentifier(node.callee.property, { name: "get" }) || - t.isIdentifier(node.callee.property, { name: "post" })) - ); -} - -function resolveValue(node) { - if (t.isLiteral(node)) { - // Return literal value - return node.value; - } else if (t.isIdentifier(node)) { - // Check if the variable is known - return variableValues[node.name] || '{?}'; - } else if (t.isBinaryExpression(node) && node.operator === "+") { - // Resolve both sides of the binary expression (concatenation) - const left = resolveValue(node.left); - const right = resolveValue(node.right); - return left + right; - } else if (node.type === "CallExpression") { - // Handle function calls as unknown - return '{?}'; - } else { - // Handle any other case as unknown - return '{?}'; - } -} - -// Traverse the AST -traverse(output.ast, { - // Track variable declarations - VariableDeclarator(path) { - const varName = path.node.id.name; - const init = path.node.init; - if (init && (t.isLiteral(init) || t.isBinaryExpression(init))) { - // Store the value of the variable (literals or binary expressions) - variableValues[varName] = resolveValue(init); - } - }, - - - CallExpression(path) { - if (isApiCall(path.node)) { - const urlArg = path.node.arguments[0]; // First argument (URL) - const resolvedUrl = resolveValue(urlArg); // Try to resolve the argument - - console.log(`Resolved URL: ${path.node.callee.object.name}.${path.node.callee.property.name} to ${resolvedUrl}`); - } - } - -}); \ No newline at end of file diff --git a/src/main/java/edu/university/ecs/lab/AllConfigsExcelRunner.java b/src/main/java/edu/university/ecs/lab/AllConfigsExcelRunner.java index f9da9628..1375c469 100644 --- a/src/main/java/edu/university/ecs/lab/AllConfigsExcelRunner.java +++ b/src/main/java/edu/university/ecs/lab/AllConfigsExcelRunner.java @@ -1,32 +1,34 @@ -package edu.university.ecs.lab; - -import edu.university.ecs.lab.detection.ExcelOutputRunner; -import java.io.File; -import java.io.IOException; - -/** - * Runs excel output runner for all config files in valid_configs directory - * NOTE: Must change the ExcelOutputRunner class to take config filepath as input args - */ -public class AllConfigsExcelRunner { - public static void main(String[] args) throws IOException { - - File configDir = new File("./valid_configs"); - if (!configDir.exists() || !configDir.isDirectory()) { - System.out.println("Config directory './valid_configs' does not exist or is not a directory."); - return; - } - - File[] configFiles = configDir.listFiles((dir, name) -> name.endsWith(".json")); - if (configFiles == null || configFiles.length == 0) { - System.out.println("No configuration files found in './valid_configs' directory."); - return; - } - - for (File configFile : configFiles) { - String configPath = configFile.getAbsolutePath(); - System.out.println("Processing config file: " + configPath); - ExcelOutputRunner.main(new String[]{configPath}); - } - } -} +//package edu.university.ecs.lab; +// +//import edu.university.ecs.lab.detection.ExcelOutputRunner; +//import org.eclipse.jgit.api.errors.GitAPIException; +// +//import java.io.File; +//import java.io.IOException; +// +///** +// * Runs excel output runner for all config files in valid_configs directory +// * NOTE: Must change the ExcelOutputRunner class to take config filepath as input args +// */ +//public class AllConfigsExcelRunner { +// public static void main(String[] args) throws IOException, GitAPIException, InterruptedException { +// +// File configDir = new File("./valid_configs"); +// if (!configDir.exists() || !configDir.isDirectory()) { +// System.out.println("Config directory './valid_configs' does not exist or is not a directory."); +// return; +// } +// +// File[] configFiles = configDir.listFiles((dir, name) -> name.endsWith(".json")); +// if (configFiles == null || configFiles.length == 0) { +// System.out.println("No configuration files found in './valid_configs' directory."); +// return; +// } +// +// for (File configFile : configFiles) { +// String configPath = configFile.getAbsolutePath(); +// System.out.println("Processing config file: " + configPath); +// ExcelOutputRunner.main(new String[]{configPath}); +// } +// } +//} diff --git a/src/main/java/edu/university/ecs/lab/DeltaExtractionRunner.java b/src/main/java/edu/university/ecs/lab/DeltaExtractionRunner.java new file mode 100644 index 00000000..0a259bea --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/DeltaExtractionRunner.java @@ -0,0 +1,24 @@ +//package edu.university.ecs.lab.delta; +// +//import edu.university.ecs.lab.delta.services.DeltaExtractionService; +// +///** +// * This class acts as a runner implementation for extracting a Delta file +// */ +//public class DeltaExtractionRunner { +// /** +// * This method compares two commits on the specified branch in the config +// * +// * @param args {@literal [/path/to/config] } +// */ +// public static void main(String[] args) throws Exception { +// args = new String[]{"./config.json", "922ac448a5b404d16190a9740984251626b2d70e", "300b9ee50aaca00c3b2d02c85e350d295aa4fa0a"}; +// String[] finalArgs = args; +// +// DeltaExtractionService deltaService = new DeltaExtractionService(args[0], "./output/OldIR.json", args[1], args[2]); +// +// deltaService.generateDelta(); +// +// } +//} +// \ No newline at end of file diff --git a/src/main/java/edu/university/ecs/lab/IRExtractionRunner.java b/src/main/java/edu/university/ecs/lab/IRExtractionRunner.java new file mode 100644 index 00000000..1557a105 --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/IRExtractionRunner.java @@ -0,0 +1,31 @@ +//package edu.university.ecs.lab.intermediate; +// +//import edu.university.ecs.lab.intermediate.create.services.IRExtractionService; +// +//import java.util.Arrays; +//import java.util.Optional; +// +// +///** +// * +// *

The IR extraction process is responsible for cloning remote services, scanning through each +// * local repo and extracting rest endpoints/calls, and writing each service and endpoints to +// * intermediate representation.

+// */ +//public class IRExtractionRunner { +// +// /** +// * Intermediate extraction runner, generates IR from remote repository and writes to file. +// * +// */ +// public static void main(String[] args) throws Exception { +// args = new String[]{"./config.json"}; +// String[] finalArgs = args; +// +// // Initialize the irExtractionService +// IRExtractionService irExtractionService = new IRExtractionService(args[0], Optional.empty()); +// +// // Generate the Intermediate Representation +// irExtractionService.generateIR("./output/IR.json"); +// } +//} diff --git a/src/main/java/edu/university/ecs/lab/IRMergeRunner.java b/src/main/java/edu/university/ecs/lab/IRMergeRunner.java new file mode 100644 index 00000000..2ab175fe --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/IRMergeRunner.java @@ -0,0 +1,26 @@ +//package edu.university.ecs.lab.intermediate; +// +//import edu.university.ecs.lab.common.config.Config; +//import edu.university.ecs.lab.common.config.ConfigUtil; +//import edu.university.ecs.lab.intermediate.merge.services.MergeService; +//import java.io.IOException; +// +//public class IRMergeRunner { +// +// /** +// * Entry point for the intermediate representation merge process. +// * +// * @param args {@literal } +// * {@literal } +// */ +// public static void main(String[] args) throws IOException { +// args = new String[]{"./output/IR.json", "./output/Delta.json", "./config.json"}; +// String[] finalArgs = args; +// +// Config config = ConfigUtil.readConfig(args[0]); +// +// MergeService mergeService = new MergeService(args[0], args[1], args[2], args[3]); +// +// //mergeService.generateMergeIR(); +// } +//} diff --git a/src/main/java/edu/university/ecs/lab/common/config/Config.java b/src/main/java/edu/university/ecs/lab/common/config/Config.java deleted file mode 100644 index 96ba210c..00000000 --- a/src/main/java/edu/university/ecs/lab/common/config/Config.java +++ /dev/null @@ -1,88 +0,0 @@ -package edu.university.ecs.lab.common.config; - -import edu.university.ecs.lab.common.error.Error; -import lombok.Getter; -import lombok.Setter; - -import java.util.Objects; -import java.util.Optional; - -import static edu.university.ecs.lab.common.error.Error.NULL_ERROR; - -/** - * Model to represent the JSON configuration file - * Some additional notes, this object is p - */ -@Getter -@Setter -public class Config { - private static final String GIT_SCHEME_DOMAIN = "https://github.com/"; - private static final String GIT_PATH_EXTENSION = ".git"; - - /** - * The name of the system analyzed - */ - private final String systemName; - - /** - * The path to write cloned repository files to - */ - private final String repositoryURL; - - /** - * Initial starting commit for repository - */ - private final String branch; - - - public Config(String systemName, String repositoryURL, String branch) throws Exception { - validateConfig(systemName, repositoryURL, branch); - - this.systemName = systemName; - this.repositoryURL = repositoryURL; - this.branch = branch; - } - - /** - * Check that config file is valid and has all required fields - */ - - private void validateConfig(String systemName, String repositoryURL, String branch) { - try { - Objects.requireNonNull(systemName); - Objects.requireNonNull(repositoryURL); - Objects.requireNonNull(branch); - validateConfig(systemName, repositoryURL, branch); - - assert !systemName.isBlank() && !repositoryURL.isBlank() && !branch.isBlank(); - } catch (Exception e) { - Error.reportAndExit(Error.INVALID_CONFIG, Optional.of(e)); - } - Objects.requireNonNull(systemName, NULL_ERROR.getMessage()); - Objects.requireNonNull(repositoryURL, NULL_ERROR.getMessage()); - Objects.requireNonNull(branch, NULL_ERROR.getMessage()); - validateRepositoryURL(repositoryURL); - } - - /** - * The list of repository objects as indicated by config - */ - - private void validateRepositoryURL(String repositoryURL) { - if (!(repositoryURL.isBlank() || repositoryURL.startsWith(GIT_SCHEME_DOMAIN) || repositoryURL.endsWith(GIT_PATH_EXTENSION))) { - Error.reportAndExit(Error.INVALID_REPOSITORY_URL, Optional.empty()); - } - } - - /** - * This method gets the repository name parsed from the repositoryURL - * - * @return the plain string repository name with no path related characters - */ - public String getRepoName() { - int lastSlashIndex = repositoryURL.lastIndexOf("/"); - int lastDotIndex = repositoryURL.lastIndexOf('.'); - return repositoryURL.substring(lastSlashIndex + 1, lastDotIndex); - } - -} diff --git a/src/main/java/edu/university/ecs/lab/common/config/ConfigUtil.java b/src/main/java/edu/university/ecs/lab/common/config/ConfigUtil.java deleted file mode 100644 index 49da39ef..00000000 --- a/src/main/java/edu/university/ecs/lab/common/config/ConfigUtil.java +++ /dev/null @@ -1,27 +0,0 @@ -package edu.university.ecs.lab.common.config; - -import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; - -/** - * Utility class for reading and validating the input config file - */ -public class ConfigUtil { - - /** - * Prevent instantiation - */ - private ConfigUtil() { - } - - /** - * This method read's the input config and return Config object - * - * @param configPath path to the input config file - * @return Config object - */ - public static Config readConfig(String configPath) { - return JsonReadWriteUtils.readFromJSON(configPath, Config.class); - } - - -} diff --git a/src/main/java/edu/university/ecs/lab/common/config/package-info.java b/src/main/java/edu/university/ecs/lab/common/config/package-info.java deleted file mode 100644 index f72cb654..00000000 --- a/src/main/java/edu/university/ecs/lab/common/config/package-info.java +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Provides classes and utilities for handling configuration files related to microservice systems. - *

- * This package includes: - * - {@link edu.university.ecs.lab.common.config.Config}: Represents a configuration model for managing - * JSON configuration files, including system name, repository URL, base commit and branch, and paths - * to microservices within the repository. - * - {@link edu.university.ecs.lab.common.config.ConfigUtil}: Utility class for reading and validating - * JSON configuration files, converting them into {@code Config} objects. - */ -package edu.university.ecs.lab.common.config; diff --git a/src/main/java/edu/university/ecs/lab/common/error/Error.java b/src/main/java/edu/university/ecs/lab/common/error/Error.java deleted file mode 100644 index 3daa7e9c..00000000 --- a/src/main/java/edu/university/ecs/lab/common/error/Error.java +++ /dev/null @@ -1,67 +0,0 @@ -package edu.university.ecs.lab.common.error; - -import edu.university.ecs.lab.common.services.LoggerManager; -import lombok.Getter; - -import java.util.Optional; - -/** - * Enum representing different error types with corresponding error codes and messages. - */ -@Getter -public enum Error { - UNKNOWN_ERROR(1, "Unknown error has occured!"), - NULL_ERROR(1, "Input cannot be null!"), - INVALID_REPOSITORY_URL(2, "Invalid repository URL!"), - INVALID_REPO_PATHS(3, "Invalid relative repository paths!"), - INVALID_REPO_PATH(4, "Invalid repository relative path after update! Skipping!"), - INVALID_CONFIG_PATH(5, "Invalid configuration file path!"), - REPO_DONT_EXIST(6, "The specified repository does not exist!"), - GIT_FAILED(7, "The requested git action failed for an unknown reason!"), - INVALID_ARGS(8, "Invalid arguments!"), - INVALID_JSON_READ(9, "Unable to read JSON from file!"), - INVALID_JSON_WRITE(10, "Unable to write JSON to file!"), - JPARSE_FAILED(10, "Failed to parse Java Code!"), - INVALID_CONFIG(10, "Invalid configuration file!"), - MISSING_CONFIG(10, "Missing configuration file!"); - - /** - * The unique error code identifying the error type. - */ - private final int code; - /** - * The detailed message describing the error. - */ - private final String message; - - /** - * Constructor for Error enum. - * - * @param code The error code. - * @param message The error message. - */ - Error(int code, String message) { - this.code = code; - this.message = message; - } - - /** - * Prints the error message to standard error and exits the program with the error code. - * - * @param error The error enum value to report and exit with. - */ - public static void reportAndExit(Error error, Optional exception) { - LoggerManager.error(error::getMessage, exception); - System.exit(error.code); - } - - /** - * Returns a string representation of the error. - * - * @return The formatted string representation of the error. - */ - @Override - public String toString() { - return "Error " + code + ": " + message; - } -} diff --git a/src/main/java/edu/university/ecs/lab/common/error/package-info.java b/src/main/java/edu/university/ecs/lab/common/error/package-info.java deleted file mode 100644 index 89f7d9e7..00000000 --- a/src/main/java/edu/university/ecs/lab/common/error/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Provides an enumeration for handling errors within the tool for the creation of the end product. - *

- * This package contains an enumeration representing various error types that can occur during - * the operation of the tool. Each error type includes an error code and a descriptive message - * to identify and communicate errors effectively. - */ -package edu.university.ecs.lab.common.error; diff --git a/src/main/java/edu/university/ecs/lab/common/models/enums/ClassRole.java b/src/main/java/edu/university/ecs/lab/common/models/enums/ClassRole.java deleted file mode 100644 index 1848f469..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/enums/ClassRole.java +++ /dev/null @@ -1,49 +0,0 @@ -package edu.university.ecs.lab.common.models.enums; - -import edu.university.ecs.lab.common.models.ir.JClass; -import lombok.Getter; - -/** - * Enum to represent the role of a class in a system - */ -public enum ClassRole { - CONTROLLER(JClass.class), - SERVICE(JClass.class), - REPOSITORY(JClass.class), - ENTITY(JClass.class), - REP_REST_RSC(JClass.class), - FEIGN_CLIENT(JClass.class), - UNKNOWN(null); - - /** - * Get the associated class type for a role - */ - @Getter - private final Class classType; - - /** - * Private constructor to link enum to class type - * - * @param classType the class type to associate with the role - */ - ClassRole(Class classType) { - this.classType = classType; - } - - /** - * Get the class role from the class type - * - * @param roleName the name of the class role - * @return associated class type if it exists, else null (unknown or not found) - */ - public static Class classFromRoleName(String roleName) { - // Iterate over type names - for (ClassRole role : ClassRole.values()) { - if (role.name().equalsIgnoreCase(roleName)) { - return role.classType; - } - } - return null; - } - -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/enums/EndpointTemplate.java b/src/main/java/edu/university/ecs/lab/common/models/enums/EndpointTemplate.java deleted file mode 100644 index fa90fcf4..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/enums/EndpointTemplate.java +++ /dev/null @@ -1,163 +0,0 @@ -package edu.university.ecs.lab.common.models.enums; - -import com.github.javaparser.ast.body.MethodDeclaration; -import com.github.javaparser.ast.expr.*; -import edu.university.ecs.lab.intermediate.utils.StringParserUtils; -import lombok.Getter; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * Factory class for generating an endpoint template from annotations - */ -@Getter -public class EndpointTemplate { - public static final List ENDPOINT_ANNOTATIONS = Arrays.asList("RequestMapping", "GetMapping", "PutMapping", "PostMapping", "DeleteMapping", "PatchMapping"); - private final HttpMethod httpMethod; - private final String name; - private final String url; - - - - public EndpointTemplate(AnnotationExpr requestMapping, AnnotationExpr endpointMapping) { - HttpMethod finalHttpMethod = HttpMethod.ALL; - - String preUrl = ""; - if(requestMapping != null) { - if (requestMapping instanceof NormalAnnotationExpr) { - NormalAnnotationExpr nae = (NormalAnnotationExpr) requestMapping; - for (MemberValuePair pair : nae.getPairs()) { - if (pair.getNameAsString().equals("value")) { - preUrl = pair.getValue().toString().replaceAll("\"", ""); - } - } - } else if (requestMapping instanceof SingleMemberAnnotationExpr) { - preUrl = requestMapping.asSingleMemberAnnotationExpr().getMemberValue().toString().replaceAll("\"", ""); - } - } - - String url = ""; - if (endpointMapping instanceof NormalAnnotationExpr) { - NormalAnnotationExpr nae = (NormalAnnotationExpr) endpointMapping; - for (MemberValuePair pair : nae.getPairs()) { - if (pair.getNameAsString().equals("method")) { - String methodValue = pair.getValue().toString(); - finalHttpMethod = httpFromMapping(methodValue); - } else if(pair.getNameAsString().equals("path") || pair.getNameAsString().equals("value")) { - url = pair.getValue().toString().replaceAll("\"", ""); - } - } - } else if (endpointMapping instanceof SingleMemberAnnotationExpr) { - url = endpointMapping.asSingleMemberAnnotationExpr().getMemberValue().toString().replaceAll("\"", ""); - } else if(endpointMapping instanceof MarkerAnnotationExpr) { - if(preUrl.isEmpty()) { - url = "/"; - } - } - - if(finalHttpMethod == HttpMethod.ALL) { - finalHttpMethod = httpFromMapping(endpointMapping.getNameAsString()); - } - - String finalURL = ""; - // Ensure preUrl starts with a slash if it exists - if((!preUrl.isEmpty() && !preUrl.startsWith("/"))) { - preUrl = "/" + preUrl; - // Ensure Url starts with a slash if it exists - } else if ((!url.isEmpty() && !url.startsWith("/"))) { - url = "/" + url; - } - - - if(preUrl.isEmpty() && url.isEmpty()) { - finalURL = "/"; - } else { - finalURL = preUrl + url; - } - - // Replace any double slashes - finalURL = finalURL.replaceAll("//", "/"); - // If it ends with a slash remove it - finalURL = finalURL.endsWith("/") && !finalURL.equals("/") ? finalURL.substring(0, finalURL.length() - 1) : finalURL; - - - // Get query Parameters - - this.httpMethod = finalHttpMethod; - this.name = endpointMapping.getNameAsString(); - this.url = simplifyEndpointURL(finalURL); - } - - - /** - * Method to get http method from mapping - * - * @param mapping mapping string for a given method - * @return HttpMethod object of same method type - */ - private static HttpMethod httpFromMapping(String mapping) { - switch (mapping) { - case "GetMapping": - case "RequestMethod.GET": - return HttpMethod.GET; - case "PostMapping": - case "RequestMethod.POST": - return HttpMethod.POST; - case "DeleteMapping": - case "RequestMethod.DELETE": - return HttpMethod.DELETE; - case "PutMapping": - case "RequestMethod.PUT": - return HttpMethod.PUT; - case "PatchMapping": - case "RequestMethod.PATCH": - return HttpMethod.PATCH; - default: - return HttpMethod.ALL; - } - - } - - /** - * Method to get endpoint path from annotations - * - * @param ae annotation expression from method - * @param url string formatted as a url - * @return endpoint path/url from annotation expression - */ - public static String getPathFromAnnotation(AnnotationExpr ae, String url) { - // Annotations of type @Mapping("/endpoint") - if (ae.isSingleMemberAnnotationExpr()) { - url = url + StringParserUtils.simplifyEndpointURL( - StringParserUtils.removeOuterQuotations( - ae.asSingleMemberAnnotationExpr().getMemberValue().toString())); - } - - // Annotations of type @Mapping(path="/endpoint") - else if (ae.isNormalAnnotationExpr() && !ae.asNormalAnnotationExpr().getPairs().isEmpty()) { - for (MemberValuePair mvp : ae.asNormalAnnotationExpr().getPairs()) { - if (mvp.getName().toString().equals("path") || mvp.getName().toString().equals("value")) { - url = url + StringParserUtils.simplifyEndpointURL( - StringParserUtils.removeOuterQuotations(mvp.getValue().toString())); - break; - } - } - } - return url; - } - - /** - * Simplifies all path arguments to {?}. - * - * @param url the endpoint URL - * @return the simplified endpoint URL - */ - public static String simplifyEndpointURL(String url) { - return url.replaceAll("\\{[^{}]*\\}", "{?}"); - } - - -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/enums/FileType.java b/src/main/java/edu/university/ecs/lab/common/models/enums/FileType.java deleted file mode 100644 index 5b3d69e2..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/enums/FileType.java +++ /dev/null @@ -1,10 +0,0 @@ -package edu.university.ecs.lab.common.models.enums; - -/** - * File types enum - */ -public enum FileType { - JCLASS, - CONFIG, - POM -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/enums/HttpMethod.java b/src/main/java/edu/university/ecs/lab/common/models/enums/HttpMethod.java deleted file mode 100644 index 9f99a8a8..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/enums/HttpMethod.java +++ /dev/null @@ -1,16 +0,0 @@ -package edu.university.ecs.lab.common.models.enums; - -/** - * Enum to represent the HTTP methods - */ -public enum HttpMethod { - GET, - PUT, - POST, - DELETE, - OPTIONS, - HEAD, - PATCH, - ALL, - NONE -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/enums/RestCallTemplate.java b/src/main/java/edu/university/ecs/lab/common/models/enums/RestCallTemplate.java deleted file mode 100644 index ecab9dc1..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/enums/RestCallTemplate.java +++ /dev/null @@ -1,221 +0,0 @@ -package edu.university.ecs.lab.common.models.enums; - -import com.github.javaparser.ast.CompilationUnit; -import com.github.javaparser.ast.Node; -import com.github.javaparser.ast.body.FieldDeclaration; -import com.github.javaparser.ast.body.VariableDeclarator; -import com.github.javaparser.ast.expr.*; -import edu.university.ecs.lab.common.models.ir.MethodCall; -import edu.university.ecs.lab.intermediate.utils.StringParserUtils; -import javassist.expr.Expr; -import lombok.Getter; - -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -/** - * Enum to represent Spring methodName and HttpMethod combinations and determine HttpMethod from - * methodName. - */ -@Getter -public class RestCallTemplate { - public static final Set REST_OBJECTS = Set.of("RestTemplate", "OAuth2RestOperations", "OAuth2RestTemplate", "WebClient"); - public static final Set REST_METHODS = Set.of("getForObject", "postForObject", "patchForObject", "put", "delete", "exchange", "get", "post", "options", "patch"); - private static final String UNKNOWN_VALUE = "{?}"; - - private final String url; - private final HttpMethod httpMethod; - private final CompilationUnit cu; - private final MethodCallExpr mce; - - public RestCallTemplate(MethodCallExpr mce, MethodCall mc, CompilationUnit cu) { - this.cu = cu; - this.mce = mce; - this.url = simplifyEndpointURL(preParseURL(mce, mc)); - this.httpMethod = getHttpFromName(mce); - } - - /** - * Find the RestTemplate by the method name. - * - * @param mce the method call - * @return the RestTemplate found (null if not found) - */ - public HttpMethod getHttpFromName(MethodCallExpr mce) { - String methodName = mce.getNameAsString(); - switch (methodName) { - case "getForObject": - case "get": - return HttpMethod.GET; - case "postForObject": - case "post": - return HttpMethod.POST; - case "patchForObject": - case "patch": - return HttpMethod.PATCH; - case "put": - return HttpMethod.PUT; - case "delete": - return HttpMethod.DELETE; - case "exchange": - return getHttpMethodForExchange(mce.getArguments().stream().map(Node::toString).collect(Collectors.joining())); - } - - return HttpMethod.NONE; - } - - /** - * Get the HTTP method for the JSF exchange() method call. - * - * @param arguments the arguments of the exchange() method - * @return the HTTP method extracted - */ - public HttpMethod getHttpMethodForExchange(String arguments) { - if (arguments.contains("HttpMethod.POST")) { - return HttpMethod.POST; - } else if (arguments.contains("HttpMethod.PUT")) { - return HttpMethod.PUT; - } else if (arguments.contains("HttpMethod.DELETE")) { - return HttpMethod.DELETE; - } else if (arguments.contains("HttpMethod.PATCH")) { - return HttpMethod.PATCH; - } else { - return HttpMethod.GET; // default - } - } - - /** - * Find the URL from the given expression. - * - * @param exp the expression to extract url from - * @return the URL found - */ - private String parseURL(Expression exp) { - if (exp.isStringLiteralExpr()) { - return exp.asStringLiteralExpr().asString(); - } else if (exp.isFieldAccessExpr()) { - return parseFieldValue(exp.asFieldAccessExpr().getNameAsString()); - } else if (exp.isBinaryExpr()) { - String left = parseURL(exp.asBinaryExpr().getLeft()); - String right = parseURL(exp.asBinaryExpr().getRight()); - return left + right; - } else if(exp.isEnclosedExpr()) { - return parseURL(exp.asEnclosedExpr()); - // Base case, if we are a method call or a u - } else if(exp.isMethodCallExpr()) { - // Here we may try to find a modified url in a method call expr - return backupParseURL(exp).isEmpty() ? UNKNOWN_VALUE : backupParseURL(exp); - } else if(exp.isNameExpr()) { - // Special case - if(exp.asNameExpr().getNameAsString().contains("uri") || exp.asNameExpr().getNameAsString().contains("url")) { - return ""; - } - return UNKNOWN_VALUE; - } - - // If all fails, try to find some viable url - return backupParseURL(exp); - } - - /** - * Find the URL from the given expression. - * - * @param exp the expression to extract url from - * @return the URL found - */ - private String backupParseURL(Expression exp) { - // Regular expression to match the first instance of "/.*" - String regex = "\".*(/.+?)\""; - - // Compile the pattern - Pattern pattern = Pattern.compile(regex); - - // Create a matcher for the input string - Matcher matcher = pattern.matcher(exp.toString()); - - // Find the first match - if (matcher.find()) { - // Extract the first instance of "/.*" - String extracted = matcher.group(0).replace("\"", ""); // Group 1 corresponds to the part in parentheses (captured group) - - // Replace string formatters if they are present - extracted = extracted.replaceAll("%[sdif]", UNKNOWN_VALUE); - - return cleanURL(extracted); - } - - return ""; - - } - - /** - * Shorten URLs to only endpoint query - * - * @param str full url - * @return url query - */ - private static String cleanURL(String str) { - str = str.replace("http://", ""); - str = str.replace("https://", ""); - - // Remove everything before the first / - int backslashNdx = str.indexOf("/"); - if (backslashNdx > 0) { - str = str.substring(backslashNdx); - } - - // Remove any trailing quotes - if (str.endsWith("\"")) { - str = str.substring(0, str.length() - 1); - } - - // Remove trailing / (does not affect functionality, trailing /'s are ignored in Spring) - if (str.endsWith("/")) { - str = str.substring(0, str.length() - 1); - } - - return str; - } - - private String parseFieldValue(String fieldName) { - for (FieldDeclaration fd : cu.findAll(FieldDeclaration.class)) { - if (fd.getVariables().toString().contains(fieldName)) { - Expression init = fd.getVariable(0).getInitializer().orElse(null); - if (init != null) { - return StringParserUtils.removeOuterQuotations(init.toString()); - } - } - } - - return ""; - } - - - private String preParseURL(MethodCallExpr mce, MethodCall mc) { - - // Nuance for webclient with method appender pattern - if(mc.getObjectType().equals("WebClient")) { - if(mce.getParentNode().isPresent()) { - if(mce.getParentNode().get() instanceof MethodCallExpr pmce) { - return pmce.getArguments().get(0).toString().isEmpty() ? "" : cleanURL(parseURL(pmce.getArguments().get(0))); - } - } - } else { - return mce.getArguments().get(0).toString().isEmpty() ? "" : cleanURL(parseURL(mce.getArguments().get(0))); - } - - return ""; - } - - /** - * Simplifies all path arguments to {?}. - * - * @param url the endpoint URL - * @return the simplified endpoint URL - */ - public static String simplifyEndpointURL(String url) { - return url.replaceAll("\\{[^{}]*\\}", "{?}"); - } -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/ir/Annotation.java b/src/main/java/edu/university/ecs/lab/common/models/ir/Annotation.java deleted file mode 100644 index 171b9f27..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/ir/Annotation.java +++ /dev/null @@ -1,89 +0,0 @@ -package edu.university.ecs.lab.common.models.ir; - -import com.github.javaparser.ast.expr.*; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * Represents an annotation in Java - */ -@Data -@EqualsAndHashCode -public class Annotation extends Node { - - private Map attributes; - - public Annotation(AnnotationExpr annotationExpr, String packageAndClassName) { - this.name = annotationExpr.getNameAsString(); - this.packageAndClassName = packageAndClassName; - this.attributes = parseAttributes(annotationExpr); - } - - public Annotation(String name, String packageAndClassName, HashMap attributes) { - this.name = name; - this.packageAndClassName = packageAndClassName; - this.attributes = attributes; - } - - /** - * Get contents of annotation object - * - * @return comma-delimmited list of annotation content key-value pairs - */ - public String getContents() { - return getAttributes().entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).collect(Collectors.joining(",")); - } - - /** - * see {@link JsonSerializable#toJsonObject()} - */ - @Override - public JsonObject toJsonObject() { - JsonObject jsonObject = new JsonObject(); - Gson gson = new Gson(); - - jsonObject.addProperty("name", getName()); - jsonObject.addProperty("packageAndClassName", getPackageAndClassName()); - JsonElement attributesJson = gson.toJsonTree(attributes, new TypeToken>(){}.getType()); - jsonObject.add("attributes", attributesJson); - - return jsonObject; - } - - /** - * Map attributes from annotation expression - * - * @param annotationExpr annotation expression object to parse - * @return map of annotation attributes and their values - */ - private static HashMap parseAttributes(AnnotationExpr annotationExpr) { - HashMap attributes = new HashMap<>(); - - if(annotationExpr instanceof MarkerAnnotationExpr) { - return attributes; - } else if (annotationExpr instanceof SingleMemberAnnotationExpr smAnnotationExpr) { - if(smAnnotationExpr.getMemberValue() instanceof StringLiteralExpr sle) { - attributes.put("default", sle.asString()); - } else { - return attributes; - } - } else if (annotationExpr instanceof NormalAnnotationExpr nAnnotationExpr) { - for(MemberValuePair mvp : nAnnotationExpr.getPairs()) { - if(mvp.getValue() instanceof StringLiteralExpr sle) { - attributes.put(mvp.getNameAsString(), sle.asString()); - } - } - } - - return attributes; - } -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/ir/ConfigFile.java b/src/main/java/edu/university/ecs/lab/common/models/ir/ConfigFile.java deleted file mode 100644 index 971bb86a..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/ir/ConfigFile.java +++ /dev/null @@ -1,28 +0,0 @@ -package edu.university.ecs.lab.common.models.ir; - -import com.google.gson.JsonObject; -import edu.university.ecs.lab.common.models.enums.FileType; -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; -import lombok.Getter; - -/** - * Represents a project configuration file - */ -@Getter -public class ConfigFile extends ProjectFile implements JsonSerializable { - private final JsonObject data; - - public ConfigFile(String path, String name, JsonObject data, FileType type) { - this.path = path; - this.name = name; - this.data = data; - this.fileType = FileType.CONFIG; - } - - @Override - public JsonObject toJsonObject() { - JsonObject jsonObject = super.toJsonObject(); - jsonObject.add("data", data); - return jsonObject; - } -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/ir/Endpoint.java b/src/main/java/edu/university/ecs/lab/common/models/ir/Endpoint.java deleted file mode 100644 index 664fdc4a..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/ir/Endpoint.java +++ /dev/null @@ -1,60 +0,0 @@ -package edu.university.ecs.lab.common.models.ir; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import edu.university.ecs.lab.common.models.enums.HttpMethod; -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.HashSet; -import java.util.Set; -import java.util.List; - -/** - * Represents an extension of a method declaration. An endpoint exists at the controller level and - * signifies an open mapping that can be the target of a rest call. - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class Endpoint extends Method { - - /** - * The URL of the endpoint e.g. /api/v1/users/login, May have parameters like {param} - * which are converted to {?} - */ - private String url; - - /** - * The HTTP method of the endpoint, e.g. GET, POST, etc. - */ - private HttpMethod httpMethod; - - - - public Endpoint(String methodName, String packageName, Set parameters, String returnType, Set annotations, String microserviceName, - String className) { - super(methodName, packageName, parameters, returnType, annotations, microserviceName, className); - } - - public Endpoint(Method method, String url, HttpMethod httpMethod) { - super(method.name, method.packageAndClassName, method.parameters, method.returnType, method.annotations, method.microserviceName, method.className); - this.url = url; - this.httpMethod = httpMethod; - } - - /** - * see {@link JsonSerializable#toJsonObject()} - */ - @Override - public JsonObject toJsonObject() { - JsonObject jsonObject = super.toJsonObject(); - - jsonObject.addProperty("url", url); - jsonObject.addProperty("httpMethod", httpMethod.name()); - - return jsonObject; - } - - -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/ir/Field.java b/src/main/java/edu/university/ecs/lab/common/models/ir/Field.java deleted file mode 100644 index 7e21f92f..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/ir/Field.java +++ /dev/null @@ -1,39 +0,0 @@ -package edu.university.ecs.lab.common.models.ir; - -import com.google.gson.JsonObject; -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * Represents a field attribute in a Java class or in our case a JClass. - */ -@Data -@EqualsAndHashCode -public class Field extends Node { - /** - * Java class type of the class variable e.g. String - */ - private String type; - - public Field(String name, String packageAndClassName, String type) { - this.name = name; - this.packageAndClassName = packageAndClassName; - this.type = type; - } - - - /** - * see {@link JsonSerializable#toJsonObject()} - */ - @Override - public JsonObject toJsonObject() { - JsonObject jsonObject = new JsonObject(); - - jsonObject.addProperty("name", getName()); - jsonObject.addProperty("packageAndClassName", getPackageAndClassName()); - jsonObject.addProperty("type", getType()); - - return jsonObject; - } -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/ir/Flow.java b/src/main/java/edu/university/ecs/lab/common/models/ir/Flow.java deleted file mode 100644 index afa51337..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/ir/Flow.java +++ /dev/null @@ -1,68 +0,0 @@ -package edu.university.ecs.lab.common.models.ir; - -import com.google.gson.JsonNull; -import com.google.gson.JsonObject; -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; -import lombok.*; - -/** Represents a flow from controller level down to DAO. */ -@Data -@AllArgsConstructor -@NoArgsConstructor -@EqualsAndHashCode -public class Flow implements JsonSerializable { - private Microservice model; - private JClass controller; - private Endpoint controllerMethod; - private MethodCall serviceMethodCall; - private Field controllerServiceField; - private JClass service; - private Method serviceMethod; - private MethodCall repositoryMethodCall; - private Field serviceRepositoryField; - private JClass repository; - private Method repositoryMethod; - - /** - * Create JSON object from flow object - */ - @Override - public JsonObject toJsonObject() { - JsonObject jsonObject = new JsonObject(); - - jsonObject.add("model", model == null ? JsonNull.INSTANCE : model.toJsonObject()); - jsonObject.add("controller", controller == null ? JsonNull.INSTANCE : controller.toJsonObject()); - jsonObject.add("controllerMethod", controllerMethod == null ? JsonNull.INSTANCE : controllerMethod.toJsonObject()); - jsonObject.add("serviceMethodCall", serviceMethodCall == null ? JsonNull.INSTANCE : serviceMethodCall.toJsonObject()); - jsonObject.add("service", service == null ? JsonNull.INSTANCE : service.toJsonObject()); - jsonObject.add("serviceMethod", serviceMethod == null ? JsonNull.INSTANCE : serviceMethod.toJsonObject()); - jsonObject.add("repositoryMethodCall", repositoryMethodCall == null ? JsonNull.INSTANCE : repositoryMethodCall.toJsonObject()); - jsonObject.add("serviceRepositoryField", serviceRepositoryField == null ? JsonNull.INSTANCE : serviceRepositoryField.toJsonObject()); - jsonObject.add("repository", repository == null ? JsonNull.INSTANCE : repository.toJsonObject()); - jsonObject.add("repositoryMethod", repositoryMethod == null ? JsonNull.INSTANCE : repositoryMethod.toJsonObject()); - - return jsonObject; - } - - /** - * Create JSON object from flow object with only names - * - * @return flow JSON object - */ - public JsonObject toSmallJsonObject() { - JsonObject jsonObject = new JsonObject(); - - jsonObject.addProperty("model", model == null ? "" : model.getName()); - jsonObject.addProperty("controller", controller == null ? "" : controller.getName()); - jsonObject.addProperty("controllerMethod", controllerMethod == null ? "" : controllerMethod.getName()); - jsonObject.addProperty("serviceMethodCall", serviceMethodCall == null ? "" : serviceMethodCall.getName()); - jsonObject.addProperty("service", service == null ? "" : service.getName()); - jsonObject.addProperty("serviceMethod", serviceMethod == null ? "" : serviceMethod.getName()); - jsonObject.addProperty("repositoryMethodCall", repositoryMethodCall == null ? "" : repositoryMethodCall.getName()); - jsonObject.addProperty("serviceRepositoryField", serviceRepositoryField == null ? "" : serviceRepositoryField.getName()); - jsonObject.addProperty("repository", repository == null ? "" : repository.getName()); - jsonObject.addProperty("repositoryMethod", repositoryMethod == null ? "" : repositoryMethod.getName()); - - return jsonObject; - } -} \ No newline at end of file diff --git a/src/main/java/edu/university/ecs/lab/common/models/ir/JClass.java b/src/main/java/edu/university/ecs/lab/common/models/ir/JClass.java deleted file mode 100644 index c1ebc9bf..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/ir/JClass.java +++ /dev/null @@ -1,137 +0,0 @@ -package edu.university.ecs.lab.common.models.ir; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import edu.university.ecs.lab.common.models.enums.ClassRole; -import edu.university.ecs.lab.common.models.enums.FileType; -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NonNull; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; -import java.util.List; -import java.util.stream.Collectors; - -/** - * Represents a class in Java. It holds all information regarding that class including all method - * declarations, method calls, fields, etc. - */ -@Data -@EqualsAndHashCode(callSuper = true) -public class JClass extends ProjectFile implements JsonSerializable { - private String packageName; - - /** - * Class implementations - */ - private Set implementedTypes; - - /** - * Role of the class in the microservice system. See {@link ClassRole} - */ - private ClassRole classRole; - - /** - * Set of methods in the class - */ - private Set methods; - - /** - * Set of class fields - */ - private Set fields; - - /** - * Set of class level annotations - */ - private Set annotations; - - /** - * List of method invocations made from within this class - */ - private List methodCalls; - - - public JClass(String name, String path, String packageName, ClassRole classRole) { - this.name = name; - this.packageName = packageName; - this.path = path; - this.classRole = classRole; - this.methods = new HashSet<>(); - this.fields = new HashSet<>(); - this.annotations = new HashSet<>(); - this.methodCalls = new ArrayList<>(); - this.implementedTypes = new HashSet<>(); - this.fileType = FileType.JCLASS; - } - - public JClass(String name, String path, String packageName, ClassRole classRole, Set methods, Set fields, Set classAnnotations, List methodCalls, Set implementedTypes) { - this.name = name; - this.packageName = packageName; - this.path = path; - this.classRole = classRole; - this.methods = methods; - this.fields = fields; - this.annotations = classAnnotations; - this.methodCalls = methodCalls; - this.implementedTypes = implementedTypes; - this.fileType = FileType.JCLASS; - } - - - /** - * see {@link JsonSerializable#toJsonObject()} - */ - @Override - public JsonObject toJsonObject() { - JsonObject jsonObject = super.toJsonObject(); - Gson gson = new Gson(); - - jsonObject.addProperty("packageName", getPackageName()); - jsonObject.addProperty("classRole", getClassRole().name()); - jsonObject.add("annotations", JsonSerializable.toJsonArray(getAnnotations())); - jsonObject.add("fields", JsonSerializable.toJsonArray(getFields())); - jsonObject.add("methods", JsonSerializable.toJsonArray(getMethods())); - jsonObject.add("methodCalls", JsonSerializable.toJsonArray(getMethodCalls())); - jsonObject.add("implementedTypes", gson.toJsonTree(getImplementedTypes()).getAsJsonArray()); - - return jsonObject; - } - - /** - * This method returns all endpoints found in the methods of this class, - * grouped under the same list as an Endpoint is an extension of a Method - * see {@link Endpoint} - * @return set of all endpoints - */ - public Set getEndpoints() { - if((!getClassRole().equals(ClassRole.CONTROLLER) && !getClassRole().equals(ClassRole.REP_REST_RSC)) || getMethods().isEmpty()) { - return new HashSet<>(); - } - return methods.stream().filter(method -> method instanceof Endpoint).map(method -> (Endpoint) method).collect(Collectors.toUnmodifiableSet()); - } - - /** - * This method returns all restCalls found in the methodCalls of this class, - * grouped under the same list as an RestCall is an extension of a MethodCall - * see {@link RestCall} - * @return set of all restCalls - */ - public List getRestCalls() { - - return methodCalls.stream().filter(methodCall -> methodCall instanceof RestCall).map(methodCall -> (RestCall) methodCall).collect(Collectors.toUnmodifiableList()); - } - - /** - * If we are adding a class or a class is being adopted/orphanized lets update ms name - * - * @param name - */ - public void updateMicroserviceName(String name) { - methodCalls.forEach(methodCall -> methodCall.setMicroserviceName(name)); - methods.forEach(methodCall -> methodCall.setMicroserviceName(name)); - } -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/ir/Method.java b/src/main/java/edu/university/ecs/lab/common/models/ir/Method.java deleted file mode 100644 index 60852ea3..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/ir/Method.java +++ /dev/null @@ -1,100 +0,0 @@ -package edu.university.ecs.lab.common.models.ir; - -import com.github.javaparser.ast.NodeList; -import com.github.javaparser.ast.body.MethodDeclaration; -import com.google.gson.JsonObject; -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -import java.util.*; - -/** - * Represents a method declaration in Java. - */ -@Data -@NoArgsConstructor -@EqualsAndHashCode(callSuper = false) -public class Method extends Node { - // Protection Not Yet Implemented - // protected String protection; - - /** - * Set of fields representing parameters - */ - protected Set parameters; - - /** - * Java return type of the method - */ - protected String returnType; - - /** - * The microservice id that this method belongs to - */ - protected String microserviceName; - - /** - * Method definition level annotations - */ - protected Set annotations; - - /** - * The class id that this method belongs to - */ - protected String className; - - public Method(String name, String packageAndClassName, Set parameters, String typeAsString, Set annotations, String microserviceName, - String className) { - this.name = name; - this.packageAndClassName = packageAndClassName; - this.parameters = parameters; - this.returnType = typeAsString; - this.annotations = annotations; - this.microserviceName = microserviceName; - this.className = className; - } - - public Method(MethodDeclaration methodDeclaration) { - this.name = methodDeclaration.getNameAsString(); - this.packageAndClassName = methodDeclaration.getClass().getPackageName() + "." + methodDeclaration.getClass().getName(); - this.parameters = parseParameters(methodDeclaration.getParameters()); - } - - /** - * see {@link JsonSerializable#toJsonObject()} - */ - @Override - public JsonObject toJsonObject() { - JsonObject jsonObject = new JsonObject(); - - jsonObject.addProperty("name", getName()); - jsonObject.addProperty("packageAndClassName", getPackageAndClassName()); - jsonObject.add("annotations", JsonSerializable.toJsonArray(getAnnotations())); - jsonObject.add("parameters", JsonSerializable.toJsonArray(getParameters())); - jsonObject.addProperty("returnType", getReturnType()); - jsonObject.addProperty("microserviceName", microserviceName); - jsonObject.addProperty("className", className); - - return jsonObject; - } - - /** - * Get set of parameters from node list - * - * @param parameters Node list of javaparser parameter objects - * @return set of parameter objects - */ - private Set parseParameters(NodeList parameters) { - HashSet parameterSet = new HashSet<>(); - - for(com.github.javaparser.ast.body.Parameter parameter : parameters) { - parameterSet.add(new Parameter(parameter, getPackageAndClassName())); - } - - - return parameterSet; - } - -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/ir/MethodCall.java b/src/main/java/edu/university/ecs/lab/common/models/ir/MethodCall.java deleted file mode 100644 index 2c18fb26..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/ir/MethodCall.java +++ /dev/null @@ -1,92 +0,0 @@ -package edu.university.ecs.lab.common.models.ir; - -import com.google.gson.JsonObject; -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -/** - * Represents a method call in Java. - */ -@Data -@NoArgsConstructor -@EqualsAndHashCode(callSuper = false) -public class MethodCall extends Node { - - /** - * Name of object that defines the called method (Maybe a static class instance, just whatever is before - * the ".") - */ - protected String objectName; - - /** - * Type of object that defines that method - */ - protected String objectType; - - /** - * Name of method that contains this call - */ - protected String calledFrom; - - /** - * Contents within the method call (params) but as a raw string - */ - protected String parameterContents; - - /** - * The name of the microservice this MethodCall is called from - */ - protected String microserviceName; - - /** - * The class id that this MethodCall is called from - */ - protected String className; - - public MethodCall(String name, String packageName,String objectType, String objectName, String calledFrom, String parameterContents, String microserviceName, - String className) { - this.name = name; - this.packageAndClassName = packageName; - this.objectName = objectName; - this.objectType = objectType; - this.calledFrom = calledFrom; - this.parameterContents = parameterContents; - this.microserviceName = microserviceName; - this.className = className; - } - - /** - * see {@link JsonSerializable#toJsonObject()} - */ - @Override - public JsonObject toJsonObject() { - JsonObject jsonObject = new JsonObject(); - - jsonObject.addProperty("name", getName()); - jsonObject.addProperty("packageAndClassName", getPackageAndClassName()); - jsonObject.addProperty("objectName", getObjectName()); - jsonObject.addProperty("calledFrom", getCalledFrom()); - jsonObject.addProperty("objectType", getObjectType()); - jsonObject.addProperty("parameterContents", getParameterContents()); - jsonObject.addProperty("microserviceName", microserviceName); - jsonObject.addProperty("className", className); - - return jsonObject; - } - - /** - * Checks if a method call matches a given method - * - * @param methodCall method call object to match - * @param method method object to match - * @return true if method call and method match, false otherwise - */ - public static boolean matchMethod(MethodCall methodCall, Method method) { - return methodCall.microserviceName.equals(method.microserviceName) && methodCall.objectType.equals(method.className) - && methodCall.name.equals(method.name); - - } - -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/ir/Microservice.java b/src/main/java/edu/university/ecs/lab/common/models/ir/Microservice.java deleted file mode 100644 index 9b2aedf8..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/ir/Microservice.java +++ /dev/null @@ -1,317 +0,0 @@ -package edu.university.ecs.lab.common.models.ir; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; -import edu.university.ecs.lab.common.utils.FileUtils; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * Represents the overarching structure of a microservice system. It is composed of classes which - * hold all information in that class. - */ -@Data -@AllArgsConstructor -@EqualsAndHashCode -public class Microservice implements JsonSerializable { - /** - * The name of the service (ex: "ts-assurance-service") - */ - private String name; - - /** - * The path to the folder that represents the microservice - */ - private String path; - - /** - * Controller classes belonging to the microservice. - */ - private final Set controllers; - - /** - * Service classes to the microservice. - */ - private final Set services; - - /** - * Repository classes belonging to the microservice. - */ - private final Set repositories; - - /** - * Entity classes belonging to the microservice. - */ - private final Set entities; - - /** - * Embeddable classes belonging to the microservice. - */ -// private final Set embeddables; - - /** - * Feign client classes belonging to the microservice. - */ - private final Set feignClients; - - /** - * Static files belonging to the microservice. - */ - private final Set files; - - public Microservice(String name, String path) { - this.name = name; - this.path = path; - this.controllers = new HashSet<>(); - this.services = new HashSet<>(); - this.repositories = new HashSet<>(); - this.entities = new HashSet<>(); -// this.embeddables = new HashSet<>(); - this.feignClients = new HashSet<>(); - this.files = new HashSet<>(); - } - - /** - * see {@link JsonSerializable#toJsonObject()} - */ - @Override - public JsonObject toJsonObject() { - JsonObject jsonObject = new JsonObject(); - - jsonObject.addProperty("name", name); - jsonObject.addProperty("path", path); - jsonObject.add("controllers", JsonSerializable.toJsonArray(controllers)); - jsonObject.add("entities", JsonSerializable.toJsonArray(entities)); - jsonObject.add("feignClients", JsonSerializable.toJsonArray(feignClients)); - jsonObject.add("services", JsonSerializable.toJsonArray(services)); - jsonObject.add("repositories", JsonSerializable.toJsonArray(repositories)); - jsonObject.add("files", JsonSerializable.toJsonArray(files)); - - return jsonObject; - } - - - /** - * see {@link JsonSerializable#toJsonArray(Iterable)} - */ - private static JsonArray toJsonArray(Iterable list) { - JsonArray jsonArray = new JsonArray(); - for (JsonObject object : list) { - jsonArray.add(object); - } - return jsonArray; - } - - /** - * Update's the microservice name of the JClass and add's - * it to the appropriate Set - * - * @param jClass the JClass to add - */ - public void addJClass(JClass jClass) { - jClass.updateMicroserviceName(getName()); - - switch (jClass.getClassRole()) { - case CONTROLLER: - controllers.add(jClass); - break; - case SERVICE: - services.add(jClass); - break; - case REPOSITORY: - case REP_REST_RSC: - repositories.add(jClass); - break; - case ENTITY: - entities.add(jClass); - break; - case FEIGN_CLIENT: - feignClients.add(jClass); - break; - - - } - } - - /** - * This method removes a JClass from the microservice - * by looking up it's path - * - * @param path the path to search for removal - */ - public void removeJClass(String path) { - Set classes = getClasses(); - JClass removeClass = null; - - for (JClass jClass : classes) { - if (jClass.getPath().equals(path)) { - removeClass = jClass; - break; - } - } - - // If we cannot find the class no problem, we will skip it quietly - if (removeClass == null) { - return; - } - - switch (removeClass.getClassRole()) { - case CONTROLLER: - controllers.remove(removeClass); - break; - case SERVICE: - services.remove(removeClass); - break; - case REPOSITORY: - case REP_REST_RSC: - repositories.remove(removeClass); - break; - case ENTITY: - entities.remove(removeClass); - break; - case FEIGN_CLIENT: - feignClients.remove(removeClass); - break; - } - } - - /** - * This method removes a ProjectFile from the microservice - * by looking up it's path - * - * @param filePath the path to search for - */ - public void removeProjectFile(String filePath) { - - if(FileUtils.isConfigurationFile(filePath)) { - // First search configFile because there are less - ConfigFile removeFile = null; - - for (ConfigFile configFile : getFiles()) { - if (configFile.getPath().equals(filePath)) { - removeFile = configFile; - break; - } - } - - // If we cannot find the class no problem, we will skip it quietly - if (removeFile == null) { - return; - } - - getFiles().remove(removeFile); - - } else { - Set classes = getClasses(); - JClass removeClass = null; - - for (JClass jClass : classes) { - if (jClass.getPath().equals(filePath)) { - removeClass = jClass; - break; - } - } - - // If we cannot find the class no problem, we will skip it quietly - if (removeClass == null) { - return; - } - - switch (removeClass.getClassRole()) { - case CONTROLLER: - controllers.remove(removeClass); - break; - case SERVICE: - services.remove(removeClass); - break; - case REPOSITORY: - case REP_REST_RSC: - repositories.remove(removeClass); - break; - case ENTITY: - entities.remove(removeClass); - break; - case FEIGN_CLIENT: - feignClients.remove(removeClass); - break; - } - - } - } - - /** - * This method returns all classes of the microservice in a new set - * - * @return the set of all JClasses - */ - public Set getClasses() { - Set classes = new HashSet<>(); - classes.addAll(getControllers()); - classes.addAll(getServices()); - classes.addAll(getRepositories()); - classes.addAll(getEntities()); - classes.addAll(getFeignClients()); - - return classes; - } - - /** - * This method returns all files of a microservice, it is - * the aggregate of getClasses() and getFiles() - * - * @return the set of all classes and files - */ - public Set getAllFiles() { - Set set = new HashSet<>(getClasses()); - set.addAll(getFiles()); - set.addAll(getClasses()); - return set; - } - - /** - * This method returns all rest calls of a microservice - * - * @return the list of all rest calls - */ - public List getRestCalls () { - return getClasses().stream() - .flatMap(jClass -> jClass.getRestCalls().stream()).collect(Collectors.toList()); - } - - /** - * This method returns all endpoints of a microservice - * - * @return the set of all endpoints - */ - public Set getEndpoints () { - return getControllers().stream().flatMap(controller -> - controller.getEndpoints().stream()).collect(Collectors.toSet()); - } - - /** - * This method returns all method calls of a microservice - * - * @return the set of all method calls - */ - public Set getMethodCalls () { - return getClasses().stream().flatMap(jClass -> jClass.getMethodCalls().stream()).collect(Collectors.toSet()); - } - - /** - * This method returns all methods of a microservice - * - * @return the set of all methods - */ - public Set getMethods () { - return getClasses().stream().flatMap(jClass -> jClass.getMethods().stream()).collect(Collectors.toSet()); - } - - -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/ir/MicroserviceSystem.java b/src/main/java/edu/university/ecs/lab/common/models/ir/MicroserviceSystem.java deleted file mode 100644 index 83a7c2d5..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/ir/MicroserviceSystem.java +++ /dev/null @@ -1,168 +0,0 @@ -package edu.university.ecs.lab.common.models.ir; - -import com.google.gson.JsonObject; -import edu.university.ecs.lab.common.models.enums.FileType; -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.HashSet; -import java.util.Set; - -/** - * Represents the intermediate structure of a microservice system. - */ -@Data -@AllArgsConstructor -@EqualsAndHashCode -public class MicroserviceSystem implements JsonSerializable { - /** - * The name of the system - */ - private String name; - - /** - * The commit ID of the system - */ - private String commitID; - - /** - * Set of microservices in the system - */ - private Set microservices; - - /** - * Set of present files (class or configurations) who have no microservice - */ - private Set orphans; - - /** - * see {@link JsonSerializable#toJsonObject()} - */ - @Override - public JsonObject toJsonObject() { - JsonObject jsonObject = new JsonObject(); - - jsonObject.addProperty("name", name); - jsonObject.addProperty("commitID", commitID); - jsonObject.add("microservices", JsonSerializable.toJsonArray(microservices)); - jsonObject.add("orphans", JsonSerializable.toJsonArray(orphans)); - - return jsonObject; - } - - /** - * Returns the microservice whose path is the start of the passed path - * - * @param path the path to search for - * @return microservice instance of matching path or null - */ - public Microservice findMicroserviceByPath(String path) { - return getMicroservices().stream().filter(microservice -> path.startsWith(microservice.getPath())).findFirst().orElse(null); - } - - - /** - * Given an existing microservice, if it must now be orphanized - * then all JClasses belonging to that service will be added to - * the system's pool of orphans for later use - * - * @param microservice the microservice to orphanize - */ - public void orphanize(Microservice microservice) { - Set classes = microservice.getClasses(); - classes.forEach(c -> c.updateMicroserviceName("")); - orphans.addAll(classes); - } - - /** - * Given a new or modified microservice, we must adopt awaiting - * orphans based on their file paths containing the microservices - * (folder) path - * - * @param microservice the microservice adopting orphans - */ - public void adopt(Microservice microservice) { - Set updatedOrphans = new HashSet<>(getOrphans()); - - for (ProjectFile file : getOrphans()) { - // If the microservice is in the same folder as the path to the microservice - if (file.getPath().contains(microservice.getPath())) { - if(file.getFileType().equals(FileType.JCLASS)) { - JClass jClass = (JClass) file; - jClass.updateMicroserviceName(microservice.getName()); - microservice.addJClass(jClass); - updatedOrphans.remove(file); - } else { - microservice.getFiles().add((ConfigFile) file); - } - } - - } - - setOrphans(updatedOrphans); - - } - - /** - * Get the class of a given endpoint - * - * @param path endpoint - * @return class that endpoint is in - */ - public JClass findClass(String path){ - JClass returnClass = null; - returnClass = getMicroservices().stream().flatMap(m -> m.getClasses().stream()).filter(c -> c.getPath().equals(path)).findFirst().orElse(null); - if(returnClass == null){ - returnClass = getOrphans().stream().filter(c -> c instanceof JClass).filter(c -> c.getPath().equals(path)).map(c -> (JClass) c).findFirst().orElse(null); - } - - return returnClass; - } - - /** - * Get the file of a given endpoint - * - * @param path endpoint - * @return file that endpoint is in - */ - public ProjectFile findFile(String path){ - ProjectFile returnFile = null; - returnFile = getMicroservices().stream().flatMap(m -> m.getAllFiles().stream()).filter(c -> c.getPath().equals(path)).findFirst().orElse(null); - if(returnFile == null){ - returnFile = getOrphans().stream().filter(c -> c.getPath().equals(path)).findFirst().orElse(null); - } - - return returnFile; - } - - /** - * This method returns the name of the microservice associated with - * a file that exists in the system. Note this method will not work - * if the file is not present somewhere in the system - * - * @param path the ProjectFile path - * @return string name of microservice or "" if it does not exist - */ - public String getMicroserviceFromFile(String path){ - for(Microservice microservice : getMicroservices()) { - for(ProjectFile file : microservice.getFiles()) { - if(file.getPath().equals(path)) { - return microservice.getName(); - } - } - } - - return ""; - } - - public void orphanizeAndAdopt(Microservice microservice) { - orphanize(microservice); - for(Microservice m : getMicroservices()){ - adopt(m); - } - } - - -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/ir/Node.java b/src/main/java/edu/university/ecs/lab/common/models/ir/Node.java deleted file mode 100644 index f87fbcb7..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/ir/Node.java +++ /dev/null @@ -1,31 +0,0 @@ -package edu.university.ecs.lab.common.models.ir; - -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; -import lombok.Data; - -/** - * Abstract class for general datatypes that fall under - * JClass - */ -@Data -public abstract class Node implements JsonSerializable { - /** - * Name of the structure - */ - protected String name; - - /** - * Name of the package + class (package path e.g. edu.university.lab.AdminController) - */ - protected String packageAndClassName; - - /** - * This method generates a unique ID for datatypes that fall - * under a JClass - * - * @return the string unique ID - */ - public final String getID() { - return packageAndClassName + "." + name; - } -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/ir/Parameter.java b/src/main/java/edu/university/ecs/lab/common/models/ir/Parameter.java deleted file mode 100644 index 81a1b21b..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/ir/Parameter.java +++ /dev/null @@ -1,52 +0,0 @@ -package edu.university.ecs.lab.common.models.ir; - -import com.google.gson.JsonObject; -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; -import lombok.Data; - -import java.util.Set; -import java.util.stream.Collectors; - -/** - * Represents a method call parameter - */ -@Data -public class Parameter extends Node implements JsonSerializable { - - /** - * Java class type of the class variable e.g. String - */ - private String type; - - private Set annotations; - - public Parameter(String name, String packageAndClassName, String type, Set annotations) { - this.name = name; - this.packageAndClassName = packageAndClassName; - this.type = type; - this.annotations = annotations; - } - - public Parameter(com.github.javaparser.ast.body.Parameter parameter, String packageAndClassName) { - this.name = parameter.getNameAsString(); - this.type = parameter.getTypeAsString(); - this.packageAndClassName = packageAndClassName; - this.annotations = parameter.getAnnotations().stream().map(annotationExpr -> new Annotation(annotationExpr, packageAndClassName)).collect(Collectors.toSet()); - } - - - /** - * see {@link JsonSerializable#toJsonObject()} - */ - @Override - public JsonObject toJsonObject() { - JsonObject jsonObject = new JsonObject(); - - jsonObject.addProperty("name", getName()); - jsonObject.addProperty("packageAndClassName", getPackageAndClassName()); - jsonObject.addProperty("type", getType()); - jsonObject.add("annotations", JsonSerializable.toJsonArray(annotations)); - - return jsonObject; - } -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/ir/ProjectFile.java b/src/main/java/edu/university/ecs/lab/common/models/ir/ProjectFile.java deleted file mode 100644 index 01f6194b..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/ir/ProjectFile.java +++ /dev/null @@ -1,28 +0,0 @@ -package edu.university.ecs.lab.common.models.ir; - -import com.google.gson.JsonObject; -import edu.university.ecs.lab.common.models.enums.FileType; -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; -import lombok.Data; -import lombok.EqualsAndHashCode; - -/** - * This class represents any file in a project's directory - */ -@Data -@EqualsAndHashCode -public abstract class ProjectFile implements JsonSerializable { - protected String name; - protected String path; - protected FileType fileType; - - - @Override - public JsonObject toJsonObject() { - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("name", name); - jsonObject.addProperty("path", path); - jsonObject.addProperty("fileType", fileType.name()); - return jsonObject; - } -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/ir/RestCall.java b/src/main/java/edu/university/ecs/lab/common/models/ir/RestCall.java deleted file mode 100644 index c8d28fdd..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/ir/RestCall.java +++ /dev/null @@ -1,112 +0,0 @@ -package edu.university.ecs.lab.common.models.ir; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import edu.university.ecs.lab.common.models.enums.HttpMethod; -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; -import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.Set; - - -/** - * Represents an extension of a method call. A rest call exists at the service level and represents - * a call to an endpoint mapping. - */ -@Data -@EqualsAndHashCode(callSuper=true) -public class RestCall extends MethodCall { - - /** - * The URL of the rest call e.g. /api/v1/users/login, May have dynamic parameters - * which are converted to {?} - */ - private String url; - - /** - * The httpMethod of the api endpoint e.g. GET, POST, PUT see semantics.models.enums.httpMethod - */ - private HttpMethod httpMethod; - - - - - public RestCall(String methodName, String packageAndClassName, String objectType, String objectName, String calledFrom, String parameterContents, - String microserviceName, String className) { - super(methodName, packageAndClassName, objectType, objectName, calledFrom, parameterContents, - microserviceName, className); - } - - public RestCall(MethodCall methodCall, String url, HttpMethod httpMethod) { - super(methodCall.name, methodCall.packageAndClassName, methodCall.objectType, methodCall.objectName, methodCall.calledFrom, methodCall.parameterContents, - methodCall.microserviceName, methodCall.className); - this.url = url; - this.httpMethod = httpMethod; - } - - /** - * see {@link JsonSerializable#toJsonObject()} - */ - public JsonObject toJsonObject() { - JsonObject jsonObject = super.toJsonObject(); - - jsonObject.addProperty("url", url); - jsonObject.addProperty("httpMethod", httpMethod.name()); - - return jsonObject; - } - - /** - * Checks if a rest call matches a given endpoint - * - * @param restcall rest call to match - * @param endpoint endpoint to match - * @return true if rest call and enpoint match, false otherwise - */ - public static boolean matchEndpoint(RestCall restcall, Endpoint endpoint){ - if(restcall.getMicroserviceName().equals(endpoint.getMicroserviceName())){ - return false; - } - - int queryParamIndex = restcall.getUrl().replace("{?}", "temp").indexOf("?"); - String baseURL = queryParamIndex == -1 ? restcall.getUrl() : restcall.getUrl().substring(0, queryParamIndex); - return baseURL.equals(endpoint.getUrl()) && (restcall.getHttpMethod().equals(endpoint.getHttpMethod()) || endpoint.getHttpMethod().equals(HttpMethod.ALL)) && matchQueryParams(restcall, endpoint, queryParamIndex); - } - - /** - * Checks if rest call parameters match parameters for the target endpoint - * - * @param restCall rest call to match - * @param endpoint endpoint to match - * @param queryParamIndex string index at which query parameters start - * @return true if parameters match, false otherwise - */ - private static boolean matchQueryParams(RestCall restCall, Endpoint endpoint, int queryParamIndex) { - for(Parameter parameter : endpoint.getParameters()) { - for(Annotation annotation : parameter.getAnnotations()) { - if(annotation.getName().equals("RequestParam")) { - String queryParameterName = ""; - if(annotation.getAttributes().containsKey("default")) { - queryParameterName = annotation.getAttributes().get("default"); - } else if(annotation.getAttributes().containsKey("name")) { - if(annotation.getAttributes().containsKey("required") - && annotation.getAttributes().get("required").equals("false")) { - continue; - } - queryParameterName = annotation.getAttributes().get("name"); - } else { - queryParameterName = parameter.getName(); - } - - if(!restCall.getUrl().substring(queryParamIndex + 1, restCall.getUrl().length()).contains(queryParameterName + "=")) { - return false; - } - } - } - } - return true; - } - -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/package-info.java b/src/main/java/edu/university/ecs/lab/common/models/package-info.java deleted file mode 100644 index 26f71d29..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Provides classes and sub-packages that represent various components of a microservice system - * and facilitate configuration of these representations in JSON format. - *

- * This package includes: - * - - * - {@link edu.university.ecs.lab.common.models.enums}: Enumerations used for categorizing different components, such as Class Roles, HTTP Methods, etc. - * - {@link edu.university.ecs.lab.common.models.serialization}: Serialization and deserialization utilities for converting Java objects to JSON and vice versa - * - Other model classes representing key elements of the microservice system: - * - {@link edu.university.ecs.lab.common.models.ir.Annotation}: Represents annotations within classes. - * - {@link edu.university.ecs.lab.common.models.sdg.RestCallEdge}: Represents an edge in a network graph schema - * modeling microservice connections. - * - {@link edu.university.ecs.lab.common.models.ir.Endpoint}: Represents an endpoint exposed by a microservice. - * - {@link edu.university.ecs.lab.common.models.ir.Field}: Represents fields within classes. - * - {@link edu.university.ecs.lab.common.models.ir.JClass}: Represents a Java class within a microservice. - * - {@link edu.university.ecs.lab.common.models.ir.Method}: Represents a method within classes. - * - {@link edu.university.ecs.lab.common.models.ir.MethodCall}: Represents a method call within microservices. - * - {@link edu.university.ecs.lab.common.models.ir.Microservice}: Represents a microservice within the system, - * including its components like controllers, services, etc. - * - {@link edu.university.ecs.lab.common.models.ir.MicroserviceSystem}: Represents a microservice system and all its components, - * including the name of the system, the set of microservices, etc. - * - {@link edu.university.ecs.lab.common.models.sdg.ServiceDependencyGraph}: Represents the microservice system in a Static SDG schema (nodes and edges) - * - {@link edu.university.ecs.lab.common.models.ir.RestCall}: Represents an a call to an endpoing mapping and exists at the service level - * - */ -package edu.university.ecs.lab.common.models; \ No newline at end of file diff --git a/src/main/java/edu/university/ecs/lab/common/models/serialization/JsonSerializable.java b/src/main/java/edu/university/ecs/lab/common/models/serialization/JsonSerializable.java deleted file mode 100644 index f822d4c5..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/serialization/JsonSerializable.java +++ /dev/null @@ -1,42 +0,0 @@ -package edu.university.ecs.lab.common.models.serialization; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import edu.university.ecs.lab.common.models.ir.Flow; - -/** - * Interface for classes that can be serialized to JSON object - */ -public interface JsonSerializable { - /** - * This method is a generalizable definition for converting an object of - * any type to a JsonObject - * - * @return a JsonObject representing this - */ - JsonObject toJsonObject(); - - /** - * This method is a generalizable implementation for converting an iterable of - * objects that extends this class using {@link JsonSerializable#toJsonObject()} to a JsonArray - * - * @param list - * @return - */ - static JsonArray toJsonArray(Iterable list) { - JsonArray jsonArray = new JsonArray(); - for (JsonSerializable item : list) { - jsonArray.add(item.toJsonObject()); - } - return jsonArray; - } - - static JsonArray toShortJsonArray(Iterable list) { - JsonArray jsonArray = new JsonArray(); - for (Flow item : list) { - jsonArray.add(item.toSmallJsonObject()); - } - return jsonArray; - } - -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/serialization/MethodCallDeserializer.java b/src/main/java/edu/university/ecs/lab/common/models/serialization/MethodCallDeserializer.java deleted file mode 100644 index 289d1ffc..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/serialization/MethodCallDeserializer.java +++ /dev/null @@ -1,51 +0,0 @@ -package edu.university.ecs.lab.common.models.serialization; - -import com.google.gson.*; -import edu.university.ecs.lab.common.models.ir.MethodCall; -import edu.university.ecs.lab.common.models.ir.RestCall; -import edu.university.ecs.lab.common.models.enums.HttpMethod; -import java.lang.reflect.Type; -import java.util.HashSet; -import java.util.Set; - -/** - * Class for deserializing a MethodCall when using Gson - */ -public class MethodCallDeserializer implements JsonDeserializer { - - @Override - public MethodCall deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - JsonObject jsonObject = json.getAsJsonObject(); - if (jsonObject.has("url")) { - return jsonToRestCall(jsonObject); - } else { - return jsonToMethodCall(jsonObject); - } - } - - private MethodCall jsonToMethodCall(JsonObject json) throws JsonParseException { - MethodCall methodCall = new MethodCall(); - methodCall.setName(json.get("name").getAsString()); - methodCall.setCalledFrom(json.get("calledFrom").getAsString()); - methodCall.setObjectName(json.get("objectName").getAsString()); - methodCall.setParameterContents(json.get("parameterContents").getAsString()); - methodCall.setPackageAndClassName(json.get("packageAndClassName").getAsString()); - methodCall.setObjectType(json.get("objectType").getAsString()); - methodCall.setMicroserviceName(json.get("microserviceName").getAsString()); - methodCall.setClassName(json.get("className").getAsString()); - - - return methodCall; - } - - private RestCall jsonToRestCall(JsonObject json) throws JsonParseException { - MethodCall methodCall = jsonToMethodCall(json); - String url = json.get("url").getAsString(); - String httpMethod = json.get("httpMethod").getAsString(); - - - - - return new RestCall(methodCall, url, HttpMethod.valueOf(httpMethod)); - } -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/serialization/MethodDeserializer.java b/src/main/java/edu/university/ecs/lab/common/models/serialization/MethodDeserializer.java deleted file mode 100644 index be163af8..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/serialization/MethodDeserializer.java +++ /dev/null @@ -1,60 +0,0 @@ -package edu.university.ecs.lab.common.models.serialization; - -import com.google.gson.*; -import edu.university.ecs.lab.common.models.ir.*; -import edu.university.ecs.lab.common.models.enums.HttpMethod; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; -import java.util.List; - -/** - * Class for deserializing a Method when using Gson - */ -public class MethodDeserializer implements JsonDeserializer { - - @Override - public Method deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - JsonObject jsonObject = json.getAsJsonObject(); - if (jsonObject.has("url")) { - return jsonToEndpoint(jsonObject, context); - } else { - return jsonToMethod(jsonObject, context); - } - } - - private Method jsonToMethod(JsonObject json, JsonDeserializationContext context) throws JsonParseException { - Method method = new Method(); - method.setName(json.get("name").getAsString()); - method.setReturnType(json.get("returnType").getAsString()); - - Set annotations = new HashSet<>(); - for (JsonElement annotationJson : json.get("annotations").getAsJsonArray()) { - annotations.add(context.deserialize(annotationJson, Annotation.class)); - } - method.setAnnotations(annotations); - - Set parameters = new HashSet<>(); - for (JsonElement fieldJson : json.get("parameters").getAsJsonArray()) { - parameters.add(context.deserialize(fieldJson, Parameter.class)); - } - method.setParameters(parameters); - method.setPackageAndClassName(json.get("packageAndClassName").getAsString()); - method.setMicroserviceName(json.get("microserviceName").getAsString()); - method.setClassName(json.get("className").getAsString()); - - - return method; - } - - private Method jsonToEndpoint(JsonObject json, JsonDeserializationContext context) throws JsonParseException { - Method method = jsonToMethod(json, context); - String url = json.get("url").getAsString(); - String httpMethod = json.get("httpMethod").getAsString(); - - - return new Endpoint(method, url, HttpMethod.valueOf(httpMethod)); - } - -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/serialization/ProjectFileDeserializer.java b/src/main/java/edu/university/ecs/lab/common/models/serialization/ProjectFileDeserializer.java deleted file mode 100644 index 49ec3069..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/serialization/ProjectFileDeserializer.java +++ /dev/null @@ -1,27 +0,0 @@ -package edu.university.ecs.lab.common.models.serialization; - -import com.google.gson.*; -import edu.university.ecs.lab.common.models.ir.*; - -import java.lang.reflect.Type; - -public class ProjectFileDeserializer implements JsonDeserializer { - - @Override - public ProjectFile deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { - JsonObject jsonObject = json.getAsJsonObject(); - String type = jsonObject.get("fileType").getAsString(); - switch (type) { - case "JCLASS": - return context.deserialize(json, JClass.class); - case "POM": - return context.deserialize(json, ConfigFile.class); - case "CONFIG": - return context.deserialize(json, ConfigFile.class); - default: - throw new JsonParseException("Unsupported type: " + type); - } - } - - -} diff --git a/src/main/java/edu/university/ecs/lab/common/models/serialization/package-info.java b/src/main/java/edu/university/ecs/lab/common/models/serialization/package-info.java deleted file mode 100644 index 9fc3677d..00000000 --- a/src/main/java/edu/university/ecs/lab/common/models/serialization/package-info.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Provides utilities and classes for serializing Java objects to JSON and deserializing JSON - * back to Java objects using Gson library. - *

- * This package includes: - * - {@link edu.university.ecs.lab.common.models.serialization.JsonSerializable}: Interface for classes - * that can be serialized to JSON objects. - * - {@link edu.university.ecs.lab.common.models.serialization.MethodCallDeserializer}: Deserializer - * for converting JSON to {@link edu.university.ecs.lab.common.models.ir.MethodCall} and - * {@link edu.university.ecs.lab.common.models.ir.RestCall} objects. - * - {@link edu.university.ecs.lab.common.models.serialization.MethodDeserializer}: Deserializer for - * converting JSON to {@link edu.university.ecs.lab.common.models.ir.Method} and - * {@link edu.university.ecs.lab.common.models.ir.Endpoint} objects. - *

- * These classes facilitate conversion between Java objects and JSON representations. - */ -package edu.university.ecs.lab.common.models.serialization; diff --git a/src/main/java/edu/university/ecs/lab/common/package-info.java b/src/main/java/edu/university/ecs/lab/common/package-info.java deleted file mode 100644 index 3be1b0ec..00000000 --- a/src/main/java/edu/university/ecs/lab/common/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Provides various components for managing and configuring a microservice system. - *

- * This package includes: - * - {@link edu.university.ecs.lab.common.config}: Classes for handling configuration files - * and Git repository path extensions. - * - {@link edu.university.ecs.lab.common.error}: Enumerations for handling errors within the tool. - * - {@link edu.university.ecs.lab.common.models}: Components representing various aspects of - * microservices, including annotations, edges, endpoints, fields, classes, methods, method calls, - * microservices, microservice systems, network graphs, and REST calls. - * - {@link edu.university.ecs.lab.common.utils}: Utility classes for file management, JSON handling, - * and source code parsing. - */ -package edu.university.ecs.lab.common; diff --git a/src/main/java/edu/university/ecs/lab/common/services/GitService.java b/src/main/java/edu/university/ecs/lab/common/services/GitService.java deleted file mode 100644 index 9e72a04c..00000000 --- a/src/main/java/edu/university/ecs/lab/common/services/GitService.java +++ /dev/null @@ -1,294 +0,0 @@ -package edu.university.ecs.lab.common.services; - -import edu.university.ecs.lab.common.config.Config; -import edu.university.ecs.lab.common.config.ConfigUtil; -import edu.university.ecs.lab.common.error.Error; -import edu.university.ecs.lab.common.utils.FileUtils; -import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.api.ResetCommand; -import org.eclipse.jgit.diff.DiffEntry; -import org.eclipse.jgit.lib.*; -import org.eclipse.jgit.revwalk.RevCommit; -import org.eclipse.jgit.revwalk.RevWalk; -import org.eclipse.jgit.storage.file.FileRepositoryBuilder; -import org.eclipse.jgit.treewalk.CanonicalTreeParser; -import org.eclipse.jgit.treewalk.TreeWalk; - -import java.io.File; -import java.nio.charset.StandardCharsets; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - * Service to perform Git opperations - */ -public class GitService { - private static final int EXIT_SUCCESS = 0; - private static final String HEAD_COMMIT = "HEAD"; - - private final Config config; - private final Repository repository; - - /** - * Create a Git service object from a project configuration file - * - * @param configPath path to project configuration file - */ - public GitService(String configPath) { - this.config = ConfigUtil.readConfig(configPath); - FileUtils.makeDirs(); - cloneRemote(); - this.repository = initRepository(); - } - - /** - * Method to clone a repository - */ - public void cloneRemote() { - String repositoryPath = FileUtils.getRepositoryPath(config.getRepoName()); - - // Check if repository was already cloned - if (new File(repositoryPath).exists()) { - return; - } - - // Create and execute operating system process to clone repository - try { - ProcessBuilder processBuilder = - new ProcessBuilder("git", "clone", config.getRepositoryURL(), repositoryPath); - processBuilder.redirectErrorStream(true); - Process process = processBuilder.start(); - int exitCode = process.waitFor(); - - if (exitCode != EXIT_SUCCESS) { - throw new Exception(); - } - - } catch (Exception e) { - Error.reportAndExit(Error.GIT_FAILED, Optional.of(e)); - } - - LoggerManager.info(() -> "Cloned repository " + config.getRepoName()); - } - - /** - * Method to reset repository to a given commit - * - * @param commitID commit id to reset to - */ - public void resetLocal(String commitID) { - validateLocalExists(); - - if (Objects.isNull(commitID) || commitID.isEmpty()) { - return; - } - - // Reset branch to old commit - try (Git git = new Git(repository)) { - git.reset().setMode(ResetCommand.ResetType.HARD).setRef(commitID).call(); - } catch (Exception e) { - Error.reportAndExit(Error.GIT_FAILED, Optional.of(e)); - } - - LoggerManager.info(() -> "Set repository " + config.getRepoName() + " to " + commitID); - } - - /** - * Method to check that local directory exists - */ - private void validateLocalExists() { - File file = new File(FileUtils.getRepositoryPath(config.getRepoName())); - if (!(file.exists() && file.isDirectory())) { - Error.reportAndExit(Error.REPO_DONT_EXIST, Optional.empty()); - } - } - - /** - * Method to initialize repository from repository name - * - * @return file repository - */ - public Repository initRepository() { - validateLocalExists(); - - Repository repository = null; - - try { - File repositoryPath = new File(FileUtils.getRepositoryPath(config.getRepoName())); - repository = new FileRepositoryBuilder().setGitDir(new File(repositoryPath, ".git")).build(); - - } catch (Exception e) { - Error.reportAndExit(Error.GIT_FAILED, Optional.of(e)); - } - - return repository; - } - - /** - * Method to get differences between old and new commits - * - * @param commitOld old commit id - * @param commitNew new commit id - * @return list of changes from old commit to new commit - */ - public List getDifferences(String commitOld, String commitNew) { - List returnList = null; - RevCommit oldCommit = null, newCommit = null; - RevWalk revWalk = new RevWalk(repository); - - try { - // Parse the old and new commits - oldCommit = revWalk.parseCommit(repository.resolve(commitOld)); - newCommit = revWalk.parseCommit(repository.resolve(commitNew)); - } catch (Exception e) { - Error.reportAndExit(Error.GIT_FAILED, Optional.of(e)); - } - - // Prepare tree parsers for both commits - try (ObjectReader reader = repository.newObjectReader()) { - CanonicalTreeParser oldTreeParser = new CanonicalTreeParser(); - CanonicalTreeParser newTreeParser = new CanonicalTreeParser(); - - // Use tree objects from the commits - oldTreeParser.reset(reader, oldCommit.getTree().getId()); - newTreeParser.reset(reader, newCommit.getTree().getId()); - - // Compute differences between the trees of the two commits - try (Git git = new Git(repository)) { - List rawDiffs = git.diff() - .setOldTree(oldTreeParser) - .setNewTree(newTreeParser) - .call(); - - // Filter out diffs that only contain whitespace or comment changes - RevCommit finalOldCommit = oldCommit; - RevCommit finalNewCommit = newCommit; - returnList = rawDiffs.stream() - .filter(diff -> isCodeChange(diff, repository, finalOldCommit, finalNewCommit)) - .collect(Collectors.toList()); - } - } catch (Exception e) { - Error.reportAndExit(Error.GIT_FAILED, Optional.of(e)); - } - - LoggerManager.debug(() -> "Got differences of repository " + config.getRepoName() + " between " + commitOld + " -> " + commitNew); - - return returnList; - } - - /** - * Method to check if a commit difference was a change to the code - * - * @param diff DiffEntry object - * @param repository repository to check - * @param oldCommit old commit id - * @param newCommit new commit id - * - * @return true if difference was a change to the code, false otherwise - */ - private boolean isCodeChange(DiffEntry diff, Repository repository, RevCommit oldCommit, RevCommit newCommit) { - if((!diff.getOldPath().endsWith(".java") && !diff.getNewPath().endsWith(".java"))) { - return true; - } - - // Read the file contents before and after the changes - String oldContent = getContentFromTree(repository, oldCommit.getTree().getId(), diff.getOldPath()); - String newContent = getContentFromTree(repository, newCommit.getTree().getId(), diff.getNewPath()); - - // Remove comments and whitespace from both contents - String oldCode = stripCommentsAndWhitespace(oldContent); - String newCode = stripCommentsAndWhitespace(newContent); - - // If the meaningful code is different, return true - return !oldCode.equals(newCode); - } - - /** - * Get file data from a file tree - * - * @param repository repository to check - * @param treeId id of the tree to check - * @param filePath file to get data from - * @return data from the file, or an empty string if an error occurs or file is not found - */ - private String getContentFromTree(Repository repository, ObjectId treeId, String filePath) { - try (ObjectReader reader = repository.newObjectReader(); - TreeWalk treeWalk = new TreeWalk(repository)) { - - // Add the tree to the tree walker - treeWalk.addTree(treeId); - treeWalk.setRecursive(true); // We want to search recursively - - // Walk through the tree to find the file - while (treeWalk.next()) { - String currentPath = treeWalk.getPathString(); - if (currentPath.equals(filePath)) { - // Ensure we have a blob (file) and not a tree - if (treeWalk.getFileMode(0).getObjectType() == Constants.OBJ_BLOB) { - // Read the file content and return it - byte[] data = reader.open(treeWalk.getObjectId(0)).getBytes(); - return new String(data, StandardCharsets.UTF_8); - } - } - } - - } catch (Exception e) { - // Return an empty string in case of an error - return ""; - } - - // If the file is not found, return an empty string - return ""; - } - - /** - * Remove comments and whitespace from file content - * - * @param content string of all file content - * @return string of file content with whitespace and comments removed - */ - private String stripCommentsAndWhitespace(String content) { - return content.replaceAll("(//.*|/\\*[^*]*\\*+(?:[^/*][^*]*\\*+)*/|\\s+)", ""); - } - - /** - * Get Git log - * - * @return Git log as a list - */ - public Iterable getLog() { - Iterable returnList = null; - - try (Git git = new Git(repository)) { - returnList = git.log().call(); - } catch (Exception e) { - Error.reportAndExit(Error.GIT_FAILED, Optional.of(e)); - } - - return returnList; - } - - /** - * Get head commit for the repository - * - * @return commit id of head commit - */ - public String getHeadCommit() { - String commitID = ""; - - try { - Ref head = repository.findRef(HEAD_COMMIT); - RevWalk walk = new RevWalk(repository); - ObjectId commitId = head.getObjectId(); - RevCommit commit = walk.parseCommit(commitId); - commitID = commit.getName(); - walk.close(); - } catch (Exception e) { - Error.reportAndExit(Error.GIT_FAILED, Optional.of(e)); - } - - return commitID; - } -} diff --git a/src/main/java/edu/university/ecs/lab/common/services/LoggerManager.java b/src/main/java/edu/university/ecs/lab/common/services/LoggerManager.java deleted file mode 100644 index 7bf5e225..00000000 --- a/src/main/java/edu/university/ecs/lab/common/services/LoggerManager.java +++ /dev/null @@ -1,66 +0,0 @@ -package edu.university.ecs.lab.common.services; - - -import edu.university.ecs.lab.common.error.Error; -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import java.util.Optional; -import java.util.function.Supplier; - -/** - * Static functions to manage logger object - */ -public class LoggerManager { - private static final Logger logger = LogManager.getLogger(LoggerManager.class); - - - /** - * Log an info message - * - * @param msgSupplier the message to log - */ - public static void info(Supplier msgSupplier) { - log(Level.INFO, msgSupplier); - } - - /** - * Log a warning message - * - * @param msgSupplier the message to log - */ - public static void warn(Supplier msgSupplier) { - log(Level.WARN, msgSupplier); - } - - /** - * Log a debug message - * - * @param msgSupplier the message to log - */ - public static void debug(Supplier msgSupplier) { - log(Level.DEBUG, msgSupplier); - } - - /** - * Log an error message - * - * @param msgSupplier the message to log - */ - public static void error(Supplier msgSupplier, Optional exception) { - log(Level.ERROR, msgSupplier); - exception.ifPresent(e -> logger.error(e.getMessage(), e)); - } - - /** - * Log message - * - * @param level the logging level - * @param msgSupplier the message to log - */ - private static void log(Level level, Supplier msgSupplier) { - logger.log(level, msgSupplier.get()); - } - - -} diff --git a/src/main/java/edu/university/ecs/lab/common/utils/FileUtils.java b/src/main/java/edu/university/ecs/lab/common/utils/FileUtils.java deleted file mode 100644 index 26947cf9..00000000 --- a/src/main/java/edu/university/ecs/lab/common/utils/FileUtils.java +++ /dev/null @@ -1,154 +0,0 @@ -package edu.university.ecs.lab.common.utils; - -import edu.university.ecs.lab.common.error.Error; -import java.io.File; -import java.util.Arrays; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - - -/** - * Manages all file paths and file path conversion functions. - */ -public class FileUtils { - public static final Set VALID_FILES = Set.of("pom.xml", ".java", ".yml", "build.gradle"); - public static final String SYS_SEPARATOR = System.getProperty("file.separator"); - public static final String SPECIAL_SEPARATOR = SYS_SEPARATOR.replace("\\", "\\\\"); - private static final String DEFAULT_OUTPUT_PATH = "output"; - private static final String DEFAULT_CLONE_PATH = "clone"; - private static final String DOT = "."; - public static final String GIT_SEPARATOR = "/"; - - /** - * Private constructor to prevent instantiation. - */ - private FileUtils() {} - - /** - * This method returns the relative path of the cloned repository directory as ./DEFAULT_CLONE_PATH/repoName. - * This will be a working relative path to the repository directory on the local file system. - * - * @param repoName the name of the repo - * @return the relative path string where that repository is cloned to - */ - public static String getRepositoryPath(String repoName) { - return getClonePath() + SYS_SEPARATOR + repoName; - } - - /** - * This method returns the relative local path of the output directory as ./DEFAULT_OUTPUT_PATH. - * This will be a working relative path to the output directory on the local file system. - * - * @return the relative path string where the output will exist - */ - public static String getOutputPath() { - return DOT + SYS_SEPARATOR + DEFAULT_OUTPUT_PATH; - } - - /** - * This method returns the relative local path of the output directory as ./DEFAULT_OUTPUT_PATH. - * This will be a working relative path to the output directory on the local file system. - * - * @return the relative path string where the output will exist - */ - public static String getClonePath() { - return DOT + SYS_SEPARATOR + DEFAULT_CLONE_PATH; - } - - /** - * This method converts a path of the form .\clone\repoName\pathToFile to the form - * /pathToFile - * - * @param localPath the local path to be converted - * @param repoName the name of the repo cloned locally - * @return the relative repo path - */ - public static String localPathToGitPath(String localPath, String repoName) { - return localPath.replace(FileUtils.getRepositoryPath(repoName), "").replaceAll(SPECIAL_SEPARATOR, GIT_SEPARATOR); - } - /** - * This method converts a path of the form .\clone\repoName\pathToFile to the form - * /pathToFile - * - * @param localPath the local path to be converted - * @param repoName the name of the repo cloned locally - * @return the relative repo path - */ - public static String gitPathToLocalPath(String localPath, String repoName) { - return getRepositoryPath(repoName) + localPath.replace(GIT_SEPARATOR, SYS_SEPARATOR); - } - - - - @Deprecated - public static String getMicroserviceNameFromPath(String path) { - if (!path.startsWith(DOT + SYS_SEPARATOR + DEFAULT_CLONE_PATH + SYS_SEPARATOR)) { - Error.reportAndExit(Error.INVALID_REPO_PATHS, Optional.empty()); - } - - String[] split = path.replace(DOT + SYS_SEPARATOR + DEFAULT_CLONE_PATH + SYS_SEPARATOR, "").split(SPECIAL_SEPARATOR); - return split[split.length-1]; - } - - /** - * This method returns a Git path without the filename at the end. - * - * @param path the path to remove filename from - * @return the path without the file name or if too short just GIT_SEPARATOR - */ - public static String getGitPathNoFileName(String path) { - String[] split = path.split(GIT_SEPARATOR); - - if(split.length > 1) { - return String.join(GIT_SEPARATOR, Arrays.copyOfRange(split, 0, split.length - 1)); - } else { - return GIT_SEPARATOR; - } - } - - /** - * This method creates the default output and clone directories - */ - public static void makeDirs() { - try { - new File(getOutputPath()).mkdirs(); - new File(getClonePath()).mkdirs(); - } catch (Exception e) { - Error.reportAndExit(Error.INVALID_REPO_PATHS, Optional.of(e)); - } - } - - /** - * This method filters the file's that should be present in the project - * - * @param path the file for checking - * @return boolean true if it belongs in the project - */ - public static boolean isValidFile(String path) { - // Special check for github metadata files - if(path.contains(".github")) { - return false; - } - - for(String f : VALID_FILES) { - if(path.endsWith(f)) { - return true; - } - } - - return false; - } - - /** - * This method filters the static files present in the project, - * not including Java source file but configuration files only - * - * @param path the file for checking - * @return boolean true if it is a configuration file - */ - public static boolean isConfigurationFile(String path) { - return isValidFile(path) && !path.endsWith(".java"); - } - -} diff --git a/src/main/java/edu/university/ecs/lab/common/utils/FlowUtils.java b/src/main/java/edu/university/ecs/lab/common/utils/FlowUtils.java deleted file mode 100644 index 578bb16b..00000000 --- a/src/main/java/edu/university/ecs/lab/common/utils/FlowUtils.java +++ /dev/null @@ -1,255 +0,0 @@ -package edu.university.ecs.lab.common.utils; - -import edu.university.ecs.lab.common.models.ir.*; - -import java.util.*; -import java.util.stream.Collectors; - -public class FlowUtils { - - /** - * Method for generating all possibilities - * of Flows - * - * @param microserviceSystem the microservice system to scan for flows - * @return the list of all possible flows - */ - public static List buildFlows(MicroserviceSystem microserviceSystem) { - List allFlows = new ArrayList<>(); - List baseFlows = generateNewFlows(getAllMicroserviceControllers(microserviceSystem)); - Flow flowCopy1, flowCopy2, flowCopy3, flowCopy4; - - for(Flow flow : baseFlows) { - List serviceMethodCalls = findAllServiceMethodCalls(flow); - for(MethodCall serviceMethodCall : serviceMethodCalls) { - flowCopy1 = flow; - flowCopy1.setServiceMethodCall(serviceMethodCall); - - Optional serviceField = Optional.ofNullable(findServiceField(flowCopy1)); - if (serviceField.isPresent()) { - flowCopy1.setControllerServiceField(serviceField.get()); - - List serviceClasses = findAllServices(flowCopy1); - for (JClass serviceClass : serviceClasses) { - flowCopy2 = flowCopy1; - flowCopy2.setService(serviceClass); - - Optional serviceMethod = Optional.ofNullable(findServiceMethod(flowCopy2)); - if (serviceMethod.isPresent()) { - flowCopy2.setServiceMethod(serviceMethod.get()); - - List repositoryMethodCalls = findAllRepositoryMethodCalls(flowCopy2); - for (MethodCall repositroyMethodCall : repositoryMethodCalls) { - flowCopy3 = flowCopy2; - flow.setRepositoryMethodCall(repositroyMethodCall); - - Optional repositoryField = Optional.ofNullable(findRepositoryField(flowCopy3)); - if (repositoryField.isPresent()) { - flowCopy3.setServiceRepositoryField(repositoryField.get()); - - List repositoryClasses = findAllRepositorys(flowCopy3); - for (JClass repositoryClass : repositoryClasses) { - flowCopy4 = flowCopy3; - - flowCopy4.setRepository(repositoryClass); - - Optional repositoryMethod = Optional.ofNullable(findRepositoryMethod(flowCopy4)); - if (repositoryMethod.isPresent()) { - flowCopy4.setRepositoryMethod(repositoryMethod.get()); - } - - allFlows.add(flowCopy4); - } - } else { - allFlows.add(flowCopy3); - } - - } - } else { - allFlows.add(flowCopy2); - } - - } - } else { - allFlows.add(flowCopy1); - } - - } - - if(serviceMethodCalls.isEmpty()) { - allFlows.add(flow); - } - - } - - return allFlows; - } - - /** - * This method returns a map of microservices to their controller classes - * - * @param microserviceSystem the microservice system to convert - * @return the map of microservice to JClass controllers - */ - private static Map> getAllMicroserviceControllers(MicroserviceSystem microserviceSystem) { - Map> controllerMap = new HashMap<>(); - - for (Microservice microservice : microserviceSystem.getMicroservices()) { - controllerMap.put(microservice, microservice.getControllers()); - } - - return controllerMap; - } - - /** - * This method generates the base flows - * - * @param controllerMap the controller map - * @return the base flows - */ - private static List generateNewFlows(Map> controllerMap) { - List flows = new ArrayList<>(); - Flow f; - - for (Map.Entry> controllerList : controllerMap.entrySet()) { - for (JClass controller : controllerList.getValue()) { - for (Endpoint endpoint : controller.getEndpoints()) { - f = new Flow(); - f.setController(controller); - f.setControllerMethod(endpoint); - f.setModel(controllerList.getKey()); - flows.add(f); - } - } - } - return flows; - } - - private static List generateNewFlows( - Microservice microservice, List controllers) { - List flows = new ArrayList<>(); - Flow f; - - for (JClass controller : controllers) { - for (Endpoint endpoint : controller.getEndpoints()) { - f = new Flow(); - f.setController(controller); - f.setControllerMethod(endpoint); - f.setModel(microservice); - flows.add(f); - } - } - - return flows; - } - - /** - * This method find's all method calls from the controllerMethod of a flow - * - * @param flow the flow - * @return the list of MethodCalls from the controllerMethod of the flow - */ - private static List findAllServiceMethodCalls(Flow flow) { - return flow.getController().getMethodCalls().stream() - .filter(mc -> mc.getCalledFrom().equals(flow.getControllerMethod().getName())) - .collect(Collectors.toUnmodifiableList()); - } - - /** - * This method find's the service field affiliated with a methodCall of a flow - * - * @param flow the flow - * @return the field called from this flow's serviceMethodCall - */ - private static Field findServiceField(Flow flow) { - return flow.getController().getFields().stream() - .filter(f -> f.getName().equals(flow.getServiceMethodCall().getObjectName())) - .findFirst() - .orElse(null); - } - - /** - * This method finds any jClass affiliated with the serviceField of a flow. - * Due to polymorphism the type is not guaranteed to match one class so all - * possibilities will be considered. - * Note: This is a source of approximation -- Runtime types - * - * @param flow the flow - * @return the jClass affiliated with the serviceField - */ - private static List findAllServices(Flow flow) { - return flow.getModel().getServices().stream() - .filter( - jClass -> jClass.getImplementedTypes().contains(flow.getControllerServiceField().getType()) || jClass.getName().equals(flow.getControllerServiceField().getType())) - .collect(Collectors.toUnmodifiableList()); - } - - /** - * This method finds the method affiliated with the serviceMethodCall of a flow - * - * @param flow the flow - * @return the method affiliated with the serviceMethodCall - */ - private static Method findServiceMethod(Flow flow) { - return flow.getService().getMethods().stream() - .filter( - method -> method.getName().equals(flow.getServiceMethodCall().getName())) - .findFirst() - .orElse(null); - } - - /** - * This method find's all method calls from the serviceMethod of a flow - * - * @param flow the flow - * @return the list of MethodCalls from the serviceMethod of the flow - */ - private static List findAllRepositoryMethodCalls(Flow flow) { - return flow.getService().getMethodCalls().stream() - .filter(mc -> mc.getCalledFrom().equals(flow.getServiceMethod().getName())) - .collect(Collectors.toUnmodifiableList()); - } - - /** - * This method find's the repository field affiliated with a methodCall of a flow - * - * @param flow the flow - * @return the field called from this flow's repositoryMethodCall - */ - private static Field findRepositoryField(Flow flow) { - return flow.getService().getFields().stream() - .filter(f -> f.getName().equals(flow.getRepositoryMethodCall().getObjectName())) - .findFirst() - .orElse(null); - } - - /** - * This method finds any jClass affiliated with the repositoryField of a flow. - * Due to polymorphism the type is not guaranteed to match one class so all - * possibilities will be considered. - * Note: This is a source of approximation -- Runtime types - * - * @param flow the flow - * @return the jClass affiliated with the repositoryField - */ - private static List findAllRepositorys(Flow flow) { - return flow.getModel().getRepositories().stream() - .filter( - jClass -> jClass.getImplementedTypes().contains(flow.getServiceRepositoryField().getType()) || jClass.getName().equals(flow.getServiceRepositoryField().getType())) - .collect(Collectors.toUnmodifiableList()); - } - - /** - * This method finds the method affiliated with the repositoryMethodCall of a flow - * - * @param flow the flow - * @return the method affiliated with the repositoryMethodCall - */ - private static Method findRepositoryMethod(Flow flow) { - return flow.getRepository().getMethods().stream() - .filter( - method -> method.getName().equals(flow.getRepositoryMethodCall().getName())) - .findFirst() - .orElse(null); - } -} \ No newline at end of file diff --git a/src/main/java/edu/university/ecs/lab/common/utils/JsonReadWriteUtils.java b/src/main/java/edu/university/ecs/lab/common/utils/JsonReadWriteUtils.java deleted file mode 100644 index 26967660..00000000 --- a/src/main/java/edu/university/ecs/lab/common/utils/JsonReadWriteUtils.java +++ /dev/null @@ -1,82 +0,0 @@ -package edu.university.ecs.lab.common.utils; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import edu.university.ecs.lab.common.error.Error; -import edu.university.ecs.lab.common.models.ir.Method; -import edu.university.ecs.lab.common.models.ir.MethodCall; -import edu.university.ecs.lab.common.models.ir.ProjectFile; -import edu.university.ecs.lab.common.models.serialization.MethodCallDeserializer; -import edu.university.ecs.lab.common.models.serialization.MethodDeserializer; -import edu.university.ecs.lab.common.models.serialization.ProjectFileDeserializer; - -import java.io.*; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Optional; - -/** - * Utility class for reading and writing JSON to a file. - */ -public class JsonReadWriteUtils { - /** - * Private constructor to prevent instantiation. - */ - private JsonReadWriteUtils() { - } - - /** - * Writes an object to a JSON file at a specified path. - * - * @param the type of the object to write - * @param object the object to serialize into JSON - * @param filePath the file path where the JSON should be saved - */ - public static void writeToJSON(String filePath, T object) { - Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); - try { - Path path = Paths.get(filePath); - Files.createDirectories(path.getParent()); - try (Writer writer = Files.newBufferedWriter(path)) { - gson.toJson(object, writer); - } - } catch (IOException e) { - Error.reportAndExit(Error.INVALID_JSON_WRITE, Optional.of(e)); - } - } - - /** - * Reads a JSON file from a given path and converts it into an object of the specified type. - * - * @param the type of the object to return - * @param filePath the file path to the JSON file - * @param type the Class representing the type of the object to deserialize - * @return an object of type T containing the data from the JSON file - */ - public static T readFromJSON(String filePath, Class type) { - // Register appropriate deserializers to allow compaction of data - - Gson gson = registerDeserializers(); - try (Reader reader = new BufferedReader(new FileReader(filePath))) { - return gson.fromJson(reader, type); - } catch (Exception e) { - Error.reportAndExit(Error.INVALID_JSON_READ, Optional.of(e)); - } - - return null; - } - - /** - * Function for register custom deserializers when reading JSON from a file - * @return - */ - public static Gson registerDeserializers() { - - return new GsonBuilder() - .registerTypeAdapter(Method.class, new MethodDeserializer()) - .registerTypeAdapter(MethodCall.class, new MethodCallDeserializer()) - .registerTypeAdapter(ProjectFile.class, new ProjectFileDeserializer()) - .create(); - } -} diff --git a/src/main/java/edu/university/ecs/lab/common/utils/NonJsonReadWriteUtils.java b/src/main/java/edu/university/ecs/lab/common/utils/NonJsonReadWriteUtils.java deleted file mode 100644 index ffdb556f..00000000 --- a/src/main/java/edu/university/ecs/lab/common/utils/NonJsonReadWriteUtils.java +++ /dev/null @@ -1,160 +0,0 @@ -package edu.university.ecs.lab.common.utils; - -import com.google.gson.*; -import edu.university.ecs.lab.common.config.Config; -import edu.university.ecs.lab.common.models.enums.FileType; -import edu.university.ecs.lab.common.models.ir.ConfigFile; -import org.json.JSONObject; -import org.json.XML; -import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.SafeConstructor; - -import java.io.*; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Stack; - -/** - * Utility class for reading files that don't abide by JSON format - */ -public class NonJsonReadWriteUtils { - - /** - * Private constructor to prevent instantiation. - */ - private NonJsonReadWriteUtils() { - } - - /** - * This method reads YAML from a file returning structure as JsonObject - * @param path the path to the YAML file. - * @return JsonObject YAML file structure as json object - */ - public static ConfigFile readFromYaml(String path, Config config) { - JsonObject data = null; - Yaml yaml = new Yaml(new SafeConstructor()); - Gson gson = new Gson(); - - try (FileInputStream fis = new FileInputStream(path)) { - // Parse YAML file to Map - Map yamlMap = yaml.load(fis); - - if (yamlMap == null || yamlMap.isEmpty()) { - // Handle empty file or empty YAML content - data = new JsonObject(); - } else { - String jsonString = gson.toJson(yamlMap); - data = JsonParser.parseString(jsonString).getAsJsonObject(); - } - - } catch (Exception e) { - // Handle I/O errors (file not found, etc.) - return null; - } - - return new ConfigFile(FileUtils.localPathToGitPath(path, config.getRepoName()), new File(path).getName(), data, FileType.CONFIG); - } - - public static ConfigFile readFromDocker(String path, Config config) { - List instructions = new ArrayList<>(); - JsonObject jsonObject; - try (BufferedReader br = new BufferedReader(new FileReader(path))) { - String line; - while ((line = br.readLine()) != null) { - instructions.add(line.trim()); // Add each line as an instruction - } - } catch (Exception e) { - return null; - } - jsonObject = new JsonObject(); - JsonArray jsonArray = new JsonArray(); - for (String instruction : instructions) { - jsonArray.add(instruction); - } - jsonObject.add("instructions", jsonArray); - - return new ConfigFile(FileUtils.localPathToGitPath(path, config.getRepoName()), new File(path).getName(), jsonObject, FileType.CONFIG); - } - - public static ConfigFile readFromPom(String path, Config config) { - String xmlContent = null; - JsonObject jsonObject; - try { - // Read the entire file content - xmlContent = new String(Files.readAllBytes(Paths.get(path))); - - if (xmlContent.trim().isEmpty()) { - jsonObject = new JsonObject(); - } else { - // Convert XML to JSONObject using org.json - JSONObject jsonObjectOld = XML.toJSONObject(xmlContent); - - // Convert JSONObject to Gson JsonObject - JsonElement jsonElement = JsonParser.parseString(jsonObjectOld.toString()); - jsonObject = jsonElement.getAsJsonObject(); - } - } catch (Exception e) { - return null; - } - - - return new ConfigFile(FileUtils.localPathToGitPath(path, config.getRepoName()), new File(path).getName(), jsonObject, FileType.CONFIG); - } - - public static ConfigFile readFromGradle(String path, Config config) { - JsonObject jsonObject = new JsonObject(); - Stack jsonStack = new Stack<>(); - jsonStack.push(jsonObject); - - try (BufferedReader br = new BufferedReader(new FileReader(path))) { - String line; - String currentKey = null; - - while ((line = br.readLine()) != null) { - line = line.trim(); - - if (line.isEmpty()) { - continue; - } - - if (line.endsWith("{")) { - String key = line.substring(0, line.length() - 1).trim(); - JsonObject newObject = new JsonObject(); - jsonStack.peek().add(key, newObject); - jsonStack.push(newObject); - currentKey = key; - } else if (line.equals("}")) { - jsonStack.pop(); - currentKey = null; - } else if (line.contains("=")) { - String[] parts = line.split("=", 2); - if (parts.length == 2) { - String key = parts[0].trim(); - String value = parts[1].trim().replace("'", "\""); - jsonStack.peek().addProperty(key, value); - } - } else { - if (currentKey != null) { - JsonArray array = jsonStack.peek().has(currentKey) ? - jsonStack.peek().getAsJsonArray(currentKey) : new JsonArray(); - array.add(line); - jsonStack.peek().add(currentKey, array); - } - } - } - } catch (IOException e) { - return null; - } - - return new ConfigFile( - FileUtils.localPathToGitPath(path, config.getRepoName()), - new File(path).getName(), - jsonObject, - FileType.CONFIG - ); - } - -} diff --git a/src/main/java/edu/university/ecs/lab/common/utils/SourceToObjectUtils.java b/src/main/java/edu/university/ecs/lab/common/utils/SourceToObjectUtils.java deleted file mode 100644 index 5cd68f21..00000000 --- a/src/main/java/edu/university/ecs/lab/common/utils/SourceToObjectUtils.java +++ /dev/null @@ -1,575 +0,0 @@ -package edu.university.ecs.lab.common.utils; - -import com.github.javaparser.StaticJavaParser; -import com.github.javaparser.ast.CompilationUnit; -import com.github.javaparser.ast.Node; -import com.github.javaparser.ast.PackageDeclaration; -import com.github.javaparser.ast.body.*; -import com.github.javaparser.ast.body.Parameter; -import com.github.javaparser.ast.expr.*; -import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName; -import com.github.javaparser.resolution.UnsolvedSymbolException; -import com.github.javaparser.symbolsolver.JavaSymbolSolver; -import com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade; -import com.github.javaparser.symbolsolver.model.resolution.TypeSolver; -import com.github.javaparser.symbolsolver.model.typesystem.ReferenceTypeImpl; -import com.github.javaparser.symbolsolver.resolution.typesolvers.CombinedTypeSolver; -import com.github.javaparser.symbolsolver.resolution.typesolvers.JavaParserTypeSolver; -import com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver; -import edu.university.ecs.lab.common.config.Config; -import edu.university.ecs.lab.common.error.Error; -import edu.university.ecs.lab.common.models.enums.ClassRole; -import edu.university.ecs.lab.common.models.enums.EndpointTemplate; -import edu.university.ecs.lab.common.models.enums.HttpMethod; -import edu.university.ecs.lab.common.models.enums.RestCallTemplate; -import edu.university.ecs.lab.common.models.ir.*; -import edu.university.ecs.lab.common.services.LoggerManager; - -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStreamReader; -import java.util.*; -import java.util.stream.Collectors; - -/** - * Static utility class for parsing a file and returning associated models from code structure. - */ -public class SourceToObjectUtils { - private static CompilationUnit cu; - private static String microserviceName = ""; - private static String path; - private static String className; - private static String packageName; - private static String packageAndClassName; - private static CombinedTypeSolver combinedTypeSolver; - private static Config config; - - - private static void generateStaticValues(File sourceFile, Config config1) { - // Parse the highest level node being compilation unit - config = config1; - try { - cu = StaticJavaParser.parse(sourceFile); - } catch (Exception e) { - LoggerManager.warn(() -> "Failed to parse " + sourceFile.getPath()); - microserviceName = ""; - return; -// Error.reportAndExit(Error.JPARSE_FAILED, Optional.of(e)); - } - if (!cu.findAll(PackageDeclaration.class).isEmpty()) { - packageName = cu.findAll(PackageDeclaration.class).get(0).getNameAsString(); - packageAndClassName = packageName + "." + sourceFile.getName().replace(".java", ""); - } - path = FileUtils.localPathToGitPath(sourceFile.getPath(), config.getRepoName()); - - TypeSolver reflectionTypeSolver = new ReflectionTypeSolver(); - TypeSolver javaParserTypeSolver = new JavaParserTypeSolver(FileUtils.getRepositoryPath(config.getRepoName())); - - combinedTypeSolver = new CombinedTypeSolver(); - combinedTypeSolver.add(reflectionTypeSolver); - combinedTypeSolver.add(javaParserTypeSolver); - - JavaSymbolSolver symbolSolver = new JavaSymbolSolver(combinedTypeSolver); - StaticJavaParser.getConfiguration().setSymbolResolver(symbolSolver); - className = sourceFile.getName().replace(".java", ""); - - } - - /** - * This method parses a Java class file and return a JClass object. - * - * @param sourceFile the file to parse - * @return the JClass object representing the file - */ - public static JClass parseClass(File sourceFile, Config config, String microserviceName) { - // Guard condition - if(Objects.isNull(sourceFile) || FileUtils.isConfigurationFile(sourceFile.getPath())) { - LoggerManager.warn(() -> "JClass filtered " + sourceFile.getPath() + " is config or null"); - return null; - } - - generateStaticValues(sourceFile, config); - if (!microserviceName.isEmpty()) { - SourceToObjectUtils.microserviceName = microserviceName; - } - - // Calculate early to determine classrole based on annotation, filter for class based annotations only - Set classAnnotations = filterClassAnnotations(); - AnnotationExpr requestMapping = classAnnotations.stream().filter(ae -> ae.getNameAsString().equals("RequestMapping")).findFirst().orElse(null); - - ClassRole classRole = parseClassRole(classAnnotations); - - // Return unknown classRoles where annotation not found - if (classRole.equals(ClassRole.UNKNOWN)) { - LoggerManager.warn(() -> "JClass filtered " + sourceFile.getPath() + " class role unknown"); - return null; - } - - JClass jClass = null; - if(classRole == ClassRole.FEIGN_CLIENT) { - jClass = handleFeignClient(requestMapping, classAnnotations); - } else if(classRole == ClassRole.REP_REST_RSC) { - jClass = handleRepositoryRestResource(requestMapping, classAnnotations); - } else { - jClass = new JClass( - className, - path, - packageName, - classRole, - parseMethods(cu.findAll(MethodDeclaration.class), requestMapping), - parseFields(cu.findAll(FieldDeclaration.class)), - parseAnnotations(classAnnotations), - parseMethodCalls(cu.findAll(MethodDeclaration.class)), - cu.findAll(ClassOrInterfaceDeclaration.class).get(0).getImplementedTypes().stream().map(NodeWithSimpleName::getNameAsString).collect(Collectors.toSet())); - } - - // Build the JClass - return jClass; - - } - - - /** - * This method parses methodDeclarations list and returns a Set of Method models - * - * @param methodDeclarations the list of methodDeclarations to be parsed - * @return a set of Method models representing the MethodDeclarations - */ - public static Set parseMethods(List methodDeclarations, AnnotationExpr requestMapping) { - // Get params and returnType - Set methods = new HashSet<>(); - - for (MethodDeclaration methodDeclaration : methodDeclarations) { - Set parameters = new HashSet<>(); - for (Parameter parameter : methodDeclaration.getParameters()) { - parameters.add(new edu.university.ecs.lab.common.models.ir.Parameter(parameter, packageAndClassName)); - } - - Method method = new Method( - methodDeclaration.getNameAsString(), - packageAndClassName, - parameters, - methodDeclaration.getTypeAsString(), - parseAnnotations(methodDeclaration.getAnnotations()), - microserviceName, - className); - - method = convertValidEndpoints(methodDeclaration, method, requestMapping); - - methods.add(method); - } - - return methods; - } - - /** - * This method converts a valid Method to an Endpoint - * - * @param methodDeclaration the MethodDeclaration associated with Method - * @param method the Method to be converted - * @param requestMapping the class level requestMapping - * @return returns method if it is invalid, otherwise a new Endpoint - */ - public static Method convertValidEndpoints(MethodDeclaration methodDeclaration, Method method, AnnotationExpr requestMapping) { - for (AnnotationExpr ae : methodDeclaration.getAnnotations()) { - String ae_name = ae.getNameAsString(); - if (EndpointTemplate.ENDPOINT_ANNOTATIONS.contains(ae_name)) { - EndpointTemplate endpointTemplate = new EndpointTemplate(requestMapping, ae); - - // By Spring documentation, only the first valid @Mapping annotation is considered; - // And getAnnotations() return them in order, so we can return immediately - return new Endpoint(method, endpointTemplate.getUrl(), endpointTemplate.getHttpMethod()); - } - } - - return method; - } - - - - /** - * This method parses methodDeclarations list and returns a Set of MethodCall models - * - * @param methodDeclarations the list of methodDeclarations to be parsed - * @return a set of MethodCall models representing MethodCallExpressions found in the MethodDeclarations - */ - public static List parseMethodCalls(List methodDeclarations) { - List methodCalls = new ArrayList<>(); - - // loop through method calls - for (MethodDeclaration methodDeclaration : methodDeclarations) { - for (MethodCallExpr mce : methodDeclaration.findAll(MethodCallExpr.class)) { - String methodName = mce.getNameAsString(); - - String calledServiceName = getCallingObjectName(mce); - String calledServiceType = getCallingObjectType(mce); - - String parameterContents = mce.getArguments().stream().map(Objects::toString).collect(Collectors.joining(",")); - - if (Objects.nonNull(calledServiceName)) { - MethodCall methodCall = new MethodCall(methodName, packageAndClassName, calledServiceType, calledServiceName, - methodDeclaration.getNameAsString(), parameterContents, microserviceName, className); - - methodCall = convertValidRestCalls(mce, methodCall); - - methodCalls.add(methodCall); - } - } - } - - return methodCalls; - } - - /** - * This method converts a valid MethodCall to an RestCall - * - * @param methodCallExpr the MethodDeclaration associated with Method - * @param methodCall the MethodCall to be converted - * @return returns methodCall if it is invalid, otherwise a new RestCall - */ - public static MethodCall convertValidRestCalls(MethodCallExpr methodCallExpr, MethodCall methodCall) { - if ((!RestCallTemplate.REST_OBJECTS.contains(methodCall.getObjectType()) || !RestCallTemplate.REST_METHODS.contains(methodCallExpr.getNameAsString()))) { - return methodCall; - } - - RestCallTemplate restCallTemplate = new RestCallTemplate(methodCallExpr,methodCall, cu); - - if (restCallTemplate.getUrl().isEmpty()) { - return methodCall; - } - - return new RestCall(methodCall, restCallTemplate.getUrl(), restCallTemplate.getHttpMethod()); - } - - /** - * This method converts a list of FieldDeclarations to a set of Field models - * - * @param fieldDeclarations the field declarations to parse - * @return the set of Field models - */ - private static Set parseFields(List fieldDeclarations) { - Set javaFields = new HashSet<>(); - - // loop through class declarations - for (FieldDeclaration fd : fieldDeclarations) { - for (VariableDeclarator variable : fd.getVariables()) { - javaFields.add(new Field(variable.getNameAsString(), packageAndClassName, variable.getTypeAsString())); - } - - } - - return javaFields; - } - - - /** - * Get the name of the object a method is being called from (callingObj.methodName()) - * - * @return the name of the object the method is being called from - */ - private static String getCallingObjectName(MethodCallExpr mce) { - - - Expression scope = mce.getScope().orElse(null); - - if (Objects.nonNull(scope) && scope instanceof NameExpr) { - NameExpr fae = scope.asNameExpr(); - return fae.getNameAsString(); - } - - return ""; - - } - - private static String getCallingObjectType(MethodCallExpr mce) { - - Expression scope = mce.getScope().orElse(null); - - if (Objects.isNull(scope)) { - return ""; - } - - try { - // Resolve the type of the object - var resolvedType = JavaParserFacade.get(combinedTypeSolver).getType(scope); - List parts = List.of(((ReferenceTypeImpl) resolvedType).getQualifiedName().split("\\.")); - if(parts.isEmpty()) { - return ""; - } - - return parts.get(parts.size() - 1); - } catch (Exception e) { - if(e instanceof UnsolvedSymbolException && ((UnsolvedSymbolException) e).getName() != null) { - return ((UnsolvedSymbolException) e).getName(); - } - return ""; - } - } - - - /** - * This method parses a list of annotation expressions and returns a set of Annotation models - * - * @param annotationExprs the annotation expressions to parse - * @return the Set of Annotation models - */ - private static Set parseAnnotations(Iterable annotationExprs) { - Set annotations = new HashSet<>(); - - for (AnnotationExpr ae : annotationExprs) { - annotations.add(new Annotation(ae, packageAndClassName)); - } - - return annotations; - } - - /** - * This method searches a list of Annotation expressions and returns a ClassRole found - * - * @param annotations the list of annotations to search - * @return the ClassRole determined - */ - private static ClassRole parseClassRole(Set annotations) { - for (AnnotationExpr annotation : annotations) { - switch (annotation.getNameAsString()) { - case "RestController": - case "Controller": - return ClassRole.CONTROLLER; - case "Service": - return ClassRole.SERVICE; - case "Repository": - return ClassRole.REPOSITORY; - case "RepositoryRestResource": - return ClassRole.REP_REST_RSC; - case "Entity": - case "Embeddable": - return ClassRole.ENTITY; - case "FeignClient": - return ClassRole.FEIGN_CLIENT; - } - } - return ClassRole.UNKNOWN; - } - - /** - * Get the name of the microservice based on the file - * - * @param sourceFile the file we are getting microservice name for - * @return - */ - private static String getMicroserviceName(File sourceFile) { - List split = Arrays.asList(sourceFile.getPath().split(FileUtils.SPECIAL_SEPARATOR)); - return split.get(3); - } - - /** - * FeignClient represents an interface for making rest calls to a service - * other than the current one. As such this method converts feignClient - * interfaces into a service class whose methods simply contain the exact - * rest call outlined by the interface annotations. - * - * @param classAnnotations - * @return - */ - private static JClass handleFeignClient(AnnotationExpr requestMapping, Set classAnnotations) { - - // Parse the methods - Set methods = parseMethods(cu.findAll(MethodDeclaration.class), requestMapping); - - // New methods for conversion - Set newMethods = new HashSet<>(); - // New rest calls for conversion - List newRestCalls = new ArrayList<>(); - - // For each method that is detected as an endpoint convert into a Method + RestCall - for(Method method : methods) { - if(method instanceof Endpoint) { - Endpoint endpoint = (Endpoint) method; - newMethods.add(new Method(method.getName(), packageAndClassName, method.getParameters(), method.getReturnType(), method.getAnnotations(), method.getMicroserviceName(), method.getClassName())); - - StringBuilder queryParams = new StringBuilder(); - for(edu.university.ecs.lab.common.models.ir.Parameter parameter : method.getParameters()) { - for(Annotation annotation : parameter.getAnnotations()) { - if(annotation.getName().equals("RequestParam")) { - queryParams.append("&"); - if(annotation.getAttributes().containsKey("default")) { - queryParams.append(annotation.getAttributes().get("default")); - } else if(annotation.getAttributes().containsKey("name")) { - queryParams.append(annotation.getAttributes().get("name")); - } else { - queryParams.append(parameter.getName()); - } - - queryParams.append("={?}"); - } - } - } - - if(!queryParams.isEmpty()) { - queryParams.replace(0, 1, "?"); - } - - newRestCalls.add(new RestCall(new MethodCall("exchange", packageAndClassName, "RestCallTemplate", "restCallTemplate", method.getName(), "", endpoint.getMicroserviceName(), endpoint.getClassName()), endpoint.getUrl() + queryParams, endpoint.getHttpMethod())); - } else { - newMethods.add(method); - } - } - - - // Build the JClass - return new JClass( - className, - path, - packageName, - ClassRole.FEIGN_CLIENT, - newMethods, - parseFields(cu.findAll(FieldDeclaration.class)), - parseAnnotations(classAnnotations), - newRestCalls, - cu.findAll(ClassOrInterfaceDeclaration.class).get(0).getImplementedTypes().stream().map(NodeWithSimpleName::getNameAsString).collect(Collectors.toSet())); - } - - public static ConfigFile parseConfigurationFile(File file, Config config) { - if(file.getName().endsWith(".yml")) { - return NonJsonReadWriteUtils.readFromYaml(file.getPath(), config); - } else if(file.getName().equals("DockerFile")) { - return NonJsonReadWriteUtils.readFromDocker(file.getPath(), config); - } else if(file.getName().equals("pom.xml")) { - return NonJsonReadWriteUtils.readFromPom(file.getPath(), config); - } else if (file.getName().equals("build.gradle")){ - return NonJsonReadWriteUtils.readFromGradle(file.getPath(), config); - } else { - return null; - } - } - - private static Set filterClassAnnotations() { - Set classAnnotations = new HashSet<>(); - for (AnnotationExpr ae : cu.findAll(AnnotationExpr.class)) { - if (ae.getParentNode().isPresent()) { - Node n = ae.getParentNode().get(); - if (n instanceof ClassOrInterfaceDeclaration) { - classAnnotations.add(ae); - } - } - } - return classAnnotations; - } - - /** - * FeignClient represents an interface for making rest calls to a service - * other than the current one. As such this method converts feignClient - * interfaces into a service class whose methods simply contain the exact - * rest call outlined by the interface annotations. - * - * @param classAnnotations - * @return - */ - private static JClass handleRepositoryRestResource(AnnotationExpr requestMapping, Set classAnnotations) { - - // Parse the methods - Set methods = parseMethods(cu.findAll(MethodDeclaration.class), requestMapping); - - // New methods for conversion - Set newEndpoints = new HashSet<>(); - // New rest calls for conversion - List newRestCalls = new ArrayList<>(); - - // Arbitrary preURL naming scheme if not defined in the annotation - String preURL = "/" + className.toLowerCase().replace("repository", "") + "s"; - - for(AnnotationExpr annotation : classAnnotations) { - if(annotation.getNameAsString().equals("RepositoryRestResource")) { - if (requestMapping instanceof NormalAnnotationExpr) { - NormalAnnotationExpr nae = (NormalAnnotationExpr) requestMapping; - for (MemberValuePair pair : nae.getPairs()) { - if (pair.getNameAsString().equals("path")) { - preURL += pair.getValue().toString(); - break; - } - } - } else if (requestMapping instanceof SingleMemberAnnotationExpr) { - preURL += annotation.asSingleMemberAnnotationExpr().getMemberValue().toString(); - break; - } - } - } - - // For each method that is detected as an endpoint convert into a Method + RestCall - for(Method method : methods) { - - String url = "/search"; - boolean restResourceFound = false; - boolean isExported = true; - for(Annotation ae : method.getAnnotations()) { - if (requestMapping instanceof NormalAnnotationExpr) { - NormalAnnotationExpr nae = (NormalAnnotationExpr) requestMapping; - for (MemberValuePair pair : nae.getPairs()) { - if (pair.getNameAsString().equals("path")) { - preURL = pair.getValue().toString(); - restResourceFound = true; - } else if(pair.getNameAsString().equals("exported")) { - if(pair.getValue().toString().equals("false")) { - isExported = false; - } - } - } - } - } - - // This method not exported (exposed) as an Endpoint - if(!isExported) { - continue; - } - - // If no restResource annotation found we use default /search url start - if(!restResourceFound) { - url += ("/" + method.getName()); - } - - Endpoint endpoint = new Endpoint(method, preURL + url, HttpMethod.GET); - newEndpoints.add(endpoint); - } - - - // Build the JClass - return new JClass( - className, - path, - packageName, - ClassRole.REP_REST_RSC, - newEndpoints, - parseFields(cu.findAll(FieldDeclaration.class)), - parseAnnotations(classAnnotations), - newRestCalls, - cu.findAll(ClassOrInterfaceDeclaration.class).get(0).getImplementedTypes().stream().map(NodeWithSimpleName::getNameAsString).collect(Collectors.toSet())); - } - - private static JClass handleJS(String filePath) { - JClass jClass = new JClass(filePath, filePath, "", ClassRole.FEIGN_CLIENT, new HashSet<>(), new HashSet<>(), new HashSet<>(), new ArrayList<>(), new HashSet<>()); - try { - Set restCalls = new HashSet<>(); - // Command to run Node.js script - ProcessBuilder processBuilder = new ProcessBuilder("node", "scripts/parser.js"); - Process process = processBuilder.start(); - - // Capture the output - BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); - String line; - while ((line = reader.readLine()) != null) { - String[] split = line.split(";"); - restCalls.add(new RestCall(split[0], split[1], split[2], split[3], split[4], split[5], split[6], split[7])); - System.out.println("Node.js Output: " + line); - } - - // Wait for the Node.js process to complete - int exitCode = process.waitFor(); - System.out.println("Node.js process exited with code: " + exitCode); - } catch (Exception e) { - System.err.println(e); - System.exit(1); - } - - return jClass; - } -} diff --git a/src/main/java/edu/university/ecs/lab/common/utils/package-info.java b/src/main/java/edu/university/ecs/lab/common/utils/package-info.java deleted file mode 100644 index 1eb108d5..00000000 --- a/src/main/java/edu/university/ecs/lab/common/utils/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Contains utility classes for file management, JSON handling, and source code parsing. - *

- * This package includes various components necessary for managing file paths, reading/writing JSON files, - * and parsing Java source files to extract meaningful data models in the context of a microservice architecture. - *

- * The main classes include: - * - {@link edu.university.ecs.lab.common.utils.FileUtils} - Manages file paths and conversions. - * - {@link edu.university.ecs.lab.common.utils.JsonReadWriteUtils} - Handles JSON serialization and deserialization. - * - {@link edu.university.ecs.lab.common.utils.SourceToObjectUtils} - Parses Java source files into data models. - */ -package edu.university.ecs.lab.common.utils; diff --git a/src/main/java/edu/university/ecs/lab/delta/DeltaExtractionRunner.java b/src/main/java/edu/university/ecs/lab/delta/DeltaExtractionRunner.java deleted file mode 100644 index dd0cd355..00000000 --- a/src/main/java/edu/university/ecs/lab/delta/DeltaExtractionRunner.java +++ /dev/null @@ -1,33 +0,0 @@ -package edu.university.ecs.lab.delta; - -import edu.university.ecs.lab.common.error.Error; -import edu.university.ecs.lab.common.services.LoggerManager; -import edu.university.ecs.lab.delta.services.DeltaExtractionService; -import org.apache.logging.log4j.Level; - -import java.util.Arrays; -import java.util.Optional; - -/** - * This class acts as a runner implementation for extracting a Delta file - */ -public class DeltaExtractionRunner { - /** - * This method compares two commits on the specified branch in the config - * - * @param args {@literal [/path/to/config] } - */ - public static void main(String[] args) throws Exception { - args = new String[]{"./config.json", "06f3e1efe2e2539d05d91b0699cc8d9fe7be29d7", "82949fa07dcf82f66641f5807d629d15bab663a6"}; - String[] finalArgs = args; - LoggerManager.info(() -> "DeltaExtractionRunner starting... args: " + Arrays.toString(finalArgs)); - if (args.length != 3) { - Error.reportAndExit(Error.INVALID_ARGS, Optional.empty()); - } - - DeltaExtractionService deltaService = new DeltaExtractionService(args[0], "./output/OldIR.json", args[1], args[2]); - - deltaService.generateDelta(); - - } -} diff --git a/src/main/java/edu/university/ecs/lab/delta/models/Delta.java b/src/main/java/edu/university/ecs/lab/delta/models/Delta.java deleted file mode 100644 index 9cde49ea..00000000 --- a/src/main/java/edu/university/ecs/lab/delta/models/Delta.java +++ /dev/null @@ -1,112 +0,0 @@ -package edu.university.ecs.lab.delta.models; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.google.gson.JsonSyntaxException; -import edu.university.ecs.lab.common.models.ir.ConfigFile; -import edu.university.ecs.lab.common.models.ir.JClass; -import edu.university.ecs.lab.common.models.ir.ProjectFile; -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; -import edu.university.ecs.lab.common.services.LoggerManager; -import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -import edu.university.ecs.lab.delta.models.enums.ChangeType; -import lombok.AllArgsConstructor; -import lombok.Data; - -/** - * This class represents a single Delta change between two commits. - * In the case of ChangeType.DELETE @see {@link ChangeType} the - * classChange will respectively be null as the instance of this class - * is no longer locally present for parsing at the new commit - */ -@Data -@AllArgsConstructor -public class Delta implements JsonSerializable { - - private static final Gson gson = JsonReadWriteUtils.registerDeserializers(); - /** - * The new path to the file changed/added - * Note: The path may be null in the event of an add - */ - private String oldPath; - - /** - * The old path to the file changed/added - * Note: The path may be null in the event of an delete - */ - private String newPath; - - /** - * The type of change that occurred - */ - private ChangeType changeType; - - /** - * The changed contents, could be a changed class or - * a changed configuration file - */ - private JsonObject data; - - /** - * This method returns an instance of JClass if parsable. - * - * @return JClass instance if parsable otherwise null - */ - public JClass getClassChange() { - if(data.size() == 0) { - return null; - } - try { - if(data.get("fileType").getAsString().equals("JCLASS")) { - return gson.fromJson(data, JClass.class); - } else { - return null; - } - } catch (JsonSyntaxException e) { - if(data.get("fileType").getAsString().equals("JCLASS")) { - LoggerManager.debug(e::getMessage); - } - return null; - } - - } - - /** - * This method returns an instance of ConfigFile if parsable. - * - * @return ConfigFile instance if parsable otherwise null - */ - public ConfigFile getConfigChange() { - if(data.size() == 0) { - return null; - } - try { - if(data.get("fileType").getAsString().equals("CONFIG")) { - return gson.fromJson(data, ConfigFile.class); - } else { - return null; - } - } catch (JsonSyntaxException e) { - if(data.get("fileType").getAsString().equals("CONFIG")) { - LoggerManager.debug(e::getMessage); - } - - return null; - } - } - - /** - * see {@link JsonSerializable#toJsonObject()} - */ - public JsonObject toJsonObject() { - JsonObject jsonObject = new JsonObject(); - - jsonObject.addProperty("changeType", changeType.name()); - jsonObject.addProperty("oldPath", oldPath); - jsonObject.addProperty("newPath", newPath); - jsonObject.add("data", data); - - return jsonObject; - } - -} diff --git a/src/main/java/edu/university/ecs/lab/delta/models/SystemChange.java b/src/main/java/edu/university/ecs/lab/delta/models/SystemChange.java deleted file mode 100644 index c60f8814..00000000 --- a/src/main/java/edu/university/ecs/lab/delta/models/SystemChange.java +++ /dev/null @@ -1,49 +0,0 @@ -package edu.university.ecs.lab.delta.models; - -import com.google.gson.JsonObject; -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.ArrayList; -import java.util.List; - -/** - * This class represents the overall change in the IR from oldCommit - * to newCommit as a list of Deltas see {@link Delta} - */ -@Data -@AllArgsConstructor -@NoArgsConstructor -public class SystemChange implements JsonSerializable { - - /** - * The old commitID - */ - private String oldCommit; - - /** - * The new commitID - */ - private String newCommit; - - /** - * List of delta changes - */ - private List changes = new ArrayList<>(); - - - /** - * see {@link JsonSerializable#toJsonObject()} - */ - public JsonObject toJsonObject() { - JsonObject jsonObject = new JsonObject(); - - jsonObject.add("changes", JsonSerializable.toJsonArray(changes)); - jsonObject.addProperty("oldCommit", oldCommit); - jsonObject.addProperty("newCommit", newCommit); - - return jsonObject; - } -} diff --git a/src/main/java/edu/university/ecs/lab/delta/models/enums/ChangeType.java b/src/main/java/edu/university/ecs/lab/delta/models/enums/ChangeType.java deleted file mode 100644 index 8779d0c7..00000000 --- a/src/main/java/edu/university/ecs/lab/delta/models/enums/ChangeType.java +++ /dev/null @@ -1,25 +0,0 @@ -package edu.university.ecs.lab.delta.models.enums; - -import org.eclipse.jgit.diff.DiffEntry; - -/** - * Enumerated type for defining the types of changes used by jgit - */ -public enum ChangeType { - ADD, - MODIFY, - DELETE; - - public static ChangeType fromDiffEntry(DiffEntry entry) { - switch (entry.getChangeType()) { - case ADD: - return ADD; - case MODIFY: - return MODIFY; - case DELETE: - return DELETE; - default: - throw new IllegalArgumentException("Unknown change type: " + entry.getChangeType()); - } - } -} diff --git a/src/main/java/edu/university/ecs/lab/delta/models/package-info.java b/src/main/java/edu/university/ecs/lab/delta/models/package-info.java deleted file mode 100644 index 73c71182..00000000 --- a/src/main/java/edu/university/ecs/lab/delta/models/package-info.java +++ /dev/null @@ -1,11 +0,0 @@ -/** - * This package and subpackage {@link edu.university.ecs.lab.delta.models.enums}contains models used for representing changes between two commits in a microservice system. - *

- * It includes: - * - {@link edu.university.ecs.lab.delta.models.Delta}: Represents a single change between two commits. - * - {@link edu.university.ecs.lab.delta.models.SystemChange}: Represents the overall change in the Intermediate Representation (IR) - * from an old commit to a new commit. - * - {@link edu.university.ecs.lab.delta.models.enums.ChangeType}: Enumerates types of changes (ADD, MODIFY, DELETE). - *

- */ -package edu.university.ecs.lab.delta.models; diff --git a/src/main/java/edu/university/ecs/lab/delta/package-info.java b/src/main/java/edu/university/ecs/lab/delta/package-info.java deleted file mode 100644 index 6643f8d2..00000000 --- a/src/main/java/edu/university/ecs/lab/delta/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * This package contains classes and sub-packages related to the extraction of delta changes - * between commits in a microservice system repository. - * - *

The main components include:

- * - The {@link edu.university.ecs.lab.delta.models} package, which holds the data models representing individual - * and overall changes between commits. - * - The {@link edu.university.ecs.lab.delta.models.enums} package, which defines enumerations used within the - * data models, such as {@link edu.university.ecs.lab.delta.models.enums.ChangeType}. - * - The {@link edu.university.ecs.lab.delta.services} package, which provides services for extracting and - * processing differences between commits, such as the {@link edu.university.ecs.lab.delta.services.DeltaExtractionService}. - * - *

The package also includes a runner class, {@link edu.university.ecs.lab.delta.DeltaExtractionRunner}, for executing - * a test delta process.

- */ -package edu.university.ecs.lab.delta; diff --git a/src/main/java/edu/university/ecs/lab/delta/services/DeltaExtractionService.java b/src/main/java/edu/university/ecs/lab/delta/services/DeltaExtractionService.java deleted file mode 100644 index 1fcb1548..00000000 --- a/src/main/java/edu/university/ecs/lab/delta/services/DeltaExtractionService.java +++ /dev/null @@ -1,212 +0,0 @@ -package edu.university.ecs.lab.delta.services; - -import com.google.gson.JsonObject; -import edu.university.ecs.lab.common.config.Config; -import edu.university.ecs.lab.common.config.ConfigUtil; -import edu.university.ecs.lab.common.models.ir.ConfigFile; -import edu.university.ecs.lab.common.models.ir.JClass; -import edu.university.ecs.lab.common.services.GitService; -import edu.university.ecs.lab.common.services.LoggerManager; -import edu.university.ecs.lab.common.utils.FileUtils; -import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -import edu.university.ecs.lab.common.utils.SourceToObjectUtils; -import edu.university.ecs.lab.delta.models.Delta; -import edu.university.ecs.lab.delta.models.SystemChange; -import edu.university.ecs.lab.delta.models.enums.ChangeType; -import org.eclipse.jgit.diff.DiffEntry; - -import java.io.File; -import java.util.List; - -/** - * Service for extracting the differences between two commits of a repository. - * This class does cleaning of output so not all changes will be reflected in - * the Delta output file. - */ -public class DeltaExtractionService { - private static final String DEV_NULL = "/dev/null"; - /** - * Config object representing the contents of the config file - */ - private final Config config; - - /** - * GitService instance for interacting with the local repository - */ - private final GitService gitService; - - /** - * The old commit for comparison - */ - private final String commitOld; - - /** - * The new commit for comparison - */ - private final String commitNew; - - /** - * System change object that will be returned - */ - private SystemChange systemChange; - - /** - * The type of change that is made - */ - private ChangeType changeType; - - /** - * The path to the output file - */ - private String outputPath; - - - /** - * Constructor for the DeltaExtractionService - * - * @param configPath path to the config file - * @param outputPath output path for file - * @param commitOld old commit for comparison - * @param commitNew new commit for comparison - */ - public DeltaExtractionService(String configPath, String outputPath, String commitOld, String commitNew) { - this.config = ConfigUtil.readConfig(configPath); - this.gitService = new GitService(configPath); - this.commitOld = commitOld; - this.commitNew = commitNew; - this.outputPath = outputPath.isEmpty() ? "./Delta.json" : outputPath; - } - - /** - * Generates Delta file representing changes between commitOld and commitNew - */ - public void generateDelta() { - List differences = null; - - // Ensure we start at commitOld - gitService.resetLocal(commitOld); - - // Get the differences between commits - differences = gitService.getDifferences(commitOld, commitNew); - - // Advance the local commit for parsing - gitService.resetLocal(commitNew); - - // process/write differences to delta output - processDelta(differences); - - } - - /** - * Process differences between commits - * - * @param diffEntries list of differences - */ - public void processDelta(List diffEntries) { - // Set up a new SystemChangeObject - systemChange = new SystemChange(); - systemChange.setOldCommit(commitOld); - systemChange.setNewCommit(commitNew); - JsonObject data = null; - - - // process each difference - for (DiffEntry entry : diffEntries) { - // Git path - String path = entry.getChangeType().equals(DiffEntry.ChangeType.ADD) ? entry.getNewPath() : entry.getOldPath(); - - // Special case for root pom - if(path.equals("pom.xml")) { - continue; - } - - // Guard condition, skip invalid files - if(!FileUtils.isValidFile(path)) { - continue; - } - - // Setup oldPath, newPath for Delta - String oldPath = ""; - String newPath = ""; - - if (DiffEntry.ChangeType.DELETE.equals(entry.getChangeType())) { - oldPath = FileUtils.GIT_SEPARATOR + entry.getOldPath(); - newPath = DEV_NULL; - - } else if (DiffEntry.ChangeType.ADD.equals(entry.getChangeType())) { - oldPath = DEV_NULL; - newPath = FileUtils.GIT_SEPARATOR + entry.getNewPath(); - - } else { - oldPath = FileUtils.GIT_SEPARATOR + entry.getOldPath(); - newPath = FileUtils.GIT_SEPARATOR + entry.getNewPath(); - - } - - changeType = ChangeType.fromDiffEntry(entry); - - switch(changeType) { - case ADD: - data = add(newPath); - break; - case MODIFY: - data = add(oldPath); - break; - case DELETE: - data = delete(); - } - - systemChange.getChanges().add(new Delta(oldPath, newPath, changeType, data)); - } - - // Output the system changes - JsonReadWriteUtils.writeToJSON(outputPath, systemChange); - - // Report - LoggerManager.info(() -> "Delta changes extracted between " + commitOld + " -> " + commitNew); - - } - - /** - * This method parses a newly added file into a JsonObject containing - * the data of the change (updated file). Returns a blank JsonObject if - * parsing fails (returns null). - * - * @param newPath git path of new file - * @return JsonObject of data of the new file - */ - private JsonObject add(String newPath) { - // Check if it is a configuration file - if(FileUtils.isConfigurationFile(newPath)) { - ConfigFile configFile = SourceToObjectUtils.parseConfigurationFile(new File(FileUtils.gitPathToLocalPath(newPath, config.getRepoName())), config); - if(configFile == null || configFile.getData() == null) { - return new JsonObject(); - } else { - return configFile.toJsonObject(); - } - - // Else it is a Java file - } else { - JClass jClass = SourceToObjectUtils.parseClass(new File(FileUtils.gitPathToLocalPath(newPath, config.getRepoName())), config, ""); - if(jClass == null) { - return new JsonObject(); - } else { - return jClass.toJsonObject(); - } - } - - } - - /** - * This method returns a blank JsonObject() as there is no data to parse - * - * @return JsonObject that is empty - */ - private JsonObject delete() { - return new JsonObject(); - } - - - - -} diff --git a/src/main/java/edu/university/ecs/lab/delta/services/package-info.java b/src/main/java/edu/university/ecs/lab/delta/services/package-info.java deleted file mode 100644 index 16e638fd..00000000 --- a/src/main/java/edu/university/ecs/lab/delta/services/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This package provides services for extracting and processing delta changes between - * commits in a repository. - * - *

The main service in this package handles the extraction of differences between two specified commits. It utilizes various utility classes - * and models from the common library to achieve this.

- */ -package edu.university.ecs.lab.delta.services; diff --git a/src/main/java/edu/university/ecs/lab/detection/ExcelOutputRunner.java b/src/main/java/edu/university/ecs/lab/detection/ExcelOutputRunner.java deleted file mode 100644 index 66a22b7b..00000000 --- a/src/main/java/edu/university/ecs/lab/detection/ExcelOutputRunner.java +++ /dev/null @@ -1,29 +0,0 @@ -package edu.university.ecs.lab.detection; - -import edu.university.ecs.lab.common.error.Error; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Optional; - -/** - * Runner class to execute detection service - */ -public class ExcelOutputRunner { - - public static void main(String[] args) throws IOException { - String configPath = "./config.json"; - try { - File conifgFile = new File(configPath); - if (!conifgFile.exists()) { - throw new FileNotFoundException(); - } - } catch (Exception e) { - Error.reportAndExit(Error.MISSING_CONFIG, Optional.of(e)); - } - DetectionService detectionService = new DetectionService(configPath); - detectionService.runDetection(); - } - -} diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/AbstractAntiPattern.java b/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/AbstractAntiPattern.java deleted file mode 100644 index 424740e3..00000000 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/AbstractAntiPattern.java +++ /dev/null @@ -1,25 +0,0 @@ -package edu.university.ecs.lab.detection.antipatterns.models; - -import com.google.gson.JsonObject; -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; - -/** - * Abstract implementation of an Antipattern should be the parent - * of all system Antipatterns - */ -public abstract class AbstractAntiPattern implements JsonSerializable { - protected abstract String getName(); - protected abstract String getDescription(); - protected abstract JsonObject getMetaData(); - - @Override - public final JsonObject toJsonObject() { - JsonObject jsonObject = new JsonObject(); - - jsonObject.addProperty("name", getName()); - jsonObject.addProperty("description", getDescription()); - jsonObject.add("metaData", getMetaData()); - - return jsonObject; - } -} diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/package-info.java b/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/package-info.java deleted file mode 100644 index e461c419..00000000 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Contains model classes representing various entities related to microservices and anti-pattern detection. - * These models are used to represent different aspects of microservice architecture and anti-patterns. - *

- * Models: - * - {@link edu.university.ecs.lab.detection.antipatterns.models.CyclicDependency}: Represents cyclic dependencies - * detected within a microservice network graph. - * - {@link edu.university.ecs.lab.detection.antipatterns.models.GreedyMicroservice}: Represents microservices identified - * as greedy based on REST call thresholds. - * - {@link edu.university.ecs.lab.detection.antipatterns.models.HubLikeMicroservice}: Represents microservices identified - * as hub-like based on REST call thresholds. - * - {@link edu.university.ecs.lab.detection.antipatterns.models.NoApiGateway}: Represents the absence of an API Gateway, - * indicating potential issues with centralized routing and access control. - * - {@link edu.university.ecs.lab.detection.antipatterns.models.NoHealthcheck}: Represents the absence of health check - * mechanisms, which are crucial for monitoring and maintaining the health of microservices. - * - {@link edu.university.ecs.lab.detection.antipatterns.models.ServiceChain}: Represents a chain of services within a - * microservice network graph, potentially introducing latency and complexity. - * - {@link edu.university.ecs.lab.detection.antipatterns.models.WrongCuts}: Represents clusters of services that are - * incorrectly segmented, leading to inefficiencies and increased coupling within the microservice network. - * - {@link edu.university.ecs.lab.detection.antipatterns.models.WobblyServiceInteraction}: Represents service interactions - * characterized by unstable or inconsistent communication patterns within microservice classes and methods. - *

- * These models are utilized across various services and components within the anti-pattern detection framework to - * analyze and report issues related to microservices architecture. - */ -package edu.university.ecs.lab.detection.antipatterns.models; diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/package-info.java b/src/main/java/edu/university/ecs/lab/detection/antipatterns/package-info.java deleted file mode 100644 index 26f393ec..00000000 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/package-info.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Provides classes and services for detecting various anti-patterns in microservices architecture. - * Includes detection of cyclic dependencies, greedy microservices, hub-like microservices, wrong cuts, - * service chains, wobbly service interactions, and absence of API gateway and health checks. - *

- * Classes: - * - {@link edu.university.ecs.lab.detection.antipatterns.AntipatternDetection}: Main class for running - * anti-pattern detection routines using configuration and services. - *

- *

- * Models Package: - * - {@link edu.university.ecs.lab.detection.antipatterns.models.CyclicDependency}: Represents cyclic dependencies - * detected within a microservice network graph. - * - {@link edu.university.ecs.lab.detection.antipatterns.models.GreedyMicroservice}: Represents microservices identified - * as greedy based on REST call thresholds. - * - {@link edu.university.ecs.lab.detection.antipatterns.models.HubLikeMicroservice}: Represents microservices identified - * as hub-like based on REST call thresholds. - * - {@link edu.university.ecs.lab.detection.antipatterns.models.NoApiGateway}: Represents the absence of an API Gateway, - * indicating potential issues with centralized routing and access control. - * - {@link edu.university.ecs.lab.detection.antipatterns.models.NoHealthcheck}: Represents the absence of health check - * mechanisms, which are crucial for monitoring and maintaining the health of microservices. - * - {@link edu.university.ecs.lab.detection.antipatterns.models.ServiceChain}: Represents a chain of services within a - * microservice network graph, potentially introducing latency and complexity. - * - {@link edu.university.ecs.lab.detection.antipatterns.models.WrongCuts}: Represents clusters of services that are - * incorrectly segmented, leading to inefficiencies and increased coupling within the microservice network. - * - {@link edu.university.ecs.lab.detection.antipatterns.models.WobblyServiceInteraction}: Represents service interactions - * characterized by unstable or inconsistent communication patterns within microservice classes and methods. - *

- *

- * Services Package: - * - {@link edu.university.ecs.lab.detection.antipatterns.services.CyclicDependencyMethodLevelService}: Service for detecting - * cyclic dependencies within a method network graph. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.CyclicDependencyMSLevelService}: Service for detecting - * cyclic dependencies within a microservice network graph. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.GreedyService}: Service for identifying and managing - * microservices identified as greedy based on REST call thresholds. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.HubLikeService}: Service for identifying and managing - * microservices identified as hub-like based on REST call thresholds. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.ServiceChainMethodLevelService}: Service for detecting and managing - * service chains within a method network graph. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.ServiceChainMSLevelService}: Service for detecting and managing - * service chains within a microservice network graph. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.WrongCutsService}: Service for identifying and reporting - * clusters of services that are incorrectly interconnected within a microservice network graph. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.WobblyServiceInteractionService}: Service for detecting - * wobbly service interactions within a microservice system based on specific annotations. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.NoApiGatewayService}: Service for checking the presence of an - * API gateway configuration in a YAML file. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.NoHealthcheckService}: Service for checking the presence of - * health check configurations in a YAML file. - *

- */ -package edu.university.ecs.lab.detection.antipatterns; diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/package-info.java b/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/package-info.java deleted file mode 100644 index e500b791..00000000 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/package-info.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Provides services for detecting and analyzing various anti-patterns in microservices architecture. - * These services encapsulate logic for identifying specific issues within microservice systems and - * generating reports or performing corrective actions. - *

- * Services: - * - {@link edu.university.ecs.lab.detection.antipatterns.services.CyclicDependencyMethodLevelService}: Service for detecting - * cyclic dependencies within a method network graph. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.CyclicDependencyMSLevelService}: Service for detecting - * cyclic dependencies within a microservice network graph. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.GreedyService}: Service for identifying and managing - * microservices identified as greedy based on REST call thresholds. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.HubLikeService}: Service for identifying and managing - * microservices identified as hub-like based on REST call thresholds. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.ServiceChainMethodLevelService}: Service for detecting and managing - * service chains within a method network graph. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.ServiceChainMSLevelService}: Service for detecting and managing - * service chains within a microservice network graph. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.WrongCutsService}: Service for identifying and reporting - * clusters of services that are incorrectly interconnected within a microservice network graph. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.WobblyServiceInteractionService}: Service for detecting - * wobbly service interactions within a microservice system based on specific annotations. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.NoApiGatewayService}: Service for checking the presence of an - * API gateway configuration in a YAML file. - * - {@link edu.university.ecs.lab.detection.antipatterns.services.NoHealthcheckService}: Service for checking the presence of - * health check configurations in a YAML file. - *

- */ -package edu.university.ecs.lab.detection.antipatterns.services; diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR1.java b/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR1.java deleted file mode 100644 index 46f82081..00000000 --- a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR1.java +++ /dev/null @@ -1,151 +0,0 @@ -package edu.university.ecs.lab.detection.architecture.models; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -import com.google.gson.JsonObject; - -import edu.university.ecs.lab.common.models.enums.ClassRole; -import edu.university.ecs.lab.common.models.ir.*; -import edu.university.ecs.lab.common.utils.FlowUtils; -import edu.university.ecs.lab.delta.models.Delta; -import edu.university.ecs.lab.delta.models.enums.ChangeType; -import lombok.Data; - -/** - * Architectural Rule 1 Class: Floating call due to endpoint removal (internal) - */ -@Data -public class AR1 extends AbstractAR { - - /** - * Architectural rule 1 details - */ - protected static final String TYPE = "Architectural Rule 1"; - protected static final String NAME = "Floating call due to endpoint removal (internal)"; - protected static final String DESC = "An endpoint was removed, inter service calls depending on this method are no longer called"; - - private String oldCommitID; - private String newCommitID; - protected JsonObject metaData; - - @Override - public String getName() { - return NAME; - } - - @Override - public String getDescription() { - return DESC; - } - - @Override - public double getWeight() { - return 0; - } - - @Override - public JsonObject getMetaData() { - return metaData; - } - - @Override - public String getType() { - return TYPE; - } - - /** - * Scan and compare old microservice system and new microservice system to identify endpoint removals - * - * @param delta change between old commit and new microservice systems - * @param oldSystem old commit of microservice system - * @param newSystem new commit of microservice system - * @return list of restCalls called in severed flow (if method was deleted) - */ - public static List scan(Delta delta, MicroserviceSystem oldSystem, MicroserviceSystem newSystem){ - List useCases = new ArrayList<>(); - - // Old class for delete, delta class for modify - JClass jClass = delta.getChangeType().equals(ChangeType.MODIFY) ? delta.getClassChange() : oldSystem.findClass(delta.getOldPath()); - - if(delta.getChangeType().equals(ChangeType.ADD) || !jClass.getClassRole().equals(ClassRole.CONTROLLER)) { - return useCases; - } - - List flows = FlowUtils.buildFlows(oldSystem); - Endpoint endpointMatch = null; - for(Flow flow : flows){ - if(flow.getController() != null && flow.getController().getPath().equals(delta.getOldPath())){ - for(Endpoint endpoint : jClass.getEndpoints()) { - if(endpoint.getName().equals(flow.getControllerMethod().getName())){ - endpointMatch = endpoint; - } - } - // If we find no match or its a delete, we have removed this method - if((Objects.nonNull(endpointMatch) || delta.getChangeType().equals(ChangeType.DELETE)) && flow.getService() != null){ - for(RestCall restCall : flow.getService().getRestCalls()) { - // If this restCall is called in the severed flow - if(flow.getServiceMethod() != null && restCall.getCalledFrom().equals(flow.getServiceMethod().getName())){ - AR1 useCase1 = new AR1(); - JsonObject jsonObject = new JsonObject(); -// jsonObject.add("RestCall", restCall.toJsonObject()); -// jsonObject.add("Endpoint", endpointMatch == null ? new JsonObject() : endpointMatch.toJsonObject()); - useCase1.setMetaData(jsonObject); - useCase1.setOldCommitID(oldSystem.getCommitID()); - useCase1.setNewCommitID(newSystem.getCommitID()); - useCases.add(useCase1); - } - } - } - - endpointMatch = null; - } - - - } - - // Return list of restCalls called in severed flow (if method was deleted) - return useCases; - } - - /** - * Scan and compare old microservice system and new microservice system to identify endpoint removals - * - * @param delta change between old commit and new microservice systems - * @param oldSystem old commit of microservice system - * @param newSystem new commit of microservice system - * @return list of restCalls not in any flows - */ - public static List scan2(Delta delta, MicroserviceSystem oldSystem, MicroserviceSystem newSystem){ - List useCases = new ArrayList<>(); - - List flows = FlowUtils.buildFlows(oldSystem); - List allRestCalls = newSystem.getMicroservices().stream().flatMap(microservice -> microservice.getServices().stream()).flatMap(jClass -> jClass.getRestCalls().stream()).collect(Collectors.toList()); - - for(RestCall restCall : allRestCalls) { - outer: - { - for (Flow flow : flows) { - if (Objects.nonNull(flow.getRepositoryMethodCall()) && flow.getRepositoryMethodCall().equals(restCall)) { - break outer; - } - } - - // If the restCall is not in any flows (flows start at controller) - AR1 archRule1 = new AR1(); - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("RestCall", restCall.getID()); - archRule1.setMetaData(jsonObject); - archRule1.setOldCommitID(oldSystem.getCommitID()); - archRule1.setNewCommitID(newSystem.getCommitID()); - useCases.add(archRule1); - - } - } - - // Return list of restCalls not in any flows - return useCases; - } -} diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AbstractAR.java b/src/main/java/edu/university/ecs/lab/detection/architecture/models/AbstractAR.java deleted file mode 100644 index 740f1920..00000000 --- a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AbstractAR.java +++ /dev/null @@ -1,78 +0,0 @@ -package edu.university.ecs.lab.detection.architecture.models; - -import com.google.gson.JsonObject; - -import edu.university.ecs.lab.common.models.serialization.JsonSerializable; - -/** - * Architectural Rule class template for all architectural rules. - */ -public abstract class AbstractAR implements JsonSerializable { - - /** - * Get the name of the Architectural Rule - * - * @return string name of the Architectural Rule - */ - public abstract String getName(); - - /** - * Get the description of the Architectural Rule - * - * @return string description of the Architectural Rule - */ - public abstract String getDescription(); - - /** - * Get the meta data of the Architectural Rule - * - * @return JSON object meta data of the Architectural Rule - */ - public abstract JsonObject getMetaData(); - - /** - * Get the weight of the Architectural Rule - * - * @return double weight of the Architectural Rule - */ - public abstract double getWeight(); - - /** - * Get the old commitID - * - * @return string old commitID - */ - public abstract String getOldCommitID(); - - /** - * Get the new commitID - * - * @return string new commitID - */ - public abstract String getNewCommitID(); - - /** - * Get the new commitID - * - * @return string new commitID - */ - public abstract String getType(); - - /** - * Create JSON object with Architectural Rule name, type, old commit ID, new commit ID, and meta data - * - * @return JSON object with Architectural Rule details - */ - @Override - public final JsonObject toJsonObject() { - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("name", getName()); - jsonObject.addProperty("type", getType()); - jsonObject.addProperty("oldCommitID", getOldCommitID()); - jsonObject.addProperty("newCommitID", getNewCommitID()); - jsonObject.add("metadata", getMetaData()); - - return jsonObject; - } - -} diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/models/enums/Confidence.java b/src/main/java/edu/university/ecs/lab/detection/architecture/models/enums/Confidence.java deleted file mode 100644 index 47bdf0d6..00000000 --- a/src/main/java/edu/university/ecs/lab/detection/architecture/models/enums/Confidence.java +++ /dev/null @@ -1,7 +0,0 @@ -package edu.university.ecs.lab.detection.architecture.models.enums; - -public enum Confidence { - CONFIDENT, - INFERENCE, - UNKNOWN -} diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/models/package-info.java b/src/main/java/edu/university/ecs/lab/detection/architecture/models/package-info.java deleted file mode 100644 index ef64bcef..00000000 --- a/src/main/java/edu/university/ecs/lab/detection/architecture/models/package-info.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Provides classes and enums for representing architectural rules within the microservice system. - * This package is part of the {@link edu.university.ecs.lab.detection.architecture} package, which focuses on detecting architectural rules and related information in a microservice system. - * - *

This package includes: - * - {@link edu.university.ecs.lab.detection.architecture.models.enums}: Contains enumerations used within the architectural models, such as confidence levels. - * - {@link edu.university.ecs.lab.detection.architecture.models.AbstractAR}: Provides a template for all architectural rules, including methods to get the name, description, weight, commit IDs, and type of the rule, and to convert the rule to a JSON object. - * - {@link edu.university.ecs.lab.detection.architecture.models.AR1}: Represents the rule for detecting floating calls due to endpoint removal within the microservice system, including methods for scanning and detecting such instances. - * - {@link edu.university.ecs.lab.detection.architecture.models.AR3}: Represents the rule for detecting floating calls due to invalid call creation within the microservice system, including methods for scanning and detecting such instances. - * - {@link edu.university.ecs.lab.detection.architecture.models.AR4}: Represents the rule for detecting floating endpoints due to last call removal within the microservice system, including methods for scanning and detecting such instances. - * - {@link edu.university.ecs.lab.detection.architecture.models.AR6}: Represents the rule for detecting affected endpoints due to business logic updates within the microservice system, including methods for scanning and detecting such instances. - * - {@link edu.university.ecs.lab.detection.architecture.models.AR7}: Represents the rule for detecting affected endpoints due to data access logic updates within the microservice system, including methods for scanning and detecting such instances. - * - {@link edu.university.ecs.lab.detection.architecture.models.AR20}: Represents the rule for identifying hub-like services within the microservice architecture, including methods for scanning and detecting such instances. - * - {@link edu.university.ecs.lab.detection.architecture.models.AR21}: Represents the rule for detecting clusters of wrongly interconnected services (wrongcuts) within the microservice system, including methods for scanning and detecting such instances. - * - {@link edu.university.ecs.lab.detection.architecture.models.AR22}: Represents the rule for detecting inconsistent modifications of entities across services within the microservice system, including methods for scanning and detecting such instances. - * - {@link edu.university.ecs.lab.detection.architecture.models.AR23}: Represents the rule for detecting the absence of API gateway configuration in the microservice system, including methods for scanning and detecting such instances. - * - {@link edu.university.ecs.lab.detection.architecture.models.AR24}: Represents the rule for detecting the absence of health check configurations in the microservice system, including methods for scanning and detecting such instances. - *

- */ -package edu.university.ecs.lab.detection.architecture.models; diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/package-info.java b/src/main/java/edu/university/ecs/lab/detection/architecture/package-info.java deleted file mode 100644 index 73a55049..00000000 --- a/src/main/java/edu/university/ecs/lab/detection/architecture/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Provides classes and related services for detecting architectural rules and related information in a microservice system. - * - *

This package includes: - * - {@link edu.university.ecs.lab.detection.architecture.models}: Contains classes that represent each individual architectural rule and the logic for detection in the microservice system. - * - {@link edu.university.ecs.lab.detection.architecture.services}: Provides tools scanning the entire microservice system at each Delta and checking for all the architectural rules. - *

- */ - -package edu.university.ecs.lab.detection.architecture; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/models/package-info.java b/src/main/java/edu/university/ecs/lab/detection/metrics/models/package-info.java deleted file mode 100644 index 58a35d66..00000000 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/models/package-info.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * This package contains classes that represent models used for calculating various metrics related to microservices - * and service dependency graphs. - *

- * This package includes: - * - {@link edu.university.ecs.lab.detection.metrics.models.ConnectedComponentsModularity}: - * Contains the implementation of the modularity metric of partitioning a graph into strongly connected components. - * - {@link edu.university.ecs.lab.detection.metrics.models.DegreeCoupling}: - * Contains the calculation of degree-related Coupling metrics. - * - {@link edu.university.ecs.lab.detection.metrics.models.IInputFile}: - * Represents an input file of different formats and creates a Service Descriptor object. - * - {@link edu.university.ecs.lab.detection.metrics.models.IServiceDescriptor}: - * Represents a service descriptor interface defining methods for service name, version, operations, and their types. - * - {@link edu.university.ecs.lab.detection.metrics.models.IServiceDescriptorBuilder}: Provides a method to build a service descriptor from a file path. - * - {@link edu.university.ecs.lab.detection.metrics.models.Operation}: - * Represents an operation of a microservice with parameters, using types, response type, and path. - * - {@link edu.university.ecs.lab.detection.metrics.models.Parameter}: - * Represents a parameter of a method or operation. - * - {@link edu.university.ecs.lab.detection.metrics.models.ServiceDescriptor}: - * - {@link edu.university.ecs.lab.detection.metrics.models.Statements}: Enumerates various statements or types used within the metrics calculation context. - * Represents a service descriptor with service name, operations, and version. - * - {@link edu.university.ecs.lab.detection.metrics.models.StructuralCoupling}: Contains the implementation of the Structural Coupling Metric. - *

- */ -package edu.university.ecs.lab.detection.metrics.models; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/package-info.java b/src/main/java/edu/university/ecs/lab/detection/metrics/package-info.java deleted file mode 100644 index 0bb30352..00000000 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/package-info.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * This package contains classes and utilities for calculating various metrics related to microservices - * and service dependency graphs. - *

- * This package include: - * - {@link edu.university.ecs.lab.detection.metrics.MetricCalculation}: Calculates structural and degree coupling metrics, - * and modularity metrics for a microservice system based on service dependency graph (SDG). - * - {@link edu.university.ecs.lab.detection.metrics.RunCohesionMetrics}: Calculates cohesion metrics for a microservice system - * based on its intermediate representation (IR). - * - {@link edu.university.ecs.lab.detection.metrics.models}: Contains models used in metric calculations. - * - {@link edu.university.ecs.lab.detection.metrics.services}: Contains services for calculating and aggregating metric results. - * - {@link edu.university.ecs.lab.detection.metrics.utils}: Contains utility classes for common operations related to metric calculations. - *

- * The main purpose of this package is to provide tools for assessing the architecture and design quality of microservice systems - * through various quantitative metrics. - */ -package edu.university.ecs.lab.detection.metrics; diff --git a/src/main/java/edu/university/ecs/lab/detection/models/results/DetectionResult.java b/src/main/java/edu/university/ecs/lab/detection/models/results/DetectionResult.java new file mode 100644 index 00000000..47440411 --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/DetectionResult.java @@ -0,0 +1,30 @@ +package edu.university.ecs.lab.detection.models.results; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.databind.ObjectMapper; +import edu.university.ecs.lab.detection.models.results.antipatterns.*; +import edu.university.ecs.lab.detection.models.results.architecture.AbstractAR; +import lombok.Data; + +import java.util.Map; + +@Data +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "type" +) +@JsonSubTypes({@JsonSubTypes.Type(value = AbstractAntiPattern.class, name = "AbstractAntiPattern"), + @JsonSubTypes.Type(value = AbstractAR.class, name = "AbstractAR"),}) +public abstract class DetectionResult { + protected final ObjectMapper objectMapper = new ObjectMapper(); + + protected String description; + protected String location; + protected Map additionalData; + + public String toString() { + return description + " " + location; + } +} diff --git a/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/AbstractAntiPattern.java b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/AbstractAntiPattern.java new file mode 100644 index 00000000..c8a4026c --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/AbstractAntiPattern.java @@ -0,0 +1,33 @@ +package edu.university.ecs.lab.detection.models.results.antipatterns; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import edu.university.ecs.lab.detection.models.results.DetectionResult; + +/** + * Abstract implementation of an Antipattern should be the parent + * of all system Antipatterns + */ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "type" +) +@JsonSubTypes({@JsonSubTypes.Type(value = CyclicDependency.class, name = "CyclicDependency"), + @JsonSubTypes.Type(value = GreedyMicroservice.class, name = "GreedyMicroservice"), + @JsonSubTypes.Type(value = HubLikeMicroservice.class, name = "HubLikeMicroservice"), + @JsonSubTypes.Type(value = NoApiGateway.class, name = "NoApiGateway"), + @JsonSubTypes.Type(value = NoHealthcheck.class, name = "NoHealthcheck"), + @JsonSubTypes.Type(value = ServiceChain.class, name = "ServiceChain"), + @JsonSubTypes.Type(value = WobblyServiceInteraction.class, name = "WobblyServiceInteraction"), + @JsonSubTypes.Type(value = WrongCuts.class, name = "WrongCuts")}) +public abstract class AbstractAntiPattern extends DetectionResult { + + @JsonIgnore + protected abstract String getName(); + @JsonIgnore + protected abstract JsonNode getMetaData(); +} diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/CyclicDependency.java b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/CyclicDependency.java similarity index 63% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/models/CyclicDependency.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/CyclicDependency.java index 6c0c76c5..4993366c 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/CyclicDependency.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/CyclicDependency.java @@ -1,18 +1,23 @@ -package edu.university.ecs.lab.detection.antipatterns.models; +package edu.university.ecs.lab.detection.models.results.antipatterns; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; import lombok.Data; import java.util.List; -import com.google.gson.Gson; -import com.google.gson.JsonObject; +import lombok.EqualsAndHashCode; /** * Represents a list of one cycle of Cyclic Dependency Anti-pattern detected */ +@EqualsAndHashCode(callSuper = true) @Data +@JsonTypeName("CyclicDependency") public class CyclicDependency extends AbstractAntiPattern { /** * Anti-pattern name @@ -39,24 +44,21 @@ public CyclicDependency(List> cycles) { } @Override + @JsonIgnore protected String getName() { return NAME; } @Override - protected String getDescription() { + @JsonIgnore + public String getDescription() { return DESCRIPTION; } @Override - protected JsonObject getMetaData() { - JsonObject jsonObject = new JsonObject(); - - Gson gson = new Gson(); - - jsonObject.add("Cyclic Dependencies Found", gson.toJsonTree(cycles).getAsJsonArray()); - - return jsonObject; + @JsonIgnore + protected JsonNode getMetaData() { + return JsonNodeFactory.instance.objectNode().set("Cyclic Dependencies Found", objectMapper.valueToTree(cycles)); } public int numCyclicDep(){ diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/GreedyMicroservice.java b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/GreedyMicroservice.java similarity index 69% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/models/GreedyMicroservice.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/GreedyMicroservice.java index 106be674..1b1865f2 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/GreedyMicroservice.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/GreedyMicroservice.java @@ -1,8 +1,11 @@ -package edu.university.ecs.lab.detection.antipatterns.models; +package edu.university.ecs.lab.detection.models.results.antipatterns; -import com.google.gson.Gson; -import com.google.gson.JsonObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; import lombok.Data; +import lombok.EqualsAndHashCode; import java.util.List; @@ -10,7 +13,9 @@ /** * Represents a collection of microservices identified as greedy. */ +@EqualsAndHashCode(callSuper = true) @Data +@JsonTypeName("GreedyMicroservice") public class GreedyMicroservice extends AbstractAntiPattern { /** * Anti-pattern name @@ -45,24 +50,21 @@ public boolean isEmpty(){ } @Override + @JsonIgnore protected String getName() { return NAME; } @Override - protected String getDescription() { + @JsonIgnore + public String getDescription() { return DESCRIPTION; } @Override - protected JsonObject getMetaData() { - JsonObject jsonObject = new JsonObject(); - - Gson gson = new Gson(); - - jsonObject.add("Greedy Microservices Found", gson.toJsonTree(greedyMicroservices).getAsJsonArray()); - - return jsonObject; + @JsonIgnore + protected JsonNode getMetaData() { + return JsonNodeFactory.instance.objectNode().set("Greedy Microservices Found", objectMapper.valueToTree(greedyMicroservices)); } public int numGreedyMicro(){ diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/HubLikeMicroservice.java b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/HubLikeMicroservice.java similarity index 68% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/models/HubLikeMicroservice.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/HubLikeMicroservice.java index 92d5b404..79f26195 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/HubLikeMicroservice.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/HubLikeMicroservice.java @@ -1,15 +1,21 @@ -package edu.university.ecs.lab.detection.antipatterns.models; +package edu.university.ecs.lab.detection.models.results.antipatterns; -import com.google.gson.Gson; -import com.google.gson.JsonObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; import lombok.Data; +import lombok.EqualsAndHashCode; import java.util.List; /** * Represents a collection of microservices identified as hub-like. */ + +@EqualsAndHashCode(callSuper = true) @Data +@JsonTypeName("HubLikeMicroservice") public class HubLikeMicroservice extends AbstractAntiPattern { /** * Anti-pattern name @@ -45,24 +51,21 @@ public boolean isEmpty(){ } @Override + @JsonIgnore protected String getName() { return NAME; } @Override - protected String getDescription() { + @JsonIgnore + public String getDescription() { return DESCRIPTION; } @Override - protected JsonObject getMetaData() { - JsonObject jsonObject = new JsonObject(); - - Gson gson = new Gson(); - - jsonObject.add("Hub-like Microservices Found", gson.toJsonTree(hublikeMicroservices).getAsJsonArray()); - - return jsonObject; + @JsonIgnore + protected JsonNode getMetaData() { + return JsonNodeFactory.instance.objectNode().set("Hub-like Microservices Found", objectMapper.valueToTree(hublikeMicroservices)); } public int numHubLike(){ diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/NoApiGateway.java b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/NoApiGateway.java similarity index 70% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/models/NoApiGateway.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/NoApiGateway.java index 6b401240..a7992590 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/NoApiGateway.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/NoApiGateway.java @@ -1,13 +1,19 @@ -package edu.university.ecs.lab.detection.antipatterns.models; +package edu.university.ecs.lab.detection.models.results.antipatterns; -import com.google.gson.JsonObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; import lombok.Data; +import lombok.EqualsAndHashCode; /** * Represents the "No API-Gateway" anti-pattern */ +@EqualsAndHashCode(callSuper = true) @Data +@JsonTypeName("NoApiGateway") public class NoApiGateway extends AbstractAntiPattern { /** * Anti-pattern name @@ -43,22 +49,21 @@ public boolean getnoApiGateway(){ } @Override + @JsonIgnore protected String getName() { return NAME; } @Override - protected String getDescription() { + @JsonIgnore + public String getDescription() { return DESCRIPTION; } @Override - protected JsonObject getMetaData() { - JsonObject jsonObject = new JsonObject(); - - jsonObject.addProperty("No API-Gateway:", noApiGateway); - - return jsonObject; + @JsonIgnore + protected JsonNode getMetaData() { + return JsonNodeFactory.instance.objectNode().set("No API-Gateway:", objectMapper.valueToTree(noApiGateway)); } public int getBoolApiGateway(){ diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/NoHealthcheck.java b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/NoHealthcheck.java similarity index 71% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/models/NoHealthcheck.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/NoHealthcheck.java index 60956a05..ddabe642 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/NoHealthcheck.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/NoHealthcheck.java @@ -1,16 +1,21 @@ -package edu.university.ecs.lab.detection.antipatterns.models; +package edu.university.ecs.lab.detection.models.results.antipatterns; import java.util.Map; -import com.google.gson.Gson; -import com.google.gson.JsonObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; import lombok.Data; +import lombok.EqualsAndHashCode; /** * Represents the "No Health Check" anti-pattern */ +@EqualsAndHashCode(callSuper = true) @Data +@JsonTypeName("NoHealthcheck") public class NoHealthcheck extends AbstractAntiPattern { /** * Anti-pattern name @@ -41,28 +46,27 @@ public NoHealthcheck(Map noHealthcheck){ * * @return boolean flag indicating whether the "No Health Check" anti-pattern is present */ + @JsonIgnore public Map getnoHealthcheck(){ return this.noHealthcheck; } @Override + @JsonIgnore protected String getName() { return NAME; } @Override - protected String getDescription() { + @JsonIgnore + public String getDescription() { return DESCRIPTION; } @Override - protected JsonObject getMetaData() { - JsonObject jsonObject = new JsonObject(); - Gson gson = new Gson(); - - jsonObject.add("Microservices and Healthchecks Found", gson.toJsonTree(noHealthcheck).getAsJsonObject()); - - return jsonObject; + @JsonIgnore + protected JsonNode getMetaData() { + return JsonNodeFactory.instance.objectNode().set("Microservices and Healthchecks Found", objectMapper.valueToTree(noHealthcheck)); } public int numNoHealthChecks(){ diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/ServiceChain.java b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/ServiceChain.java similarity index 66% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/models/ServiceChain.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/ServiceChain.java index 7295b973..32a72121 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/ServiceChain.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/ServiceChain.java @@ -1,16 +1,21 @@ -package edu.university.ecs.lab.detection.antipatterns.models; +package edu.university.ecs.lab.detection.models.results.antipatterns; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; import lombok.Data; import java.util.List; -import com.google.gson.Gson; -import com.google.gson.JsonObject; +import lombok.EqualsAndHashCode; /** * Represents a service chain, which is a sequence of services in a network graph. */ +@EqualsAndHashCode(callSuper = true) @Data +@JsonTypeName("ServiceChain") public class ServiceChain extends AbstractAntiPattern { /** * Anti-pattern name @@ -47,27 +52,28 @@ public boolean isEmpty(){ } @Override + @JsonIgnore protected String getName() { return NAME; } @Override - protected String getDescription() { + @JsonIgnore + public String getDescription() { return DESCRIPTION; } @Override - protected JsonObject getMetaData() { - JsonObject jsonObject = new JsonObject(); - - Gson gson = new Gson(); - - jsonObject.add("Service Chains Found", gson.toJsonTree(chain).getAsJsonArray()); - - return jsonObject; + @JsonIgnore + protected JsonNode getMetaData() { + return JsonNodeFactory.instance.objectNode().set("Service Chains Found", objectMapper.valueToTree(chain)); } public int numServiceChains(){ return chain.size(); } + + public String toString() { + return chain.toString(); + } } \ No newline at end of file diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/WobblyServiceInteraction.java b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/WobblyServiceInteraction.java similarity index 65% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/models/WobblyServiceInteraction.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/WobblyServiceInteraction.java index dbdc7c15..f14fe34d 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/WobblyServiceInteraction.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/WobblyServiceInteraction.java @@ -1,16 +1,21 @@ -package edu.university.ecs.lab.detection.antipatterns.models; +package edu.university.ecs.lab.detection.models.results.antipatterns; import java.util.List; -import com.google.gson.Gson; -import com.google.gson.JsonObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; import lombok.Data; +import lombok.EqualsAndHashCode; /** * Represents a wobbly service interaction. */ +@EqualsAndHashCode(callSuper = true) @Data +@JsonTypeName("WobblyServiceInteraction") public class WobblyServiceInteraction extends AbstractAntiPattern { /** * Anti-pattern name @@ -37,23 +42,21 @@ public WobblyServiceInteraction(List wobblyServiceInteractions) { } @Override + @JsonIgnore protected String getName() { return NAME; } @Override - protected String getDescription() { + @JsonIgnore + public String getDescription() { return DESCRIPTION; } @Override - protected JsonObject getMetaData() { - JsonObject jsonObject = new JsonObject(); - - Gson gson = new Gson(); - - jsonObject.add("Wobbly Service Interactions Found", gson.toJsonTree(wobblyServiceInteractions).getAsJsonArray()); - return jsonObject; + @JsonIgnore + protected JsonNode getMetaData() { + return JsonNodeFactory.instance.objectNode().set("Wobbly Service Interactions Found", objectMapper.valueToTree(wobblyServiceInteractions)); } public int numWobbblyService(){ diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/WrongCuts.java b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/WrongCuts.java similarity index 64% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/models/WrongCuts.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/WrongCuts.java index e82819c0..71aa66f3 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/models/WrongCuts.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/WrongCuts.java @@ -1,16 +1,21 @@ -package edu.university.ecs.lab.detection.antipatterns.models; +package edu.university.ecs.lab.detection.models.results.antipatterns; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; import lombok.Data; import java.util.List; -import com.google.gson.Gson; -import com.google.gson.JsonObject; +import lombok.EqualsAndHashCode; /** * Represents a cluster of wrongly interconnected services (Wrong Cuts) detected in a microservice network graph. */ +@EqualsAndHashCode(callSuper = true) @Data +@JsonTypeName("WrongCuts") public class WrongCuts extends AbstractAntiPattern { /** * Anti-pattern name @@ -37,27 +42,28 @@ public WrongCuts(List wrongCuts) { } @Override + @JsonIgnore protected String getName() { return NAME; } @Override - protected String getDescription() { + @JsonIgnore + public String getDescription() { return DESCRIPTION; } @Override - protected JsonObject getMetaData() { - JsonObject jsonObject = new JsonObject(); - - Gson gson = new Gson(); - - jsonObject.add("Wrong Cuts Found", gson.toJsonTree(wrongCuts).getAsJsonArray()); - - return jsonObject; + @JsonIgnore + protected JsonNode getMetaData() { + return JsonNodeFactory.instance.objectNode().set("Wrong Cuts Found", objectMapper.valueToTree(wrongCuts)); } public int numWrongCuts(){ return wrongCuts.size(); } + + public String toString() { + return getMetaData().toString(); + } } diff --git a/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/package-info.java b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/package-info.java new file mode 100644 index 00000000..e56e5985 --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/antipatterns/package-info.java @@ -0,0 +1,26 @@ +/** + * Contains model classes representing various entities related to microservices and anti-pattern detection. + * These models are used to represent different aspects of microservice architecture and anti-patterns. + *

+ * Models: + * - {@link edu.university.ecs.lab.detection.models.results.antipatterns.CyclicDependency}: Represents cyclic dependencies + * detected within a microservice network graph. + * - {@link edu.university.ecs.lab.detection.models.results.antipatterns.GreedyMicroservice}: Represents microservices identified + * as greedy based on REST call thresholds. + * - {@link edu.university.ecs.lab.detection.models.results.antipatterns.HubLikeMicroservice}: Represents microservices identified + * as hub-like based on REST call thresholds. + * - {@link edu.university.ecs.lab.detection.models.results.antipatterns.NoApiGateway}: Represents the absence of an API Gateway, + * indicating potential issues with centralized routing and access control. + * - {@link edu.university.ecs.lab.detection.models.results.antipatterns.NoHealthcheck}: Represents the absence of health check + * mechanisms, which are crucial for monitoring and maintaining the health of microservices. + * - {@link edu.university.ecs.lab.detection.models.results.antipatterns.ServiceChain}: Represents a chain of services within a + * microservice network graph, potentially introducing latency and complexity. + * - {@link edu.university.ecs.lab.detection.models.results.antipatterns.WrongCuts}: Represents clusters of services that are + * incorrectly segmented, leading to inefficiencies and increased coupling within the microservice network. + * - {@link edu.university.ecs.lab.detection.models.results.antipatterns.WobblyServiceInteraction}: Represents service interactions + * characterized by unstable or inconsistent communication patterns within microservice classes and methods. + *

+ * These models are utilized across various services and components within the anti-pattern detection framework to + * analyze and report issues related to microservices architecture. + */ +package edu.university.ecs.lab.detection.models.results.antipatterns; diff --git a/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR1.java b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR1.java new file mode 100644 index 00000000..ff94c71d --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR1.java @@ -0,0 +1,151 @@ +//package edu.university.ecs.lab.detection.models.results.architecture; +// +//import java.util.ArrayList; +//import java.util.List; +//import java.util.Objects; +//import java.util.stream.Collectors; +// +//import com.fasterxml.jackson.annotation.JsonIgnore; +//import com.fasterxml.jackson.databind.JsonNode; +//import com.fasterxml.jackson.databind.node.JsonNodeFactory; +//import com.fasterxml.jackson.databind.node.ObjectNode; +// +//import edu.university.ecs.lab.common.models.enums.ClassRole; +//import edu.university.ecs.lab.common.models.ir.*; +//import edu.university.ecs.lab.common.utils.FlowUtils; +//import edu.university.ecs.lab.delta.models.Delta; +//import edu.university.ecs.lab.delta.models.enums.ChangeType; +//import lombok.Data; +//import lombok.EqualsAndHashCode; +// +///** +// * Architectural Rule 1 Class: Floating call due to endpoint removal (internal) +// */ +//@EqualsAndHashCode(callSuper = true) +//@Data +//public class AR1 extends AbstractAR { +// +// /** +// * Architectural rule 1 details +// */ +// protected static final String TYPE = "Architectural Rule 1"; +// protected static final String NAME = "Floating call due to endpoint removal (internal)"; +// protected static final String DESC = "An endpoint was removed, inter service calls depending on this method are no longer called"; +// +// @Override +// @JsonIgnore +// public String getName() { +// return NAME; +// } +// +// @Override +// @JsonIgnore +// public String getDescription() { +// return DESC; +// } +// +// @Override +// @JsonIgnore +// public double getWeight() { +// return 0; +// } +// +// @Override +// public String getType() { +// return TYPE; +// } +// +// /** +// * Scan and compare old microservice system and new microservice system to identify endpoint removals +// * +// * @param delta change between old commit and new microservice systems +// * @param oldSystem old commit of microservice system +// * @param newSystem new commit of microservice system +// * @return list of restCalls called in severed flow (if method was deleted) +// */ +// public static List scan(Delta delta, MicroserviceSystem oldSystem, MicroserviceSystem newSystem){ +// List useCases = new ArrayList<>(); +// +// // Old class for delete, delta class for modify +// JClass jClass = delta.getChangeType().equals(ChangeType.MODIFY) ? delta.getClassChange() : oldSystem.findClass(delta.getOldPath()); +// +// if(delta.getChangeType().equals(ChangeType.ADD) || !jClass.getClassRole().equals(ClassRole.CONTROLLER)) { +// return useCases; +// } +// +// List flows = FlowUtils.buildFlows(oldSystem); +// Endpoint endpointMatch = null; +// for(Flow flow : flows){ +// if(flow.getController() != null && flow.getController().getPath().equals(delta.getOldPath())){ +// for(Endpoint endpoint : jClass.getEndpoints()) { +// if(endpoint.getName().equals(flow.getControllerMethod().getName())){ +// endpointMatch = endpoint; +// } +// } +// // If we find no match or its a delete, we have removed this method +// if((Objects.nonNull(endpointMatch) || delta.getChangeType().equals(ChangeType.DELETE)) && flow.getService() != null){ +// for(RestCall restCall : flow.getService().getRestCalls()) { +// // If this restCall is called in the severed flow +// if(flow.getServiceMethod() != null && restCall.getCalledFrom().equals(flow.getServiceMethod().getName())){ +// AR1 useCase1 = new AR1(); +// JsonNode jsonObject = JsonNodeFactory.instance.objectNode(); +// jsonObject.add("RestCall", restCall.toJsonObject()); +// jsonObject.add("Endpoint", endpointMatch == null ? new JsonObject() : endpointMatch.toJsonObject()); +// useCase1.setMetaData(jsonObject); +// useCase1.setOldCommitID(oldSystem.getCommitID()); +// useCase1.setNewCommitID(newSystem.getCommitID()); +// useCases.add(useCase1); +// } +// } +// } +// +// endpointMatch = null; +// } +// +// +// } +// +// // Return list of restCalls called in severed flow (if method was deleted) +// return useCases; +// } +// +// /** +// * Scan and compare old microservice system and new microservice system to identify endpoint removals +// * +// * @param delta change between old commit and new microservice systems +// * @param oldSystem old commit of microservice system +// * @param newSystem new commit of microservice system +// * @return list of restCalls not in any flows +// */ +// public static List scan2(Delta delta, MicroserviceSystem oldSystem, MicroserviceSystem newSystem){ +// List useCases = new ArrayList<>(); +// +// List flows = FlowUtils.buildFlows(oldSystem); +// List allRestCalls = newSystem.getMicroservices().stream().flatMap(microservice -> microservice.getServices().stream()).flatMap(jClass -> jClass.getRestCalls().stream()).collect(Collectors.toList()); +// +// for(RestCall restCall : allRestCalls) { +// outer: +// { +// for (Flow flow : flows) { +// if (Objects.nonNull(flow.getRepositoryMethodCall()) && flow.getRepositoryMethodCall().equals(restCall)) { +// break outer; +// } +// } +// +// // If the restCall is not in any flows (flows start at controller) +// AR1 archRule1 = new AR1(); +// ObjectNode jsonObject = JsonNodeFactory.instance.objectNode(); +// jsonObject.put("RestCall", restCall.getID()); +// archRule1.setMetaData(jsonObject); +// archRule1.setOldCommitID(oldSystem.getCommitID()); +// archRule1.setNewCommitID(newSystem.getCommitID()); +// useCases.add(archRule1); +// +// } +// } +// +// // Return list of restCalls not in any flows +// return useCases; +// } +//} +// \ No newline at end of file diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR12.java b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR12.java similarity index 100% rename from src/main/java/edu/university/ecs/lab/detection/architecture/models/AR12.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR12.java diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR2.java b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR2.java similarity index 100% rename from src/main/java/edu/university/ecs/lab/detection/architecture/models/AR2.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR2.java diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR20.java b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR20.java similarity index 81% rename from src/main/java/edu/university/ecs/lab/detection/architecture/models/AR20.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR20.java index 045110a9..97ab2695 100644 --- a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR20.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR20.java @@ -1,10 +1,14 @@ -package edu.university.ecs.lab.detection.architecture.models; +package edu.university.ecs.lab.detection.models.results.architecture; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.gson.JsonObject; import edu.university.ecs.lab.common.models.ir.Microservice; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; -import edu.university.ecs.lab.common.models.sdg.ServiceDependencyGraph; +import edu.university.ecs.lab.detection.models.sdg.ServiceDependencyGraph; import lombok.Data; +import lombok.EqualsAndHashCode; import java.util.ArrayList; import java.util.List; @@ -14,6 +18,7 @@ /** * Architectural Rule 20 Class: Hublike Service */ +@EqualsAndHashCode(callSuper = true) @Data public class AR20 extends AbstractAR { @@ -23,10 +28,6 @@ public class AR20 extends AbstractAR { protected static final String TYPE = "Architectural Rule 20"; protected static final String NAME = "Hublike Service"; protected static final String DESC = ""; - - private String oldCommitID; - private String newCommitID; - protected JsonObject metaData; @Override public String getName() { @@ -38,7 +39,6 @@ public String getDescription() { return DESC; } - @Override public double getWeight() { return 0; @@ -49,11 +49,6 @@ public String getType() { return TYPE; } - @Override - public JsonObject getMetaData() { - return metaData; - } - /** * Scan and compare old microservice system and new microservice system to identify hublike services * @@ -74,8 +69,8 @@ public static List scan(MicroserviceSystem oldSystem, MicroserviceSystem n getHubMicroservices.forEach(s -> { AR20 archRule20 = new AR20(); - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("Microservice", s); + ObjectNode jsonObject = JsonNodeFactory.instance.objectNode(); + jsonObject.put("Microservice", s); archRule20.setMetaData(jsonObject); archRule20.setOldCommitID(oldSystem.getCommitID()); archRule20.setNewCommitID(newSystem.getCommitID()); diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR21.java b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR21.java similarity index 90% rename from src/main/java/edu/university/ecs/lab/detection/architecture/models/AR21.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR21.java index 01e81640..b57792f4 100644 --- a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR21.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR21.java @@ -1,9 +1,12 @@ -package edu.university.ecs.lab.detection.architecture.models; +package edu.university.ecs.lab.detection.models.results.architecture; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.gson.JsonObject; import edu.university.ecs.lab.common.models.ir.Microservice; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; -import edu.university.ecs.lab.common.models.sdg.ServiceDependencyGraph; +import edu.university.ecs.lab.detection.models.sdg.ServiceDependencyGraph; import lombok.Data; import java.util.*; @@ -19,10 +22,6 @@ public class AR21 extends AbstractAR { protected static final String TYPE = "Architectural Rule 21"; protected static final String NAME = "Wrongcuts Service"; protected static final String DESC = ""; - - private String oldCommitID; - private String newCommitID; - protected JsonObject metaData; @Override public String getName() { @@ -44,11 +43,6 @@ public String getType() { return TYPE; } - @Override - public JsonObject getMetaData() { - return metaData; - } - /** * Scan and compare old microservice system and new microservice system to identify wrongly interconnected services * @@ -64,8 +58,8 @@ public static List scan(MicroserviceSystem oldSystem, MicroserviceSystem n wrongCuts.forEach(s -> { AR21 archRule21 = new AR21(); - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("Microservice", String.join(",", s)); + ObjectNode jsonObject = JsonNodeFactory.instance.objectNode(); + jsonObject.put("Microservice", String.join(",", s)); archRule21.setMetaData(jsonObject); archRule21.setOldCommitID(oldSystem.getCommitID()); archRule21.setNewCommitID(newSystem.getCommitID()); diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR22.java b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR22.java similarity index 84% rename from src/main/java/edu/university/ecs/lab/detection/architecture/models/AR22.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR22.java index d6c82a71..092f2692 100644 --- a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR22.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR22.java @@ -1,11 +1,13 @@ -package edu.university.ecs.lab.detection.architecture.models; +package edu.university.ecs.lab.detection.models.results.architecture; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.google.gson.JsonObject; +import edu.university.ecs.lab.detection.models.results.architecture.enums.Confidence; import edu.university.ecs.lab.common.models.enums.ClassRole; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; import edu.university.ecs.lab.delta.models.Delta; import edu.university.ecs.lab.delta.models.enums.ChangeType; -import edu.university.ecs.lab.detection.architecture.models.enums.Confidence; import lombok.Data; import java.util.*; @@ -22,10 +24,6 @@ public class AR22 extends AbstractAR { protected static final String NAME = "Entity Modification"; protected static final String DESC = "Any entity has been modified inconsistently among services"; protected static final Confidence CONFIDENCE = Confidence.UNKNOWN; - - private String oldCommitID; - private String newCommitID; - protected JsonObject metaData; @Override public String getName() { @@ -47,11 +45,6 @@ public String getType() { return TYPE; } - @Override - public JsonObject getMetaData() { - return metaData; - } - /** * Scan and compare old microservice system and new microservice system to identify inconsistently modified entities * @@ -69,7 +62,7 @@ public static List scan(Delta delta, MicroserviceSystem oldSystem, Microse AR22 archRules22 = new AR22(); - JsonObject jsonObject = new JsonObject(); + JsonNode jsonObject = JsonNodeFactory.instance.objectNode(); archRules22.setMetaData(jsonObject); archRules22.setOldCommitID(oldSystem.getCommitID()); archRules22.setNewCommitID(newSystem.getCommitID()); diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR23.java b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR23.java similarity index 81% rename from src/main/java/edu/university/ecs/lab/detection/architecture/models/AR23.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR23.java index 285efc87..08aba9ab 100644 --- a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR23.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR23.java @@ -1,15 +1,19 @@ -package edu.university.ecs.lab.detection.architecture.models; +package edu.university.ecs.lab.detection.models.results.architecture; import java.util.ArrayList; import java.util.List; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.gson.JsonObject; +import edu.university.ecs.lab.detection.models.results.architecture.enums.Confidence; import edu.university.ecs.lab.common.models.enums.FileType; import edu.university.ecs.lab.common.models.ir.ConfigFile; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; import edu.university.ecs.lab.delta.models.Delta; -import edu.university.ecs.lab.detection.architecture.models.enums.Confidence; import lombok.Data; /** @@ -25,10 +29,6 @@ public class AR23 extends AbstractAR{ protected static final String NAME = "No API Gateway Found"; protected static final String DESC = "The absence of a centralized entry point for managing, routing, and securing API calls, leading to potential inefficiencies and security vulnerabilities."; protected static final Confidence CONFIDENCE = Confidence.UNKNOWN; - - private String oldCommitID; - private String newCommitID; - protected JsonObject metaData; @Override public String getName() { @@ -50,11 +50,6 @@ public String getType() { return TYPE; } - @Override - public JsonObject getMetaData() { - return metaData; - } - /** * Scan and compare old microservice system and new microservice system to check for API gateway * @@ -90,12 +85,12 @@ public static AR23 checkforApiGateway(Delta delta, ConfigFile configFile, Micros AR23 archRule23 = new AR23(); if (configFile.getName().equals("application.yml") && configFile.getFileType().equals(FileType.CONFIG)){ - JsonObject data = configFile.getData(); + JsonNode data = configFile.getData(); if (data != null) { if (containsApiGatewayConfiguration(data)) { - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("No API Gateway:", false); - jsonObject.addProperty("Change Type: ", delta.getChangeType().toString()); + ObjectNode jsonObject = JsonNodeFactory.instance.objectNode(); + jsonObject.put("No API Gateway:", false); + jsonObject.put("Change Type: ", delta.getChangeType().toString()); archRule23.setOldCommitID(oldSystem.getCommitID()); archRule23.setNewCommitID(newSystem.getCommitID()); archRule23.setMetaData(jsonObject); @@ -116,11 +111,11 @@ public static AR23 checkforApiGateway(Delta delta, ConfigFile configFile, Micros * @param data JSON object to check * @return true if API gateway configuration is found, false otherwise */ - private static boolean containsApiGatewayConfiguration(JsonObject data) { + private static boolean containsApiGatewayConfiguration(JsonNode data) { if (data.has("spring")) { - JsonObject spring = data.getAsJsonObject("spring"); + JsonNode spring = data.get("spring"); if (spring.has("cloud")) { - JsonObject cloud = spring.getAsJsonObject("cloud"); + JsonNode cloud = spring.get("cloud"); if (cloud.has("gateway")) { return true; } diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR24.java b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR24.java similarity index 74% rename from src/main/java/edu/university/ecs/lab/detection/architecture/models/AR24.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR24.java index 326be73b..472efd87 100644 --- a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR24.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR24.java @@ -1,15 +1,19 @@ -package edu.university.ecs.lab.detection.architecture.models; +package edu.university.ecs.lab.detection.models.results.architecture; import java.util.ArrayList; import java.util.List; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.gson.JsonObject; +import edu.university.ecs.lab.detection.models.results.architecture.enums.Confidence; import edu.university.ecs.lab.common.models.enums.FileType; import edu.university.ecs.lab.common.models.ir.ConfigFile; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; import edu.university.ecs.lab.delta.models.Delta; -import edu.university.ecs.lab.detection.architecture.models.enums.Confidence; import lombok.Data; /** @@ -25,10 +29,6 @@ public class AR24 extends AbstractAR{ protected static final String NAME = "No Health Checks Found"; protected static final String DESC = "The lack of mechanisms for monitoring the health and availability of microservices, which can result in undetected failures and decreased system reliability."; protected static final Confidence CONFIDENCE = Confidence.UNKNOWN; - - private String oldCommitID; - private String newCommitID; - protected JsonObject metaData; @Override public String getName() { @@ -50,11 +50,6 @@ public String getType() { return TYPE; } - @Override - public JsonObject getMetaData() { - return metaData; - } - /** * Scan and compare old microservice system and new microservice system to check for health check configuration * @@ -90,15 +85,15 @@ public static AR24 checkHealthcheck(Delta delta, ConfigFile configFile, Microser AR24 archRule24 = new AR24(); if (configFile.getName().equals("application.yml") && configFile.getFileType().equals(FileType.CONFIG)){ - JsonObject data = configFile.getData(); + JsonNode data = configFile.getData(); if (data != null){ if (containsHealthCheck(data)){ return null; } else{ - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty(" No Health Check Found:", true); - jsonObject.addProperty("Change Type: ", delta.getChangeType().toString()); + ObjectNode jsonObject = JsonNodeFactory.instance.objectNode(); + jsonObject.put(" No Health Check Found:", true); + jsonObject.put("Change Type: ", delta.getChangeType().toString()); archRule24.setOldCommitID(oldSystem.getCommitID()); archRule24.setNewCommitID(newSystem.getCommitID()); archRule24.setMetaData(jsonObject); @@ -119,21 +114,21 @@ public static AR24 checkHealthcheck(Delta delta, ConfigFile configFile, Microser * @param data The JsonObject representing the configuration data to check. * @return true if the necessary health check configurations are present and enabled, false otherwise. */ - private static boolean containsHealthCheck(JsonObject data){ + private static boolean containsHealthCheck(JsonNode data){ boolean healthCheckEnabled = false; boolean registerHealthIndicatorCB = false; boolean registerHealthIndicatorRL = false; if (data.has("management")) { - JsonObject management = data.getAsJsonObject("management"); + JsonNode management = data.get("management"); if (management.has("health")) { - JsonObject health = management.getAsJsonObject("health"); + JsonNode health = management.get("health"); if (health.has("circuitbreakers")) { if (health.has("ratelimiters")) { - JsonObject ratelimiters = health.getAsJsonObject("ratelimiters"); - JsonObject circuitbreakers = health.getAsJsonObject("circuitbreakers"); - if (circuitbreakers.has("enabled") && circuitbreakers.get("enabled").getAsBoolean() && - ratelimiters.has("enabled") && ratelimiters.get("enabled").getAsBoolean()) { + JsonNode ratelimiters = health.get("ratelimiters"); + JsonNode circuitbreakers = health.get("circuitbreakers"); + if (circuitbreakers.has("enabled") && circuitbreakers.get("enabled").asBoolean() && + ratelimiters.has("enabled") && ratelimiters.get("enabled").asBoolean()) { healthCheckEnabled = true; } } @@ -142,14 +137,14 @@ private static boolean containsHealthCheck(JsonObject data){ } if (data.has("resilience4j")) { - JsonObject resilience4j = data.getAsJsonObject("resilience4j"); + JsonNode resilience4j = data.get("resilience4j"); if (resilience4j.has("circuitbreaker")) { - JsonObject circuitbreaker = resilience4j.getAsJsonObject("circuitbreaker"); + JsonNode circuitbreaker = resilience4j.get("circuitbreaker"); if (circuitbreaker.has("configs")) { - JsonObject configs = circuitbreaker.getAsJsonObject("configs"); + JsonNode configs = circuitbreaker.get("configs"); if (configs.has("default")) { - JsonObject defaultConfig = configs.getAsJsonObject("default"); - if (defaultConfig.has("registerHealthIndicator") && defaultConfig.get("registerHealthIndicator").getAsBoolean()) { + JsonNode defaultConfig = configs.get("default"); + if (defaultConfig.has("registerHealthIndicator") && defaultConfig.get("registerHealthIndicator").asBoolean()) { registerHealthIndicatorCB = true; } } @@ -157,12 +152,12 @@ private static boolean containsHealthCheck(JsonObject data){ } if (resilience4j.has("ratelimiter")) { - JsonObject ratelimiter = resilience4j.getAsJsonObject("ratelimiter"); + JsonNode ratelimiter = resilience4j.get("ratelimiter"); if (ratelimiter.has("configs")) { - JsonObject configs = ratelimiter.getAsJsonObject("configs"); + JsonNode configs = ratelimiter.get("configs"); if (configs.has("instances")) { - JsonObject instances = configs.getAsJsonObject("instances"); - if (instances.has("registerHealthIndicator") && instances.get("registerHealthIndicator").getAsBoolean()) { + JsonNode instances = configs.get("instances"); + if (instances.has("registerHealthIndicator") && instances.get("registerHealthIndicator").asBoolean()) { registerHealthIndicatorRL = true; } } diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR3.java b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR3.java similarity index 85% rename from src/main/java/edu/university/ecs/lab/detection/architecture/models/AR3.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR3.java index 3ae09342..71fa2fa6 100644 --- a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR3.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR3.java @@ -1,5 +1,10 @@ -package edu.university.ecs.lab.detection.architecture.models; +package edu.university.ecs.lab.detection.models.results.architecture; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; import edu.university.ecs.lab.common.models.ir.Endpoint; import edu.university.ecs.lab.common.models.ir.JClass; import edu.university.ecs.lab.common.models.ir.Microservice; @@ -15,10 +20,12 @@ import java.util.stream.Collectors; import com.google.gson.JsonObject; +import lombok.EqualsAndHashCode; /** * Architectural Rule 3 Class: Floating call due to invalid call creation */ +@EqualsAndHashCode(callSuper = true) @Data public class AR3 extends AbstractAR { @@ -28,37 +35,31 @@ public class AR3 extends AbstractAR { protected static final String TYPE = "Architectural Rule 3"; protected static final String NAME = "Floating call due to invalid call creation"; protected static final String DESC = "A rest call is added that references a nonexistent endpoint"; - - - private String oldCommitID; - private String newCommitID; - protected JsonObject metaData; @Override + @JsonIgnore public String getName() { return NAME; } @Override + @JsonIgnore public String getDescription() { return DESC; } @Override + @JsonIgnore public double getWeight() { return 0; } @Override + @JsonIgnore public String getType() { return TYPE; } - @Override - public JsonObject getMetaData() { - return metaData; - } - /** * Scan and compare old microservice system and new microservice system to identify invalid call creation * @@ -84,8 +85,8 @@ public List scan(Delta delta, MicroserviceSystem oldSystem, MicroserviceSys for (RestCall restCall : delta.getClassChange().getRestCalls()) { if (!findMatch(restCall, newSystem)) { AR3 archRule3 = new AR3(); - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("RestCall", restCall.getID()); + ObjectNode jsonObject = JsonNodeFactory.instance.objectNode(); + jsonObject.put("RestCall", restCall.getID()); archRule3.setMetaData(jsonObject); archRule3.setOldCommitID(oldSystem.getCommitID()); archRule3.setNewCommitID(newSystem.getCommitID()); @@ -136,8 +137,9 @@ public static List scan2(MicroserviceSystem oldSystem, MicroserviceSystem n for (RestCall restCall : allRestCalls) { if (!findMatch(restCall, newSystem)) { AR3 archRule3 = new AR3(); - JsonObject jsonObject = new JsonObject(); - jsonObject.add("RestCall", restCall.toJsonObject()); + ObjectMapper objMapper = new ObjectMapper(); + ObjectNode jsonObject = JsonNodeFactory.instance.objectNode(); + jsonObject.set("RestCall", objMapper.valueToTree(restCall)); archRule3.setMetaData(jsonObject); archRule3.setOldCommitID(oldSystem.getCommitID()); archRule3.setNewCommitID(newSystem.getCommitID()); diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR4.java b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR4.java similarity index 90% rename from src/main/java/edu/university/ecs/lab/detection/architecture/models/AR4.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR4.java index 778b677a..ddf46904 100644 --- a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR4.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR4.java @@ -1,8 +1,12 @@ -package edu.university.ecs.lab.detection.architecture.models; +package edu.university.ecs.lab.detection.models.results.architecture; import java.util.*; import java.util.stream.Collectors; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.gson.JsonObject; import edu.university.ecs.lab.common.models.ir.Endpoint; @@ -14,10 +18,12 @@ import edu.university.ecs.lab.delta.models.Delta; import edu.university.ecs.lab.delta.models.enums.ChangeType; import lombok.Data; +import lombok.EqualsAndHashCode; /** * Architectural Rule 4 Class: Floating endpoint */ +@EqualsAndHashCode(callSuper = true) @Data public class AR4 extends AbstractAR { @@ -27,10 +33,6 @@ public class AR4 extends AbstractAR { protected static final String TYPE = "Architectural Rule 4"; protected static final String NAME = "Floating endpoint"; protected static final String DESC = "No rest calls reference this endpoint. This endpoint is now unused by any other microservice"; - - private String oldCommitID; - private String newCommitID; - protected JsonObject metaData; @Override public String getName() { @@ -47,11 +49,6 @@ public double getWeight() { return 0; } - @Override - public JsonObject getMetaData() { - return metaData; - } - /** * Scan and compare old microservice system and new microservice system to identify last call removal * @@ -92,8 +89,9 @@ public static List scan(Delta delta, MicroserviceSystem oldSystem, Microser // If we match, they once called but no longer call if (RestCall.matchEndpoint(restCall, endpoint)) { AR4 archRule4 = new AR4(); - JsonObject jsonObject = new JsonObject(); - jsonObject.add("RestCall", restCall.toJsonObject()); + ObjectNode jsonObject = JsonNodeFactory.instance.objectNode(); + ObjectMapper objMapper = new ObjectMapper(); + jsonObject.set("RestCall", objMapper.valueToTree(restCall)); archRule4.setMetaData(jsonObject); archRule4.setOldCommitID(oldSystem.getCommitID()); archRule4.setNewCommitID(newSystem.getCommitID()); @@ -200,8 +198,9 @@ public static List scan2(MicroserviceSystem oldSystem, MicroserviceSystem n for(Endpoint endpoint: allEndpoints){ if(!findMatch(endpoint, newSystem)){ AR4 archRule4 = new AR4(); - JsonObject jsonObject = new JsonObject(); - jsonObject.add("Endpoint", endpoint.toJsonObject()); + ObjectMapper objMapper = new ObjectMapper(); + ObjectNode jsonObject = JsonNodeFactory.instance.objectNode(); + jsonObject.set("Endpoint", objMapper.valueToTree(endpoint)); archRule4.setMetaData(jsonObject); archRule4.setOldCommitID(oldSystem.getCommitID()); archRule4.setNewCommitID(newSystem.getCommitID()); diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR6.java b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR6.java similarity index 88% rename from src/main/java/edu/university/ecs/lab/detection/architecture/models/AR6.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR6.java index 3b5aca78..413a18f5 100644 --- a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR6.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR6.java @@ -1,5 +1,9 @@ -package edu.university.ecs.lab.detection.architecture.models; +package edu.university.ecs.lab.detection.models.results.architecture; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.gson.JsonObject; import edu.university.ecs.lab.common.models.ir.JClass; import edu.university.ecs.lab.common.models.ir.Method; @@ -9,14 +13,14 @@ import edu.university.ecs.lab.delta.models.Delta; import edu.university.ecs.lab.delta.models.enums.ChangeType; import lombok.Data; -import org.apache.poi.ss.formula.functions.T; +import lombok.EqualsAndHashCode; import java.util.*; -import java.util.stream.Collectors; /** * Architectural Rule 6 Class: Affected endpoint due to business logic update */ +@EqualsAndHashCode(callSuper = true) @Data public class AR6 extends AbstractAR { @@ -26,9 +30,6 @@ public class AR6 extends AbstractAR { protected static final String TYPE = "Architectural Rule 6"; protected static final String NAME = "Affected endpoint due to business logic update"; protected static final String DESC = "A service method was modified and now causes inconsistent results for calling endpoints"; - private String oldCommitID; - private String newCommitID; - protected JsonObject metaData; @Override public String getName() { @@ -50,11 +51,6 @@ public String getType() { return TYPE; } - @Override - public JsonObject getMetaData() { - return metaData; - } - /** * Scan and compare old microservice system and new microservice system to identify endpoints affected by business logic update * @@ -93,10 +89,11 @@ public static List scan(Delta delta, MicroserviceSystem oldSystem, Microser && method.getName().equals(methodCall.getCalledFrom())) { AR6 archRule6 = new AR6(); - JsonObject jsonObject = new JsonObject(); + ObjectMapper objMapper = new ObjectMapper(); + ObjectNode jsonObject = JsonNodeFactory.instance.objectNode(); + jsonObject.set("AffectedMethod", objMapper.valueToTree(method)); + jsonObject.set("MethodCall", objMapper.valueToTree(methodCall)); - jsonObject.add("AffectedMethod", method.toJsonObject()); - jsonObject.add("MethodCall", methodCall.toJsonObject()); archRule6.setOldCommitID(oldSystem.getCommitID()); archRule6.setNewCommitID(newSystem.getCommitID()); diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR7.java b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR7.java similarity index 82% rename from src/main/java/edu/university/ecs/lab/detection/architecture/models/AR7.java rename to src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR7.java index 5ab6ddee..0b5f35f5 100644 --- a/src/main/java/edu/university/ecs/lab/detection/architecture/models/AR7.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AR7.java @@ -1,4 +1,4 @@ -package edu.university.ecs.lab.detection.architecture.models; +package edu.university.ecs.lab.detection.models.results.architecture; import java.util.ArrayList; import java.util.HashSet; @@ -6,6 +6,9 @@ import java.util.Set; import java.util.stream.Collectors; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.gson.JsonObject; import edu.university.ecs.lab.common.models.ir.Annotation; @@ -16,19 +19,17 @@ import edu.university.ecs.lab.delta.models.Delta; import edu.university.ecs.lab.delta.models.enums.ChangeType; import lombok.Data; +import lombok.EqualsAndHashCode; /** * Architectural Rule 7 Class: Affected endpoint due to data access logic update */ +@EqualsAndHashCode(callSuper = true) @Data public class AR7 extends AbstractAR { protected static final String TYPE = "Architectural Rule 7"; protected static final String NAME = "Affected endpoint due to data access logic update"; protected static final String DESC = "A repository method was modified and now causes inconsistent results"; - private String oldCommitID; - private String newCommitID; - protected JsonObject metaData; - @Override public String getName() { @@ -45,11 +46,6 @@ public double getWeight() { return 0; } - @Override - public JsonObject getMetaData() { - return metaData; - } - @Override public String getType() { return TYPE; @@ -100,11 +96,11 @@ public static List scan(Delta delta, MicroserviceSystem oldSystem, Microser if (!addedAnnotations.isEmpty() || !removedAnnotations.isEmpty()) { AR7 useCase7 = new AR7(); - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("OldMethodDeclaration", methodOld.getID()); - jsonObject.addProperty("NewMethodDeclaration", methodNew.getID()); - jsonObject.addProperty("AddedAnnotations", addedAnnotations.toString()); - jsonObject.addProperty("RemovedAnnotations", removedAnnotations.toString()); + ObjectNode jsonObject = JsonNodeFactory.instance.objectNode(); + jsonObject.put("OldMethodDeclaration", methodOld.getID()); + jsonObject.put("NewMethodDeclaration", methodNew.getID()); + jsonObject.put("AddedAnnotations", addedAnnotations.toString()); + jsonObject.put("RemovedAnnotations", removedAnnotations.toString()); useCase7.setOldCommitID(oldSystem.getCommitID()); useCase7.setNewCommitID(newSystem.getCommitID()); useCase7.setMetaData(jsonObject); @@ -118,10 +114,10 @@ public static List scan(Delta delta, MicroserviceSystem oldSystem, Microser if (annotationNew.getName().equals(annotationOld.getName()) && !annotationNew.getContents().equals(annotationOld.getContents())) { AR7 useCase7 = new AR7(); - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty("OldMethodDeclaration", methodOld.getID()); - jsonObject.addProperty("NewMethodDeclaration", methodNew.getID()); - jsonObject.addProperty("ModifiedAnnotation", annotationNew.getName()); + ObjectNode jsonObject = JsonNodeFactory.instance.objectNode(); + jsonObject.put("OldMethodDeclaration", methodOld.getID()); + jsonObject.put("NewMethodDeclaration", methodNew.getID()); + jsonObject.put("ModifiedAnnotation", annotationNew.getName()); useCase7.setOldCommitID(oldSystem.getCommitID()); useCase7.setNewCommitID(newSystem.getCommitID()); useCase7.setMetaData(jsonObject); diff --git a/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AbstractAR.java b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AbstractAR.java new file mode 100644 index 00000000..5185c5ac --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/AbstractAR.java @@ -0,0 +1,68 @@ +package edu.university.ecs.lab.detection.models.results.architecture; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.databind.JsonNode; + +import edu.university.ecs.lab.detection.models.results.DetectionResult; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * Architectural Rule class template for all architectural rules. + */ +@EqualsAndHashCode(callSuper = true) +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "type" +) +@JsonSubTypes({@JsonSubTypes.Type(value = AR1.class, name = "AR1"), + @JsonSubTypes.Type(value = AR3.class, name = "AR3"), + @JsonSubTypes.Type(value = AR4.class, name = "AR4"), + @JsonSubTypes.Type(value = AR6.class, name = "AR6"), + @JsonSubTypes.Type(value = AR7.class, name = "AR7"), + @JsonSubTypes.Type(value = AR20.class, name = "AR20"), + @JsonSubTypes.Type(value = AR21.class, name = "AR21"), + @JsonSubTypes.Type(value = AR22.class, name = "AR22"), + @JsonSubTypes.Type(value = AR23.class, name = "AR23"), + @JsonSubTypes.Type(value = AR24.class, name = "AR24")}) +@Data +public abstract class AbstractAR extends DetectionResult { + protected String oldCommitID; + protected String newCommitID; + protected JsonNode metaData; + + /** + * Get the name of the Architectural Rule + * + * @return string name of the Architectural Rule + */ + @JsonIgnore + public abstract String getName(); + + /** + * Get the description of the Architectural Rule + * + * @return string description of the Architectural Rule + */ + @JsonIgnore + public abstract String getDescription(); + + /** + * Get the weight of the Architectural Rule + * + * @return double weight of the Architectural Rule + */ + @JsonIgnore + public abstract double getWeight(); + + /** + * Get the new commitID + * + * @return string new commitID + */ + @JsonIgnore + public abstract String getType(); +} diff --git a/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/enums/Confidence.java b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/enums/Confidence.java new file mode 100644 index 00000000..eb1e4667 --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/enums/Confidence.java @@ -0,0 +1,7 @@ +package edu.university.ecs.lab.detection.models.results.architecture.enums; + +public enum Confidence { + CONFIDENT, + INFERENCE, + UNKNOWN +} diff --git a/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/package-info.java b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/package-info.java new file mode 100644 index 00000000..91dfc123 --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection/models/results/architecture/package-info.java @@ -0,0 +1,20 @@ +/** + * Provides classes and enums for representing architectural rules within the microservice system. + * This package is part of the {@link edu.university.ecs.lab.detection_old.architecture} package, which focuses on detecting architectural rules and related information in a microservice system. + * + *

This package includes: + * - {@link edu.university.ecs.lab.detection_old.architecture.models.enums}: Contains enumerations used within the architectural models, such as confidence levels. + * - {@link edu.university.ecs.lab.detection.models.results.architecture.AbstractAR}: Provides a template for all architectural rules, including methods to get the name, description, weight, commit IDs, and type of the rule, and to convert the rule to a JSON object. + * - {@link edu.university.ecs.lab.detection.models.results.architecture.AR1}: Represents the rule for detecting floating calls due to endpoint removal within the microservice system, including methods for scanning and detecting such instances. + * - {@link edu.university.ecs.lab.detection.models.results.architecture.AR3}: Represents the rule for detecting floating calls due to invalid call creation within the microservice system, including methods for scanning and detecting such instances. + * - {@link edu.university.ecs.lab.detection.models.results.architecture.AR4}: Represents the rule for detecting floating endpoints due to last call removal within the microservice system, including methods for scanning and detecting such instances. + * - {@link edu.university.ecs.lab.detection.models.results.architecture.AR6}: Represents the rule for detecting affected endpoints due to business logic updates within the microservice system, including methods for scanning and detecting such instances. + * - {@link edu.university.ecs.lab.detection.models.results.architecture.AR7}: Represents the rule for detecting affected endpoints due to data access logic updates within the microservice system, including methods for scanning and detecting such instances. + * - {@link edu.university.ecs.lab.detection.models.results.architecture.AR20}: Represents the rule for identifying hub-like services within the microservice architecture, including methods for scanning and detecting such instances. + * - {@link edu.university.ecs.lab.detection.models.results.architecture.AR21}: Represents the rule for detecting clusters of wrongly interconnected services (wrongcuts) within the microservice system, including methods for scanning and detecting such instances. + * - {@link edu.university.ecs.lab.detection.models.results.architecture.AR22}: Represents the rule for detecting inconsistent modifications of entities across services within the microservice system, including methods for scanning and detecting such instances. + * - {@link edu.university.ecs.lab.detection.models.results.architecture.AR23}: Represents the rule for detecting the absence of API gateway configuration in the microservice system, including methods for scanning and detecting such instances. + * - {@link edu.university.ecs.lab.detection.models.results.architecture.AR24}: Represents the rule for detecting the absence of health check configurations in the microservice system, including methods for scanning and detecting such instances. + *

+ */ +package edu.university.ecs.lab.detection.models.results.architecture; diff --git a/src/main/java/edu/university/ecs/lab/common/models/sdg/DependencyGraphI.java b/src/main/java/edu/university/ecs/lab/detection/models/sdg/DependencyGraphI.java similarity index 97% rename from src/main/java/edu/university/ecs/lab/common/models/sdg/DependencyGraphI.java rename to src/main/java/edu/university/ecs/lab/detection/models/sdg/DependencyGraphI.java index c653b046..5b540336 100644 --- a/src/main/java/edu/university/ecs/lab/common/models/sdg/DependencyGraphI.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/sdg/DependencyGraphI.java @@ -1,4 +1,4 @@ -package edu.university.ecs.lab.common.models.sdg; +package edu.university.ecs.lab.detection.models.sdg; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/src/main/java/edu/university/ecs/lab/common/models/sdg/MethodDependencyGraph.java b/src/main/java/edu/university/ecs/lab/detection/models/sdg/MethodDependencyGraph.java similarity index 99% rename from src/main/java/edu/university/ecs/lab/common/models/sdg/MethodDependencyGraph.java rename to src/main/java/edu/university/ecs/lab/detection/models/sdg/MethodDependencyGraph.java index 93be1597..e3abfe6b 100644 --- a/src/main/java/edu/university/ecs/lab/common/models/sdg/MethodDependencyGraph.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/sdg/MethodDependencyGraph.java @@ -1,4 +1,4 @@ -package edu.university.ecs.lab.common.models.sdg; +package edu.university.ecs.lab.detection.models.sdg; import com.google.gson.*; import edu.university.ecs.lab.common.models.ir.*; diff --git a/src/main/java/edu/university/ecs/lab/common/models/sdg/RestCallEdge.java b/src/main/java/edu/university/ecs/lab/detection/models/sdg/RestCallEdge.java similarity index 96% rename from src/main/java/edu/university/ecs/lab/common/models/sdg/RestCallEdge.java rename to src/main/java/edu/university/ecs/lab/detection/models/sdg/RestCallEdge.java index 12884e84..038aab30 100644 --- a/src/main/java/edu/university/ecs/lab/common/models/sdg/RestCallEdge.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/sdg/RestCallEdge.java @@ -1,4 +1,4 @@ -package edu.university.ecs.lab.common.models.sdg; +package edu.university.ecs.lab.detection.models.sdg; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/edu/university/ecs/lab/common/models/sdg/ServiceDependencyGraph.java b/src/main/java/edu/university/ecs/lab/detection/models/sdg/ServiceDependencyGraph.java similarity index 98% rename from src/main/java/edu/university/ecs/lab/common/models/sdg/ServiceDependencyGraph.java rename to src/main/java/edu/university/ecs/lab/detection/models/sdg/ServiceDependencyGraph.java index 75379571..2807fdc1 100644 --- a/src/main/java/edu/university/ecs/lab/common/models/sdg/ServiceDependencyGraph.java +++ b/src/main/java/edu/university/ecs/lab/detection/models/sdg/ServiceDependencyGraph.java @@ -1,4 +1,4 @@ -package edu.university.ecs.lab.common.models.sdg; +package edu.university.ecs.lab.detection.models.sdg; import com.google.gson.*; import edu.university.ecs.lab.common.models.ir.*; diff --git a/src/main/java/edu/university/ecs/lab/detection/package-info.java b/src/main/java/edu/university/ecs/lab/detection/package-info.java deleted file mode 100644 index 15606b1a..00000000 --- a/src/main/java/edu/university/ecs/lab/detection/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Provides classes and related services for detecting trends and information in a microservice system. - * This package includes functionality for detecting antipatterns, broken architectural rules, and related metrics. - * - *

This package includes: - * - {@link edu.university.ecs.lab.detection.antipatterns}: Contains classes for detecting common antipatterns in microservice architectures. - * - {@link edu.university.ecs.lab.detection.architecture}: Provides tools for analyzing and evaluating architecture rules of microservice architecture. - * - {@link edu.university.ecs.lab.detection.metrics}: Includes classes for gathering and analyzing various metrics from microservice systems. - * - {@link edu.university.ecs.lab.detection.ExcelOutputRunner}: Contains the main class for generating Excel reports of detected trends and metrics. - * - {@link edu.university.ecs.lab.detection.DetectionService}: Contains the main class for detecting and analyzing architectural rules. - - *

- */ -package edu.university.ecs.lab.detection; diff --git a/src/main/java/edu/university/ecs/lab/detection/reporting/AbstractReporter.java b/src/main/java/edu/university/ecs/lab/detection/reporting/AbstractReporter.java new file mode 100644 index 00000000..43290e05 --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection/reporting/AbstractReporter.java @@ -0,0 +1,7 @@ +package edu.university.ecs.lab.detection.reporting; + +public abstract class AbstractReporter { + public void report() { + + } +} diff --git a/src/main/java/edu/university/ecs/lab/detection/reporting/Pipeline.java b/src/main/java/edu/university/ecs/lab/detection/reporting/Pipeline.java new file mode 100644 index 00000000..cdd5a9e3 --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection/reporting/Pipeline.java @@ -0,0 +1,69 @@ +package edu.university.ecs.lab.detection.reporting; + +import edu.university.ecs.lab.detection.scanning.common.AbstractScanner; +import lombok.NoArgsConstructor; + +import java.util.Arrays; +import java.util.List; + +/** + * A pipeline class for running analytics on a continuous flow of data. + * @param The data type + */ +@NoArgsConstructor +public class Pipeline { + /** + * The data source for the pipeline. + */ + private Iterable dataSource; + + /** + * The scanners registered to this pipeline. + */ + private List scanners; + + /** + * The reporters registered to this pipeline. + */ + private List reporters; + + /** + * Registers new scanners with this pipeline. + * @param scanners The scanner(s) to register. + */ + public void registerScanners(AbstractScanner... scanners) { + this.scanners.addAll(Arrays.asList(scanners)); + } + + /** + * Removes registered scanners from this pipeline. + * @param scanners The scanner(s) to remove. + */ + public void deregisterScanners(AbstractScanner... scanners) { + this.scanners.removeAll(Arrays.asList(scanners)); + } + + /** + * Registers new reporters with this pipeline. + * @param reporters The reporter(s) to register. + */ + public void registerReporters(AbstractReporter... reporters) { + this.reporters.addAll(Arrays.asList(reporters)); + } + + /** + * Removes registered reporters from this pipeline. + * @param reporters The reporter(s) to remove. + */ + public void deregisterReporters(AbstractReporter... reporters) { + this.reporters.removeAll(Arrays.asList(reporters)); + } + + public void runScanners() { + this.scanners.forEach(AbstractScanner::scan); + } + + public void runReporters() { + this.reporters.forEach(AbstractReporter::report); + } +} diff --git a/src/main/java/edu/university/ecs/lab/detection/scanning/antipatterns/AbstractAntipatternScanner.java b/src/main/java/edu/university/ecs/lab/detection/scanning/antipatterns/AbstractAntipatternScanner.java new file mode 100644 index 00000000..37dc8a24 --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection/scanning/antipatterns/AbstractAntipatternScanner.java @@ -0,0 +1,15 @@ +package edu.university.ecs.lab.detection.scanning.antipatterns; + +import edu.university.ecs.lab.detection.scanning.common.AbstractScanner; + +public abstract class AbstractAntipatternScanner extends AbstractScanner { + public boolean scan() { + return false; + } + + public boolean filter() { + return false; + } + + public void report() {} +} diff --git a/src/main/java/edu/university/ecs/lab/detection/scanning/architecture/AbstractARScanner.java b/src/main/java/edu/university/ecs/lab/detection/scanning/architecture/AbstractARScanner.java new file mode 100644 index 00000000..50c0c2c0 --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection/scanning/architecture/AbstractARScanner.java @@ -0,0 +1,4 @@ +package edu.university.ecs.lab.detection.scanning.architecture; + +public abstract class AbstractARScanner { +} diff --git a/src/main/java/edu/university/ecs/lab/detection/scanning/common/AbstractScanner.java b/src/main/java/edu/university/ecs/lab/detection/scanning/common/AbstractScanner.java new file mode 100644 index 00000000..055ac8d5 --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection/scanning/common/AbstractScanner.java @@ -0,0 +1,23 @@ +package edu.university.ecs.lab.detection.scanning.common; + +import edu.university.ecs.lab.detection.models.results.DetectionResult; +import edu.university.ecs.lab.detection.strategies.ScanStrategy; + +import java.util.Arrays; +import java.util.List; + +public abstract class AbstractScanner implements ScanStrategy { + protected List results; + + protected String name; + + public abstract void setStrategy(); + + public abstract boolean scan(); + + public abstract void report(); + + public void addResults(DetectionResult... results) { + this.results.addAll(Arrays.asList(results)); + } +} diff --git a/src/main/java/edu/university/ecs/lab/detection/scanning/common/GraphScanner.java b/src/main/java/edu/university/ecs/lab/detection/scanning/common/GraphScanner.java new file mode 100644 index 00000000..2c7f1d8f --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection/scanning/common/GraphScanner.java @@ -0,0 +1,4 @@ +package edu.university.ecs.lab.detection.scanning.common; + +public class GraphScanner { +} diff --git a/src/main/java/edu/university/ecs/lab/detection/scanning/common/SimpleScanner.java b/src/main/java/edu/university/ecs/lab/detection/scanning/common/SimpleScanner.java new file mode 100644 index 00000000..b7bac3be --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection/scanning/common/SimpleScanner.java @@ -0,0 +1,4 @@ +package edu.university.ecs.lab.detection.scanning.common; + +public class SimpleScanner { +} diff --git a/src/main/java/edu/university/ecs/lab/detection/scanning/metrics/AbstractMetricScanner.java b/src/main/java/edu/university/ecs/lab/detection/scanning/metrics/AbstractMetricScanner.java new file mode 100644 index 00000000..08ef9079 --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection/scanning/metrics/AbstractMetricScanner.java @@ -0,0 +1,4 @@ +package edu.university.ecs.lab.detection.scanning.metrics; + +public abstract class AbstractMetricScanner { +} diff --git a/src/main/java/edu/university/ecs/lab/detection/strategies/GraphStrategy.java b/src/main/java/edu/university/ecs/lab/detection/strategies/GraphStrategy.java new file mode 100644 index 00000000..a39230fc --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection/strategies/GraphStrategy.java @@ -0,0 +1,5 @@ +package edu.university.ecs.lab.detection.strategies; + +public interface GraphStrategy { + boolean scan(); +} diff --git a/src/main/java/edu/university/ecs/lab/detection/strategies/ScanStrategy.java b/src/main/java/edu/university/ecs/lab/detection/strategies/ScanStrategy.java new file mode 100644 index 00000000..76dfa3be --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection/strategies/ScanStrategy.java @@ -0,0 +1,4 @@ +package edu.university.ecs.lab.detection.strategies; + +public interface ScanStrategy extends GraphStrategy { +} diff --git a/src/main/java/edu/university/ecs/lab/detection/ARDetectionRunner.java b/src/main/java/edu/university/ecs/lab/detection_old/ARDetectionRunner.java similarity index 100% rename from src/main/java/edu/university/ecs/lab/detection/ARDetectionRunner.java rename to src/main/java/edu/university/ecs/lab/detection_old/ARDetectionRunner.java diff --git a/src/main/java/edu/university/ecs/lab/detection/DetectionService.java b/src/main/java/edu/university/ecs/lab/detection_old/DetectionService.java similarity index 90% rename from src/main/java/edu/university/ecs/lab/detection/DetectionService.java rename to src/main/java/edu/university/ecs/lab/detection_old/DetectionService.java index d17618a5..157dd893 100644 --- a/src/main/java/edu/university/ecs/lab/detection/DetectionService.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/DetectionService.java @@ -1,37 +1,36 @@ -package edu.university.ecs.lab.detection; +package edu.university.ecs.lab.detection_old; import com.google.gson.JsonArray; import edu.university.ecs.lab.common.config.Config; import edu.university.ecs.lab.common.config.ConfigUtil; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; -import edu.university.ecs.lab.common.models.sdg.MethodDependencyGraph; -import edu.university.ecs.lab.common.models.sdg.ServiceDependencyGraph; +import edu.university.ecs.lab.detection.models.results.architecture.*; +import edu.university.ecs.lab.detection.models.sdg.MethodDependencyGraph; +import edu.university.ecs.lab.detection.models.sdg.ServiceDependencyGraph; import edu.university.ecs.lab.common.services.GitService; import edu.university.ecs.lab.common.utils.FileUtils; import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; import edu.university.ecs.lab.delta.models.SystemChange; import edu.university.ecs.lab.delta.services.DeltaExtractionService; -import edu.university.ecs.lab.detection.antipatterns.services.*; -import edu.university.ecs.lab.detection.architecture.models.*; -import edu.university.ecs.lab.detection.architecture.services.ARDetectionService; -import edu.university.ecs.lab.detection.metrics.RunCohesionMetrics; -import edu.university.ecs.lab.detection.metrics.models.ConnectedComponentsModularity; -import edu.university.ecs.lab.detection.metrics.models.DegreeCoupling; -import edu.university.ecs.lab.detection.metrics.models.StructuralCoupling; -import edu.university.ecs.lab.detection.metrics.services.MetricResultCalculation; +import edu.university.ecs.lab.detection.models.results.antipatterns.ServiceChain; +import edu.university.ecs.lab.detection.models.architecture.*; +import edu.university.ecs.lab.detection_old.antipatterns.services.*; +import edu.university.ecs.lab.detection_old.metrics.RunCohesionMetrics; +import edu.university.ecs.lab.detection_old.metrics.models.ConnectedComponentsModularity; +import edu.university.ecs.lab.detection_old.metrics.models.DegreeCoupling; +import edu.university.ecs.lab.detection_old.metrics.models.StructuralCoupling; +import edu.university.ecs.lab.detection_old.metrics.services.MetricResultCalculation; import edu.university.ecs.lab.intermediate.create.services.IRExtractionService; import edu.university.ecs.lab.intermediate.merge.services.MergeService; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.revwalk.RevCommit; import java.io.FileOutputStream; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; import java.util.*; /** @@ -66,19 +65,14 @@ public class DetectionService { private final String configPath; private final Config config; private final GitService gitService; - private IRExtractionService irExtractionService; - private ARDetectionService arDetectionService; - private DeltaExtractionService deltaExtractionService; - private MergeService mergeService; private final XSSFWorkbook workbook; private XSSFSheet sheet; -// private final String firstCommitID /** * Construct with given configuration file path * @param configPath YAML file to extract microservice details from */ - public DetectionService(String configPath) { + public DetectionService(String configPath) throws IOException, InterruptedException { this.configPath = configPath; // Read in config config = ConfigUtil.readConfig(configPath); @@ -95,14 +89,14 @@ public DetectionService(String configPath) { /** * Method to detect antipatterns, architectural rule violations, and metrics */ - public void runDetection() { + public void runDetection() throws GitAPIException, IOException, InterruptedException { // Get list of commits Iterable iterable = gitService.getLog(); List commits = iterableToList(iterable); // Generate the initial IR - irExtractionService = new IRExtractionService(configPath, Optional.of(commits.get(0).toString().split(" ")[1])); + IRExtractionService irExtractionService = new IRExtractionService(configPath, Optional.of(commits.get(0).toString().split(" ")[1])); String firstCommit = commits.get(0).getName().substring(0, 4); irExtractionService.generateIR(BASE_IR_PATH + "1_" + firstCommit + ".json"); @@ -145,12 +139,10 @@ public void runDetection() { String newIRPath = BASE_IR_PATH + (i+2) + "_" + commitIdNew.substring(0, 4) +".json"; String deltaPath = BASE_DELTA_PATH + (i+1) + "_" + commitIdOld.substring(0, 4) + "_" + commitIdNew.substring(0, 4) + ".json"; - deltaExtractionService = new DeltaExtractionService(configPath, deltaPath, commitIdOld, commitIdNew); - deltaExtractionService.generateDelta(); + DeltaExtractionService.createAndWrite(configPath, commitIdOld, commitIdNew, deltaPath); // Merge Delta changes to old IR to create new IR representing new commit changes - MergeService mergeService = new MergeService(oldIRPath, deltaPath, configPath, newIRPath); - mergeService.generateMergeIR(commitIdNew.substring(0, 4)); + MergeService.createAndWrite(configPath, oldIRPath, deltaPath, "", newIRPath); // Read in the new system and system change newSystem = JsonReadWriteUtils.readFromJSON(newIRPath, MicroserviceSystem.class); @@ -252,6 +244,9 @@ private void detectAntipatterns(MicroserviceSystem microserviceSystem, Map metrics, String oldIRPath) { + private void detectMetrics(MicroserviceSystem microserviceSystem, Map metrics, String oldIRPath) throws IOException { // Create SDG ServiceDependencyGraph sdg = new ServiceDependencyGraph(microserviceSystem); diff --git a/src/main/java/edu/university/ecs/lab/detection_old/ExcelOutputRunner.java b/src/main/java/edu/university/ecs/lab/detection_old/ExcelOutputRunner.java new file mode 100644 index 00000000..52adc349 --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection_old/ExcelOutputRunner.java @@ -0,0 +1,25 @@ +package edu.university.ecs.lab.detection_old; + +import org.eclipse.jgit.api.errors.GitAPIException; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; + +/** + * Runner class to execute detection service + */ +public class ExcelOutputRunner { + + public static void main(String[] args) throws IOException, InterruptedException, GitAPIException { + String configPath = "./config.json"; + File conifgFile = new File(configPath); + if (!conifgFile.exists()) { + throw new FileNotFoundException(); + } + + DetectionService detectionService = new DetectionService(configPath); + detectionService.runDetection(); + } + +} diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/AntipatternDetection.java b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/AntipatternDetection.java similarity index 91% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/AntipatternDetection.java rename to src/main/java/edu/university/ecs/lab/detection_old/antipatterns/AntipatternDetection.java index 49bcb072..5670a57d 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/AntipatternDetection.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/AntipatternDetection.java @@ -1,14 +1,16 @@ -package edu.university.ecs.lab.detection.antipatterns; +package edu.university.ecs.lab.detection_old.antipatterns; import com.google.gson.Gson; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; -import edu.university.ecs.lab.common.models.sdg.MethodDependencyGraph; -import edu.university.ecs.lab.common.models.sdg.ServiceDependencyGraph; +import edu.university.ecs.lab.detection.models.results.antipatterns.*; +import edu.university.ecs.lab.detection.models.sdg.MethodDependencyGraph; +import edu.university.ecs.lab.detection.models.sdg.ServiceDependencyGraph; import edu.university.ecs.lab.common.utils.FileUtils; import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; +import edu.university.ecs.lab.detection.models.antipatterns.*; +import edu.university.ecs.lab.detection_old.antipatterns.services.*; import edu.university.ecs.lab.intermediate.create.services.IRExtractionService; -import edu.university.ecs.lab.detection.antipatterns.models.*; -import edu.university.ecs.lab.detection.antipatterns.services.*; +import org.eclipse.jgit.api.errors.GitAPIException; import java.io.FileWriter; import java.io.IOException; @@ -18,9 +20,9 @@ * Class to detect multiple antipatterns from IR of a given system */ public class AntipatternDetection { - public static void main(String[] args) { + public static void main(String[] args) throws IOException, GitAPIException, InterruptedException { // Create IR of first commit - createIRSystem("./configs/config_spring-boot-microservices.json", "IR.json"); + createIRSystem("./valid_configs/spring-cloud-movie-recommendation.json", "./output/IR.json"); // Creat Microservice System based on generated IR MicroserviceSystem currentSystem = JsonReadWriteUtils.readFromJSON("./output/IR.json", MicroserviceSystem.class); @@ -134,7 +136,7 @@ public static void main(String[] args) { * @param configPath path to configuration file * @param fileName name of output file for IR extraction */ - private static void createIRSystem(String configPath, String fileName) { + private static void createIRSystem(String configPath, String fileName) throws GitAPIException, IOException, InterruptedException { // Create both directories needed FileUtils.makeDirs(); diff --git a/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/package-info.java b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/package-info.java new file mode 100644 index 00000000..f79b03ad --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/package-info.java @@ -0,0 +1,53 @@ +/** + * Provides classes and services for detecting various anti-patterns in microservices architecture. + * Includes detection of cyclic dependencies, greedy microservices, hub-like microservices, wrong cuts, + * service chains, wobbly service interactions, and absence of API gateway and health checks. + *

+ * Classes: + * - {@link edu.university.ecs.lab.detection_old.antipatterns.AntipatternDetection}: Main class for running + * anti-pattern detection routines using configuration and services. + *

+ *

+ * Models Package: + * - {@link edu.university.ecs.lab.detection.models.results.antipatterns.CyclicDependency}: Represents cyclic dependencies + * detected within a microservice network graph. + * - {@link edu.university.ecs.lab.detection.models.results.antipatterns.GreedyMicroservice}: Represents microservices identified + * as greedy based on REST call thresholds. + * - {@link edu.university.ecs.lab.detection.models.results.antipatterns.HubLikeMicroservice}: Represents microservices identified + * as hub-like based on REST call thresholds. + * - {@link edu.university.ecs.lab.detection.models.results.antipatterns.NoApiGateway}: Represents the absence of an API Gateway, + * indicating potential issues with centralized routing and access control. + * - {@link edu.university.ecs.lab.detection.models.results.antipatterns.NoHealthcheck}: Represents the absence of health check + * mechanisms, which are crucial for monitoring and maintaining the health of microservices. + * - {@link edu.university.ecs.lab.detection.models.results.antipatterns.ServiceChain}: Represents a chain of services within a + * microservice network graph, potentially introducing latency and complexity. + * - {@link edu.university.ecs.lab.detection.models.results.antipatterns.WrongCuts}: Represents clusters of services that are + * incorrectly segmented, leading to inefficiencies and increased coupling within the microservice network. + * - {@link edu.university.ecs.lab.detection.models.results.antipatterns.WobblyServiceInteraction}: Represents service interactions + * characterized by unstable or inconsistent communication patterns within microservice classes and methods. + *

+ *

+ * Services Package: + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.CyclicDependencyMethodLevelService}: Service for detecting + * cyclic dependencies within a method network graph. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.CyclicDependencyMSLevelService}: Service for detecting + * cyclic dependencies within a microservice network graph. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.GreedyService}: Service for identifying and managing + * microservices identified as greedy based on REST call thresholds. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.HubLikeService}: Service for identifying and managing + * microservices identified as hub-like based on REST call thresholds. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.ServiceChainMethodLevelService}: Service for detecting and managing + * service chains within a method network graph. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.ServiceChainMSLevelService}: Service for detecting and managing + * service chains within a microservice network graph. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.WrongCutsService}: Service for identifying and reporting + * clusters of services that are incorrectly interconnected within a microservice network graph. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.WobblyServiceInteractionService}: Service for detecting + * wobbly service interactions within a microservice system based on specific annotations. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.NoApiGatewayService}: Service for checking the presence of an + * API gateway configuration in a YAML file. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.NoHealthcheckService}: Service for checking the presence of + * health check configurations in a YAML file. + *

+ */ +package edu.university.ecs.lab.detection_old.antipatterns; diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/CyclicDependencyMSLevelService.java b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/CyclicDependencyMSLevelService.java similarity index 93% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/services/CyclicDependencyMSLevelService.java rename to src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/CyclicDependencyMSLevelService.java index 19a0cbd7..740f49a7 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/CyclicDependencyMSLevelService.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/CyclicDependencyMSLevelService.java @@ -1,8 +1,8 @@ -package edu.university.ecs.lab.detection.antipatterns.services; +package edu.university.ecs.lab.detection_old.antipatterns.services; import edu.university.ecs.lab.common.models.ir.Microservice; -import edu.university.ecs.lab.common.models.sdg.ServiceDependencyGraph; -import edu.university.ecs.lab.detection.antipatterns.models.CyclicDependency; +import edu.university.ecs.lab.detection.models.sdg.ServiceDependencyGraph; +import edu.university.ecs.lab.detection.models.results.antipatterns.CyclicDependency; import java.util.*; diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/CyclicDependencyMethodLevelService.java b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/CyclicDependencyMethodLevelService.java similarity index 94% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/services/CyclicDependencyMethodLevelService.java rename to src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/CyclicDependencyMethodLevelService.java index 294fc560..e3f014b3 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/CyclicDependencyMethodLevelService.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/CyclicDependencyMethodLevelService.java @@ -1,8 +1,8 @@ -package edu.university.ecs.lab.detection.antipatterns.services; +package edu.university.ecs.lab.detection_old.antipatterns.services; import edu.university.ecs.lab.common.models.ir.Method; -import edu.university.ecs.lab.common.models.sdg.MethodDependencyGraph; -import edu.university.ecs.lab.detection.antipatterns.models.CyclicDependency; +import edu.university.ecs.lab.detection.models.sdg.MethodDependencyGraph; +import edu.university.ecs.lab.detection.models.results.antipatterns.CyclicDependency; import java.util.*; diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/GreedyService.java b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/GreedyService.java similarity index 86% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/services/GreedyService.java rename to src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/GreedyService.java index 7c87ec5d..75560ca1 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/GreedyService.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/GreedyService.java @@ -1,8 +1,8 @@ -package edu.university.ecs.lab.detection.antipatterns.services; +package edu.university.ecs.lab.detection_old.antipatterns.services; import edu.university.ecs.lab.common.models.ir.Microservice; -import edu.university.ecs.lab.common.models.sdg.ServiceDependencyGraph; -import edu.university.ecs.lab.detection.antipatterns.models.GreedyMicroservice; +import edu.university.ecs.lab.detection.models.sdg.ServiceDependencyGraph; +import edu.university.ecs.lab.detection.models.results.antipatterns.GreedyMicroservice; import java.util.List; import java.util.stream.Collectors; diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/HubLikeService.java b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/HubLikeService.java similarity index 87% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/services/HubLikeService.java rename to src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/HubLikeService.java index 5ad2899f..7fc1f984 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/HubLikeService.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/HubLikeService.java @@ -1,8 +1,8 @@ -package edu.university.ecs.lab.detection.antipatterns.services; +package edu.university.ecs.lab.detection_old.antipatterns.services; import edu.university.ecs.lab.common.models.ir.Microservice; -import edu.university.ecs.lab.common.models.sdg.ServiceDependencyGraph; -import edu.university.ecs.lab.detection.antipatterns.models.HubLikeMicroservice; +import edu.university.ecs.lab.detection.models.sdg.ServiceDependencyGraph; +import edu.university.ecs.lab.detection.models.results.antipatterns.HubLikeMicroservice; import java.util.List; import java.util.stream.Collectors; diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/NoApiGatewayService.java b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/NoApiGatewayService.java similarity index 93% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/services/NoApiGatewayService.java rename to src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/NoApiGatewayService.java index fc761368..7278aa2f 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/NoApiGatewayService.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/NoApiGatewayService.java @@ -1,4 +1,4 @@ -package edu.university.ecs.lab.detection.antipatterns.services; +package edu.university.ecs.lab.detection_old.antipatterns.services; import com.google.gson.JsonObject; @@ -6,7 +6,7 @@ import edu.university.ecs.lab.common.models.ir.ConfigFile; import edu.university.ecs.lab.common.models.ir.Microservice; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; -import edu.university.ecs.lab.detection.antipatterns.models.NoApiGateway; +import edu.university.ecs.lab.detection.models.results.antipatterns.NoApiGateway; /** * Service class to detect the presence of an API Gateway configuration in a YAML file. diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/NoHealthcheckService.java b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/NoHealthcheckService.java similarity index 97% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/services/NoHealthcheckService.java rename to src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/NoHealthcheckService.java index f512d6be..6c43044b 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/NoHealthcheckService.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/NoHealthcheckService.java @@ -1,4 +1,4 @@ -package edu.university.ecs.lab.detection.antipatterns.services; +package edu.university.ecs.lab.detection_old.antipatterns.services; import java.util.Map; import java.util.HashMap; @@ -9,7 +9,7 @@ import edu.university.ecs.lab.common.models.ir.ConfigFile; import edu.university.ecs.lab.common.models.ir.Microservice; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; -import edu.university.ecs.lab.detection.antipatterns.models.NoHealthcheck; +import edu.university.ecs.lab.detection.models.results.antipatterns.NoHealthcheck; /** diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/ServiceChainMSLevelService.java b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/ServiceChainMSLevelService.java similarity index 94% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/services/ServiceChainMSLevelService.java rename to src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/ServiceChainMSLevelService.java index 78525fa0..3d6e3821 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/ServiceChainMSLevelService.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/ServiceChainMSLevelService.java @@ -1,8 +1,8 @@ -package edu.university.ecs.lab.detection.antipatterns.services; +package edu.university.ecs.lab.detection_old.antipatterns.services; import edu.university.ecs.lab.common.models.ir.Microservice; -import edu.university.ecs.lab.common.models.sdg.ServiceDependencyGraph; -import edu.university.ecs.lab.detection.antipatterns.models.ServiceChain; +import edu.university.ecs.lab.detection.models.sdg.ServiceDependencyGraph; +import edu.university.ecs.lab.detection.models.results.antipatterns.ServiceChain; import java.util.*; diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/ServiceChainMethodLevelService.java b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/ServiceChainMethodLevelService.java similarity index 92% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/services/ServiceChainMethodLevelService.java rename to src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/ServiceChainMethodLevelService.java index 5531511d..1f9aaa81 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/ServiceChainMethodLevelService.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/ServiceChainMethodLevelService.java @@ -1,8 +1,8 @@ -package edu.university.ecs.lab.detection.antipatterns.services; +package edu.university.ecs.lab.detection_old.antipatterns.services; import edu.university.ecs.lab.common.models.ir.Method; -import edu.university.ecs.lab.common.models.sdg.MethodDependencyGraph; -import edu.university.ecs.lab.detection.antipatterns.models.ServiceChain; +import edu.university.ecs.lab.detection.models.sdg.MethodDependencyGraph; +import edu.university.ecs.lab.detection.models.results.antipatterns.ServiceChain; import java.util.*; diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/WobblyServiceInteractionService.java b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/WobblyServiceInteractionService.java similarity index 95% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/services/WobblyServiceInteractionService.java rename to src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/WobblyServiceInteractionService.java index 97762cfe..40639095 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/WobblyServiceInteractionService.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/WobblyServiceInteractionService.java @@ -1,11 +1,11 @@ -package edu.university.ecs.lab.detection.antipatterns.services; +package edu.university.ecs.lab.detection_old.antipatterns.services; import edu.university.ecs.lab.common.models.ir.Annotation; import edu.university.ecs.lab.common.models.ir.JClass; import edu.university.ecs.lab.common.models.ir.Method; import edu.university.ecs.lab.common.models.ir.Microservice; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; -import edu.university.ecs.lab.detection.antipatterns.models.WobblyServiceInteraction; +import edu.university.ecs.lab.detection.models.results.antipatterns.WobblyServiceInteraction; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/WrongCutsService.java b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/WrongCutsService.java similarity index 88% rename from src/main/java/edu/university/ecs/lab/detection/antipatterns/services/WrongCutsService.java rename to src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/WrongCutsService.java index 191b2ad2..1aff85b8 100644 --- a/src/main/java/edu/university/ecs/lab/detection/antipatterns/services/WrongCutsService.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/WrongCutsService.java @@ -1,8 +1,8 @@ -package edu.university.ecs.lab.detection.antipatterns.services; +package edu.university.ecs.lab.detection_old.antipatterns.services; import edu.university.ecs.lab.common.models.ir.Microservice; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; -import edu.university.ecs.lab.detection.antipatterns.models.WrongCuts; +import edu.university.ecs.lab.detection.models.results.antipatterns.WrongCuts; import java.util.*; diff --git a/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/package-info.java b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/package-info.java new file mode 100644 index 00000000..4bac219a --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection_old/antipatterns/services/package-info.java @@ -0,0 +1,29 @@ +/** + * Provides services for detecting and analyzing various anti-patterns in microservices architecture. + * These services encapsulate logic for identifying specific issues within microservice systems and + * generating reports or performing corrective actions. + *

+ * Services: + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.CyclicDependencyMethodLevelService}: Service for detecting + * cyclic dependencies within a method network graph. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.CyclicDependencyMSLevelService}: Service for detecting + * cyclic dependencies within a microservice network graph. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.GreedyService}: Service for identifying and managing + * microservices identified as greedy based on REST call thresholds. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.HubLikeService}: Service for identifying and managing + * microservices identified as hub-like based on REST call thresholds. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.ServiceChainMethodLevelService}: Service for detecting and managing + * service chains within a method network graph. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.ServiceChainMSLevelService}: Service for detecting and managing + * service chains within a microservice network graph. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.WrongCutsService}: Service for identifying and reporting + * clusters of services that are incorrectly interconnected within a microservice network graph. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.WobblyServiceInteractionService}: Service for detecting + * wobbly service interactions within a microservice system based on specific annotations. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.NoApiGatewayService}: Service for checking the presence of an + * API gateway configuration in a YAML file. + * - {@link edu.university.ecs.lab.detection_old.antipatterns.services.NoHealthcheckService}: Service for checking the presence of + * health check configurations in a YAML file. + *

+ */ +package edu.university.ecs.lab.detection_old.antipatterns.services; diff --git a/src/main/java/edu/university/ecs/lab/detection_old/architecture/package-info.java b/src/main/java/edu/university/ecs/lab/detection_old/architecture/package-info.java new file mode 100644 index 00000000..f990f1f3 --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection_old/architecture/package-info.java @@ -0,0 +1,10 @@ +/** + * Provides classes and related services for detecting architectural rules and related information in a microservice system. + * + *

This package includes: + * - {@link edu.university.ecs.lab.detection_old.architecture.models}: Contains classes that represent each individual architectural rule and the logic for detection in the microservice system. + * - {@link edu.university.ecs.lab.detection_old.architecture.services}: Provides tools scanning the entire microservice system at each Delta and checking for all the architectural rules. + *

+ */ + +package edu.university.ecs.lab.detection_old.architecture; diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/services/ARDetectionService.java b/src/main/java/edu/university/ecs/lab/detection_old/architecture/services/ARDetectionService.java similarity index 94% rename from src/main/java/edu/university/ecs/lab/detection/architecture/services/ARDetectionService.java rename to src/main/java/edu/university/ecs/lab/detection_old/architecture/services/ARDetectionService.java index 4b385b7b..a7c3543c 100644 --- a/src/main/java/edu/university/ecs/lab/detection/architecture/services/ARDetectionService.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/architecture/services/ARDetectionService.java @@ -1,11 +1,13 @@ -package edu.university.ecs.lab.detection.architecture.services; +package edu.university.ecs.lab.detection_old.architecture.services; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; import edu.university.ecs.lab.delta.models.Delta; import edu.university.ecs.lab.delta.models.SystemChange; -import edu.university.ecs.lab.detection.architecture.models.*; +import edu.university.ecs.lab.detection.models.architecture.*; +import edu.university.ecs.lab.detection.models.results.architecture.*; +import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -24,7 +26,7 @@ public class ARDetectionService { * @param OldIRPath path to old commit JSON file * @param NewIRPath path to new commit JSON file */ - public ARDetectionService(String DeltaPath, String OldIRPath, String NewIRPath) { + public ARDetectionService(String DeltaPath, String OldIRPath, String NewIRPath) throws IOException { oldSystem = JsonReadWriteUtils.readFromJSON(DeltaPath, SystemChange.class); microserviceSystemOld = JsonReadWriteUtils.readFromJSON(OldIRPath, MicroserviceSystem.class); microserviceSystemNew = JsonReadWriteUtils.readFromJSON(NewIRPath, MicroserviceSystem.class); diff --git a/src/main/java/edu/university/ecs/lab/detection/architecture/services/package-info.java b/src/main/java/edu/university/ecs/lab/detection_old/architecture/services/package-info.java similarity index 81% rename from src/main/java/edu/university/ecs/lab/detection/architecture/services/package-info.java rename to src/main/java/edu/university/ecs/lab/detection_old/architecture/services/package-info.java index 89b61ca4..91c1d91c 100644 --- a/src/main/java/edu/university/ecs/lab/detection/architecture/services/package-info.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/architecture/services/package-info.java @@ -3,9 +3,9 @@ * Includes utilities for reading system changes and microservice snapshots, * and utilizes specific architectural rule classes for detection. * - *

The main class in this package is {@link edu.university.ecs.lab.detection.architecture.services.ARDetectionService}, + *

The main class in this package is {@link edu.university.ecs.lab.detection_old.architecture.services.ARDetectionService}, * which orchestrates the detection process by scanning {@link edu.university.ecs.lab.delta.models.Delta} changes * and comparing {@link edu.university.ecs.lab.common.models.ir.MicroserviceSystem} instances to identify instances * of architectural rules.

*/ -package edu.university.ecs.lab.detection.architecture.services; +package edu.university.ecs.lab.detection_old.architecture.services; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/MetricCalculation.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/MetricCalculation.java similarity index 82% rename from src/main/java/edu/university/ecs/lab/detection/metrics/MetricCalculation.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/MetricCalculation.java index ab2254aa..f9c1c563 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/MetricCalculation.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/MetricCalculation.java @@ -1,16 +1,18 @@ -package edu.university.ecs.lab.detection.metrics; +package edu.university.ecs.lab.detection_old.metrics; import edu.university.ecs.lab.common.config.Config; import edu.university.ecs.lab.common.config.ConfigUtil; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; -import edu.university.ecs.lab.common.models.sdg.ServiceDependencyGraph; +import edu.university.ecs.lab.detection.models.sdg.ServiceDependencyGraph; import edu.university.ecs.lab.common.utils.FileUtils; import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -import edu.university.ecs.lab.detection.metrics.models.ConnectedComponentsModularity; -import edu.university.ecs.lab.detection.metrics.models.DegreeCoupling; -import edu.university.ecs.lab.detection.metrics.models.StructuralCoupling; +import edu.university.ecs.lab.detection_old.metrics.models.ConnectedComponentsModularity; +import edu.university.ecs.lab.detection_old.metrics.models.DegreeCoupling; +import edu.university.ecs.lab.detection_old.metrics.models.StructuralCoupling; import edu.university.ecs.lab.intermediate.create.services.IRExtractionService; +import org.eclipse.jgit.api.errors.GitAPIException; +import java.io.IOException; import java.util.Optional; /** @@ -18,7 +20,7 @@ */ public class MetricCalculation { - public static void main(String[] args) { + public static void main(String[] args) throws IOException, GitAPIException, InterruptedException { Config config = ConfigUtil.readConfig("./config.json"); // Create IR of first commit @@ -60,7 +62,7 @@ public static void main(String[] args) { System.out.printf("Amount of Strongly Connected Components: %d%n", m.getSCC().size()); System.out.printf("Modularity of Strongly Connected Components: %.2f%n", m.getModularity()); } - private static void createIRSystem(Config config, String fileName) { + private static void createIRSystem(Config config, String fileName) throws GitAPIException, IOException, InterruptedException { // Create both directories needed FileUtils.makeDirs(); diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/RunCohesionMetrics.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/RunCohesionMetrics.java similarity index 81% rename from src/main/java/edu/university/ecs/lab/detection/metrics/RunCohesionMetrics.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/RunCohesionMetrics.java index d69feedf..734e822c 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/RunCohesionMetrics.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/RunCohesionMetrics.java @@ -1,14 +1,15 @@ -package edu.university.ecs.lab.detection.metrics; +package edu.university.ecs.lab.detection_old.metrics; import edu.university.ecs.lab.common.models.ir.*; import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -import edu.university.ecs.lab.detection.metrics.models.IServiceDescriptor; -import edu.university.ecs.lab.detection.metrics.models.Operation; -import edu.university.ecs.lab.detection.metrics.models.Parameter; -import edu.university.ecs.lab.detection.metrics.models.ServiceDescriptor; -import edu.university.ecs.lab.detection.metrics.services.MetricCalculator; -import edu.university.ecs.lab.detection.metrics.services.MetricResult; -import edu.university.ecs.lab.detection.metrics.services.MetricResultCalculation; +import edu.university.ecs.lab.detection_old.metrics.models.IServiceDescriptor; +import edu.university.ecs.lab.detection_old.metrics.models.Operation; +import edu.university.ecs.lab.detection_old.metrics.models.ServiceDescriptor; +import edu.university.ecs.lab.detection_old.metrics.services.MetricCalculator; +import edu.university.ecs.lab.detection_old.metrics.services.MetricResult; +import edu.university.ecs.lab.detection_old.metrics.services.MetricResultCalculation; + +import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -17,7 +18,7 @@ */ public class RunCohesionMetrics { - public static void main(String[] args) { + public static void main(String[] args) throws IOException { calculateCohesionMetrics("./output/OldIR.json"); } @@ -27,7 +28,7 @@ public static void main(String[] args) { * @param IRPath path to intermediate representation JSON * @return metric result calculation object */ - public static MetricResultCalculation calculateCohesionMetrics(String IRPath) { + public static MetricResultCalculation calculateCohesionMetrics(String IRPath) throws IOException { // Create microservice system object MicroserviceSystem microserviceSystem = JsonReadWriteUtils.readFromJSON(IRPath, MicroserviceSystem.class); diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/models/ConnectedComponentsModularity.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/ConnectedComponentsModularity.java similarity index 88% rename from src/main/java/edu/university/ecs/lab/detection/metrics/models/ConnectedComponentsModularity.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/models/ConnectedComponentsModularity.java index 558a3bf3..390e4f1b 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/models/ConnectedComponentsModularity.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/ConnectedComponentsModularity.java @@ -1,8 +1,8 @@ -package edu.university.ecs.lab.detection.metrics.models; +package edu.university.ecs.lab.detection_old.metrics.models; import edu.university.ecs.lab.common.models.ir.Microservice; -import edu.university.ecs.lab.common.models.sdg.RestCallEdge; -import edu.university.ecs.lab.common.models.sdg.ServiceDependencyGraph; +import edu.university.ecs.lab.detection.models.sdg.RestCallEdge; +import edu.university.ecs.lab.detection.models.sdg.ServiceDependencyGraph; import lombok.Getter; import org.jgrapht.alg.clustering.UndirectedModularityMeasurer; import org.jgrapht.alg.connectivity.KosarajuStrongConnectivityInspector; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/models/DegreeCoupling.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/DegreeCoupling.java similarity index 97% rename from src/main/java/edu/university/ecs/lab/detection/metrics/models/DegreeCoupling.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/models/DegreeCoupling.java index ed1e6039..b57e6de6 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/models/DegreeCoupling.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/DegreeCoupling.java @@ -1,7 +1,7 @@ -package edu.university.ecs.lab.detection.metrics.models; +package edu.university.ecs.lab.detection_old.metrics.models; import edu.university.ecs.lab.common.models.ir.Microservice; -import edu.university.ecs.lab.common.models.sdg.ServiceDependencyGraph; +import edu.university.ecs.lab.detection.models.sdg.ServiceDependencyGraph; import java.util.Comparator; import java.util.HashMap; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/models/IInputFile.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/IInputFile.java similarity index 77% rename from src/main/java/edu/university/ecs/lab/detection/metrics/models/IInputFile.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/models/IInputFile.java index 415d03bf..e876860e 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/models/IInputFile.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/IInputFile.java @@ -1,4 +1,4 @@ -package edu.university.ecs.lab.detection.metrics.models; +package edu.university.ecs.lab.detection_old.metrics.models; import java.io.IOException; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/models/IServiceDescriptor.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/IServiceDescriptor.java similarity index 83% rename from src/main/java/edu/university/ecs/lab/detection/metrics/models/IServiceDescriptor.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/models/IServiceDescriptor.java index 81dcb8d2..0b8dcdf5 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/models/IServiceDescriptor.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/IServiceDescriptor.java @@ -1,4 +1,4 @@ -package edu.university.ecs.lab.detection.metrics.models; +package edu.university.ecs.lab.detection_old.metrics.models; import java.util.List; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/models/IServiceDescriptorBuilder.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/IServiceDescriptorBuilder.java similarity index 72% rename from src/main/java/edu/university/ecs/lab/detection/metrics/models/IServiceDescriptorBuilder.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/models/IServiceDescriptorBuilder.java index 93250b35..773f3803 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/models/IServiceDescriptorBuilder.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/IServiceDescriptorBuilder.java @@ -1,4 +1,4 @@ -package edu.university.ecs.lab.detection.metrics.models; +package edu.university.ecs.lab.detection_old.metrics.models; import java.io.IOException; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/models/Operation.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/Operation.java similarity index 96% rename from src/main/java/edu/university/ecs/lab/detection/metrics/models/Operation.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/models/Operation.java index 9d277146..9f2d4b87 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/models/Operation.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/Operation.java @@ -1,4 +1,4 @@ -package edu.university.ecs.lab.detection.metrics.models; +package edu.university.ecs.lab.detection_old.metrics.models; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/models/Parameter.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/Parameter.java similarity index 94% rename from src/main/java/edu/university/ecs/lab/detection/metrics/models/Parameter.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/models/Parameter.java index 3e87c382..cc2f7b50 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/models/Parameter.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/Parameter.java @@ -1,4 +1,4 @@ -package edu.university.ecs.lab.detection.metrics.models; +package edu.university.ecs.lab.detection_old.metrics.models; import java.util.List; import java.util.stream.Collectors; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/models/ServiceDescriptor.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/ServiceDescriptor.java similarity index 96% rename from src/main/java/edu/university/ecs/lab/detection/metrics/models/ServiceDescriptor.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/models/ServiceDescriptor.java index 9d84f8b6..77b94d57 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/models/ServiceDescriptor.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/ServiceDescriptor.java @@ -1,4 +1,4 @@ -package edu.university.ecs.lab.detection.metrics.models; +package edu.university.ecs.lab.detection_old.metrics.models; import java.io.IOException; import java.util.ArrayList; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/models/Statements.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/Statements.java similarity index 63% rename from src/main/java/edu/university/ecs/lab/detection/metrics/models/Statements.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/models/Statements.java index cdda1a7d..58d7ed01 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/models/Statements.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/Statements.java @@ -1,4 +1,4 @@ -package edu.university.ecs.lab.detection.metrics.models; +package edu.university.ecs.lab.detection_old.metrics.models; public enum Statements { OPERATION_NAME, OPERATION_USE_OF_TYPE, OPERATION_PARAM, BLANK, SERVICE_NAME diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/models/StructuralCoupling.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/StructuralCoupling.java similarity index 97% rename from src/main/java/edu/university/ecs/lab/detection/metrics/models/StructuralCoupling.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/models/StructuralCoupling.java index 82f9c67c..568ccbfa 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/models/StructuralCoupling.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/StructuralCoupling.java @@ -1,7 +1,7 @@ -package edu.university.ecs.lab.detection.metrics.models; +package edu.university.ecs.lab.detection_old.metrics.models; import edu.university.ecs.lab.common.models.ir.Microservice; -import edu.university.ecs.lab.common.models.sdg.ServiceDependencyGraph; +import edu.university.ecs.lab.detection.models.sdg.ServiceDependencyGraph; import lombok.Getter; import java.util.*; diff --git a/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/package-info.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/package-info.java new file mode 100644 index 00000000..a9610a14 --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/models/package-info.java @@ -0,0 +1,25 @@ +/** + * This package contains classes that represent models used for calculating various metrics related to microservices + * and service dependency graphs. + *

+ * This package includes: + * - {@link edu.university.ecs.lab.detection_old.metrics.models.ConnectedComponentsModularity}: + * Contains the implementation of the modularity metric of partitioning a graph into strongly connected components. + * - {@link edu.university.ecs.lab.detection_old.metrics.models.DegreeCoupling}: + * Contains the calculation of degree-related Coupling metrics. + * - {@link edu.university.ecs.lab.detection_old.metrics.models.IInputFile}: + * Represents an input file of different formats and creates a Service Descriptor object. + * - {@link edu.university.ecs.lab.detection_old.metrics.models.IServiceDescriptor}: + * Represents a service descriptor interface defining methods for service name, version, operations, and their types. + * - {@link edu.university.ecs.lab.detection_old.metrics.models.IServiceDescriptorBuilder}: Provides a method to build a service descriptor from a file path. + * - {@link edu.university.ecs.lab.detection_old.metrics.models.Operation}: + * Represents an operation of a microservice with parameters, using types, response type, and path. + * - {@link edu.university.ecs.lab.detection_old.metrics.models.Parameter}: + * Represents a parameter of a method or operation. + * - {@link edu.university.ecs.lab.detection_old.metrics.models.ServiceDescriptor}: + * - {@link edu.university.ecs.lab.detection_old.metrics.models.Statements}: Enumerates various statements or types used within the metrics calculation context. + * Represents a service descriptor with service name, operations, and version. + * - {@link edu.university.ecs.lab.detection_old.metrics.models.StructuralCoupling}: Contains the implementation of the Structural Coupling Metric. + *

+ */ +package edu.university.ecs.lab.detection_old.metrics.models; diff --git a/src/main/java/edu/university/ecs/lab/detection_old/metrics/package-info.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/package-info.java new file mode 100644 index 00000000..b73a8886 --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/package-info.java @@ -0,0 +1,17 @@ +/** + * This package contains classes and utilities for calculating various metrics related to microservices + * and service dependency graphs. + *

+ * This package include: + * - {@link edu.university.ecs.lab.detection_old.metrics.MetricCalculation}: Calculates structural and degree coupling metrics, + * and modularity metrics for a microservice system based on service dependency graph (SDG). + * - {@link edu.university.ecs.lab.detection_old.metrics.RunCohesionMetrics}: Calculates cohesion metrics for a microservice system + * based on its intermediate representation (IR). + * - {@link edu.university.ecs.lab.detection_old.metrics.models}: Contains models used in metric calculations. + * - {@link edu.university.ecs.lab.detection_old.metrics.services}: Contains services for calculating and aggregating metric results. + * - {@link edu.university.ecs.lab.detection_old.metrics.utils}: Contains utility classes for common operations related to metric calculations. + *

+ * The main purpose of this package is to provide tools for assessing the architecture and design quality of microservice systems + * through various quantitative metrics. + */ +package edu.university.ecs.lab.detection_old.metrics; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/services/AbstractMetric.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/AbstractMetric.java similarity index 87% rename from src/main/java/edu/university/ecs/lab/detection/metrics/services/AbstractMetric.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/services/AbstractMetric.java index 51d410db..39358d9d 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/services/AbstractMetric.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/AbstractMetric.java @@ -1,6 +1,6 @@ -package edu.university.ecs.lab.detection.metrics.services; +package edu.university.ecs.lab.detection_old.metrics.services; -import edu.university.ecs.lab.detection.metrics.models.IServiceDescriptor; +import edu.university.ecs.lab.detection_old.metrics.models.IServiceDescriptor; /** * Abstract metric class template for all metrics diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/services/IMetric.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/IMetric.java similarity index 74% rename from src/main/java/edu/university/ecs/lab/detection/metrics/services/IMetric.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/services/IMetric.java index ee424ca3..30dbda8b 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/services/IMetric.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/IMetric.java @@ -1,9 +1,9 @@ /** * */ -package edu.university.ecs.lab.detection.metrics.services; +package edu.university.ecs.lab.detection_old.metrics.services; -import edu.university.ecs.lab.detection.metrics.models.IServiceDescriptor; +import edu.university.ecs.lab.detection_old.metrics.models.IServiceDescriptor; /** * @author Mateus Gabi Moreira diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/services/LackOfMessageLevelCohesion.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/LackOfMessageLevelCohesion.java similarity index 93% rename from src/main/java/edu/university/ecs/lab/detection/metrics/services/LackOfMessageLevelCohesion.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/services/LackOfMessageLevelCohesion.java index 662b4740..a067123c 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/services/LackOfMessageLevelCohesion.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/LackOfMessageLevelCohesion.java @@ -1,9 +1,8 @@ -package edu.university.ecs.lab.detection.metrics.services; +package edu.university.ecs.lab.detection_old.metrics.services; -import edu.university.ecs.lab.detection.metrics.models.IServiceDescriptor; -import edu.university.ecs.lab.detection.metrics.models.Operation; -import edu.university.ecs.lab.detection.metrics.models.Parameter; -import edu.university.ecs.lab.detection.metrics.utils.Utils; +import edu.university.ecs.lab.detection_old.metrics.models.IServiceDescriptor; +import edu.university.ecs.lab.detection_old.metrics.models.Operation; +import edu.university.ecs.lab.detection_old.metrics.utils.Utils; import java.util.ArrayList; import java.util.HashSet; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/services/MetricCalculator.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/MetricCalculator.java similarity index 89% rename from src/main/java/edu/university/ecs/lab/detection/metrics/services/MetricCalculator.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/services/MetricCalculator.java index c6d99d6a..0314b88a 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/services/MetricCalculator.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/MetricCalculator.java @@ -1,6 +1,6 @@ -package edu.university.ecs.lab.detection.metrics.services; +package edu.university.ecs.lab.detection_old.metrics.services; -import edu.university.ecs.lab.detection.metrics.models.IServiceDescriptor; +import edu.university.ecs.lab.detection_old.metrics.models.IServiceDescriptor; import java.util.Arrays; import java.util.List; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/services/MetricResult.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/MetricResult.java similarity index 96% rename from src/main/java/edu/university/ecs/lab/detection/metrics/services/MetricResult.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/services/MetricResult.java index a9e0e68d..8ba5874e 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/services/MetricResult.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/MetricResult.java @@ -1,4 +1,4 @@ -package edu.university.ecs.lab.detection.metrics.services; +package edu.university.ecs.lab.detection_old.metrics.services; /** * Result of a single metric calculation diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/services/MetricResultCalculation.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/MetricResultCalculation.java similarity index 97% rename from src/main/java/edu/university/ecs/lab/detection/metrics/services/MetricResultCalculation.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/services/MetricResultCalculation.java index aa84d315..76d98617 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/services/MetricResultCalculation.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/MetricResultCalculation.java @@ -1,4 +1,4 @@ -package edu.university.ecs.lab.detection.metrics.services; +package edu.university.ecs.lab.detection_old.metrics.services; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/services/NumberOfOperations.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/NumberOfOperations.java similarity index 85% rename from src/main/java/edu/university/ecs/lab/detection/metrics/services/NumberOfOperations.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/services/NumberOfOperations.java index 95212972..61f01ea1 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/services/NumberOfOperations.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/NumberOfOperations.java @@ -1,6 +1,6 @@ -package edu.university.ecs.lab.detection.metrics.services; +package edu.university.ecs.lab.detection_old.metrics.services; -import edu.university.ecs.lab.detection.metrics.models.IServiceDescriptor; +import edu.university.ecs.lab.detection_old.metrics.models.IServiceDescriptor; /** * Metric Service Class to determine the Number of Operations in a microservice diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/services/ServiceInterfaceDataCohesion.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/ServiceInterfaceDataCohesion.java similarity index 89% rename from src/main/java/edu/university/ecs/lab/detection/metrics/services/ServiceInterfaceDataCohesion.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/services/ServiceInterfaceDataCohesion.java index faa583c5..f9d6f509 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/services/ServiceInterfaceDataCohesion.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/ServiceInterfaceDataCohesion.java @@ -1,9 +1,8 @@ -package edu.university.ecs.lab.detection.metrics.services; +package edu.university.ecs.lab.detection_old.metrics.services; -import edu.university.ecs.lab.detection.metrics.models.IServiceDescriptor; -import edu.university.ecs.lab.detection.metrics.models.Operation; -import edu.university.ecs.lab.detection.metrics.models.Parameter; -import edu.university.ecs.lab.detection.metrics.utils.Utils; +import edu.university.ecs.lab.detection_old.metrics.models.IServiceDescriptor; +import edu.university.ecs.lab.detection_old.metrics.models.Operation; +import edu.university.ecs.lab.detection_old.metrics.utils.Utils; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/services/StrictServiceImplementationCohesion.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/StrictServiceImplementationCohesion.java similarity index 91% rename from src/main/java/edu/university/ecs/lab/detection/metrics/services/StrictServiceImplementationCohesion.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/services/StrictServiceImplementationCohesion.java index 4bfea4d9..988e091b 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/services/StrictServiceImplementationCohesion.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/StrictServiceImplementationCohesion.java @@ -1,11 +1,11 @@ /** * */ -package edu.university.ecs.lab.detection.metrics.services; +package edu.university.ecs.lab.detection_old.metrics.services; -import edu.university.ecs.lab.detection.metrics.models.IServiceDescriptor; -import edu.university.ecs.lab.detection.metrics.models.Operation; -import edu.university.ecs.lab.detection.metrics.utils.Utils; +import edu.university.ecs.lab.detection_old.metrics.models.IServiceDescriptor; +import edu.university.ecs.lab.detection_old.metrics.models.Operation; +import edu.university.ecs.lab.detection_old.metrics.utils.Utils; import java.util.List; import java.util.stream.Collectors; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/services/package-info.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/package-info.java similarity index 52% rename from src/main/java/edu/university/ecs/lab/detection/metrics/services/package-info.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/services/package-info.java index 59174db7..024dcd7a 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/services/package-info.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/services/package-info.java @@ -3,24 +3,24 @@ * and service dependency graphs. *

* This package includes: - * - {@link edu.university.ecs.lab.detection.metrics.services.AbstractMetric}: + * - {@link edu.university.ecs.lab.detection_old.metrics.services.AbstractMetric}: * Contains an Abstract class providing a base for implementing metrics. - * - {@link edu.university.ecs.lab.detection.metrics.services.IMetric}: + * - {@link edu.university.ecs.lab.detection_old.metrics.services.IMetric}: * Contains an interface defining methods for metric calculation. - * - {@link edu.university.ecs.lab.detection.metrics.services.LackOfMessageLevelCohesion}: + * - {@link edu.university.ecs.lab.detection_old.metrics.services.LackOfMessageLevelCohesion}: * Contains a service calculating the Lack of Message-Level Cohesion (LMC) metric between microservices operations. - * - {@link edu.university.ecs.lab.detection.metrics.services.MetricCalculator}: + * - {@link edu.university.ecs.lab.detection_old.metrics.services.MetricCalculator}: * Contains a utility class that orchestrates the evaluation of multiple metrics for a given service descriptor. - * - {@link edu.university.ecs.lab.detection.metrics.services.MetricResult}: + * - {@link edu.university.ecs.lab.detection_old.metrics.services.MetricResult}: * Represents the result of a single metric calculation. - * - {@link edu.university.ecs.lab.detection.metrics.services.MetricResultCalculation}: + * - {@link edu.university.ecs.lab.detection_old.metrics.services.MetricResultCalculation}: * Contains the aggregation and calculation overall metric results. - * - {@link edu.university.ecs.lab.detection.metrics.services.NumberOfOperations}: + * - {@link edu.university.ecs.lab.detection_old.metrics.services.NumberOfOperations}: * Contains a service calculating the total number of operations within a microservice. - * - {@link edu.university.ecs.lab.detection.metrics.services.ServiceInterfaceDataCohesion}: + * - {@link edu.university.ecs.lab.detection_old.metrics.services.ServiceInterfaceDataCohesion}: * Contains a service Interface Data Cohesion (SIDC) metric calculation service. - * - {@link edu.university.ecs.lab.detection.metrics.services.StrictServiceImplementationCohesion}: + * - {@link edu.university.ecs.lab.detection_old.metrics.services.StrictServiceImplementationCohesion}: * Contains the Strict Service Implementation Cohesion (SSIC) metric calculation service. *

*/ -package edu.university.ecs.lab.detection.metrics.services; +package edu.university.ecs.lab.detection_old.metrics.services; diff --git a/src/main/java/edu/university/ecs/lab/detection/metrics/utils/Utils.java b/src/main/java/edu/university/ecs/lab/detection_old/metrics/utils/Utils.java similarity index 88% rename from src/main/java/edu/university/ecs/lab/detection/metrics/utils/Utils.java rename to src/main/java/edu/university/ecs/lab/detection_old/metrics/utils/Utils.java index da39b07b..a13e3c7e 100644 --- a/src/main/java/edu/university/ecs/lab/detection/metrics/utils/Utils.java +++ b/src/main/java/edu/university/ecs/lab/detection_old/metrics/utils/Utils.java @@ -1,4 +1,4 @@ -package edu.university.ecs.lab.detection.metrics.utils; +package edu.university.ecs.lab.detection_old.metrics.utils; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/edu/university/ecs/lab/detection_old/package-info.java b/src/main/java/edu/university/ecs/lab/detection_old/package-info.java new file mode 100644 index 00000000..bc8fe0db --- /dev/null +++ b/src/main/java/edu/university/ecs/lab/detection_old/package-info.java @@ -0,0 +1,14 @@ +/** + * Provides classes and related services for detecting trends and information in a microservice system. + * This package includes functionality for detecting antipatterns, broken architectural rules, and related metrics. + * + *

This package includes: + * - {@link edu.university.ecs.lab.detection_old.antipatterns}: Contains classes for detecting common antipatterns in microservice architectures. + * - {@link edu.university.ecs.lab.detection_old.architecture}: Provides tools for analyzing and evaluating architecture rules of microservice architecture. + * - {@link edu.university.ecs.lab.detection_old.metrics}: Includes classes for gathering and analyzing various metrics from microservice systems. + * - {@link edu.university.ecs.lab.detection_old.ExcelOutputRunner}: Contains the main class for generating Excel reports of detected trends and metrics. + * - {@link edu.university.ecs.lab.detection_old.DetectionService}: Contains the main class for detecting and analyzing architectural rules. + + *

+ */ +package edu.university.ecs.lab.detection_old; diff --git a/src/main/java/edu/university/ecs/lab/intermediate/create/IRExtractionRunner.java b/src/main/java/edu/university/ecs/lab/intermediate/create/IRExtractionRunner.java deleted file mode 100644 index 5ce5b18f..00000000 --- a/src/main/java/edu/university/ecs/lab/intermediate/create/IRExtractionRunner.java +++ /dev/null @@ -1,40 +0,0 @@ -package edu.university.ecs.lab.intermediate.create; - -import edu.university.ecs.lab.common.error.Error; -import edu.university.ecs.lab.common.services.LoggerManager; -import edu.university.ecs.lab.common.utils.FileUtils; -import edu.university.ecs.lab.intermediate.create.services.IRExtractionService; - -import java.util.Arrays; -import java.util.Optional; - - -/** - * - *

The IR extraction process is responsible for cloning remote services, scanning through each - * local repo and extracting rest endpoints/calls, and writing each service and endpoints to - * intermediate representation.

- */ -public class IRExtractionRunner { - - /** - * Intermediate extraction runner, generates IR from remote repository and writes to file. - * - */ - public static void main(String[] args) throws Exception { - args = new String[]{"./config.json"}; - String[] finalArgs = args; - LoggerManager.info(() -> "IRExtractionRunner starting... args: " + Arrays.toString(finalArgs)); - if (args.length != 1) { - Error.reportAndExit(Error.INVALID_ARGS, Optional.empty()); - } - - - // Initialize the irExtractionService - IRExtractionService irExtractionService = new IRExtractionService(args[0], Optional.empty()); - - // Generate the Intermediate Representation - irExtractionService.generateIR("IR.json"); - - } -} diff --git a/src/main/java/edu/university/ecs/lab/intermediate/create/package-info.java b/src/main/java/edu/university/ecs/lab/intermediate/create/package-info.java deleted file mode 100644 index 1f87bb35..00000000 --- a/src/main/java/edu/university/ecs/lab/intermediate/create/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This package contains the classes responsible for creating the intermediate representation (IR) from remote repositories. - * - *

This package involves using the {@link edu.university.ecs.lab.intermediate.create.services.IRExtractionService} - * to clone repositories, scan them for REST endpoints and calls, and then write the extracted data to an intermediate representation file. - * {@link edu.university.ecs.lab.intermediate.create.IRExtractionRunner} is available as a test runner.

- */ -package edu.university.ecs.lab.intermediate.create; diff --git a/src/main/java/edu/university/ecs/lab/intermediate/create/services/IRExtractionService.java b/src/main/java/edu/university/ecs/lab/intermediate/create/services/IRExtractionService.java deleted file mode 100644 index cfd4488b..00000000 --- a/src/main/java/edu/university/ecs/lab/intermediate/create/services/IRExtractionService.java +++ /dev/null @@ -1,255 +0,0 @@ -package edu.university.ecs.lab.intermediate.create.services; - -import edu.university.ecs.lab.common.config.Config; -import edu.university.ecs.lab.common.config.ConfigUtil; -import edu.university.ecs.lab.common.error.Error; -import edu.university.ecs.lab.common.models.ir.ConfigFile; -import edu.university.ecs.lab.common.models.ir.JClass; -import edu.university.ecs.lab.common.models.ir.Microservice; -import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; -import edu.university.ecs.lab.common.services.GitService; -import edu.university.ecs.lab.common.services.LoggerManager; -import edu.university.ecs.lab.common.utils.FileUtils; -import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -import edu.university.ecs.lab.common.utils.SourceToObjectUtils; -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.*; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import lombok.extern.java.Log; -import org.w3c.dom.Document; -import org.w3c.dom.NodeList; - - -/** - * Top-level service for extracting intermediate representation from remote repositories. Methods - * are allowed to exit the program with an error code if an error occurs. - */ -public class IRExtractionService { - /** - * Service to handle cloning from git - */ - private final GitService gitService; - - /** - * Configuration object - */ - private final Config config; - - /** - * CommitID of IR Extraction - */ - private final String commitID; - - /** - * This constructor initializes a new IRExtractionService and instantiates a - * GitService object for repository manipulation - * - * @param configPath path to configuration file - * @param commitID optional commitID for extraction, if empty resolves to HEAD - * @see GitService - */ - public IRExtractionService(String configPath, Optional commitID) { - gitService = new GitService(configPath); - - if(commitID.isPresent()) { - this.commitID = commitID.get(); - gitService.resetLocal(this.commitID); - } else { - this.commitID = gitService.getHeadCommit(); - } - - config = ConfigUtil.readConfig(configPath); - } - - /** - * Intermediate extraction runner, generates IR from remote repository and writes to file. - * - * @param fileName name of output file for IR extraction - */ - public void generateIR(String fileName) { - // Clone remote repositories and scan through each cloned repo to extract endpoints - Set microservices = cloneAndScanServices(); - - if (microservices.isEmpty()) { - LoggerManager.info(() -> "No microservices were found during IR Extraction!"); - } - - // Write each service and endpoints to IR - writeToFile(microservices, fileName); - - } - - /** - * Clone remote repositories and scan through each local repo and extract endpoints/calls - * - * @return a map of services and their endpoints - */ - public Set cloneAndScanServices() { - Set microservices = new HashSet<>(); - - // Clone the repository present in the configuration file - gitService.cloneRemote(); - - // Start scanning from the root directory - List rootDirectories = findRootDirectories(FileUtils.getRepositoryPath(config.getRepoName())); - List rootDirectoriesCopy = List.copyOf(rootDirectories); - - // Filter more/less specific - for(String s1 : rootDirectoriesCopy) { - for(String s2 : rootDirectoriesCopy) { - if(s1.equals(s2)) { - continue; - } else if(s1.matches(s2.replace(FileUtils.SYS_SEPARATOR, FileUtils.SPECIAL_SEPARATOR) + FileUtils.SPECIAL_SEPARATOR + ".*")) { - rootDirectories.remove(s2); - } else if(s2.matches(s1.replace(FileUtils.SYS_SEPARATOR, FileUtils.SPECIAL_SEPARATOR) + FileUtils.SPECIAL_SEPARATOR + ".*")) { - rootDirectories.remove(s1); - } - } - } - - // Scan each root directory for microservices - for (String rootDirectory : rootDirectories) { - Microservice microservice = recursivelyScanFiles(rootDirectory); - if (microservice != null) { - microservices.add(microservice); - } - } - - return microservices; - } - - /** - * Recursively search for directories containing a microservice (pom.xml file) - * - * @param directory the directory to start the search from - * @return a list of directory paths containing pom.xml - */ - private List findRootDirectories(String directory) { - List rootDirectories = new ArrayList<>(); - File root = new File(directory); - if (root.exists() && root.isDirectory()) { - // Check if the current directory contains a Dockerfile - File[] files = root.listFiles(); - boolean containsPom = false; - boolean containsGradle = false; - if (files != null) { - for (File file : files) { - if (file.isFile() && file.getName().equals("pom.xml")) { - try { - - // Create a DocumentBuilder - DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - - // Parse the XML file - Document document = builder.parse(file); - - // Normalize the XML Structure - document.getDocumentElement().normalize(); - - // Get all elements with the specific tag name - NodeList nodeList = document.getElementsByTagName("modules"); - // Check if the tag is present - if (nodeList.getLength() == 0) { - containsPom = true; - } - } catch (Exception e) { - throw new RuntimeException("Error parsing pom.xml"); - } - } else if(file.isFile() && file.getName().equals("build.gradle")) { - containsGradle = true; - } else if (file.isDirectory()) { - rootDirectories.addAll(findRootDirectories(file.getPath())); - } - } - } - if (containsPom) { - rootDirectories.add(root.getPath()); - return rootDirectories; - } else if (containsGradle){ - rootDirectories.add(root.getPath()); - return rootDirectories; - } - } - return rootDirectories; - } - - - /** - * Write each service and endpoints to intermediate representation - * - * @param microservices a list of microservices extracted from repository - * @param fileName the name of the output file for IR - */ - private void writeToFile(Set microservices, String fileName) { - - MicroserviceSystem microserviceSystem = new MicroserviceSystem(config.getSystemName(), commitID, microservices, new HashSet<>()); - - JsonReadWriteUtils.writeToJSON(fileName, microserviceSystem.toJsonObject()); - - LoggerManager.info(() -> "Successfully extracted IR at " + commitID); - } - - /** - * Recursively scan the files in the given repository path and extract the endpoints and - * dependencies for a single microservice. - * - * @return model of a single service containing the extracted endpoints and dependencies - */ - public Microservice recursivelyScanFiles(String rootMicroservicePath) { - // Validate path exists and is a directory - File localDir = new File(rootMicroservicePath); - if (!localDir.exists() || !localDir.isDirectory()) { - Error.reportAndExit(Error.INVALID_REPO_PATHS, Optional.empty()); - } - - - Microservice model = new Microservice(FileUtils.getMicroserviceNameFromPath(rootMicroservicePath), - FileUtils.localPathToGitPath(rootMicroservicePath, config.getRepoName())); - scanDirectory(localDir, model); - - LoggerManager.info(() -> "Done scanning directory " + rootMicroservicePath); - return model; - } - - /** - * Recursively scan the given directory for files and extract the endpoints and dependencies. - * - * @param directory the directory to scan - */ - public void scanDirectory( - File directory, - Microservice microservice) { - File[] files = directory.listFiles(); - - if (files != null) { - for (File file : files) { - if (file.isDirectory()) { - scanDirectory(file, microservice); - } else if (FileUtils.isValidFile(file.getPath())) { - - if(FileUtils.isConfigurationFile(file.getPath())) { - ConfigFile configFile = SourceToObjectUtils.parseConfigurationFile(file, config); - if(configFile != null) { - microservice.getFiles().add(configFile); - } - - } else { - JClass jClass = SourceToObjectUtils.parseClass(file, config, microservice.getName()); - if (jClass != null) { - microservice.addJClass(jClass); - } - } - - - } - } - } - } - - -} diff --git a/src/main/java/edu/university/ecs/lab/intermediate/create/services/package-info.java b/src/main/java/edu/university/ecs/lab/intermediate/create/services/package-info.java deleted file mode 100644 index deaffc13..00000000 --- a/src/main/java/edu/university/ecs/lab/intermediate/create/services/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This package provides services for extracting intermediate representations (IR) from remote repositories. - * - *

The main service in this package is the {@link edu.university.ecs.lab.intermediate.create.services.IRExtractionService}, - * which handles the entire process of cloning repositories, scanning through each repository to extract REST endpoints and calls, - * and writing the extracted information into an intermediate representation file.

- */ -package edu.university.ecs.lab.intermediate.create.services; diff --git a/src/main/java/edu/university/ecs/lab/intermediate/merge/IRMergeRunner.java b/src/main/java/edu/university/ecs/lab/intermediate/merge/IRMergeRunner.java deleted file mode 100644 index 5ab74354..00000000 --- a/src/main/java/edu/university/ecs/lab/intermediate/merge/IRMergeRunner.java +++ /dev/null @@ -1,38 +0,0 @@ -package edu.university.ecs.lab.intermediate.merge; - -import edu.university.ecs.lab.common.config.Config; -import edu.university.ecs.lab.common.config.ConfigUtil; -import edu.university.ecs.lab.common.error.Error; -import edu.university.ecs.lab.common.services.LoggerManager; -import edu.university.ecs.lab.intermediate.merge.services.MergeService; -import org.apache.logging.log4j.Level; -import org.checkerframework.checker.nullness.Opt; - -import java.io.IOException; -import java.util.Arrays; -import java.util.Optional; - -public class IRMergeRunner { - - /** - * Entry point for the intermediate representation merge process. - * - * @param args {@literal } - * {@literal } - */ - public static void main(String[] args) throws IOException { - args = new String[]{"./output/IR.json", "./output/Delta.json", "./config.json"}; - String[] finalArgs = args; - LoggerManager.info(() -> "IRMergeRunner starting... args: " + Arrays.toString(finalArgs)); - - if (args.length != 4) { - Error.reportAndExit(Error.INVALID_ARGS, Optional.empty()); - } - - Config config = ConfigUtil.readConfig(args[0]); - - MergeService mergeService = new MergeService(args[0], args[1], args[2], args[3]); - - //mergeService.generateMergeIR(); - } -} diff --git a/src/main/java/edu/university/ecs/lab/intermediate/merge/package-info.java b/src/main/java/edu/university/ecs/lab/intermediate/merge/package-info.java deleted file mode 100644 index 6f34a46c..00000000 --- a/src/main/java/edu/university/ecs/lab/intermediate/merge/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This package contains the classes responsible for merging intermediate representations (IR) with delta changes. - * - *

The primary class in this package is {@link edu.university.ecs.lab.intermediate.merge.IRMergeRunner}, which serves - * as the main entry point for initiating the IR merge process. This process involves using the {@link edu.university.ecs.lab.intermediate.merge.services.MergeService} - * to merge an existing intermediate representation with delta changes to produce an updated intermediate representation.

- */ -package edu.university.ecs.lab.intermediate.merge; diff --git a/src/main/java/edu/university/ecs/lab/intermediate/merge/services/MergeService.java b/src/main/java/edu/university/ecs/lab/intermediate/merge/services/MergeService.java deleted file mode 100644 index 2b58b869..00000000 --- a/src/main/java/edu/university/ecs/lab/intermediate/merge/services/MergeService.java +++ /dev/null @@ -1,322 +0,0 @@ -package edu.university.ecs.lab.intermediate.merge.services; - -import edu.university.ecs.lab.common.config.Config; -import edu.university.ecs.lab.common.config.ConfigUtil; -import edu.university.ecs.lab.common.models.ir.*; -import edu.university.ecs.lab.common.services.LoggerManager; -import edu.university.ecs.lab.common.utils.FileUtils; -import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -import edu.university.ecs.lab.delta.models.Delta; -import edu.university.ecs.lab.delta.models.SystemChange; -import edu.university.ecs.lab.delta.models.enums.ChangeType; -import java.nio.file.Path; -import java.util.*; -import java.util.stream.Collectors; - - -/** - * This class is used for creating new IR's from old IR + Delta - * and provides all functionality related to updating the old - * IR - */ -public class MergeService { - private final Config config; - private final MicroserviceSystem microserviceSystem; - private final SystemChange systemChange; - private final String outputPath; - - // TODO handle exceptions here - public MergeService( - String intermediatePath, - String deltaPath, - String configPath, - String outputPath) { - this.config = ConfigUtil.readConfig(configPath); - this.microserviceSystem = JsonReadWriteUtils.readFromJSON(Path.of(intermediatePath).toAbsolutePath().toString(), MicroserviceSystem.class); - this.systemChange = JsonReadWriteUtils.readFromJSON(Path.of(deltaPath).toAbsolutePath().toString(), SystemChange.class); - this.outputPath = outputPath.isEmpty() ? "./NewIR.json" : outputPath; - } - - /** - * This method generates the new IR from the old IR + Delta file - */ - public void generateMergeIR(String newCommitID) { - - // If no changes are present we will write back out same IR - if (Objects.isNull(systemChange.getChanges())) { - LoggerManager.debug(() -> "No changes found at " + systemChange.getOldCommit() + " -> " + systemChange.getNewCommit()); - JsonReadWriteUtils.writeToJSON(outputPath, microserviceSystem); - return; - } - - - // First we make necessary changes to microservices - updateMicroservices(); - - for (Delta d : systemChange.getChanges()) { - - switch (d.getChangeType()) { - case ADD: - addFile(d); - break; - case MODIFY: - removeFile(d); - addFile(d); - break; - case DELETE: - removeFile(d); - break; - } - } - - microserviceSystem.setCommitID(systemChange.getNewCommit()); - - LoggerManager.info(() -> "Merged to new IR at " + systemChange.getNewCommit()); - JsonReadWriteUtils.writeToJSON(outputPath, microserviceSystem); - } - - - /** - * This method adds a JClass based on a Delta change - * - * @param delta the delta change for adding - */ - public void addFile(Delta delta) { - // Check for unparsable files - if(delta.getClassChange() == null && delta.getConfigChange() == null) { - LoggerManager.warn(() -> "[Filtered] An added file has no change information " + delta.getNewPath()); - return; - } - - Microservice ms = microserviceSystem.findMicroserviceByPath(delta.getNewPath()); - - // If no ms is found, it will be held in orphans - if (Objects.isNull(ms)) { - if(delta.getClassChange() != null) { - microserviceSystem.getOrphans().add(delta.getClassChange()); - } else if(delta.getConfigChange() != null) { - microserviceSystem.getOrphans().add(delta.getConfigChange()); - } - - LoggerManager.debug(() -> "[File added] " + delta.getNewPath() + " to orphans at " + systemChange.getOldCommit() + " -> " + systemChange.getNewCommit()); - return; - } - - // If we found it's ms - if(delta.getConfigChange() != null) { - ms.getFiles().add(delta.getConfigChange()); - } else { - // Add the JClass, the microservice name is updated see addJClass() - ms.addJClass(delta.getClassChange()); - } - - LoggerManager.debug(() -> "[File added] " + delta.getNewPath() + " to microservice " + ms.getPath() + " at " + systemChange.getOldCommit() + " -> " + systemChange.getNewCommit()); - - - } - - /** - * This method removes a JClass based on a Delta change - * Note it might not be found, so it will handle this gracefully - * - * @param delta the delta change for removal - */ - public void removeFile(Delta delta) { - Microservice ms = microserviceSystem.findMicroserviceByPath(delta.getOldPath()); - - // If we are removing a file and it's microservice doesn't exist - if (Objects.isNull(ms)) { - // Check the orphan pool - for (ProjectFile orphan : microserviceSystem.getOrphans()) { - // If found remove it and return - if (orphan.getPath().equals(delta.getOldPath())) { - microserviceSystem.getOrphans().remove(orphan); - LoggerManager.debug(() -> "[File removed] " + delta.getOldPath() + " from orphans at " + systemChange.getOldCommit() + " -> " + systemChange.getNewCommit()); - return; - } - } - LoggerManager.debug(() -> "[File not found] " + delta.getOldPath() + " in orphans at " + systemChange.getOldCommit() + " -> " + systemChange.getNewCommit()); - - return; - } - - // Remove the file depending on which is null, skips gracefully if not found in microservice - // see removeProjectFile() - // see removeProjectFile() - ms.removeProjectFile(delta.getOldPath()); - - LoggerManager.debug(() -> "[File removed] " + delta.getOldPath() + " from microservice " + ms.getPath() + " at " + systemChange.getOldCommit() + " -> " + systemChange.getNewCommit()); - - - } - - - /** - * Method for updating MicroserviceSystem structure (microservices) based on - * pom.xml changes in Delta file - * - */ - private void updateMicroservices() { - - // See filterBuildDeltas() - List buildDeltas = filterBuildDeltas(); - - if(buildDeltas.isEmpty()) { - return; - } - - // Loop through changes to pom.xml files - for (Delta delta : buildDeltas) { - - - Microservice microservice; - String[] tokens; - - String path = delta.getOldPath().equals("/dev/null") ? delta.getNewPath() : delta.getOldPath(); - tokens = path.split("/"); - - // Skip a pom that is in the root - if (tokens.length <= 2) { - LoggerManager.debug(() -> "Tokens check still needed?"); - } - - match: { - switch (delta.getChangeType()) { - case ADD: - - // If a delta is more/less specific than an active microservice - Microservice removeMicroservice = null; - for (Microservice compareMicroservice : microserviceSystem.getMicroservices()) { - // If delta is more specific than compareMicroservice, we remove this one - if (delta.getNewPath().replace("/pom.xml", "").replace("/build.gradle", "").matches(compareMicroservice.getPath() + "/.*")) { - removeMicroservice = compareMicroservice; - - // If a microservice already exists that is more specific, skip the addition - } else if (compareMicroservice.getPath().matches(delta.getNewPath().replace("/pom.xml", "").replace("/build.gradle", "") + "/.*")) { - break match; - } - } - - // If a match was found, orphanize and remove. They will be adopted below - if (Objects.nonNull(removeMicroservice)) { - microserviceSystem.getMicroservices().remove(removeMicroservice); - microserviceSystem.orphanize(removeMicroservice); - } - - microservice = new Microservice(tokens[tokens.length - 2], delta.getNewPath().replace("/pom.xml", "").replace("/build.gradle", "")); - // Here we must check if any orphans are waiting on this creation - microserviceSystem.adopt(microservice); - microserviceSystem.getMicroservices().add(microservice); - LoggerManager.debug(() -> "[Microservice added] " + microservice.getName() + " " + microservice.getPath() + " at " + systemChange.getOldCommit() + " -> " + systemChange.getNewCommit()); - break; - - - case DELETE: - microservice = microserviceSystem.findMicroserviceByPath(delta.getOldPath().replace("/pom.xml", "").replace("/build.gradle", "")); - - // If a less - if (microservice == null) { - LoggerManager.error(() -> "[Microservice not found] " + delta.getOldPath() + " at " + systemChange.getOldCommit() + " -> " + systemChange.getNewCommit(), Optional.of(new RuntimeException("Fail"))); - } - - // Here we must orphan all the classes of this microservice - microserviceSystem.getMicroservices().remove(microservice); - microserviceSystem.orphanize(microservice); - LoggerManager.debug(() -> "[Microservice removed] " + microservice.getName() + " " + microservice.getPath() + " at " + systemChange.getOldCommit() + " -> " + systemChange.getNewCommit()); - break; - - } - } - - } - - - } - - /** - * Filter's the delta files that deal with building project - * so either pom.xml or build.gradle - * - * @return a list of system changes that deal with build files that aren't modifications - */ - private List filterBuildDeltas() { - // deltaChanges.stream().filter(delta -> (delta.getOldPath() == null || delta.getOldPath().isEmpty() ? delta.getNewPath() : delta.getOldPath()).endsWith("/pom.xml")).collect(Collectors.toUnmodifiableList()); - List filteredDeltas = new ArrayList<>(systemChange.getChanges()); - - // Remove non build related files - filteredDeltas.removeIf(delta -> !(delta.getOldPath().endsWith("/pom.xml") || delta.getNewPath().endsWith("/pom.xml")) && !(delta.getOldPath().endsWith("/build.gradle") || delta.getNewPath().endsWith("/build.gradle"))); - - // Remove modified files, doesn't change microservice structure - filteredDeltas.removeIf(delta -> delta.getChangeType().equals(ChangeType.MODIFY)); - - // Remove deleted files, if their microservice doesn't exist (they were less specific and were filtered out) - filteredDeltas.removeIf(delta -> (delta.getChangeType().equals(ChangeType.DELETE) && microserviceSystem.findMicroserviceByPath(delta.getOldPath()) == null)); - - // Remove more specific build deltas in the same system change - List filteredDeltasCopy = new ArrayList<>(List.copyOf(filteredDeltas)); - - - // If a delta is more specific than another in same SystemChange, - // we need to remove the more general option in case of add - List addDeltas = filteredDeltas.stream().filter(d -> d.getChangeType().equals(ChangeType.ADD)).collect(Collectors.toList()); - boolean deletedFirst = false; - for(Delta delta1 : addDeltas) { - for(Delta delta2 : addDeltas) { - // If they are equal or they aren't both additions - if(delta1.equals(delta2) || !delta1.getChangeType().equals(ChangeType.ADD) || !delta2.getChangeType().equals(ChangeType.ADD)) { - continue; - } - String delta1Path = delta1.getNewPath().replace("/pom.xml", "").replace("/build.gradle", ""); - String delta2Path = delta2.getNewPath().replace("/pom.xml", "").replace("/build.gradle", ""); - if(delta1Path.equals(delta2Path) && !deletedFirst) { - LoggerManager.debug(() -> "[Filtered] Duplicates deltas detected for " + delta1.getNewPath() + " and " + delta2.getNewPath()); - filteredDeltas.remove(delta1); - deletedFirst = true; - continue; - } - - // Check if paths are more/less specific - if(delta1Path.matches(delta2Path + "/.*")) { - LoggerManager.debug(() -> "[Filtered] Delta " + delta1.getNewPath() + " more specific than " + delta2.getNewPath()); - filteredDeltasCopy.remove(delta2); - } else if(delta2Path.matches(delta1Path + "/.*")) { - LoggerManager.debug(() -> "[Filtered] Delta " + delta2.getNewPath() + " more specific than " + delta1.getNewPath()); - filteredDeltasCopy.remove(delta1); - } - } - } - - deletedFirst = false; - // Remove duplicate deletes (pom.xml and build.gradle) of the same microservice - List deleteDeltas = filteredDeltas.stream().filter(d -> d.getChangeType().equals(ChangeType.DELETE)).collect(Collectors.toList()); - for(Delta delta1 : deleteDeltas) { - for(Delta delta2 : deleteDeltas) { - String delta1Path = delta1.getOldPath().replace("/pom.xml", "").replace("/build.gradle", ""); - String delta2Path = delta2.getOldPath().replace("/pom.xml", "").replace("/build.gradle", ""); - - - // If they are equal and they aren't both additions, arbitrarily remove one of them - if(delta1Path.equals(delta2Path) && !delta1.getOldPath().equals(delta2.getOldPath()) && !deletedFirst) { - LoggerManager.debug(() -> "[Filtered] Duplicates deltas detected for " + delta1.getOldPath() + " and " + delta2.getOldPath()); - filteredDeltasCopy.remove(delta1); - deletedFirst = true; - } - } - } - - - return filteredDeltasCopy; - } - - private String getMicroserviceNameFromPath(String path) { - for (Microservice microservice : microserviceSystem.getMicroservices()) { - if (path.contains(microservice.getPath())) { - return microservice.getName(); - } - } - - return null; - } - - -} diff --git a/src/main/java/edu/university/ecs/lab/intermediate/merge/services/package-info.java b/src/main/java/edu/university/ecs/lab/intermediate/merge/services/package-info.java deleted file mode 100644 index 6ca3a371..00000000 --- a/src/main/java/edu/university/ecs/lab/intermediate/merge/services/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This package provides services for merging intermediate representations (IR) with delta changes. - * - *

The main service in this package is the {@link edu.university.ecs.lab.intermediate.merge.services.MergeService}, - * which handles the entire process of merging an existing IR with delta changes to generate an updated IR.

- * - */ -package edu.university.ecs.lab.intermediate.merge.services; diff --git a/src/main/java/edu/university/ecs/lab/intermediate/package-info.java b/src/main/java/edu/university/ecs/lab/intermediate/package-info.java deleted file mode 100644 index 453705d4..00000000 --- a/src/main/java/edu/university/ecs/lab/intermediate/package-info.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * This package contains the classes and sub-packages responsible for the intermediate representation extraction and merging processes. - * - *

The main sub-packages within this package are:

- * - {@link edu.university.ecs.lab.intermediate.create}: Includes the classes responsible for generating the intermediate representation from the source code. - * - {@link edu.university.ecs.lab.intermediate.merge}: Includes the classes responsible for merging the intermediate representation with delta changes. - * - {@link edu.university.ecs.lab.intermediate.utils}: Includes utility classes used throughout the intermediate representation processes. - * - *

The intermediate extraction process involves cloning remote services, scanning through each local repository to extract REST endpoints and calls, and writing the extracted data into an intermediate representation.

- * - *

The intermediate merging process involves taking an existing intermediate representation and applying changes based on delta files to generate an updated intermediate representation.

- */ -package edu.university.ecs.lab.intermediate; diff --git a/src/main/java/edu/university/ecs/lab/intermediate/utils/StringParserUtils.java b/src/main/java/edu/university/ecs/lab/intermediate/utils/StringParserUtils.java deleted file mode 100644 index e3bbaa3f..00000000 --- a/src/main/java/edu/university/ecs/lab/intermediate/utils/StringParserUtils.java +++ /dev/null @@ -1,40 +0,0 @@ -package edu.university.ecs.lab.intermediate.utils; - -import com.github.javaparser.ast.CompilationUnit; -import com.github.javaparser.ast.PackageDeclaration; -import org.apache.commons.io.FilenameUtils; - -/** - * Utility class for parsing strings. - */ -public class StringParserUtils { - /** - * Private constructor to prevent instantiation. - */ - private StringParserUtils() { - } - - /** - * Remove start/end quotations from the given string. - * - * - * @param s the string to remove quotations from - * @return the string with quotations removed - */ - public static String removeOuterQuotations(String s) { - if (s != null && s.length() >= 2 && s.startsWith("\"") && s.endsWith("\"")) { - return s.substring(1, s.length() - 1); - } - return s; - } - - /** - * Simplifies all path arguments to {?}. - * - * @param url the endpoint URL - * @return the simplified endpoint URL - */ - public static String simplifyEndpointURL(String url) { - return url.replaceAll("\\{[^{}]*\\}", "{?}"); - } -} diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml deleted file mode 100644 index cb6ab38b..00000000 --- a/src/main/resources/log4j2.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/test/java/integration/ComparisonTest.java b/src/test/java/integration/ComparisonTest.java deleted file mode 100644 index d7fe39e3..00000000 --- a/src/test/java/integration/ComparisonTest.java +++ /dev/null @@ -1,83 +0,0 @@ -//package integration; -// -//import edu.university.ecs.lab.common.models.ir.JClass; -//import edu.university.ecs.lab.common.models.ir.Microservice; -//import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; -//import edu.university.ecs.lab.common.models.ir.ProjectFile; -//import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -//import edu.university.ecs.lab.intermediate.create.services.IRExtractionService; -//import org.junit.Test; -// -// -//import java.util.*; -// -//import static integration.Constants.TEST_CONFIG_PATH; -//import static integration.Constants.TEST_IR_NAME; -//import static org.junit.Assert.assertTrue; -// -//public class ComparisonTest { -// -// -// @Test -// public void testIR() { -// MicroserviceSystem ms1 = JsonReadWriteUtils.readFromJSON("./output/NewIR.json", MicroserviceSystem.class); -// -// IRExtractionService irExtractionService = new IRExtractionService(TEST_CONFIG_PATH, Optional.empty()); -// irExtractionService.generateIR(TEST_IR_NAME); -// -// MicroserviceSystem ms2 = JsonReadWriteUtils.readFromJSON("./output/TestIR.json", MicroserviceSystem.class); -// ms1.setOrphans(null); -// ms2.setOrphans(null); -// deepCompareSystems(ms1, ms2); -// assertTrue(ms1.equals(ms2)); -// } -// -// private static void deepCompareSystems(MicroserviceSystem microserviceSystem1, MicroserviceSystem microserviceSystem2) { -// -// System.out.println("System equivalence is: " + Objects.deepEquals(microserviceSystem1, microserviceSystem2)); -// -// for (Microservice microservice1 : microserviceSystem1.getMicroservices()) { -// outer2: { -// for (Microservice microservice2 : microserviceSystem2.getMicroservices()) { -// if (microservice1.getName().equals(microservice2.getName())) { -// System.out.println("Microservice equivalence of " + microservice1.getPath() + " is: " + Objects.equals(microservice1, microservice2)); -// for (ProjectFile projectFile1 : microservice1.getAllFiles()) { -// outer1: { -// for (ProjectFile projectFile2 : microservice2.getAllFiles()) { -// if (projectFile1.getPath().equals(projectFile2.getPath())) { -// if(!Objects.equals(projectFile1, projectFile2)) { -// findDifferences(((JClass) projectFile1).getMethodCalls(), ((JClass) projectFile2).getMethodCalls()); -// System.out.println(""); -// } -// System.out.println("Class equivalence of " + projectFile1.getPath() + " is: " + Objects.equals(projectFile1, projectFile2)); -// break outer1; -// } -// } -// -// System.out.println("No JClass match found for " + projectFile1.getPath()); -// } -// } -// break outer2; -// } -// } -// -// System.out.println("No Microservice match found for " + microservice1.getPath()); -// } -// } -// -// } -// -// public static Map> findDifferences(Set set1, Set set2) { -// Set inFirstNotInSecond = new HashSet<>(set1); -// inFirstNotInSecond.removeAll(set2); // Elements in set1 but not in set2 -// -// Set inSecondNotInFirst = new HashSet<>(set2); -// inSecondNotInFirst.removeAll(set1); // Elements in set2 but not in set1 -// -// Map> result = new HashMap<>(); -// result.put("InFirstNotInSecond", inFirstNotInSecond); -// result.put("InSecondNotInFirst", inSecondNotInFirst); -// -// return result; -// } -//} diff --git a/src/test/java/integration/Constants.java b/src/test/java/integration/Constants.java deleted file mode 100644 index 80eb63a0..00000000 --- a/src/test/java/integration/Constants.java +++ /dev/null @@ -1,11 +0,0 @@ -package integration; - -public class Constants { - public static final String TEST_CONFIG_PATH = "./src/test/resources/test_config.json"; - public static final String OLD_IR_PATH = "./output/OldIR.json"; - public static final String NEW_IR_PATH = "./output/NewIR.json"; - public static final String TEST_IR_PATH = "./output/TestIR.json"; - public static final String TEST_IR_NAME = "TestIR.json"; - public static final String OLD_IR_NAME = "OldIR.json"; - public static final String DELTA_PATH = "./output/Delta.json"; -} diff --git a/src/test/java/integration/IRComparisonTest.java b/src/test/java/integration/IRComparisonTest.java deleted file mode 100644 index 7667ee18..00000000 --- a/src/test/java/integration/IRComparisonTest.java +++ /dev/null @@ -1,131 +0,0 @@ -package integration; - -import edu.university.ecs.lab.common.models.ir.*; -import edu.university.ecs.lab.common.services.GitService; -import edu.university.ecs.lab.common.utils.FileUtils; -import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -import edu.university.ecs.lab.delta.services.DeltaExtractionService; -import edu.university.ecs.lab.intermediate.create.services.IRExtractionService; -import edu.university.ecs.lab.intermediate.merge.services.MergeService; -import org.eclipse.jgit.revwalk.RevCommit; -import org.junit.Ignore; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; -import java.util.*; - -import static integration.Constants.*; - - -@Ignore -class IRComparisonTest { - private static IRExtractionService irExtractionService; - private static DeltaExtractionService deltaExtractionService; - private static List list; - private static GitService gitService; - - -// @BeforeAll -// public static void setUp() { -// FileUtils.makeDirs(); -// gitService = new GitService(TEST_CONFIG_PATH); -// -// list = iterableToList(gitService.getLog()); -// -// irExtractionService = new IRExtractionService(TEST_CONFIG_PATH, Optional.of(list.get(0).toString().split(" ")[1])); -// -// irExtractionService.generateIR("./output/OldIR.json"); -// } - -// @Test - void testComparison() { - - // Loop through commit history and create delta, merge, etc... - for (int i = 0; i < list.size() - 1; i++) { - String commitIdOld = list.get(i).toString().split(" ")[1]; - String commitIdNew = list.get(i + 1).toString().split(" ")[1]; - - // Extract changes from one commit to the other - deltaExtractionService = new DeltaExtractionService(TEST_CONFIG_PATH, "./output/Delta.json", commitIdOld, commitIdNew); - deltaExtractionService.generateDelta(); - - // Merge Delta changes to old IR to create new IR representing new commit changes - MergeService mergeService = new MergeService("./output/OldIR.json", "./output/Delta.json", TEST_CONFIG_PATH, "./output/NewIR.json"); - mergeService.generateMergeIR(commitIdNew); - - if(i < list.size() - 2) { - try { - Files.move(Paths.get("./output/NewIR.json"), Paths.get("./output/OldIR.json"), StandardCopyOption.REPLACE_EXISTING); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - // Create IR of last commit - irExtractionService = new IRExtractionService(TEST_CONFIG_PATH, Optional.of(list.get(list.size() - 1).toString().split(" ")[1])); - irExtractionService.generateIR("./output/TestIR.json"); - - // Compare two IR's for equivalence - MicroserviceSystem microserviceSystem1 = JsonReadWriteUtils.readFromJSON("./output/NewIR.json", MicroserviceSystem.class); - MicroserviceSystem microserviceSystem2 = JsonReadWriteUtils.readFromJSON("./output/TestIR.json", MicroserviceSystem.class); - - microserviceSystem1.setOrphans(new HashSet<>()); - microserviceSystem2.setOrphans(new HashSet<>()); - - Assertions.assertTrue(Objects.deepEquals(microserviceSystem1, microserviceSystem2)); - - } - - -// private static void deepCompareSystems(MicroserviceSystem microserviceSystem1, MicroserviceSystem microserviceSystem2) { -// // Ignore orphans for testing -// microserviceSystem1.setOrphans(null); -// microserviceSystem2.setOrphans(null); -// System.out.println("System equivalence is: " + Objects.deepEquals(microserviceSystem1, microserviceSystem2)); -// -// for (Microservice microservice1 : microserviceSystem1.getMicroservices()) { -// outer2: { -// for (Microservice microservice2 : microserviceSystem2.getMicroservices()) { -// if (microservice1.getName().equals(microservice2.getName())) { -// System.out.println("Microservice equivalence of " + microservice1.getPath() + " is: " + Objects.deepEquals(microservice1, microservice2)); -// for (ProjectFile projectFile1 : microservice1.getAllFiles()) { -// outer1: { -// for (ProjectFile projectFile2 : microservice2.getAllFiles()) { -// if (projectFile1.getPath().equals(projectFile2.getPath())) { -// System.out.println("Class equivalence of " + projectFile1.getPath() + " is: " + Objects.deepEquals(projectFile1, projectFile2)); -// break outer1; -// } -// } -// -// System.out.println("No JClass match found for " + projectFile1.getPath()); -// } -// } -// break outer2; -// } -// } -// -// System.out.println("No Microservice match found for " + microservice1.getPath()); -// } -// } -// -// } - - private static List iterableToList(Iterable iterable) { - Iterator iterator = iterable.iterator(); - List list = new LinkedList<>(); - while (iterator.hasNext()) { - list.add(iterator.next()); - } - Collections.reverse(list); - - return list; - } - - -} diff --git a/src/test/java/unit/antipatterns/CyclicDependencyTest.java b/src/test/java/unit/antipatterns/CyclicDependencyTest.java index 0fdf9dde..f2cb9fcc 100644 --- a/src/test/java/unit/antipatterns/CyclicDependencyTest.java +++ b/src/test/java/unit/antipatterns/CyclicDependencyTest.java @@ -8,19 +8,13 @@ import edu.university.ecs.lab.common.models.enums.ClassRole; import edu.university.ecs.lab.common.models.enums.HttpMethod; import edu.university.ecs.lab.common.models.ir.*; -import edu.university.ecs.lab.detection.antipatterns.models.ServiceChain; -import edu.university.ecs.lab.detection.antipatterns.services.CyclicDependencyMSLevelService; -import edu.university.ecs.lab.detection.antipatterns.services.ServiceChainMSLevelService; +import edu.university.ecs.lab.detection_old.antipatterns.services.CyclicDependencyMSLevelService; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import edu.university.ecs.lab.common.models.sdg.ServiceDependencyGraph; -import edu.university.ecs.lab.common.utils.FileUtils; -import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -import edu.university.ecs.lab.detection.antipatterns.models.CyclicDependency; -import edu.university.ecs.lab.intermediate.create.services.IRExtractionService; -import unit.Constants; +import edu.university.ecs.lab.detection.models.sdg.ServiceDependencyGraph; +import edu.university.ecs.lab.detection.models.results.antipatterns.CyclicDependency; @Ignore diff --git a/src/test/java/unit/antipatterns/GreedyMicroserviceTest.java b/src/test/java/unit/antipatterns/GreedyMicroserviceTest.java index af79ccb0..48f58556 100644 --- a/src/test/java/unit/antipatterns/GreedyMicroserviceTest.java +++ b/src/test/java/unit/antipatterns/GreedyMicroserviceTest.java @@ -7,11 +7,11 @@ import org.junit.Test; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; -import edu.university.ecs.lab.common.models.sdg.ServiceDependencyGraph; +import edu.university.ecs.lab.detection.models.sdg.ServiceDependencyGraph; import edu.university.ecs.lab.common.utils.FileUtils; import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -import edu.university.ecs.lab.detection.antipatterns.models.GreedyMicroservice; -import edu.university.ecs.lab.detection.antipatterns.services.GreedyService; +import edu.university.ecs.lab.detection.models.results.antipatterns.GreedyMicroservice; +import edu.university.ecs.lab.detection_old.antipatterns.services.GreedyService; import edu.university.ecs.lab.intermediate.create.services.IRExtractionService; import unit.Constants; diff --git a/src/test/java/unit/antipatterns/HubLikeMicroserviceTest.java b/src/test/java/unit/antipatterns/HubLikeMicroserviceTest.java index 71618e81..4394ca15 100644 --- a/src/test/java/unit/antipatterns/HubLikeMicroserviceTest.java +++ b/src/test/java/unit/antipatterns/HubLikeMicroserviceTest.java @@ -9,11 +9,11 @@ import org.junit.Test; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; -import edu.university.ecs.lab.common.models.sdg.ServiceDependencyGraph; +import edu.university.ecs.lab.detection.models.sdg.ServiceDependencyGraph; import edu.university.ecs.lab.common.utils.FileUtils; import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -import edu.university.ecs.lab.detection.antipatterns.models.HubLikeMicroservice; -import edu.university.ecs.lab.detection.antipatterns.services.HubLikeService; +import edu.university.ecs.lab.detection.models.results.antipatterns.HubLikeMicroservice; +import edu.university.ecs.lab.detection_old.antipatterns.services.HubLikeService; import edu.university.ecs.lab.intermediate.create.services.IRExtractionService; import unit.Constants; diff --git a/src/test/java/unit/antipatterns/NoApiGatewayTest.java b/src/test/java/unit/antipatterns/NoApiGatewayTest.java index 06f35945..70379eb9 100644 --- a/src/test/java/unit/antipatterns/NoApiGatewayTest.java +++ b/src/test/java/unit/antipatterns/NoApiGatewayTest.java @@ -8,8 +8,8 @@ import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; import edu.university.ecs.lab.common.utils.FileUtils; import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -import edu.university.ecs.lab.detection.antipatterns.models.NoApiGateway; -import edu.university.ecs.lab.detection.antipatterns.services.NoApiGatewayService; +import edu.university.ecs.lab.detection.models.results.antipatterns.NoApiGateway; +import edu.university.ecs.lab.detection_old.antipatterns.services.NoApiGatewayService; import edu.university.ecs.lab.intermediate.create.services.IRExtractionService; import unit.Constants; diff --git a/src/test/java/unit/antipatterns/NoHealthcheckTest.java b/src/test/java/unit/antipatterns/NoHealthcheckTest.java index 814dc876..937757cb 100644 --- a/src/test/java/unit/antipatterns/NoHealthcheckTest.java +++ b/src/test/java/unit/antipatterns/NoHealthcheckTest.java @@ -1,17 +1,13 @@ package unit.antipatterns; -import static org.junit.jupiter.api.Assertions.*; - import org.junit.Before; -import org.junit.Test; import java.util.*; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; import edu.university.ecs.lab.common.utils.FileUtils; import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -import edu.university.ecs.lab.detection.antipatterns.models.NoHealthcheck; -import edu.university.ecs.lab.detection.antipatterns.services.NoHealthcheckService; +import edu.university.ecs.lab.detection_old.antipatterns.services.NoHealthcheckService; import edu.university.ecs.lab.intermediate.create.services.IRExtractionService; import unit.Constants; diff --git a/src/test/java/unit/antipatterns/ServiceChainTest.java b/src/test/java/unit/antipatterns/ServiceChainTest.java index 62bc0442..436b47e1 100644 --- a/src/test/java/unit/antipatterns/ServiceChainTest.java +++ b/src/test/java/unit/antipatterns/ServiceChainTest.java @@ -5,17 +5,17 @@ import edu.university.ecs.lab.common.models.enums.ClassRole; import edu.university.ecs.lab.common.models.enums.HttpMethod; import edu.university.ecs.lab.common.models.ir.*; -import edu.university.ecs.lab.detection.antipatterns.services.ServiceChainMSLevelService; +import edu.university.ecs.lab.detection_old.antipatterns.services.ServiceChainMSLevelService; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import java.util.*; -import edu.university.ecs.lab.common.models.sdg.ServiceDependencyGraph; +import edu.university.ecs.lab.detection.models.sdg.ServiceDependencyGraph; import edu.university.ecs.lab.common.utils.FileUtils; import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -import edu.university.ecs.lab.detection.antipatterns.models.ServiceChain; +import edu.university.ecs.lab.detection.models.results.antipatterns.ServiceChain; import edu.university.ecs.lab.intermediate.create.services.IRExtractionService; import unit.Constants; diff --git a/src/test/java/unit/antipatterns/WobblyServiceInteractionsTest.java b/src/test/java/unit/antipatterns/WobblyServiceInteractionsTest.java index e2899336..f49a2d14 100644 --- a/src/test/java/unit/antipatterns/WobblyServiceInteractionsTest.java +++ b/src/test/java/unit/antipatterns/WobblyServiceInteractionsTest.java @@ -6,13 +6,12 @@ import org.checkerframework.checker.nullness.Opt; import org.junit.Before; -import org.junit.Test; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; import edu.university.ecs.lab.common.utils.FileUtils; import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -import edu.university.ecs.lab.detection.antipatterns.models.WobblyServiceInteraction; -import edu.university.ecs.lab.detection.antipatterns.services.WobblyServiceInteractionService; +import edu.university.ecs.lab.detection.models.results.antipatterns.WobblyServiceInteraction; +import edu.university.ecs.lab.detection_old.antipatterns.services.WobblyServiceInteractionService; import edu.university.ecs.lab.intermediate.create.services.IRExtractionService; import unit.Constants; diff --git a/src/test/java/unit/antipatterns/WrongCutsTest.java b/src/test/java/unit/antipatterns/WrongCutsTest.java index 3ec2b8b3..88dcd864 100644 --- a/src/test/java/unit/antipatterns/WrongCutsTest.java +++ b/src/test/java/unit/antipatterns/WrongCutsTest.java @@ -1,17 +1,13 @@ package unit.antipatterns; -import static org.junit.jupiter.api.Assertions.*; - import java.util.*; import org.junit.Before; -import org.junit.Test; import edu.university.ecs.lab.common.models.ir.MicroserviceSystem; import edu.university.ecs.lab.common.utils.FileUtils; import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -import edu.university.ecs.lab.detection.antipatterns.models.WrongCuts; -import edu.university.ecs.lab.detection.antipatterns.services.WrongCutsService; +import edu.university.ecs.lab.detection_old.antipatterns.services.WrongCutsService; import edu.university.ecs.lab.intermediate.create.services.IRExtractionService; import unit.Constants; diff --git a/src/test/java/unit/extraction/ExtractionTest.java b/src/test/java/unit/extraction/ExtractionTest.java deleted file mode 100644 index 7359d0a9..00000000 --- a/src/test/java/unit/extraction/ExtractionTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package unit.extraction; - -import edu.university.ecs.lab.common.config.ConfigUtil; -import edu.university.ecs.lab.common.models.ir.*; -import edu.university.ecs.lab.common.services.GitService; -import edu.university.ecs.lab.common.utils.JsonReadWriteUtils; -import edu.university.ecs.lab.common.utils.SourceToObjectUtils; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.io.File; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - - -@Ignore -public class ExtractionTest { - private static final String TEST_FILE1 = "src/test/resources/TestFile2.java"; - private static final String TEST_FILE2 = "src/test/resources/TestFile3.java"; - - - private static final String TEST_CONFIG_FILE = "src/test/resources/test_config.json"; - private static final int EXPECTED_CALLS = 6; - private static final String PRE_URL = "/api/v1/seatservice/test"; - - @Before - public void setUp() { - } - - @Test - public void restCallExtractionTest1() { - GitService gitService = new GitService(TEST_CONFIG_FILE); - MicroserviceSystem ms1 = JsonReadWriteUtils.readFromJSON("C:\\Users\\ninja\\IdeaProjects\\cimet2\\output\\java-microservice\\IR\\IR1_8948.json", MicroserviceSystem.class); - JClass jClass1 = SourceToObjectUtils.parseClass(new File(TEST_FILE1), ConfigUtil.readConfig(TEST_CONFIG_FILE), ""); - JClass jClass2 = SourceToObjectUtils.parseClass(new File(TEST_FILE2), ConfigUtil.readConfig(TEST_CONFIG_FILE), ""); - - for(Endpoint e : jClass1.getEndpoints()) { - for(RestCall rc : jClass2.getRestCalls()) { - if(RestCall.matchEndpoint(rc, e)) { - System.out.println("Passed " + rc.getUrl() + " " + e.getUrl()); - - } - } - - } - -// -// int i = 1; -// for(RestCall restCall : jClass.getRestCalls()) { -// assertTrue(restCall.getUrl().startsWith(PRE_URL + i++)); -// } - - } - - -} diff --git a/valid_configs/config_cwa-server.json b/valid_configs/config_cwa-server.json index 680ef473..9f7489ca 100644 --- a/valid_configs/config_cwa-server.json +++ b/valid_configs/config_cwa-server.json @@ -3,4 +3,4 @@ "repositoryURL": "https://github.com/corona-warn-app/cwa-server.git", "baseCommit": "c61d55f6f83b6d005cb6aca9e9b455afac572d72", "baseBranch": "main" - } \ No newline at end of file +} \ No newline at end of file