Search in sources :

Example 1 with UpdateIssueSubTypeRQ

use of com.epam.ta.reportportal.ws.model.project.config.UpdateIssueSubTypeRQ in project service-api by reportportal.

the class UpdateProjectSettingsHandlerImplTest method emptyRequest.

@Test
void emptyRequest() {
    ReportPortalUser user = getRpUser("user", UserRole.USER, ProjectRole.PROJECT_MANAGER, 1L);
    UpdateIssueSubTypeRQ updateIssueSubTypeRQ = new UpdateIssueSubTypeRQ();
    updateIssueSubTypeRQ.setIds(Collections.emptyList());
    ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.updateProjectIssueSubType("test_project", user, updateIssueSubTypeRQ));
    assertEquals("Forbidden operation. Please specify at least one item data for update.", exception.getMessage());
}
Also used : ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) UpdateIssueSubTypeRQ(com.epam.ta.reportportal.ws.model.project.config.UpdateIssueSubTypeRQ) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Test(org.junit.jupiter.api.Test)

Example 2 with UpdateIssueSubTypeRQ

use of com.epam.ta.reportportal.ws.model.project.config.UpdateIssueSubTypeRQ in project service-api by reportportal.

the class UpdateProjectSettingsHandlerImpl method updateProjectIssueSubType.

@Override
public OperationCompletionRS updateProjectIssueSubType(String projectName, ReportPortalUser user, UpdateIssueSubTypeRQ updateIssueSubTypeRQ) {
    expect(updateIssueSubTypeRQ.getIds().size() > 0, equalTo(true)).verify(FORBIDDEN_OPERATION, "Please specify at least one item data for update.");
    Project project = projectRepository.findByName(projectName).orElseThrow(() -> new ReportPortalException(PROJECT_NOT_FOUND, projectName));
    List<IssueTypeActivityResource> issueTypeActivityResources = updateIssueSubTypeRQ.getIds().stream().map(subTypeRQ -> TO_ACTIVITY_RESOURCE.apply(validateAndUpdate(subTypeRQ, project.getProjectIssueTypes().stream().map(ProjectIssueType::getIssueType).collect(Collectors.toList())))).collect(Collectors.toList());
    projectRepository.save(project);
    issueTypeActivityResources.forEach(it -> messageBus.publishActivity(new DefectTypeUpdatedEvent(it, user.getUserId(), user.getUsername(), project.getId())));
    return new OperationCompletionRS("Issue sub-type(s) was updated successfully.");
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS) UpdateIssueSubTypeRQ(com.epam.ta.reportportal.ws.model.project.config.UpdateIssueSubTypeRQ) UpdateOneIssueSubTypeRQ(com.epam.ta.reportportal.ws.model.project.config.UpdateOneIssueSubTypeRQ) PatternTemplate(com.epam.ta.reportportal.entity.pattern.PatternTemplate) Autowired(org.springframework.beans.factory.annotation.Autowired) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) MessageBus(com.epam.ta.reportportal.core.events.MessageBus) UpdateProjectSettingsHandler(com.epam.ta.reportportal.core.project.settings.UpdateProjectSettingsHandler) StringUtils(org.apache.commons.lang3.StringUtils) DefectTypeUpdatedEvent(com.epam.ta.reportportal.core.events.activity.DefectTypeUpdatedEvent) PatternTemplateActivityResource(com.epam.ta.reportportal.ws.model.activity.PatternTemplateActivityResource) Predicates(com.epam.ta.reportportal.commons.Predicates) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) PatternUpdatedEvent(com.epam.ta.reportportal.core.events.activity.PatternUpdatedEvent) Service(org.springframework.stereotype.Service) IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) PatternTemplateConverter(com.epam.ta.reportportal.ws.converter.converters.PatternTemplateConverter) BusinessRule(com.epam.ta.reportportal.commons.validation.BusinessRule) IssueTypeActivityResource(com.epam.ta.reportportal.ws.model.activity.IssueTypeActivityResource) BusinessRule.expect(com.epam.ta.reportportal.commons.validation.BusinessRule.expect) Optional.ofNullable(java.util.Optional.ofNullable) TestItemIssueGroup(com.epam.ta.reportportal.entity.enums.TestItemIssueGroup) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) PatternTemplateRepository(com.epam.ta.reportportal.dao.PatternTemplateRepository) List(java.util.List) TO_ACTIVITY_RESOURCE(com.epam.ta.reportportal.ws.converter.converters.IssueTypeConverter.TO_ACTIVITY_RESOURCE) ProjectRepository(com.epam.ta.reportportal.dao.ProjectRepository) ProjectIssueType(com.epam.ta.reportportal.entity.project.ProjectIssueType) Suppliers(com.epam.ta.reportportal.commons.validation.Suppliers) UpdatePatternTemplateRQ(com.epam.ta.reportportal.ws.model.project.config.pattern.UpdatePatternTemplateRQ) Transactional(org.springframework.transaction.annotation.Transactional) Project(com.epam.ta.reportportal.entity.project.Project) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) DefectTypeUpdatedEvent(com.epam.ta.reportportal.core.events.activity.DefectTypeUpdatedEvent) IssueTypeActivityResource(com.epam.ta.reportportal.ws.model.activity.IssueTypeActivityResource) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Example 3 with UpdateIssueSubTypeRQ

use of com.epam.ta.reportportal.ws.model.project.config.UpdateIssueSubTypeRQ in project service-api by reportportal.

the class UpdateProjectSettingsHandlerImplTest method updateSubtypeOnNotExistProject.

@Test
void updateSubtypeOnNotExistProject() {
    long projectId = 1L;
    ReportPortalUser user = getRpUser("user", UserRole.USER, ProjectRole.PROJECT_MANAGER, projectId);
    UpdateIssueSubTypeRQ updateIssueSubTypeRQ = new UpdateIssueSubTypeRQ();
    updateIssueSubTypeRQ.setIds(Collections.singletonList(new UpdateOneIssueSubTypeRQ()));
    when(projectRepository.findByName(TEST_PROJECT_NAME)).thenReturn(Optional.empty());
    ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.updateProjectIssueSubType(TEST_PROJECT_NAME, user, updateIssueSubTypeRQ));
    assertEquals("Project 'test_project' not found. Did you use correct project name?", exception.getMessage());
}
Also used : UpdateOneIssueSubTypeRQ(com.epam.ta.reportportal.ws.model.project.config.UpdateOneIssueSubTypeRQ) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) UpdateIssueSubTypeRQ(com.epam.ta.reportportal.ws.model.project.config.UpdateIssueSubTypeRQ) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Test(org.junit.jupiter.api.Test)

Example 4 with UpdateIssueSubTypeRQ

use of com.epam.ta.reportportal.ws.model.project.config.UpdateIssueSubTypeRQ in project service-api by reportportal.

the class UpdateProjectSettingsHandlerImplTest method updateNotExistSubtype.

@Test
void updateNotExistSubtype() {
    long projectId = 1L;
    ReportPortalUser user = getRpUser("user", UserRole.USER, ProjectRole.PROJECT_MANAGER, projectId);
    UpdateIssueSubTypeRQ updateIssueSubTypeRQ = new UpdateIssueSubTypeRQ();
    UpdateOneIssueSubTypeRQ oneIssueSubTypeRQ = new UpdateOneIssueSubTypeRQ();
    oneIssueSubTypeRQ.setTypeRef("product_bug");
    oneIssueSubTypeRQ.setLocator("locator");
    updateIssueSubTypeRQ.setIds(Collections.singletonList(oneIssueSubTypeRQ));
    when(projectRepository.findByName(TEST_PROJECT_NAME)).thenReturn(Optional.of(new Project()));
    ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.updateProjectIssueSubType(TEST_PROJECT_NAME, user, updateIssueSubTypeRQ));
    assertEquals("Issue Type 'locator' not found.", exception.getMessage());
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) UpdateOneIssueSubTypeRQ(com.epam.ta.reportportal.ws.model.project.config.UpdateOneIssueSubTypeRQ) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) UpdateIssueSubTypeRQ(com.epam.ta.reportportal.ws.model.project.config.UpdateIssueSubTypeRQ) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Test(org.junit.jupiter.api.Test)

Example 5 with UpdateIssueSubTypeRQ

use of com.epam.ta.reportportal.ws.model.project.config.UpdateIssueSubTypeRQ in project service-api by reportportal.

the class UpdateProjectSettingsHandlerImplTest method updateSubtypeWithIncorrectGroup.

@Test
void updateSubtypeWithIncorrectGroup() {
    long projectId = 1L;
    ReportPortalUser user = getRpUser("user", UserRole.USER, ProjectRole.PROJECT_MANAGER, projectId);
    UpdateIssueSubTypeRQ updateIssueSubTypeRQ = new UpdateIssueSubTypeRQ();
    UpdateOneIssueSubTypeRQ oneIssueSubTypeRQ = new UpdateOneIssueSubTypeRQ();
    oneIssueSubTypeRQ.setTypeRef("wrongType");
    updateIssueSubTypeRQ.setIds(Collections.singletonList(oneIssueSubTypeRQ));
    when(projectRepository.findByName(TEST_PROJECT_NAME)).thenReturn(Optional.of(new Project()));
    ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.updateProjectIssueSubType(TEST_PROJECT_NAME, user, updateIssueSubTypeRQ));
    assertEquals("Issue Type 'wrongType' not found.", exception.getMessage());
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) UpdateOneIssueSubTypeRQ(com.epam.ta.reportportal.ws.model.project.config.UpdateOneIssueSubTypeRQ) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) UpdateIssueSubTypeRQ(com.epam.ta.reportportal.ws.model.project.config.UpdateIssueSubTypeRQ) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Test(org.junit.jupiter.api.Test)

Aggregations

UpdateIssueSubTypeRQ (com.epam.ta.reportportal.ws.model.project.config.UpdateIssueSubTypeRQ)6 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)5 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)5 UpdateOneIssueSubTypeRQ (com.epam.ta.reportportal.ws.model.project.config.UpdateOneIssueSubTypeRQ)5 Test (org.junit.jupiter.api.Test)5 Project (com.epam.ta.reportportal.entity.project.Project)3 Predicates (com.epam.ta.reportportal.commons.Predicates)1 BusinessRule (com.epam.ta.reportportal.commons.validation.BusinessRule)1 BusinessRule.expect (com.epam.ta.reportportal.commons.validation.BusinessRule.expect)1 Suppliers (com.epam.ta.reportportal.commons.validation.Suppliers)1 MessageBus (com.epam.ta.reportportal.core.events.MessageBus)1 DefectTypeUpdatedEvent (com.epam.ta.reportportal.core.events.activity.DefectTypeUpdatedEvent)1 PatternUpdatedEvent (com.epam.ta.reportportal.core.events.activity.PatternUpdatedEvent)1 UpdateProjectSettingsHandler (com.epam.ta.reportportal.core.project.settings.UpdateProjectSettingsHandler)1 PatternTemplateRepository (com.epam.ta.reportportal.dao.PatternTemplateRepository)1 ProjectRepository (com.epam.ta.reportportal.dao.ProjectRepository)1 TestItemIssueGroup (com.epam.ta.reportportal.entity.enums.TestItemIssueGroup)1 IssueType (com.epam.ta.reportportal.entity.item.issue.IssueType)1 PatternTemplate (com.epam.ta.reportportal.entity.pattern.PatternTemplate)1 ProjectIssueType (com.epam.ta.reportportal.entity.project.ProjectIssueType)1