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