Skip to content
Merged
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
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
# Development versions
commons-dev = "f7c7d2c"
commons-dao-dev = "d970c6cc2e"
commons-dao-dev = "83498e7eb1"
plugin-api-dev = "87b8788"

# Platform versions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.epam.ta.reportportal.core.tms.dto.TmsTestCaseExecutionRS;
import com.epam.ta.reportportal.core.tms.dto.TmsTestFolderRS;
import com.epam.ta.reportportal.core.tms.dto.batch.BatchAddTestCasesToLaunchRQ;
import com.epam.ta.reportportal.core.tms.dto.batch.BatchOperationResultRS;
import com.epam.ta.reportportal.core.tms.dto.batch.BatchTestCaseOperationResultRS;
import com.epam.ta.reportportal.ws.reporting.OperationCompletionRS;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand All @@ -20,7 +20,6 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
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;
Expand Down Expand Up @@ -121,7 +120,7 @@ public OperationCompletionRS batchDeleteManualLaunches(
// Test Case management in Launch
@PostMapping("/launch/{launchId}/test-case")
@Operation(summary = "Add single test case to Manual Launch")
public BatchOperationResultRS addTestCaseToLaunch(
public BatchTestCaseOperationResultRS addTestCaseToLaunch(
@Parameter(description = "Project key", required = true)
@PathVariable String projectKey,
@Parameter(description = "Launch ID", required = true)
Expand All @@ -135,7 +134,7 @@ public BatchOperationResultRS addTestCaseToLaunch(

@PostMapping("/launch/{launchId}/test-case/batch")
@Operation(summary = "Add multiple test cases to Manual Launch")
public BatchOperationResultRS addTestCasesToLaunch(
public BatchTestCaseOperationResultRS addTestCasesToLaunch(
@Parameter(description = "Project key", required = true)
@PathVariable String projectKey,
@Parameter(description = "Launch ID", required = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import com.epam.ta.reportportal.commons.EntityUtils;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.commons.querygen.Filter;
import com.epam.ta.reportportal.core.tms.dto.DuplicateTmsTestPlanRS;
import com.epam.ta.reportportal.core.tms.dto.TmsTestCaseInTestPlanRS;
import com.epam.ta.reportportal.core.tms.dto.TmsTestFolderRS;
import com.epam.ta.reportportal.core.tms.dto.TmsTestPlanRQ;
import com.epam.ta.reportportal.core.tms.dto.TmsTestPlanRS;
import com.epam.ta.reportportal.core.tms.dto.batch.BatchAddTestCasesToPlanRQ;
import com.epam.ta.reportportal.core.tms.dto.batch.BatchOperationResultRS;
import com.epam.ta.reportportal.core.tms.dto.batch.BatchTestCaseOperationResultRS;
import com.epam.ta.reportportal.core.tms.dto.batch.BatchRemoveTestCasesFromPlanRQ;
import com.epam.ta.reportportal.core.tms.service.TmsTestPlanService;
import com.epam.ta.reportportal.entity.tms.TmsTestCase;
Expand Down Expand Up @@ -182,7 +183,7 @@ public TmsTestPlanRS patchTestPlan(@PathVariable String projectKey,
tags = {"Batch Operations"}
)
@ApiResponse(responseCode = "204", description = "Test cases added to test plan successfully")
public BatchOperationResultRS addTestCasesToPlan(@PathVariable String projectKey,
public BatchTestCaseOperationResultRS addTestCasesToPlan(@PathVariable String projectKey,
@PathVariable("id") Long testPlanId,
@Valid @RequestBody BatchAddTestCasesToPlanRQ addRequest,
@AuthenticationPrincipal ReportPortalUser user) {
Expand All @@ -208,7 +209,7 @@ public BatchOperationResultRS addTestCasesToPlan(@PathVariable String projectKey
tags = {"Batch Operations"}
)
@ApiResponse(responseCode = "204", description = "Test cases removed from test plan successfully")
public BatchOperationResultRS removeTestCasesFromPlan(@PathVariable String projectKey,
public BatchTestCaseOperationResultRS removeTestCasesFromPlan(@PathVariable String projectKey,
@PathVariable("id") Long testPlanId,
@Valid @RequestBody BatchRemoveTestCasesFromPlanRQ removeRequest,
@AuthenticationPrincipal ReportPortalUser user) {
Expand Down Expand Up @@ -252,9 +253,13 @@ public Page<TmsTestFolderRS> getTestFoldersFromPlan(@PathVariable String project
description = "Duplicates test plan by test plan ID."
)
@ApiResponse(responseCode = "200", description = "Duplicated test plan")
public TmsTestPlanRS duplicateTestPlan(@PathVariable String projectKey,
public DuplicateTmsTestPlanRS duplicateTestPlan(@PathVariable String projectKey,
@PathVariable("id") Long testPlanId,
@AuthenticationPrincipal ReportPortalUser user) {
throw new UnsupportedOperationException();
return tmsTestPlanService.duplicate(
projectExtractor
.extractMembershipDetails(user, EntityUtils.normalizeId(projectKey))
.getProjectId(),
testPlanId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.epam.ta.reportportal.core.tms.dto;

import com.epam.ta.reportportal.core.tms.dto.batch.BatchTestCaseOperationResultRS;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class DuplicateTmsTestPlanRS {

private Long id;
private String name;
private String description;
private TmsTestPlanExecutionStatisticRS executionStatistic;
private List<TmsTestPlanAttributeRS> attributes;
private BatchTestCaseOperationResultRS duplicationStatistic;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.epam.ta.reportportal.core.tms.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class TmsTestPlanExecutionStatisticRS {
private Long covered;
private Long total;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.epam.ta.reportportal.core.tms.dto;

import com.epam.ta.reportportal.entity.tms.TmsTestPlanExecutionStatisticRS;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.List;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BatchOperationError {
private Long testCaseId;
public class BatchTestCaseOperationError {
private Long testCaseIds;
private String errorMessage;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BatchOperationResultRS {
private int totalCount;
private int successCount;
private int failureCount;
private List<BatchOperationError> errors;
public class BatchTestCaseOperationResultRS {
private Integer totalCount;
private Integer successCount;
private Integer failureCount;
private List<Long> successTestCaseIds;
private List<BatchTestCaseOperationError> errors;
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package com.epam.ta.reportportal.core.tms.mapper;

import com.epam.ta.reportportal.entity.tms.TmsTestCase;
import com.epam.ta.reportportal.entity.tms.TmsTestCaseExecution;
import com.epam.ta.reportportal.entity.tms.TmsTestCaseVersion;
import com.epam.ta.reportportal.entity.tms.TmsTestFolder;
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.dto.batch.BatchTestCaseOperationError;
import com.epam.ta.reportportal.core.tms.dto.batch.BatchTestCaseOperationResultRS;
import com.epam.ta.reportportal.core.tms.mapper.config.CommonMapperConfig;
import com.epam.ta.reportportal.entity.project.Project;
import com.epam.ta.reportportal.entity.tms.TmsTestCase;
import com.epam.ta.reportportal.entity.tms.TmsTestCaseExecution;
import com.epam.ta.reportportal.entity.tms.TmsTestCaseVersion;
import com.epam.ta.reportportal.entity.tms.TmsTestFolder;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.mapstruct.BeanMapping;
import org.mapstruct.Mapper;
Expand Down Expand Up @@ -123,10 +126,21 @@ protected TmsTestFolder convertToTmsTestFolder(Long tmsTestFolderId,
@Mapping(target = "testItems", ignore = true)
@Mapping(target = "createdAt", ignore = true)
@Mapping(target = "updatedAt", ignore = true)
@Mapping(target = "name", source = "originalTestCase.name")
@Mapping(target = "name", ignore = true) //unique name will be set later in service
@Mapping(target = "priority", source = "originalTestCase.priority")
@Mapping(target = "description", source = "originalTestCase.description")
@Mapping(target = "testFolder", source = "targetFolder")
public abstract TmsTestCase duplicateTestCase(TmsTestCase originalTestCase,
TmsTestFolder targetFolder);

public BatchTestCaseOperationResultRS toBatchOperationResult(List<Long> successfulIds,
List<BatchTestCaseOperationError> errors) {
BatchTestCaseOperationResultRS result = new BatchTestCaseOperationResultRS();
result.setSuccessCount(successfulIds.size());
result.setFailureCount(errors.size());
result.setTotalCount(successfulIds.size() + errors.size());
result.setErrors(errors);
result.setSuccessTestCaseIds(successfulIds);
return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.epam.ta.reportportal.core.tms.mapper;

import com.epam.ta.reportportal.entity.tms.TmsTestPlan;
import com.epam.ta.reportportal.entity.tms.TmsTestPlanAttribute;
import com.epam.ta.reportportal.core.tms.dto.TmsTestPlanAttributeRQ;
import com.epam.ta.reportportal.core.tms.dto.TmsTestPlanAttributeRS;
Expand All @@ -25,4 +26,13 @@ public abstract TmsTestPlanAttribute convertToTmsTestPlanAttribute(
@Mapping(target = "value", source = "tmsTestPlanAttribute.value")
public abstract TmsTestPlanAttributeRS convertTmsPlanAttributeRS(
TmsTestPlanAttribute tmsTestPlanAttribute);
}

@Mapping(target = "id.testPlanId", ignore = true)
@Mapping(target = "id.attributeId", source = "originalAttribute.id.attributeId")
@Mapping(target = "attribute", source = "originalAttribute.attribute")
@Mapping(target = "value", source = "originalAttribute.value")
@Mapping(target = "testPlan", source = "newTestPlan")
public abstract TmsTestPlanAttribute duplicateTestPlanAttribute(
TmsTestPlanAttribute originalAttribute,
TmsTestPlan newTestPlan);
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package com.epam.ta.reportportal.core.tms.mapper;

import com.epam.ta.reportportal.core.tms.dto.TmsTestPlanExecutionStatisticRS;
import com.epam.ta.reportportal.core.tms.mapper.config.CommonMapperConfig;
import com.epam.ta.reportportal.entity.tms.TmsTestPlanExecutionStatisticRS;
import com.epam.ta.reportportal.entity.tms.TmsTestPlanExecutionStatistic;
import org.mapstruct.Mapper;

@Mapper(config = CommonMapperConfig.class)
public interface TmsTestPlanExecutionMapper {

TmsTestPlanExecutionStatisticRS toDto(
com.epam.ta.reportportal.entity.tms.TmsTestPlanExecutionStatisticRS executionStatistic);
TmsTestPlanExecutionStatistic executionStatistic);

default TmsTestPlanExecutionStatisticRS createEmptyStatistics() {
return TmsTestPlanExecutionStatisticRS.builder()
default TmsTestPlanExecutionStatistic createEmptyStatistics() {
return TmsTestPlanExecutionStatistic.builder()
.total(0L)
.covered(0L)
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.epam.ta.reportportal.core.tms.mapper;

import com.epam.ta.reportportal.entity.tms.TmsTestPlan;
import com.epam.ta.reportportal.core.tms.dto.DuplicateTmsTestPlanRS;
import com.epam.ta.reportportal.core.tms.dto.TmsTestPlanExecutionStatisticRS;
import com.epam.ta.reportportal.core.tms.dto.TmsTestPlanRQ;
import com.epam.ta.reportportal.core.tms.dto.TmsTestPlanRS;
import com.epam.ta.reportportal.core.tms.dto.batch.BatchOperationError;
import com.epam.ta.reportportal.core.tms.dto.batch.BatchOperationResultRS;
import com.epam.ta.reportportal.core.tms.dto.batch.BatchTestCaseOperationError;
import com.epam.ta.reportportal.core.tms.dto.batch.BatchTestCaseOperationResultRS;
import com.epam.ta.reportportal.core.tms.mapper.config.CommonMapperConfig;
import com.epam.ta.reportportal.entity.tms.TmsTestPlan;
import com.epam.ta.reportportal.entity.tms.TmsTestPlanWithStatistic;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.mapstruct.BeanMapping;
Expand All @@ -19,7 +22,9 @@
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;

@Mapper(config = CommonMapperConfig.class, uses = TmsTestPlanAttributeMapper.class)
@Mapper(config = CommonMapperConfig.class, uses = {
TmsTestPlanAttributeMapper.class, TmsTestPlanExecutionMapper.class
})
public abstract class TmsTestPlanMapper {

@Mapping(target = "attributes", source = "attributes")
Expand All @@ -30,7 +35,8 @@ public abstract class TmsTestPlanMapper {
@Mapping(target = "description", source = "tmsTestPlan.testPlan.description")
@Mapping(target = "attributes", source = "tmsTestPlan.testPlan.attributes")
@Mapping(target = "executionStatistic", source = "tmsTestPlan.executionStatistic")
public abstract TmsTestPlanRS convertTmsTestPlanWithStatisticToRS(TmsTestPlanWithStatistic tmsTestPlan);
public abstract TmsTestPlanRS convertTmsTestPlanWithStatisticToRS(
TmsTestPlanWithStatistic tmsTestPlan);

@Mapping(target = "project.id", source = "projectId")
@Mapping(target = "attributes", ignore = true)
Expand All @@ -57,9 +63,9 @@ public Page<TmsTestPlanRS> convertToRS(Page<TmsTestPlan> testPlansByCriteria) {
testPlansByCriteria.getTotalElements());
}

public BatchOperationResultRS convertToRS(int totalCount, int successCount,
List<BatchOperationError> errors) {
return BatchOperationResultRS.builder()
public BatchTestCaseOperationResultRS convertToRS(int totalCount, int successCount,
List<BatchTestCaseOperationError> errors) {
return BatchTestCaseOperationResultRS.builder()
.totalCount(totalCount)
.successCount(successCount)
.failureCount(totalCount - successCount)
Expand All @@ -80,4 +86,62 @@ public Page<TmsTestPlanRS> convertTmsTestPlanWithStatisticToRS(
totalCount
);
}

@Mapping(target = "id", ignore = true)
@Mapping(target = "searchVector", ignore = true)
@Mapping(target = "attributes", ignore = true)
@Mapping(target = "milestones", ignore = true)
@Mapping(target = "launches", ignore = true)
@Mapping(target = "testCases", ignore = true)
public abstract TmsTestPlan duplicateTestPlan(TmsTestPlan originalTestPlan);

@Mapping(target = "duplicationStatistic", ignore = true)
public abstract DuplicateTmsTestPlanRS toDuplicateTmsTestPlanRS(TmsTestPlan testPlan);

public DuplicateTmsTestPlanRS buildDuplicateTestPlanResponse(TmsTestPlan testPlan,
BatchTestCaseOperationResultRS duplicationStatistic) {
var response = toDuplicateTmsTestPlanRS(testPlan);
response.setDuplicationStatistic(duplicationStatistic);
response.setExecutionStatistic(TmsTestPlanExecutionStatisticRS
.builder()
.covered(0L)
.total(Long.valueOf(duplicationStatistic.getTotalCount()))
.build());
return response;
}

public BatchTestCaseOperationResultRS combineDuplicateTestPlanBatchResults(
BatchTestCaseOperationResultRS duplicateTestCasesResult,
BatchTestCaseOperationResultRS addTestCasesToPlanResult) {
var allErrors = new ArrayList<BatchTestCaseOperationError>();
if (duplicateTestCasesResult.getErrors() != null) {
allErrors.addAll(duplicateTestCasesResult.getErrors());
}
if (addTestCasesToPlanResult.getErrors() != null) {
allErrors.addAll(addTestCasesToPlanResult.getErrors());
}

var result = new BatchTestCaseOperationResultRS();
result.setSuccessCount(
addTestCasesToPlanResult.getSuccessCount()); // Only truly successful are those added to plan
result.setFailureCount(duplicateTestCasesResult.getFailureCount() + addTestCasesToPlanResult.getFailureCount());
result.setErrors(allErrors);
result.setTotalCount(duplicateTestCasesResult.getTotalCount());
return result;
}

public BatchTestCaseOperationResultRS createFailedBatchResult(List<Long> failedIds,
String errorMessage) {
var errors = failedIds
.stream()
.map(id -> new BatchTestCaseOperationError(id, errorMessage))
.collect(Collectors.toList());

var result = new BatchTestCaseOperationResultRS();
result.setSuccessCount(0);
result.setFailureCount(failedIds.size());
result.setErrors(errors);
result.setTotalCount(failedIds.size());
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.epam.ta.reportportal.core.tms.dto.TmsTestCaseRS;
import com.epam.ta.reportportal.core.tms.dto.batch.BatchDeleteTestCasesRQ;
import com.epam.ta.reportportal.core.tms.dto.batch.BatchDuplicateTestCasesRQ;
import com.epam.ta.reportportal.core.tms.dto.batch.BatchTestCaseOperationResultRS;
import com.epam.ta.reportportal.core.tms.dto.batch.BatchPatchTestCaseAttributesRQ;
import com.epam.ta.reportportal.core.tms.dto.batch.BatchPatchTestCasesRQ;
import com.epam.ta.reportportal.model.Page;
Expand Down Expand Up @@ -73,4 +74,6 @@ void exportToFile(Long projectId, List<Long> ids, String format, boolean include
* @return A list of data transfer objects containing details of the duplicated test cases.
*/
List<TmsTestCaseRS> duplicate(long projectId, BatchDuplicateTestCasesRQ duplicateRequest);

BatchTestCaseOperationResultRS duplicateTestCases(long projectId, List<Long> originalTestCaseIds);
}
Loading
Loading