Search in sources :

Example 6 with TestItemResource

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

the class TestItemConverterTest method toResource.

@Test
void toResource() {
    final TestItem item = getItem(true);
    final TestItemResource resource = TestItemConverter.TO_RESOURCE.apply(item);
    assertEquals(resource.getName(), item.getName());
    assertEquals(resource.getDescription(), item.getDescription());
    assertEquals(resource.getLaunchId(), item.getLaunchId());
    assertEquals(resource.getUuid(), item.getUuid());
    assertEquals(resource.getItemId(), item.getItemId());
    assertEquals(resource.getParent(), item.getParentId());
    assertEquals(resource.getPath(), item.getPath());
    assertEquals(resource.getStatus(), item.getItemResults().getStatus().name());
    assertEquals(resource.getType(), item.getType().name());
    assertEquals(resource.getStartTime(), Date.from(item.getStartTime().atZone(ZoneId.of("UTC")).toInstant()));
    assertEquals(resource.getEndTime(), Date.from(item.getItemResults().getEndTime().atZone(ZoneId.of("UTC")).toInstant()));
    assertEquals(resource.getUniqueId(), item.getUniqueId());
    assertThat(resource.getAttributes().stream().map(ItemAttributeConverter.FROM_RESOURCE).collect(Collectors.toSet())).containsExactlyElementsOf(item.getAttributes());
    assertThat(resource.getParameters().stream().map(ParametersConverter.TO_MODEL).collect(Collectors.toSet())).containsExactlyElementsOf(item.getParameters());
    assertThat(resource.getStatisticsResource()).isEqualToComparingFieldByField(StatisticsConverter.TO_RESOURCE.apply(item.getItemResults().getStatistics()));
    assertEquals(resource.getIssue().getComment(), item.getItemResults().getIssue().getIssueDescription());
    assertEquals(resource.getIssue().getAutoAnalyzed(), item.getItemResults().getIssue().getAutoAnalyzed());
    assertEquals(resource.getIssue().getIssueType(), item.getItemResults().getIssue().getIssueType().getLocator());
    assertEquals(resource.getIssue().getIgnoreAnalyzer(), item.getItemResults().getIssue().getIgnoreAnalyzer());
}
Also used : TestItemResource(com.epam.ta.reportportal.ws.model.TestItemResource) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Test(org.junit.jupiter.api.Test)

Example 7 with TestItemResource

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

the class TestItemConverterTest method toResourceWithoutIssue.

@Test
void toResourceWithoutIssue() {
    final TestItem item = getItem(false);
    final TestItemResource resource = TestItemConverter.TO_RESOURCE.apply(item);
    assertEquals(resource.getName(), item.getName());
    assertEquals(resource.getDescription(), item.getDescription());
    assertEquals(resource.getLaunchId(), item.getLaunchId());
    assertEquals(resource.getUuid(), item.getUuid());
    assertEquals(resource.getItemId(), item.getItemId());
    assertEquals(resource.getParent(), item.getParentId());
    assertEquals(resource.getPath(), item.getPath());
    assertEquals(resource.getStatus(), item.getItemResults().getStatus().name());
    assertEquals(resource.getType(), item.getType().name());
    assertEquals(resource.getStartTime(), Date.from(item.getStartTime().atZone(ZoneId.of("UTC")).toInstant()));
    assertEquals(resource.getEndTime(), Date.from(item.getItemResults().getEndTime().atZone(ZoneId.of("UTC")).toInstant()));
    assertEquals(resource.getUniqueId(), item.getUniqueId());
    assertThat(resource.getAttributes().stream().map(ItemAttributeConverter.FROM_RESOURCE).collect(Collectors.toSet())).containsExactlyElementsOf(item.getAttributes());
    assertThat(resource.getParameters().stream().map(ParametersConverter.TO_MODEL).collect(Collectors.toSet())).containsExactlyElementsOf(item.getParameters());
    assertThat(resource.getStatisticsResource()).isEqualToComparingFieldByField(StatisticsConverter.TO_RESOURCE.apply(item.getItemResults().getStatistics()));
    assertNull(resource.getIssue());
}
Also used : TestItemResource(com.epam.ta.reportportal.ws.model.TestItemResource) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Test(org.junit.jupiter.api.Test)

Example 8 with TestItemResource

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

the class TestItemResourceAssembler method toResource.

public TestItemResource toResource(TestItem entity, @Nullable PathName pathName) {
    TestItemResource resource = TestItemConverter.TO_RESOURCE.apply(entity);
    ofNullable(pathName).ifPresent(pn -> resource.setPathNames(TestItemConverter.PATH_NAME_TO_RESOURCE.apply(pn)));
    return resource;
}
Also used : TestItemResource(com.epam.ta.reportportal.ws.model.TestItemResource)

Aggregations

TestItemResource (com.epam.ta.reportportal.ws.model.TestItemResource)8 TestItem (com.epam.ta.reportportal.entity.item.TestItem)7 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)5 ResourceUpdater (com.epam.ta.reportportal.ws.converter.utils.ResourceUpdater)5 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)4 Filter (com.epam.ta.reportportal.commons.querygen.Filter)4 FilterCondition (com.epam.ta.reportportal.commons.querygen.FilterCondition)4 Queryable (com.epam.ta.reportportal.commons.querygen.Queryable)4 CRITERIA_PROJECT_ID (com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_PROJECT_ID)4 CRITERIA_LAUNCH_MODE (com.epam.ta.reportportal.commons.querygen.constant.LaunchCriteriaConstant.CRITERIA_LAUNCH_MODE)4 BusinessRule (com.epam.ta.reportportal.commons.validation.BusinessRule)4 Suppliers (com.epam.ta.reportportal.commons.validation.Suppliers)4 TestItemRepository (com.epam.ta.reportportal.dao.TestItemRepository)4 LaunchModeEnum (com.epam.ta.reportportal.entity.enums.LaunchModeEnum)4 PagedResourcesAssembler (com.epam.ta.reportportal.ws.converter.PagedResourcesAssembler)4 TestItemConverter (com.epam.ta.reportportal.ws.converter.converters.TestItemConverter)4 ResourceUpdaterProvider (com.epam.ta.reportportal.ws.converter.utils.ResourceUpdaterProvider)4 TestItemUpdaterContent (com.epam.ta.reportportal.ws.converter.utils.item.content.TestItemUpdaterContent)4 Launch (com.epam.ta.reportportal.entity.launch.Launch)3 Predicates (com.epam.ta.reportportal.commons.Predicates)2