Skip to content

TMS migration #2175

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 11 commits into
base: develop
Choose a base branch
from
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
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ dependencies {
implementation 'com.epam.reportportal:plugin-api'
} else {
println("Using snapshot dependencies")
implementation 'com.github.reportportal:commons:c7041ee'
implementation 'com.github.reportportal:commons-dao:196d4ac'
implementation 'com.github.reportportal:commons:c7041ee'
implementation 'com.github.reportportal:plugin-api:8874441'
}
implementation 'jakarta.servlet:jakarta.servlet-api:6.1.0'
Expand Down Expand Up @@ -114,6 +114,7 @@ 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 'jakarta.inject:jakarta.inject-api:2.0.1'
Expand All @@ -139,6 +140,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 Down
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
6 changes: 4 additions & 2 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.13.0' : 'develop')
migrationsUrl = migrationsScriptsUrl + (releaseMode ? '5.13.0' : 'feature/EPMRPP-migrate-tms')
//TODO refactor with archive download
testScriptsSrc = [
(migrationsUrl + '/migrations/0_extensions.up.sql') : 'V001__extensions.sql',
Expand Down Expand Up @@ -71,7 +71,9 @@ 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',
]
excludeTests = ['**/entity/**',
'**/aop/**',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.epam.ta.reportportal.core.tms.controller;

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

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 io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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.imports.AvoidStarImportCheck> reported by reviewdog 🐶
Using the '.' form of import should be avoided - org.springframework.web.bind.annotation..


@RestController

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/{projectId}/tms/productversion")
@Tag(name = "Product Version", description = "Product Version API collection")
@RequiredArgsConstructor
public class ProductVersionController {

private final ProductVersionService productVersionService;

@PreAuthorize(ADMIN_ONLY)
@GetMapping("/{productVersionId}")
TmsProductVersionRS getById(@PathVariable("projectId") final long projectId,
@PathVariable("productVersionId") final long productVersionId) {
return productVersionService.getById(projectId, productVersionId);
}

@PreAuthorize(ADMIN_ONLY)
@PostMapping
TmsProductVersionRS createVersion(@PathVariable("projectId") final long projectId,
@RequestBody final ProductVersionRQ inputDto) {
return productVersionService.create(projectId, inputDto);
}

@PreAuthorize(ADMIN_ONLY)
@PutMapping("/{productVersionId}")
TmsProductVersionRS updateVersion(@PathVariable("projectId") final long projectId,
@PathVariable("productVersionId") final long productVersionId,
@RequestBody final ProductVersionRQ inputDto) {
return productVersionService.update(projectId, productVersionId, inputDto);
}

@PreAuthorize(ADMIN_ONLY)
@DeleteMapping("/{productVersionId}")
void deleteVersion(@PathVariable("projectId") final long projectId,
@PathVariable("productVersionId") final long productVersionId) {
productVersionService.delete(projectId, productVersionId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.epam.ta.reportportal.core.tms.controller;

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

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 io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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.imports.AvoidStarImportCheck> reported by reviewdog 🐶
Using the '.' form of import should be avoided - org.springframework.web.bind.annotation..


import java.util.List;

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.imports.CustomImportOrderCheck> reported by reviewdog 🐶
Extra separation in import group before 'java.util.List'

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.imports.CustomImportOrderCheck> reported by reviewdog 🐶
Wrong lexicographical order for 'java.util.List' import. Should be before 'org.springframework.web.bind.annotation.*'.


@RestController

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/{projectId}/tms/test-case")
@Tag(name = "Test Case", description = "Test Case API collection")
@RequiredArgsConstructor
public class TestCaseController {

private final TmsTestCaseService tmsTestCaseService;

@PreAuthorize(ADMIN_ONLY)
@GetMapping("/{testCaseId}")
public TmsTestCaseRS getTestCaseById(@PathVariable("projectId") final long projectId,
@PathVariable("testCaseId") final long testCaseId) {
return tmsTestCaseService.getById(projectId, testCaseId);
}

@PreAuthorize(ADMIN_ONLY)
@GetMapping
public List<TmsTestCaseRS> getTestCaseByProjectId(@PathVariable("projectId") final long projectId) {
return tmsTestCaseService.getTestCaseByProjectId(projectId);
}

@PreAuthorize(ADMIN_ONLY)
@PostMapping
public TmsTestCaseRS createTestCase(@PathVariable("projectId") final long projectId,
@RequestBody @Valid final TmsTestCaseRQ inputDto) {
return tmsTestCaseService.create(projectId, inputDto);
}

@PreAuthorize(ADMIN_ONLY)
@PutMapping("/{testCaseId}")
public TmsTestCaseRS updateTestCase(@PathVariable("projectId") final long projectId,
@PathVariable("testCaseId") final long testCaseId,
@RequestBody final TmsTestCaseRQ inputDto) {
return tmsTestCaseService.update(projectId, testCaseId, inputDto);
}

@PreAuthorize(ADMIN_ONLY)
@PatchMapping("/{testCaseId}")
public TmsTestCaseRS patchTestCase(@PathVariable("projectId") final long projectId,
@PathVariable("testCaseId") final long testCaseId,
@RequestBody final TmsTestCaseRQ inputDto) {
return tmsTestCaseService.patch(projectId, testCaseId, inputDto);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.epam.ta.reportportal.core.tms.controller;

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

import com.epam.ta.reportportal.core.tms.dto.TestFolderRQ;
import com.epam.ta.reportportal.core.tms.dto.TestFolderRS;
import com.epam.ta.reportportal.core.tms.service.TestFolderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
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;

import java.util.List;

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.imports.CustomImportOrderCheck> reported by reviewdog 🐶
Extra separation in import group before 'java.util.List'

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.imports.CustomImportOrderCheck> reported by reviewdog 🐶
Wrong lexicographical order for 'java.util.List' import. Should be before 'org.springframework.web.bind.annotation.RestController'.


@RestController

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/{projectId}/tms/folder")
@Tag(name = "Test Folder", description = "Test Folder API collection")
@RequiredArgsConstructor
public class TestFolderController {

private final TestFolderService testFolderService;

@PreAuthorize(ADMIN_ONLY)
@PostMapping
@Operation(summary = "Create Test Folder")
TestFolderRS createTestFolder(@PathVariable("projectId") final long projectId,
@RequestBody final TestFolderRQ inputDto) {
return testFolderService.createFolder(projectId, inputDto);
}

@PreAuthorize(ADMIN_ONLY)
@PutMapping("/{folderId}")
@Operation(summary = "Update Test Folder")
TestFolderRS updateTestFolder(@PathVariable("projectId") final long projectId,
@PathVariable("folderId") final long folderId,
@RequestBody final TestFolderRQ inputDto) {
return testFolderService.updateFolder(projectId, folderId, inputDto);
}

@PreAuthorize(ADMIN_ONLY)
@GetMapping("/{folderId}")
@Operation(summary = "Get Test Folder by ID")
TestFolderRS getTestFolderById(@PathVariable("projectId") final long projectId,
@PathVariable("folderId") final long folderId) {
return testFolderService.getFolderById(folderId);
}

@PreAuthorize(ADMIN_ONLY)
@GetMapping("/")
@Operation(summary = "Get Test Folders by project ID")
List<TestFolderRS> getTestFolderByProjectId(@PathVariable("projectId") final long projectId) {
return testFolderService.getFolderByProjectID(projectId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package com.epam.ta.reportportal.core.tms.controller;

import com.epam.ta.reportportal.core.tms.dto.TmsDatasetRQ;
import com.epam.ta.reportportal.core.tms.dto.TmsDatasetRS;
import com.epam.ta.reportportal.core.tms.service.TmsDatasetService;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.DeleteMapping;
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.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController

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/{projectId}/tms/dataset")
@RequiredArgsConstructor
public class TmsDatasetController {

private final TmsDatasetService tmsDatasetService;

/**
* Create a new Dataset.
*
* @param projectId The ID of the project.
* @param datasetRQ Dataset creation request object.
* @return Created Dataset information.
*/
@PostMapping
// @PreAuthorize(ADMIN_ONLY)
public TmsDatasetRS create(@PathVariable("projectId") Long projectId,
@RequestBody TmsDatasetRQ datasetRQ) {
return tmsDatasetService.create(projectId, datasetRQ);
}

/**
* Extract Dataset from a file
*
* @param projectId The ID of the project
* @param file file containing dataset data
* @return Response with created dataset details
*/
@PostMapping(path = "/upload", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
// @PreAuthorize(ADMIN_ONLY)
public List<TmsDatasetRS> uploadFromFile(@PathVariable("projectId") Long projectId,
@RequestPart MultipartFile file) {
return tmsDatasetService.uploadFromFile(projectId, file);
}

/**
* Retrieve a list of Datasets for the specified project.
*
* @param projectId The ID of the project.
* @return List of Datasets.
*/
@GetMapping
// @PreAuthorize(ADMIN_ONLY)
public List<TmsDatasetRS> getByProjectId(@PathVariable("projectId") Long projectId) {
return tmsDatasetService.getByProjectId(projectId);
}

/**
* Retrieve details of a specific Dataset.
*
* @param projectId The ID of the project.
* @param datasetId The ID of the Dataset.
* @return Dataset details.
*/
@GetMapping("/{datasetId}")
// @PreAuthorize(ADMIN_ONLY)
public TmsDatasetRS getById(@PathVariable("projectId") Long projectId,
@PathVariable("datasetId") Long datasetId) {
return tmsDatasetService.getById(projectId, datasetId);
}

/**
* Fully update a Dataset.
*
* @param projectId The ID of the project.
* @param datasetId The ID of the Dataset.
* @param datasetRQ Dataset update request object.
* @return Updated Dataset details.
*/
@PutMapping("/{datasetId}")
// @PreAuthorize(ADMIN_ONLY)
public TmsDatasetRS update(@PathVariable("projectId") Long projectId,
@PathVariable("datasetId") Long datasetId, @RequestBody TmsDatasetRQ datasetRQ) {
return tmsDatasetService.update(projectId, datasetId, datasetRQ);
}

/**
* Patch a Dataset.
*
* @param projectId The ID of the project.
* @param datasetId The ID of the Dataset.
* @param tmsDatasetUpdateRQ Patch dataset request.
* @return Updated Dataset details.
*/
@PatchMapping("/{datasetId}")
// @PreAuthorize(ADMIN_ONLY)
public TmsDatasetRS patch(@PathVariable("projectId") Long projectId,
@PathVariable("datasetId") Long datasetId, @RequestBody TmsDatasetRQ tmsDatasetUpdateRQ) {
return tmsDatasetService.patch(projectId, datasetId, tmsDatasetUpdateRQ);
}

/**
* Delete a Dataset.
*
* @param projectId The ID of the project.
* @param datasetId The ID of the Dataset.
*/
@DeleteMapping("/{datasetId}")
// @PreAuthorize(ADMIN_ONLY)
public void delete(@PathVariable("projectId") Long projectId,
@PathVariable("datasetId") Long datasetId) {
tmsDatasetService.delete(projectId, datasetId);
}
}
Loading