Search in sources :

Example 1 with IssueTypeActivityResource

use of com.epam.ta.reportportal.ws.model.activity.IssueTypeActivityResource in project service-api by reportportal.

the class DefectTypeDeletedHandlerTest method successfullyReindex.

@Test
void successfullyReindex() {
    long projectId = 2L;
    when(projectRepository.findById(projectId)).thenReturn(Optional.of(getProjectWithAnalyzerAttributes(projectId)));
    when(analyzerServiceClient.hasClients()).thenReturn(true);
    when(analyzerStatusCache.getAnalyzeStatus(AnalyzerStatusCache.AUTO_ANALYZER_KEY)).thenReturn(Optional.of(CacheBuilder.newBuilder().build()));
    List<Long> launchIds = Arrays.asList(1L, 2L, 3L);
    handler.handleDefectTypeDeleted(new DefectTypeDeletedEvent(new IssueTypeActivityResource(), 1L, "user", projectId));
    verify(logIndexer, times(1)).index(eq(projectId), any(AnalyzerConfig.class));
}
Also used : DefectTypeDeletedEvent(com.epam.ta.reportportal.core.events.activity.DefectTypeDeletedEvent) AnalyzerConfig(com.epam.ta.reportportal.ws.model.project.AnalyzerConfig) IssueTypeActivityResource(com.epam.ta.reportportal.ws.model.activity.IssueTypeActivityResource) Test(org.junit.jupiter.api.Test)

Example 2 with IssueTypeActivityResource

use of com.epam.ta.reportportal.ws.model.activity.IssueTypeActivityResource in project service-api by reportportal.

the class DefectTypeDeletedHandlerTest method deleteSubTypeOnNotExistProject.

@Test
void deleteSubTypeOnNotExistProject() {
    long projectId = 2L;
    when(projectRepository.findById(projectId)).thenReturn(Optional.empty());
    ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.handleDefectTypeDeleted(new DefectTypeDeletedEvent(new IssueTypeActivityResource(), 1L, "user", projectId)));
    assertEquals("Project '2' not found. Did you use correct project name?", exception.getMessage());
}
Also used : DefectTypeDeletedEvent(com.epam.ta.reportportal.core.events.activity.DefectTypeDeletedEvent) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) IssueTypeActivityResource(com.epam.ta.reportportal.ws.model.activity.IssueTypeActivityResource) Test(org.junit.jupiter.api.Test)

Example 3 with IssueTypeActivityResource

use of com.epam.ta.reportportal.ws.model.activity.IssueTypeActivityResource 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 4 with IssueTypeActivityResource

use of com.epam.ta.reportportal.ws.model.activity.IssueTypeActivityResource in project service-api by reportportal.

the class DefectTypeDeletedHandlerTest method analysisAlreadyRunningTest.

@Test
void analysisAlreadyRunningTest() {
    long projectId = 2L;
    when(projectRepository.findById(projectId)).thenReturn(Optional.of(new Project()));
    when(analyzerServiceClient.hasClients()).thenReturn(true);
    Cache<Long, Long> cache = CacheBuilder.newBuilder().build();
    cache.put(2L, projectId);
    when(analyzerStatusCache.getAnalyzeStatus(AnalyzerStatusCache.AUTO_ANALYZER_KEY)).thenReturn(Optional.of(cache));
    ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.handleDefectTypeDeleted(new DefectTypeDeletedEvent(new IssueTypeActivityResource(), 1L, "user", projectId)));
    assertEquals("Forbidden operation. Index can not be removed until auto-analysis proceeds.", exception.getMessage());
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) DefectTypeDeletedEvent(com.epam.ta.reportportal.core.events.activity.DefectTypeDeletedEvent) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) IssueTypeActivityResource(com.epam.ta.reportportal.ws.model.activity.IssueTypeActivityResource) Test(org.junit.jupiter.api.Test)

Example 5 with IssueTypeActivityResource

use of com.epam.ta.reportportal.ws.model.activity.IssueTypeActivityResource in project service-api by reportportal.

the class DefectTypeDeletedHandlerTest method noClientsTest.

@Test
void noClientsTest() {
    long projectId = 2L;
    when(projectRepository.findById(projectId)).thenReturn(Optional.of(new Project()));
    when(analyzerServiceClient.hasClients()).thenReturn(false);
    handler.handleDefectTypeDeleted(new DefectTypeDeletedEvent(new IssueTypeActivityResource(), 1L, "user", projectId));
    verifyZeroInteractions(logIndexer);
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) DefectTypeDeletedEvent(com.epam.ta.reportportal.core.events.activity.DefectTypeDeletedEvent) IssueTypeActivityResource(com.epam.ta.reportportal.ws.model.activity.IssueTypeActivityResource) Test(org.junit.jupiter.api.Test)

Aggregations

IssueTypeActivityResource (com.epam.ta.reportportal.ws.model.activity.IssueTypeActivityResource)6 DefectTypeDeletedEvent (com.epam.ta.reportportal.core.events.activity.DefectTypeDeletedEvent)4 Test (org.junit.jupiter.api.Test)4 Project (com.epam.ta.reportportal.entity.project.Project)3 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)3 Predicates (com.epam.ta.reportportal.commons.Predicates)1 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)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