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());
}
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.");
}
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());
}
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());
}
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());
}
Aggregations