-
Notifications
You must be signed in to change notification settings - Fork 66
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
base: feature/orgs
Are you sure you want to change the base?
Changes from all commits
3937229
ed0640d
7942b9b
423fdb4
2b794bd
169269d
b474a6f
ad331c3
432f67b
9db8ecc
815e85a
9848ef3
01de53c
a37b5c5
035eb65
5650bd4
a1c4e73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ hs_err_pid* | |
build/ | ||
.gradle/ | ||
out/ | ||
src/test/resources/db/migration/*.sql |
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 | ||
@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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
*/ | ||
@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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
*/ | ||
@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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
* for the product version. | ||
* @return A data transfer object ({@link TmsProductVersionRS}) with updated details of the product version. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
*/ | ||
@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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
@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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
* @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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
* @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 | ||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a Javadoc comment.