Skip to content

TMS Migration (to feature/orgs) #2209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 17 commits into
base: feature/orgs
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ hs_err_pid*
build/
.gradle/
out/
src/test/resources/db/migration/*.sql
44 changes: 23 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ plugins {
id "org.openapi.generator" version "7.11.0"
}

import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
import org.owasp.dependencycheck.reporting.ReportGenerator

apply from: 'project-properties.gradle'
Expand Down Expand Up @@ -116,7 +115,9 @@ dependencies {
}
// JasperReport's export to XLS uses Apache POI and openpdf for PDF export
implementation 'org.apache.poi:poi:5.4.0'
implementation 'org.apache.poi:poi-ooxml:5.4.0'
implementation 'com.github.librepdf:openpdf:2.0.3'
implementation 'org.apache.commons:commons-csv:1.10.0'

implementation 'jakarta.inject:jakarta.inject-api:2.0.1'
implementation 'com.sun.mail:jakarta.mail:2.0.1'
Expand All @@ -141,6 +142,10 @@ dependencies {
testCompileOnly "org.projectlombok:lombok:${lombokVersion}"
testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}"

//mapstruct
implementation "org.mapstruct:mapstruct:$mapstructVersion"
annotationProcessor "org.mapstruct:mapstruct-processor:$mapstructVersion"

// Tests
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.springframework:spring-web'
Expand All @@ -151,6 +156,13 @@ dependencies {
testImplementation 'io.jsonwebtoken:jjwt-jackson:0.12.5'
}

processResources {
dependsOn(gitInfo)
filesMatching('application.properties') {
expand(project.properties)
}
}

sourceSets {
main {
java {
Expand All @@ -159,24 +171,6 @@ sourceSets {
}
}


tasks.register('generateApi', GenerateTask) {
generatorName.set("spring")
inputSpec.set("$rootDir/api-registry/api/openapi/reportportal-api.yaml")
outputDir.set("${layout.buildDirectory.get()}/generated")
configFile.set("$rootDir/src/main/resources/openapi/config.json")
skipOverwrite.set(false)
cleanupOutput.set(true)
// verbose.set(true)
}

processResources {
dependsOn(gitInfo)
filesMatching('application.properties') {
expand(project.properties)
}
}

tasks.register('updateApiSubmodule', Exec) {
commandLine 'git', 'submodule', 'update', '--init', "--recursive"
}
Expand Down Expand Up @@ -216,8 +210,7 @@ test {
}
}

compileJava.dependsOn tasks.named('generateApi')
generateApi.dependsOn updateApiSubmodule
compileJava.dependsOn tasks.named('openApiGenerate')
publish.dependsOn build
publish.mustRunAfter build
checkCommitNeeded.dependsOn removeScripts
Expand Down Expand Up @@ -254,6 +247,15 @@ springBoot {
}
}

openApiGenerate {
generatorName = "spring"
inputSpec = "$rootDir/api-registry/api/openapi/reportportal-api.yaml"
outputDir = "${layout.buildDirectory.get()}/generated"
configFile = "$rootDir/src/main/resources/openapi/config.json"
skipOverwrite = false
cleanupOutput = true
}

tasks.preTagCommit.enabled = false
tasks.updateVersion.enabled = false
tasks.commitNewVersion.enabled = false
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ springBootVersion=3.4.2
jooqVersion=3.19.18
hibernateValidatorVersion=8.0.2.Final
jcloudsVersion=2.6.0
mapstructVersion = 1.5.5.Final
8 changes: 5 additions & 3 deletions project-properties.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ project.ext {
isDebugMode = System.getProperty("DEBUG", "false") == "true"
releaseMode = project.hasProperty("releaseMode") ? project.releaseMode.toBoolean() : false
scriptsUrl = commonScriptsUrl + (releaseMode ? '5.12.0' : 'develop')
migrationsUrl = migrationsScriptsUrl + (releaseMode ? '5.12.0' : 'feature/orgs')
migrationsUrl = migrationsScriptsUrl + (releaseMode ? '5.13.0' : 'feature/EPMRPP-migrate-tms-to-feature-orgs')
//TODO refactor with archive download
testScriptsSrc = [
(migrationsUrl + '/migrations/0_extensions.up.sql') : 'V001__extensions.sql',
Expand Down Expand Up @@ -72,14 +72,16 @@ project.ext {
(migrationsUrl + '/migrations/88_analytics_data_table.up.sql') : 'V088__analytics_data_table.sql',
(migrationsUrl + '/migrations/90_add_user_fields.up.sql') : 'V090__scim_user_fields.sql',
(migrationsUrl + '/migrations/91_settings_users_sso.up.sql') : 'V091__settings_users_sso.sql',
(migrationsUrl + '/migrations/93_create_groups_tables.up.sql') : 'V093__create_groups_tables.sql',
(migrationsUrl + '/migrations/92_round_last_login.up.sql') : 'V092__round_last_login.up.sql',
(migrationsUrl + '/migrations/93_create_groups_tables.up.sql') : 'V093__create_groups_tables.up.sql',
(migrationsUrl + '/migrations/96_tms_initial.up.sql') : 'V096__tms_initial.up.sql',
(migrationsUrl + '/migrations/198_add_slugify_function.up.sql') : 'V198__add_slugify_function.sql',
(migrationsUrl + '/migrations/199_organization_tables.up.sql') : 'V199__organization_tables.sql',
(migrationsUrl + '/migrations/200_migrate_org_roles.up.sql') : 'V200__migrate_org_roles.sql',
(migrationsUrl + '/migrations/201_drop_table_onboarding.up.sql') : 'V201__drop_table_onboarding.sql',
(migrationsUrl + '/migrations/202_update_project_table.up.sql') : 'V202__update_project_table.up.sql',
(migrationsUrl + '/migrations/203_user_table_extend.up.sql') : 'V203__user_table_extend.up.sql',
(migrationsUrl + '/migrations/204_bid_extend_metadata.up.sql') : 'V204__bid_extend_metadata.up.sql',
(migrationsUrl + '/migrations/204_bid_extend_metadata.up.sql') : 'V204__bid_extend_metadata.up.sql'
]
excludeTests = ['**/entity/**',
'**/aop/**',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package com.epam.ta.reportportal.core.tms.controller;

import static com.epam.ta.reportportal.auth.permissions.Permissions.IS_ADMIN;

import com.epam.ta.reportportal.commons.EntityUtils;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.core.tms.dto.ProductVersionRQ;
import com.epam.ta.reportportal.core.tms.dto.TmsProductVersionRS;
import com.epam.ta.reportportal.core.tms.service.ProductVersionService;
import com.epam.ta.reportportal.util.ProjectExtractor;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* Controller for managing product versions within a project. Each endpoint
* in this controller is secured and requires the user to have administrator
* privileges. Operations supported include creating, retrieving, updating,
* and deleting product versions associated with a specific project.
*/
@RestController
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck> reported by reviewdog 🐶
Missing a Javadoc comment.

@RequestMapping("/project/{projectKey}/tms/productversion")
@Tag(name = "Product Version", description = "Product Version API collection")
@RequiredArgsConstructor
public class ProductVersionController {

private final ProductVersionService productVersionService;
private final ProjectExtractor projectExtractor;

/**
* Retrieves a specific product version by its ID within a project.
*
* @param projectKey The key of the project to which the product version belongs.
* @param productVersionId The ID of the product version to retrieve.
* @return A data transfer object ({@link TmsProductVersionRS}) containing details of the product version.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 108).

*/
@PreAuthorize(IS_ADMIN)
@GetMapping("/{productVersionId}")
TmsProductVersionRS getById(@PathVariable("projectKey") String projectKey,
@PathVariable("productVersionId") final long productVersionId,
@AuthenticationPrincipal ReportPortalUser user) {
return productVersionService.getById(
projectExtractor
.extractProjectDetailsAdmin(user, EntityUtils.normalizeId(projectKey))
.getProjectId(),
productVersionId);
}

/**
* Creates a new product version in the specified project.
*
* @param projectKey The key of the project to which the new product version will be added.
* @param inputDto A request payload ({@link ProductVersionRQ}) containing information
* about the product version to create.
* @return A data transfer object ({@link TmsProductVersionRS}) with details of the created product version.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 110).

*/
@PreAuthorize(IS_ADMIN)
@PostMapping
TmsProductVersionRS createVersion(@PathVariable("projectKey") String projectKey,
@RequestBody final ProductVersionRQ inputDto,
@AuthenticationPrincipal ReportPortalUser user) {
return productVersionService.create(
projectExtractor
.extractProjectDetailsAdmin(user, EntityUtils.normalizeId(projectKey))
.getProjectId(),
inputDto);
}

/**
* Updates the details of an existing product version in a project.
*
* @param projectKey The key of the project to which the product version belongs.
* @param productVersionId The ID of the product version to update.
* @param inputDto A request payload ({@link ProductVersionRQ}) containing updated information
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 104).

* for the product version.
* @return A data transfer object ({@link TmsProductVersionRS}) with updated details of the product version.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 110).

*/
@PreAuthorize(IS_ADMIN)
@PutMapping("/{productVersionId}")
TmsProductVersionRS updateVersion(@PathVariable("projectKey") String projectKey,
@PathVariable("productVersionId") final long productVersionId,
@RequestBody final ProductVersionRQ inputDto,
@AuthenticationPrincipal ReportPortalUser user) {
return productVersionService.update(
projectExtractor
.extractProjectDetailsAdmin(user, EntityUtils.normalizeId(projectKey))
.getProjectId(),
productVersionId,
inputDto);
}

/**
* Deletes a specific product version from a project.
*
* @param projectKey The key of the project to which the product version belongs.
* @param productVersionId The ID of the product version to delete.
*/
@PreAuthorize(IS_ADMIN)
@DeleteMapping("/{productVersionId}")
void deleteVersion(@PathVariable("projectKey") String projectKey,
@PathVariable("productVersionId") final long productVersionId,
@AuthenticationPrincipal ReportPortalUser user) {
productVersionService.delete(
projectExtractor
.extractProjectDetailsAdmin(user, EntityUtils.normalizeId(projectKey))
.getProjectId(),
productVersionId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
package com.epam.ta.reportportal.core.tms.controller;

import static com.epam.ta.reportportal.auth.permissions.Permissions.IS_ADMIN;

import com.epam.ta.reportportal.commons.EntityUtils;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.core.tms.dto.TmsTestCaseRQ;
import com.epam.ta.reportportal.core.tms.dto.TmsTestCaseRS;
import com.epam.ta.reportportal.core.tms.service.TmsTestCaseService;
import com.epam.ta.reportportal.util.ProjectExtractor;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* Controller for managing test cases associated with a project. All endpoints
* are secured and require administrator privileges. Operations supported
* include retrieval, creation, updating, and patching test cases.
*/
@RestController
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck> reported by reviewdog 🐶
Missing a Javadoc comment.

@RequestMapping("/project/{projectKey}/tms/test-case")
@Tag(name = "Test Case", description = "Test Case API collection")
@RequiredArgsConstructor
public class TestCaseController {

private final TmsTestCaseService tmsTestCaseService;

private final ProjectExtractor projectExtractor;

/**
* Retrieves a specific test case by its ID within a project.
*
* @param projectKey The key of the project to which the test case belongs.
* @param testCaseId The ID of the test case to retrieve.
* @return A data transfer object ({@link TmsTestCaseRS}) containing details of the test case.
*/
@PreAuthorize(IS_ADMIN)
@GetMapping("/{testCaseId}")
public TmsTestCaseRS getTestCaseById(@PathVariable("projectKey") String projectKey,
@PathVariable("testCaseId") final long testCaseId,
@AuthenticationPrincipal ReportPortalUser user) {
return tmsTestCaseService.getById(
projectExtractor
.extractProjectDetailsAdmin(user, EntityUtils.normalizeId(projectKey))
.getProjectId(),
testCaseId
);
}

/**
* Retrieves all test cases associated with a specific project.
*
* @param projectKey The key of the project.
* @return A list of data transfer objects ({@link TmsTestCaseRS}) representing test cases.
*/
@PreAuthorize(IS_ADMIN)
@GetMapping
public List<TmsTestCaseRS> getTestCaseByProjectId(
@PathVariable("projectKey") String projectKey,
@AuthenticationPrincipal ReportPortalUser user) {
return tmsTestCaseService.getTestCaseByProjectId(
projectExtractor
.extractProjectDetailsAdmin(user, EntityUtils.normalizeId(projectKey))
.getProjectId()
);
}

/**
* Creates a new test case within a specific project.
*
* @param projectKey The key of the project to which the new test case will be added.
* @param inputDto A request payload ({@link TmsTestCaseRQ}) containing information about the test case to create.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 117).

* @return A data transfer object ({@link TmsTestCaseRS}) with details of the created test case.
*/
@PreAuthorize(IS_ADMIN)
@PostMapping
public TmsTestCaseRS createTestCase(@PathVariable("projectKey") String projectKey,
@RequestBody @Valid final TmsTestCaseRQ inputDto,
@AuthenticationPrincipal ReportPortalUser user) {
return tmsTestCaseService.create(
projectExtractor
.extractProjectDetailsAdmin(user, EntityUtils.normalizeId(projectKey))
.getProjectId(),
inputDto
);
}

/**
* Updates the details of an existing test case in a project.
*
* @param projectKey The key of the project to which the test case belongs.
* @param testCaseId The ID of the test case to update.
* @param inputDto A request payload ({@link TmsTestCaseRQ}) containing updated information for the test case.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 114).

* @return A data transfer object ({@link TmsTestCaseRS}) with updated details of the test case.
*/
@PreAuthorize(IS_ADMIN)
@PutMapping("/{testCaseId}")
public TmsTestCaseRS updateTestCase(@PathVariable("projectKey") String projectKey,
@PathVariable("testCaseId") final long testCaseId,
@RequestBody final TmsTestCaseRQ inputDto,
@AuthenticationPrincipal ReportPortalUser user) {
return tmsTestCaseService.update(
projectExtractor
.extractProjectDetailsAdmin(user, EntityUtils.normalizeId(projectKey))
.getProjectId(),
testCaseId,
inputDto
);
}

/**
* Applies a set of modifications to an existing test case in a project.
* Partial updates to the test case's fields can be handled via this endpoint.
*
* @param projectKey The key of the project to which the test case belongs.
* @param testCaseId The ID of the test case to patch.
* @param inputDto A request payload ({@link TmsTestCaseRQ}) containing the modifications.
* @return A data transfer object ({@link TmsTestCaseRS}) with patched details of the test case.
*/
@PreAuthorize(IS_ADMIN)
@PatchMapping("/{testCaseId}")
public TmsTestCaseRS patchTestCase(@PathVariable("projectKey") String projectKey,
@PathVariable("testCaseId") final long testCaseId,
@RequestBody final TmsTestCaseRQ inputDto,
@AuthenticationPrincipal ReportPortalUser user) {
return tmsTestCaseService.patch(
projectExtractor
.extractProjectDetailsAdmin(user, EntityUtils.normalizeId(projectKey))
.getProjectId(),
testCaseId,
inputDto
);
}
}
Loading