Search in sources :

Example 1 with LaunchResource

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

the class GetLaunchHandlerImpl method getLaunchResources.

private Iterable<LaunchResource> getLaunchResources(Page<Launch> launches) {
    final com.epam.ta.reportportal.ws.model.Page<LaunchResource> launchResourcePage = PagedResourcesAssembler.pageConverter(launchConverter.TO_RESOURCE).apply(launches);
    applicationEventPublisher.publishEvent(new GetLaunchResourceCollectionEvent(launchResourcePage.getContent()));
    return launchResourcePage;
}
Also used : GetLaunchResourceCollectionEvent(com.epam.reportportal.extension.event.GetLaunchResourceCollectionEvent) LaunchResource(com.epam.ta.reportportal.ws.model.launch.LaunchResource)

Example 2 with LaunchResource

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

the class LaunchResourceAttributeUpdaterTest method shouldUpdate.

@Test
void shouldUpdate() {
    final LaunchResource launchResource = new LaunchResource();
    final List<ItemAttribute> attributes = List.of(new ItemAttribute("k1", "v1", false), new ItemAttribute("k2", "v2", false));
    launchResourceAttributeUpdater.handle(launchResource, attributes);
    final Set<ItemAttributeResource> resourceAttributes = launchResource.getAttributes();
    Assertions.assertEquals(2, resourceAttributes.size());
    final Map<String, List<ItemAttributeResource>> mapping = resourceAttributes.stream().collect(groupingBy(ItemAttributeResource::getKey));
    final ItemAttributeResource firstResource = mapping.get("k1").get(0);
    final ItemAttributeResource secondResource = mapping.get("k2").get(0);
    final ItemAttribute firstAttribute = attributes.get(0);
    final ItemAttribute secondAttribute = attributes.get(1);
    shouldEqual(firstAttribute, firstResource);
    shouldEqual(secondAttribute, secondResource);
}
Also used : ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) List(java.util.List) ItemAttribute(com.epam.ta.reportportal.entity.ItemAttribute) LaunchResource(com.epam.ta.reportportal.ws.model.launch.LaunchResource) Test(org.junit.jupiter.api.Test)

Example 3 with LaunchResource

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

the class LaunchResourceMetadataAttributeUpdaterTest method shouldUpdateMetadataWhenAttributeMatches.

@Test
void shouldUpdateMetadataWhenAttributeMatches() {
    final LaunchResource launchResource = new LaunchResource();
    final List<ItemAttribute> attributes = List.of(new ItemAttribute(RP_CLUSTER_LAST_RUN_KEY, "v1", false), new ItemAttribute("k2", "v2", false));
    updater.handle(launchResource, attributes);
    final Map<String, Object> metadata = launchResource.getMetadata();
    Assertions.assertFalse(metadata.isEmpty());
    Assertions.assertEquals("v1", metadata.get(RP_CLUSTER_LAST_RUN_KEY));
}
Also used : ItemAttribute(com.epam.ta.reportportal.entity.ItemAttribute) LaunchResource(com.epam.ta.reportportal.ws.model.launch.LaunchResource) Test(org.junit.jupiter.api.Test)

Example 4 with LaunchResource

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

the class LaunchResourceMetadataAttributeUpdaterTest method shouldNotUpdateMetadataWhenAttributeMatches.

@Test
void shouldNotUpdateMetadataWhenAttributeMatches() {
    final LaunchResource launchResource = new LaunchResource();
    final List<ItemAttribute> attributes = List.of(new ItemAttribute("k1", "v1", false), new ItemAttribute("k2", "v2", false));
    updater.handle(launchResource, attributes);
    Assertions.assertTrue(MapUtils.isEmpty(launchResource.getMetadata()));
}
Also used : ItemAttribute(com.epam.ta.reportportal.entity.ItemAttribute) LaunchResource(com.epam.ta.reportportal.ws.model.launch.LaunchResource) Test(org.junit.jupiter.api.Test)

Example 5 with LaunchResource

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

the class GetLaunchHandlerImpl method getLaunchResource.

private LaunchResource getLaunchResource(Launch launch) {
    final LaunchResource launchResource = launchConverter.TO_RESOURCE.apply(launch);
    applicationEventPublisher.publishEvent(new GetLaunchResourceCollectionEvent(Collections.singletonList(launchResource)));
    return launchResource;
}
Also used : GetLaunchResourceCollectionEvent(com.epam.reportportal.extension.event.GetLaunchResourceCollectionEvent) LaunchResource(com.epam.ta.reportportal.ws.model.launch.LaunchResource)

Aggregations

LaunchResource (com.epam.ta.reportportal.ws.model.launch.LaunchResource)5 ItemAttribute (com.epam.ta.reportportal.entity.ItemAttribute)3 Test (org.junit.jupiter.api.Test)3 GetLaunchResourceCollectionEvent (com.epam.reportportal.extension.event.GetLaunchResourceCollectionEvent)2 ItemAttributeResource (com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource)1 List (java.util.List)1