Search in sources :

Example 1 with ClusterInfoRs

use of com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterInfoRs 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 ClusterInfoRs

use of com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterInfoRs 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)

Aggregations

ClusterData (com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterData)2 ClusterInfoRs (com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.ClusterInfoRs)2 Cluster (com.epam.ta.reportportal.entity.cluster.Cluster)2 Test (org.junit.jupiter.api.Test)2