Search in sources :

Example 16 with IssueEntity

use of com.epam.ta.reportportal.entity.item.issue.IssueEntity in project service-api by reportportal.

the class IssueConverterTest method toResource.

@Test
void toResource() {
    final Issue issue = getIssue();
    final IssueEntity issueEntity = IssueConverter.TO_ISSUE.apply(issue);
    assertEquals(issueEntity.getIgnoreAnalyzer(), issue.getIgnoreAnalyzer());
    assertEquals(issueEntity.getAutoAnalyzed(), issue.getAutoAnalyzed());
    assertEquals(issue.getComment(), issue.getComment());
}
Also used : Issue(com.epam.ta.reportportal.ws.model.issue.Issue) IssueEntity(com.epam.ta.reportportal.entity.item.issue.IssueEntity) Test(org.junit.jupiter.api.Test)

Example 17 with IssueEntity

use of com.epam.ta.reportportal.entity.item.issue.IssueEntity in project service-api by reportportal.

the class TestItemConverterTest method getItem.

private TestItem getItem(boolean hasIssue) {
    TestItem item = new TestItem();
    item.setName("name");
    item.setDescription("description");
    item.setStartTime(LocalDateTime.now());
    item.setUniqueId("uniqueId");
    item.setUuid("uuid");
    item.setItemId(1L);
    item.setType(TestItemTypeEnum.STEP);
    item.setPath("1.2.3");
    final Parameter parameter = new Parameter();
    parameter.setKey("key");
    parameter.setValue("value");
    item.setParameters(Sets.newHashSet(parameter));
    item.setAttributes(Sets.newHashSet(new ItemAttribute("key1", "value1", false), new ItemAttribute("key2", "value2", false)));
    final Launch launch = new Launch();
    launch.setProjectId(4L);
    launch.setId(2L);
    item.setLaunchId(launch.getId());
    item.setHasChildren(false);
    final TestItem parent = new TestItem();
    parent.setItemId(3L);
    item.setParentId(parent.getItemId());
    final TestItemResults itemResults = new TestItemResults();
    itemResults.setStatus(StatusEnum.FAILED);
    itemResults.setEndTime(LocalDateTime.now());
    if (hasIssue) {
        final IssueEntity issue = new IssueEntity();
        issue.setIssueId(3L);
        issue.setIssueType(new IssueType(new IssueGroup(TestItemIssueGroup.PRODUCT_BUG), "locator", "long name", "SNA", "color"));
        issue.setIgnoreAnalyzer(false);
        issue.setAutoAnalyzed(false);
        issue.setIssueDescription("issue description");
        final Ticket ticket = new Ticket();
        ticket.setTicketId("ticketId1");
        ticket.setUrl("http:/example.com/ticketId1");
        final Ticket ticket1 = new Ticket();
        ticket1.setTicketId("ticketId2");
        ticket1.setUrl("http:/example.com/ticketId2");
        issue.setTickets(Sets.newHashSet(ticket, ticket1));
        itemResults.setIssue(issue);
    }
    itemResults.setStatistics(Sets.newHashSet(new Statistics(new StatisticsField("statistics$defects$automation_bug$total"), 1, 2L)));
    item.setItemResults(itemResults);
    return item;
}
Also used : TestItemIssueGroup(com.epam.ta.reportportal.entity.enums.TestItemIssueGroup) IssueGroup(com.epam.ta.reportportal.entity.item.issue.IssueGroup) Ticket(com.epam.ta.reportportal.entity.bts.Ticket) IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) StatisticsField(com.epam.ta.reportportal.entity.statistics.StatisticsField) IssueEntity(com.epam.ta.reportportal.entity.item.issue.IssueEntity) Parameter(com.epam.ta.reportportal.entity.item.Parameter) ItemAttribute(com.epam.ta.reportportal.entity.ItemAttribute) Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItemResults(com.epam.ta.reportportal.entity.item.TestItemResults) Statistics(com.epam.ta.reportportal.entity.statistics.Statistics) TestItem(com.epam.ta.reportportal.entity.item.TestItem)

Example 18 with IssueEntity

use of com.epam.ta.reportportal.entity.item.issue.IssueEntity in project service-api by reportportal.

the class IssueEntityBuilderTest method issueEntityBuilder.

@Test
void issueEntityBuilder() {
    final boolean autoAnalyzed = false;
    final boolean ignoreAnalyzer = true;
    final IssueType issueType = new IssueType(new IssueGroup(TestItemIssueGroup.PRODUCT_BUG), "locator", "longName", "shortName", "color");
    final String description = "description";
    final IssueEntity issueEntity = new IssueEntityBuilder().addAutoAnalyzedFlag(autoAnalyzed).addIgnoreFlag(ignoreAnalyzer).addIssueType(issueType).addDescription(description).get();
    assertEquals(autoAnalyzed, issueEntity.getAutoAnalyzed());
    assertEquals(ignoreAnalyzer, issueEntity.getIgnoreAnalyzer());
    assertThat(issueEntity.getIssueType()).isEqualToComparingFieldByField(issueType);
    assertEquals(description, issueEntity.getIssueDescription());
}
Also used : IssueGroup(com.epam.ta.reportportal.entity.item.issue.IssueGroup) TestItemIssueGroup(com.epam.ta.reportportal.entity.enums.TestItemIssueGroup) IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) IssueEntity(com.epam.ta.reportportal.entity.item.issue.IssueEntity) Test(org.junit.jupiter.api.Test)

Example 19 with IssueEntity

use of com.epam.ta.reportportal.entity.item.issue.IssueEntity in project service-api by reportportal.

the class PredicatesTest method checkCanBeIndexed.

@Test
void checkCanBeIndexed() {
    TestItem testItem = new TestItem();
    testItem.setType(TestItemTypeEnum.STEP);
    final TestItemResults itemResults = new TestItemResults();
    final IssueEntity issueEntity = new IssueEntity();
    issueEntity.setIgnoreAnalyzer(false);
    final IssueType issueType = new IssueType();
    issueType.setIssueGroup(new IssueGroup(TestItemIssueGroup.PRODUCT_BUG));
    issueEntity.setIssueType(issueType);
    itemResults.setIssue(issueEntity);
    testItem.setItemResults(itemResults);
    assertTrue(ITEM_CAN_BE_INDEXED.test(testItem), "Item should be available for indexing");
}
Also used : TestItemIssueGroup(com.epam.ta.reportportal.entity.enums.TestItemIssueGroup) IssueGroup(com.epam.ta.reportportal.entity.item.issue.IssueGroup) IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) IssueEntity(com.epam.ta.reportportal.entity.item.issue.IssueEntity) TestItemResults(com.epam.ta.reportportal.entity.item.TestItemResults) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Test(org.junit.jupiter.api.Test)

Example 20 with IssueEntity

use of com.epam.ta.reportportal.entity.item.issue.IssueEntity in project service-api by reportportal.

the class DeleteProjectSettingsHandlerImpl method deleteProjectIssueSubType.

@Override
public OperationCompletionRS deleteProjectIssueSubType(String projectName, ReportPortalUser user, Long id) {
    Project project = projectRepository.findByName(projectName).orElseThrow(() -> new ReportPortalException(PROJECT_NOT_FOUND, projectName));
    ProjectIssueType type = project.getProjectIssueTypes().stream().filter(projectIssueType -> projectIssueType.getIssueType().getId().equals(id)).findFirst().orElseThrow(() -> new ReportPortalException(ISSUE_TYPE_NOT_FOUND, id));
    expect(type.getIssueType().getLocator(), not(in(Sets.newHashSet(AUTOMATION_BUG.getLocator(), PRODUCT_BUG.getLocator(), SYSTEM_ISSUE.getLocator(), NO_DEFECT.getLocator(), TO_INVESTIGATE.getLocator())))).verify(FORBIDDEN_OPERATION, "You cannot remove predefined global issue types.");
    String issueField = "statistics$defects$" + TestItemIssueGroup.fromValue(type.getIssueType().getIssueGroup().getTestItemIssueGroup().getValue()).orElseThrow(() -> new ReportPortalException(ISSUE_TYPE_NOT_FOUND, type.getIssueType().getIssueGroup())).getValue().toLowerCase() + "$" + type.getIssueType().getLocator();
    statisticsFieldRepository.deleteByName(issueField);
    IssueType defaultGroupIssueType = issueTypeRepository.findByLocator(type.getIssueType().getIssueGroup().getTestItemIssueGroup().getLocator()).orElseThrow(() -> new ReportPortalException(ErrorType.ISSUE_TYPE_NOT_FOUND, type.getIssueType()));
    List<IssueEntity> allByIssueTypeId = issueEntityRepository.findAllByIssueTypeId(id);
    allByIssueTypeId.forEach(issueEntity -> issueEntity.setIssueType(defaultGroupIssueType));
    project.getProjectIssueTypes().remove(type);
    projectRepository.save(project);
    issueTypeRepository.delete(type.getIssueType());
    updateWidgets(project, type.getIssueType());
    DefectTypeDeletedEvent defectTypeDeletedEvent = new DefectTypeDeletedEvent(TO_ACTIVITY_RESOURCE.apply(type.getIssueType()), user.getUserId(), user.getUsername(), project.getId());
    messageBus.publishActivity(defectTypeDeletedEvent);
    eventPublisher.publishEvent(defectTypeDeletedEvent);
    return new OperationCompletionRS("Issue sub-type delete operation completed successfully.");
}
Also used : ProjectIssueType(com.epam.ta.reportportal.entity.project.ProjectIssueType) Project(com.epam.ta.reportportal.entity.project.Project) DefectTypeDeletedEvent(com.epam.ta.reportportal.core.events.activity.DefectTypeDeletedEvent) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) ProjectIssueType(com.epam.ta.reportportal.entity.project.ProjectIssueType) IssueEntity(com.epam.ta.reportportal.entity.item.issue.IssueEntity) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Aggregations

IssueEntity (com.epam.ta.reportportal.entity.item.issue.IssueEntity)24 IssueType (com.epam.ta.reportportal.entity.item.issue.IssueType)18 TestItem (com.epam.ta.reportportal.entity.item.TestItem)9 TestItemResults (com.epam.ta.reportportal.entity.item.TestItemResults)8 Test (org.junit.jupiter.api.Test)7 TestItemIssueGroup (com.epam.ta.reportportal.entity.enums.TestItemIssueGroup)6 IssueGroup (com.epam.ta.reportportal.entity.item.issue.IssueGroup)6 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)4 Issue (com.epam.ta.reportportal.ws.model.issue.Issue)4 IssueEntityBuilder (com.epam.ta.reportportal.ws.converter.builders.IssueEntityBuilder)3 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)2 ItemIssueTypeDefinedEvent (com.epam.ta.reportportal.core.events.activity.ItemIssueTypeDefinedEvent)2 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)2 Launch (com.epam.ta.reportportal.entity.launch.Launch)2 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)2 TestItemActivityResource (com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource)2 TO_LOCAL_DATE_TIME (com.epam.ta.reportportal.commons.EntityUtils.TO_LOCAL_DATE_TIME)1 Preconditions (com.epam.ta.reportportal.commons.Preconditions)1 Predicates.equalTo (com.epam.ta.reportportal.commons.Predicates.equalTo)1 BusinessRule.expect (com.epam.ta.reportportal.commons.validation.BusinessRule.expect)1