Search in sources :

Example 11 with Issue

use of com.epam.ta.reportportal.ws.model.issue.Issue in project service-api by reportportal.

the class IssueConverterTest method toModel.

@Test
void toModel() {
    final IssueEntity issueEntity = getIssueEntity();
    final Issue resource = IssueConverter.TO_MODEL.apply(issueEntity);
    assertEquals(resource.getAutoAnalyzed(), issueEntity.getAutoAnalyzed());
    assertEquals(resource.getComment(), issueEntity.getIssueDescription());
    assertEquals(resource.getIgnoreAnalyzer(), issueEntity.getIgnoreAnalyzer());
    assertEquals(resource.getIssueType(), issueEntity.getIssueType().getLocator());
}
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 12 with Issue

use of com.epam.ta.reportportal.ws.model.issue.Issue in project service-api by reportportal.

the class JaskonRequiredPropertiesValidatorTest method testInnerRequiredFields2.

@Test
public void testInnerRequiredFields2() {
    FinishTestItemRQ issueRQ = new FinishTestItemRQ();
    issueRQ.setEndTime(Calendar.getInstance().getTime());
    issueRQ.setStatus("PASSED");
    issueRQ.setIssue(new Issue());
    JaskonRequiredPropertiesValidator validator = new JaskonRequiredPropertiesValidator();
    Errors errors = new BeanPropertyBindingResult(issueRQ, "issueRQ");
    validator.validate(issueRQ, errors);
    assertThat(errors.getAllErrors(), not(empty()));
}
Also used : Errors(org.springframework.validation.Errors) Issue(com.epam.ta.reportportal.ws.model.issue.Issue) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) Test(org.junit.jupiter.api.Test)

Example 13 with Issue

use of com.epam.ta.reportportal.ws.model.issue.Issue in project service-api by reportportal.

the class FinishTestItemHandlerImpl method resolveIssue.

private Optional<IssueEntity> resolveIssue(ReportPortalUser user, StatusEnum status, TestItem testItem, @Nullable Issue issue, Long projectId) {
    if (isIssueRequired(testItem, status)) {
        return ofNullable(issue).map(is -> {
            // in provided issue should be locator id or NOT_ISSUE value
            String locator = is.getIssueType();
            if (!NOT_ISSUE_FLAG.getValue().equalsIgnoreCase(locator)) {
                IssueType issueType = issueTypeHandler.defineIssueType(projectId, locator);
                IssueEntity issueEntity = IssueConverter.TO_ISSUE.apply(is);
                issueEntity.setIssueType(issueType);
                if (!CollectionUtils.isEmpty(issue.getExternalSystemIssues())) {
                    externalTicketHandler.linkExternalTickets(user.getUsername(), Lists.newArrayList(issueEntity), new ArrayList<>(issue.getExternalSystemIssues()));
                }
                return Optional.of(issueEntity);
            }
            return Optional.<IssueEntity>empty();
        }).orElseGet(() -> {
            IssueEntity issueEntity = new IssueEntity();
            IssueType toInvestigate = issueTypeHandler.defineIssueType(projectId, TO_INVESTIGATE.getLocator());
            issueEntity.setIssueType(toInvestigate);
            return Optional.of(issueEntity);
        });
    }
    return Optional.empty();
}
Also used : StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) IssueEntity(com.epam.ta.reportportal.entity.item.issue.IssueEntity) Primary(org.springframework.context.annotation.Primary) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS) ATTRIBUTE_VALUE_INTERRUPTED(com.epam.ta.reportportal.core.hierarchy.AbstractFinishHierarchyHandler.ATTRIBUTE_VALUE_INTERRUPTED) Autowired(org.springframework.beans.factory.annotation.Autowired) MessageBus(com.epam.ta.reportportal.core.events.MessageBus) StringUtils(org.apache.commons.lang3.StringUtils) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) TO_INVESTIGATE(com.epam.ta.reportportal.entity.enums.TestItemIssueGroup.TO_INVESTIGATE) Preconditions(com.epam.ta.reportportal.commons.Preconditions) TestItemRepository(com.epam.ta.reportportal.dao.TestItemRepository) Suppliers.formattedSupplier(com.epam.ta.reportportal.commons.validation.Suppliers.formattedSupplier) TestItemActivityResource(com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource) ChangeStatusHandler(com.epam.ta.reportportal.core.item.impl.status.ChangeStatusHandler) Launch(com.epam.ta.reportportal.entity.launch.Launch) LogIndexer(com.epam.ta.reportportal.core.analyzer.auto.LogIndexer) TestItemStatusChangedEvent(com.epam.ta.reportportal.core.events.activity.TestItemStatusChangedEvent) Predicate(java.util.function.Predicate) BusinessRule.expect(com.epam.ta.reportportal.commons.validation.BusinessRule.expect) IssueConverter(com.epam.ta.reportportal.ws.converter.converters.IssueConverter) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) TestItemBuilder(com.epam.ta.reportportal.ws.converter.builders.TestItemBuilder) RetryHandler(com.epam.ta.reportportal.core.item.impl.retry.RetryHandler) ITEM_CAN_BE_INDEXED(com.epam.ta.reportportal.util.Predicates.ITEM_CAN_BE_INDEXED) IssueEntityRepository(com.epam.ta.reportportal.dao.IssueEntityRepository) NOT_ISSUE_FLAG(com.epam.ta.reportportal.entity.enums.TestItemIssueGroup.NOT_ISSUE_FLAG) LaunchRepository(com.epam.ta.reportportal.dao.LaunchRepository) TestItemResults(com.epam.ta.reportportal.entity.item.TestItemResults) JStatusEnum(com.epam.ta.reportportal.jooq.enums.JStatusEnum) java.util(java.util) Issue(com.epam.ta.reportportal.ws.model.issue.Issue) TestItem(com.epam.ta.reportportal.entity.item.TestItem) TO_LOCAL_DATE_TIME(com.epam.ta.reportportal.commons.EntityUtils.TO_LOCAL_DATE_TIME) BooleanUtils(org.apache.commons.lang3.BooleanUtils) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) FinishTestItemHandler(com.epam.ta.reportportal.core.item.FinishTestItemHandler) StatusChangingStrategy(com.epam.ta.reportportal.core.item.impl.status.StatusChangingStrategy) ExternalTicketHandler(com.epam.ta.reportportal.core.item.ExternalTicketHandler) Lists(com.google.common.collect.Lists) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Predicates.equalTo(com.epam.ta.reportportal.commons.Predicates.equalTo) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) UserRole(com.epam.ta.reportportal.entity.user.UserRole) IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) Qualifier(org.springframework.beans.factory.annotation.Qualifier) LogRepository(com.epam.ta.reportportal.dao.LogRepository) Nullable(javax.annotation.Nullable) ATTRIBUTE_KEY_STATUS(com.epam.ta.reportportal.core.hierarchy.AbstractFinishHierarchyHandler.ATTRIBUTE_KEY_STATUS) RetrySearcher(com.epam.ta.reportportal.core.item.impl.retry.RetrySearcher) FinishHierarchyHandler(com.epam.ta.reportportal.core.hierarchy.FinishHierarchyHandler) Optional.ofNullable(java.util.Optional.ofNullable) TO_ACTIVITY_RESOURCE(com.epam.ta.reportportal.ws.converter.converters.TestItemConverter.TO_ACTIVITY_RESOURCE) ItemFinishedEvent(com.epam.ta.reportportal.core.events.item.ItemFinishedEvent) PROJECT_MANAGER(com.epam.ta.reportportal.entity.project.ProjectRole.PROJECT_MANAGER) Transactional(org.springframework.transaction.annotation.Transactional) IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) IssueEntity(com.epam.ta.reportportal.entity.item.issue.IssueEntity)

Example 14 with Issue

use of com.epam.ta.reportportal.ws.model.issue.Issue in project service-api by reportportal.

the class TestItemControllerTest method finishTestItemWithLinkedTicketsBadBtsUrl.

@Test
void finishTestItemWithLinkedTicketsBadBtsUrl() throws Exception {
    FinishTestItemRQ rq = new FinishTestItemRQ();
    rq.setLaunchUuid("334d153c-8f9c-4dff-8627-47dd003bee0f");
    rq.setEndTime(Date.from(LocalDateTime.now().atZone(ZoneId.of("UTC")).toInstant()));
    rq.setStatus("FAILED");
    Issue.ExternalSystemIssue ticket = new Issue.ExternalSystemIssue();
    ticket.setBtsProject("project");
    ticket.setTicketId("ticket1");
    ticket.setUrl("https://example.com/NEWTICKET1");
    Issue issue = new Issue();
    issue.setIssueType("pb001");
    issue.setIgnoreAnalyzer(false);
    issue.setExternalSystemIssues(Sets.newHashSet(ticket));
    rq.setIssue(issue);
    mockMvc.perform(put(SUPERADMIN_PROJECT_BASE_URL + "/item/3ab067e5-537b-45ff-9605-843ab695c96a").content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON).with(token(oAuthHelper.getSuperadminToken()))).andExpect(status().isBadRequest());
}
Also used : Issue(com.epam.ta.reportportal.ws.model.issue.Issue) FinishTestItemRQ(com.epam.ta.reportportal.ws.model.FinishTestItemRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 15 with Issue

use of com.epam.ta.reportportal.ws.model.issue.Issue in project service-api by reportportal.

the class TestItemControllerTest method linkExternalIssueNegative.

@Test
void linkExternalIssueNegative() throws Exception {
    LinkExternalIssueRQ rq = new LinkExternalIssueRQ();
    rq.setTestItemIds(Collections.singletonList(2L));
    Issue.ExternalSystemIssue issue = new Issue.ExternalSystemIssue();
    issue.setBtsUrl("jira.com");
    issue.setBtsProject("project");
    issue.setTicketId("ticket1");
    issue.setUrl("https://example.com/NEWTICKET1");
    rq.setIssues(Collections.singletonList(issue));
    mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/item/issue/link").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON)).andExpect(status().isBadRequest());
}
Also used : LinkExternalIssueRQ(com.epam.ta.reportportal.ws.model.item.LinkExternalIssueRQ) Issue(com.epam.ta.reportportal.ws.model.issue.Issue) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Aggregations

Issue (com.epam.ta.reportportal.ws.model.issue.Issue)23 Test (org.junit.jupiter.api.Test)19 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)15 FinishTestItemRQ (com.epam.ta.reportportal.ws.model.FinishTestItemRQ)10 IssueEntity (com.epam.ta.reportportal.entity.item.issue.IssueEntity)4 LinkExternalIssueRQ (com.epam.ta.reportportal.ws.model.item.LinkExternalIssueRQ)4 TestItem (com.epam.ta.reportportal.entity.item.TestItem)3 IssueDefinition (com.epam.ta.reportportal.ws.model.issue.IssueDefinition)3 IssueType (com.epam.ta.reportportal.entity.item.issue.IssueType)2 Launch (com.epam.ta.reportportal.entity.launch.Launch)2 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)2 ErrorRS (com.epam.ta.reportportal.ws.model.ErrorRS)2 DefineIssueRQ (com.epam.ta.reportportal.ws.model.issue.DefineIssueRQ)2 MvcResult (org.springframework.test.web.servlet.MvcResult)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 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)1 BusinessRule.expect (com.epam.ta.reportportal.commons.validation.BusinessRule.expect)1 BusinessRuleViolationException (com.epam.ta.reportportal.commons.validation.BusinessRuleViolationException)1