Search in sources :

Example 1 with ClusterData

use of com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterData in project service-api by reportportal.

the class CreateClusterHandlerImplTest method saveCluster.

@Test
void saveCluster() {
    final ClusterData clusterData = new ClusterData();
    clusterData.setProject(1L);
    clusterData.setLaunchId(1L);
    final ClusterInfoRs first = new ClusterInfoRs();
    first.setClusterId(1L);
    first.setClusterMessage("first");
    first.setLogIds(Set.of(1L, 2L));
    first.setItemIds(Set.of(1L, 2L));
    final ClusterInfoRs second = new ClusterInfoRs();
    second.setClusterId(2L);
    second.setClusterMessage("second");
    second.setLogIds(Set.of(3L, 4L));
    second.setItemIds(Set.of(3L, 4L));
    clusterData.setClusters(List.of(first, second));
    when(clusterRepository.findByIndexIdAndLaunchId(anyLong(), eq(clusterData.getLaunchId()))).thenReturn(Optional.empty());
    doAnswer(invocation -> {
        Object[] args = invocation.getArguments();
        Cluster cluster = ((Cluster) args[0]);
        cluster.setId(cluster.getIndexId());
        return cluster;
    }).when(clusterRepository).save(any(Cluster.class));
    createClusterHandler.create(clusterData);
    verify(clusterRepository, times(2)).save(any(Cluster.class));
    verify(clusterRepository, times(2)).saveClusterTestItems(any(Cluster.class), anySet());
    verify(logRepository, times(2)).updateClusterIdByIdIn(any(Long.class), anySet());
}
Also used : ClusterData(com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterData) ClusterInfoRs(com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterInfoRs) Cluster(com.epam.ta.reportportal.entity.cluster.Cluster) Test(org.junit.jupiter.api.Test)

Example 2 with ClusterData

use of com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterData in project service-api by reportportal.

the class AnalyzerClusterDataProviderTest method shouldReturnDataWhenNoIndexLaunch.

@Test
void shouldReturnDataWhenNoIndexLaunch() {
    when(analyzerServiceClient.hasClients()).thenReturn(true);
    final GenerateClustersConfig config = getConfig(false);
    when(launchPreparerService.prepare(config.getLaunchId(), config.getAnalyzerConfig())).thenReturn(Optional.of(new IndexLaunch()));
    when(analyzerServiceClient.generateClusters(any(GenerateClustersRq.class))).thenReturn(new ClusterData());
    final Optional<ClusterData> data = provider.provide(config);
    assertTrue(data.isPresent());
}
Also used : GenerateClustersRq(com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.GenerateClustersRq) ClusterData(com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterData) IndexLaunch(com.epam.ta.reportportal.ws.model.analyzer.IndexLaunch) GenerateClustersConfig(com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.GenerateClustersConfig) Test(org.junit.jupiter.api.Test)

Example 3 with ClusterData

use of com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterData in project service-api by reportportal.

the class SaveClusterDataPartProviderTest method shouldSaveWhenDataExists.

@Test
void shouldSaveWhenDataExists() {
    final GenerateClustersConfig config = getConfig(false);
    final ClusterData clusterData = new ClusterData();
    when(dataProvider.provide(config)).thenReturn(Optional.of(clusterData));
    final PipelinePart pipelinePart = provider.provide(config);
    pipelinePart.handle();
    verify(createClusterHandler, times(1)).create(clusterData);
}
Also used : ClusterData(com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterData) PipelinePart(com.epam.ta.reportportal.pipeline.PipelinePart) GenerateClustersConfig(com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.GenerateClustersConfig) Test(org.junit.jupiter.api.Test)

Example 4 with ClusterData

use of com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterData in project service-api by reportportal.

the class CreateClusterHandlerImplTest method updateCluster.

@Test
void updateCluster() {
    final ClusterData clusterData = new ClusterData();
    clusterData.setProject(1L);
    clusterData.setLaunchId(1L);
    final ClusterInfoRs first = new ClusterInfoRs();
    first.setClusterId(1L);
    first.setClusterMessage("first");
    first.setLogIds(Set.of(1L, 2L));
    first.setItemIds(Set.of(1L, 2L));
    final ClusterInfoRs second = new ClusterInfoRs();
    second.setClusterId(2L);
    second.setClusterMessage("second");
    second.setLogIds(Set.of(3L, 4L));
    second.setItemIds(Set.of(3L, 4L));
    clusterData.setClusters(List.of(first, second));
    final Cluster firstCluster = new Cluster();
    firstCluster.setIndexId(1L);
    final Cluster secondCluster = new Cluster();
    secondCluster.setIndexId(2L);
    when(clusterRepository.findByIndexIdAndLaunchId(1L, clusterData.getLaunchId())).thenReturn(Optional.of(firstCluster));
    when(clusterRepository.findByIndexIdAndLaunchId(2L, clusterData.getLaunchId())).thenReturn(Optional.of(secondCluster));
    doAnswer(invocation -> {
        Object[] args = invocation.getArguments();
        Cluster cluster = ((Cluster) args[0]);
        cluster.setId(cluster.getIndexId());
        return cluster;
    }).when(clusterRepository).save(any(Cluster.class));
    createClusterHandler.create(clusterData);
    verify(clusterRepository, times(2)).save(any(Cluster.class));
    verify(clusterRepository, times(2)).saveClusterTestItems(any(Cluster.class), anySet());
    verify(logRepository, times(2)).updateClusterIdByIdIn(any(Long.class), anySet());
}
Also used : ClusterData(com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterData) ClusterInfoRs(com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterInfoRs) Cluster(com.epam.ta.reportportal.entity.cluster.Cluster) Test(org.junit.jupiter.api.Test)

Example 5 with ClusterData

use of com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterData in project service-api by reportportal.

the class AnalyzerClusterDataProviderTest method shouldNotReturnDataWhenNoIndexLaunch.

@Test
void shouldNotReturnDataWhenNoIndexLaunch() {
    when(analyzerServiceClient.hasClients()).thenReturn(true);
    final GenerateClustersConfig config = getConfig(false);
    when(launchPreparerService.prepare(config.getLaunchId(), config.getAnalyzerConfig())).thenReturn(Optional.empty());
    final Optional<ClusterData> data = provider.provide(config);
    assertTrue(data.isEmpty());
}
Also used : ClusterData(com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterData) GenerateClustersConfig(com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.GenerateClustersConfig) Test(org.junit.jupiter.api.Test)

Aggregations

ClusterData (com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterData)5 Test (org.junit.jupiter.api.Test)5 GenerateClustersConfig (com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.GenerateClustersConfig)3 ClusterInfoRs (com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterInfoRs)2 Cluster (com.epam.ta.reportportal.entity.cluster.Cluster)2 GenerateClustersRq (com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.GenerateClustersRq)1 PipelinePart (com.epam.ta.reportportal.pipeline.PipelinePart)1 IndexLaunch (com.epam.ta.reportportal.ws.model.analyzer.IndexLaunch)1